Modules
WebHare modules
Modules are the primary method of adding custom code to WebHare
WebHare Configuration and registry
- MACRO ApplyWebHareConfiguration(RECORD options)
Ensure changes to WebHare's configuration are applied
 - FUNCTION PTR FUNCTION CreateAppliedPromise(RECORD toApply)
 - OBJECTTYPE CustomCheckBase
Base object for custom WebHare checks
 - MACRO DeleteRegistryKey(STRING confkey)
Deletes a registry key. Module registry keys can be read using the key "modulename.registrykey...".
 - MACRO DeleteRegistryNode(STRING confkey)
Deletes a registry node. Module registry keys can be read using the key "modulename.registrykey...".
 - RECORD FUNCTION GetDebuggerConfig()
Return the configuration for the debugger
 - STRING FUNCTION GetDTAPStage()
Get the server DTAP type
 - STRING FUNCTION GetInstallationRoot()
Get the installation directory
 - STRING FUNCTION GetModuleInstallationRoot(STRING modulename)
Get the directory a module is installed in
 - STRING FUNCTION GetModuleStorageRoot(STRING modulename)
Get the disk storage root for module specific data
 - STRING FUNCTION GetPrimaryWebhareInterfaceURL()
Get the primary WebHare interface URL
 - RECORD FUNCTION GetProcessInfo()
Get the name for this process
 - STRING ARRAY FUNCTION GetRegistryKeyEventMasks(STRING ARRAY keys)
Get the event masks to use to listen to specific registry keys in adhoc caches
 - STRING FUNCTION GetServerName()
Get the name for this server
 - RECORD FUNCTION GetSystemConfigurationRecord()
Returns the current system configuration
 - RECORD FUNCTION GetWebHareConfiguration()
Get the WebHare installation/configuration parameters
 - STRING FUNCTION GetWebhareVersion()
Get the version of this WebHare installation
 - RECORD FUNCTION GetWebhareVersionInfo()
Get WebHare version and branding information
 - INTEGER FUNCTION GetWebhareVersionNumber()
Get the version number of this WebHare installation
 - BOOLEAN FUNCTION IsDTAPLive()
IS this a 'considered live' environment
 - BOOLEAN FUNCTION IsModuleInstalled(STRING modulename)
Is a specific module installed ?
 - BOOLEAN FUNCTION IsModuleVersionMatch(STRING modulename, STRING semverrange)
Test if the specified module's semantic version matches the specified version range
 - BOOLEAN FUNCTION IsNodeApplicableToThisWebHare(OBJECT xmlnode, RECORD options)
Returns whether a node with version/servertype/installationtype restrictions is applicable to this WebHare installation
 - BOOLEAN FUNCTION IsProductionOrAsIf()
Is true if we're either on production, or acting as-if
 - BOOLEAN FUNCTION IsRestoredWebHare()
Is this a restored WebHare
 - BOOLEAN FUNCTION IsWebhareVersionMatch(STRING semverrange)
Test if the current WebHare semantic version matches the specified version range
 - VARIANT FUNCTION ReadRegistryKey(STRING confkey, RECORD options)
Get a registry key. Module registry keys can be read using the key "modulename.registrykey...".
 - RECORD ARRAY FUNCTION ReadRegistryKeysByMask(STRING keymask)
Read registry keys by mask
 - RECORD ARRAY FUNCTION ReadRegistryNode(STRING confkey)
Get all keys in a node
 - MACRO WriteRegistryKey(STRING confkey, VARIANT newval, RECORD options)
Set a registry key if it exists. Module registry keys can be written using the key "modulename.registrykey...".
 
WebHare resources
- RECORD ARRAY FUNCTION GetCustomModuleSettings(STRING ns, STRING localname)
Gather custom moduledefinition setting nodes
 - STRING ARRAY FUNCTION GetInstalledModuleNames()
Get a list of installed modules (includes builtin modules)
 - OBJECT FUNCTION GetModuleDefinitionXML(STRING modulename)
Get the XML module definition for a module
 - STRING FUNCTION GetModuleDefinitionXMLResourceName(STRING modulename)
Get the resource name module definition for a module
 - STRING FUNCTION GetModuleNameFromResourcePath(STRING path)
Returns the module name from a resource path
 - STRING FUNCTION GetModuleResourceURL(STRING resourcename)
Returns a URL for a WebHare module resource, if available
 - STRING ARRAY FUNCTION GetResourceEventMasks(STRING ARRAY inpaths)
Returns the events that will be sent when a WebHare resource is modified
 - STRING FUNCTION GetResourceNameFromDiskPath(STRING diskpath, RECORD options)
Returns the resource name for a disk path. Also accept webhare resource paths, which are normalized
 - BLOB FUNCTION GetWebHareResource(STRING resourcepath, RECORD options)
Get a WebHare resource (like GetHareScriptResource, but adds support for site::, whfsbyid:: etc)
 - STRING FUNCTION GetWebHareResourceDiskPath(STRING inpath)
Get the disk path for a resource. Throws for invalid module names or things which are not a disk path
 - BOOLEAN FUNCTION IsAbsoluteResourcePath(STRING base)
Returns whether a resource path is an absolute path
 - INTEGER FUNCTION LookupWHFSObject(INTEGER startingpoint, STRING fullpath)
Look up an object id by path
 - STRING FUNCTION MakeAbsoluteResourcePath(STRING base, STRING subpath)
Resolves a (relative) resource path relative to a base path
 - RECORD ARRAY FUNCTION ReadWebHareResourceFolder(STRING resourcepath)
Returns the contents of a resource folder.
 - RECORD FUNCTION RetrieveCachedXMLResource(STRING path)
Open a XML document read-only
 - OBJECTTYPE RetrieveResourceException
Exception thrown when a resource cannot be retrieved
 - RECORD FUNCTION RetrieveWebHareResource(STRING resourcepath, RECORD options)
Retrieve a WebHare resource, returning data, path and modification date
 - RECORD FUNCTION RunModuleHookTarget(STRING targetname, RECORD data)
Invoke the intercepts for a hook target
 
System services
- RECORD FUNCTION CheckIPRateLimit(RECORD criterium, INTEGER numhits, RECORD options)
Implements rate limiting for the current request IP
 - RECORD FUNCTION CheckRateLimit(RECORD criterium, INTEGER numhits, RECORD options)
Implements rate limiting
 - OBJECT FUNCTION CreateKeyPair(STRING name, BLOB privatekey, RECORD options)
Create a new keypair
 - VARIANT FUNCTION DecryptForThisServer(STRING scope, STRING data, RECORD options)
Decrypt data with this server's local key
 - STRING FUNCTION EncryptForThisServer(STRING scope, VARIANT data, RECORD options)
Encrypt data with this server's local key
 - BOOLEAN FUNCTION FlushModuleLog(STRING name)
Flushes a specific module log
 - INTEGER FUNCTION GetBestKeyPairForHostName(STRING hostname)
Returns the ID of the best keypair for a specific hostname
 - OBJECTTYPE KeyPair
A keypair contains a private key and a certificate chain
 - RECORD ARRAY FUNCTION ListKeyPairs(RECORD options)
List all keypairs
 - OBJECTTYPE LocalLockManager
Mutual exclusion manager for process-local locks
 - OBJECTTYPE LockManager
Mutual exclusion manager
 - MACRO LogAccountingHit(STRING hittype, RECORD hitdata)
Log a hit for accounting purposes
 - MACRO LogAuditEvent(STRING logsource, RECORD data)
Log an audit event by the current effective user
 - MACRO LogError(STRING logsource, STRING message, RECORD data)
Log an error to the 'notice' log
 - MACRO LogHarescriptErrors(RECORD ARRAY errors, RECORD options)
Log a list of Harescript errors to the notice log (via a HarescriptErrorException)
 - MACRO LogHarescriptException(OBJECT exc, RECORD options)
Log a Harescript exception to the notice log
 - MACRO LogInfo(STRING logsource, STRING message, RECORD data)
Log an informational message to the 'notice' log
 - MACRO LogRPCForSoapClient(STRING logsource, STRING sourcetracker, OBJECT soapclient)
Register RPC logging for a SOAP client connection
 - MACRO LogRPCForWebbrowser(STRING logsource, STRING sourcetracker, OBJECT webbrowser)
Register RPC logging for a webbrowser connection
 - MACRO LogRPCTraffic(STRING logsource, STRING transport, BOOLEAN outgoing, STRING sourcetracker, STRING transactionid, RECORD data)
Log RPC traffic
 - MACRO LogWarning(STRING logsource, STRING message, RECORD data)
Log a warning to the 'notice' log
 - RECORD FUNCTION LookupAPIKey(STRING type, STRING requestdomain, RECORD options)
Obtain an API key
 - OBJECTTYPE MultiFileLogReader
Log reader for reading log files from multiple days as a single log stream. Returned by OpenWebHareLogStream.
 - OBJECTTYPE MutexLock
Lock object
 - OBJECT FUNCTION OpenKeyPair(INTEGER id)
Get a specific keypair by id
 - OBJECT FUNCTION OpenKeyPairByName(STRING keypairname)
Get a keypair by name
 - OBJECT FUNCTION OpenLocalLockManager()
Creates a new mutexmanager object for process-local locks
 - OBJECT FUNCTION OpenLockManager()
Creates a new mutexmanager object
 - OBJECT FUNCTION OpenWebHareLogStream(STRING logfile, DATETIME startentries, DATETIME limitentries)
Opens an active logging stream for reading
 - OBJECT FUNCTION OpenWebHareLogStreamFromFiles(RECORD ARRAY files, STRING format, DATETIME startentries, DATETIME limitentries)
Opens archived log files for reading
 - ASYNC FUNCTION OpenWebHareService(STRING servicename, RECORD options)
Open a WebHare service
 - RECORD ARRAY FUNCTION ReadJSONLogLines(STRING logname, DATETIME start, VARIANT until)
 - MACRO RunWebHareService(STRING servicename, FUNCTION PTR constructor, RECORD options)
Launch a WebHare service
 - MACRO ScheduleCallbackOnServiceClose(OBJECT service, FUNCTION PTR onclose)
Schedules a function to be called when a service closes
 - OBJECTTYPE ServiceDisconnectException
Exception thrown when the connection to a service was lost
 - OBJECTTYPE ServiceUnavailableException
Exception thrown when a service is unavailable
 - MACRO UpdateAuditContext(RECORD auditcontext)
Update auditing context to automatically use for any LogAuditEvent calls
 - MACRO WriteLogMarker(STRING text)
Write a marker with optional text to all primary logfiles
 
Users and access rights management
- INTEGER FUNCTION GetAuthobjectIdByGuid(STRING guid)
Get authobject id for an authobject guid
 - INTEGER ARRAY FUNCTION GetAuthobjectIdsByGuid(STRING ARRAY guids)
Get authobject ids for multiple authobject guids
 - INTEGER ARRAY FUNCTION GetGrantedAuthObjects(STRING rightname, INTEGER obj, RECORD options)
List authobjects which have a specific right
 - OBJECT FUNCTION GetPrimaryWebhareAuthPlugin()
Get the WRD Auth plugin of the primary WebHare interface URL
 - OBJECT FUNCTION GetPrimaryWebhareUserApi()
Get the user api of the primary WebHare interface URL
 - OBJECTTYPE ObjectTypeDescriber
Objecttype for use in object describers
 - OBJECT FUNCTION RequireLoggedinWebHareUser()
Require the current request to be from a logged in WebHare user
 
Services and tasks
- ASYNC FUNCTION CallAsync(STRING func, VARIANT ARRAY args, RECORD options)
Asynchronously invoke a function in another VM
 - OBJECT FUNCTION CancelManagedTasks(INTEGER ARRAY taskids)
Cancel managed tasks
 - OBJECT FUNCTION DeleteManagedTasks(INTEGER ARRAY taskids)
Delete managed tasks
 - RECORD FUNCTION DescribeManagedTask(INTEGER taskid)
Describes a managed task
 - RECORD ARRAY FUNCTION LookupManagedTasks(STRING type, RECORD searchparameters)
Look up managed tasks
 - OBJECTTYPE ManagedTaskBase
Base class to implement managed tasks
 - INTEGER ARRAY FUNCTION RescheduleManagedTasks(INTEGER ARRAY taskids)
Reschedule multiple finished managed tasks
 - RECORD FUNCTION RetrieveManagedTaskResult(INTEGER taskid, DATETIME maxwait, RECORD options)
Waits until a managed task is finished, returns its result. Throws if the task has failed.
 - MACRO RetryPendingManagedTasks(STRING mask)
Retry all pending managed tasks of a specific type now
 - MACRO RetryPendingManagedTasksByIds(INTEGER ARRAY taskids)
Retry all pending managed tasks of a specific type now
 - OBJECT FUNCTION ScheduleEphemeralTask(STRING tasktype, RECORD taskdata, RECORD options)
Schedule an ephemeral task if this transaction commits
 - INTEGER FUNCTION ScheduleManagedTask(STRING tasktype, RECORD taskdata, RECORD options)
Schedule a managed task if this transaction commits
 - INTEGER ARRAY FUNCTION ScheduleManagedTasks(STRING tasktype, RECORD ARRAY taskdatas, RECORD options)
Schedule multiple managed tasks
 - MACRO ScheduleTimedTask(STRING taskname, RECORD options)
Schedule a timed task to run
 - MACRO SetManagedTaskMetadata(INTEGER taskid, STRING metadatakey, VARIANT metadatavalue)
Sets metadata of a managed task
 - BOOLEAN FUNCTION WaitForTimedTask(STRING taskname, DATETIME deadline, RECORD options)
Wait for timed tasks to finish
 
System dialogs and integration
- OBJECTTYPE DashboardPanelBase
Base classes for dashboard panels
 - OBJECTTYPE MonitorPanelBase
 - OBJECT FUNCTION RunConnectRemoteWebHareDialog(OBJECT parent, RECORD options)
Run a dialog to select a remote WebHare to establish a peering connection with
 - MACRO RunEmailTestDialog(OBJECT parent, OBJECT email, RECORD options)
Run a dialog to test and preview PrepareMailWitty email
 - MACRO RunEmailViewDialog(OBJECT parent, BLOB email, RECORD options)
Run a dialog to (pre)view a single mail
 - MACRO RunMailQueueDialog(OBJECT parent, STRING filter, RECORD options)
Run a mailqueue monitoir
 - MACRO RunModuleScriptDialog(OBJECT parent, STRING script, STRING ARRAY arguments, RECORD options)
Run a dialog that will run a module script
 - MACRO RunSendEmailDialog(OBJECT parent, RECORD options)
Run a dialog in which the user can compose a (rich) mail
 - MACRO RunWittyTestDialog(OBJECT parent, RECORD data, RECORD options)
Run a witty tester/developers dialog
 
Managing migrations and deprecations
- RECORD ARRAY FUNCTION ConvertContentType(STRING srctype, RECORD options)
Convert contenttypes