Qorus Integration Engine® Enterprise Edition 6.0.16_prod
Loading...
Searching...
No Matches
OMQ::QorusSystemAPIHelperBase Class Reference

This class provides an easy way to call Qorus API functions using the network API. More...

Inheritance diagram for OMQ::QorusSystemAPIHelperBase:
[legend]

Public Member Methods

 constructor (*hash< auto > n_opts, *code n_init)
 creates the object based on the options passed More...
 
 copy ()
 creates a copy of the object
 
 setQorusAuthToken (string token)
 Sets the Qorus authentication token.
 
 addDefaultHeaders (hash< auto > h)
 adds default headers to each request; these headers will be sent in all requests More...
 
hash< auto > getDefaultHeaders ()
 returns the hash of default headers to sent in all requests More...
 
 setOptions ()
 this variant of the setOptions() method does nothing when called with no argument
 
 setOptions (hash< auto > opts)
 sets connection options More...
 
 setURL (string url)
 sets the URL
 
 setProxyURL (*string url)
 sets or clears the proxy URL
 
string getURL ()
 returns the current URL value
 
*string getProxyURL ()
 returns the current proxy URL value or NOTHING if none is set
 
bool isXmlRpc ()
 returns True if the object is using the XML-RPC protocol
 
bool isJsonRpc ()
 returns True if the object is using the JSON-RPC protocol
 
bool isYamlRpc ()
 returns True if the object is using the YAML-RPC protocol
 
bool isConnected ()
 returns True if the object is currently connected to the server
 
 setConnectTimeout (int to)
 sets the connect timeout from an integer in milliseconds
 
 setConnectTimeout (date to)
 sets the connect timeout from a relative date/time value (i.e. 30s)
 
 setTimeout (int to)
 sets the send/receive I/O timeout from an integer in milliseconds
 
 setTimeout (date to)
 sets the send/receive I/O timeout from a relative date/time value (i.e. 30s)
 
*date getTimeout ()
 gets the send/receive I/O timeout as a relative date/time value More...
 
*date getConnectTimeout ()
 gets the connect timeout as a relative date/time value More...
 
 reconnect ()
 if a connection is established, closes the connection and reconnects immediately
 
 forceXmlRpc ()
 forces the use of the XML-RPC protocol
 
 forceYamlRpc ()
 forces the use of the (proprietary) YAML-RPC protocol More...
 
auto methodGate (string api)
 this method is used to redirect calls to unknown methods as the method name when calling the server
 
auto memberGate (string api)
 this method is used to redirect calls to unknown methods as the method name when calling the server
 
auto callAPIArgs (string api, auto args, bool literal=False)
 with this method you can call a method on the server and give the argument list directly as a list More...
 
auto callAPIArgsWithInfo (reference< hash< auto > > info, string api, auto args, bool literal=False)
 with this method you can call a method on the server and give the argument list directly as a list and it also requires a reference to a hash as the first argument, which will return technical information about the call More...
 
auto callAPI (string api)
 with this method you can call a method on the server, the arguments to the server method should follow the method name normally as arguments to this method More...
 
 setQueue (Queue n_q)
 this method allows you to set a Queue object to get I/O events from the underlying HTTPClient object
 

Static Public Member Methods

static hash< auto > toConfig (hash< auto > info)
 returns a hash of configuration information for the object
 

Detailed Description

This class provides an easy way to call Qorus API functions using the network API.

the class does not provide any connection pooling; it is thread-safe, but requests from concurrent threads will block while a request from another thread is in progress. This class uses YAML-RPC by default, but if calling a Qorus server that does not support YAML-RPC, will automatically fall back to XML-RPC

Note
this should not be used directly; use subclass OMQ::QorusSystemAPIHelper (in server code) or OMQ::Client::QorusSystemAPIHelper (in client code) instead

Member Function Documentation

◆ addDefaultHeaders()

OMQ::QorusSystemAPIHelperBase::addDefaultHeaders ( hash< auto >  h)

adds default headers to each request; these headers will be sent in all requests

Example:
# disable gzip and bzip encoding in responses
omqapi.addDefaultHeaders({"Accept-Encoding": "compress"});
Parameters
ha hash of headers to add to the default headers to send on each request
Note
default headers can also be set in the constructor
See also
getDefaultHeaders()
Since
Qorus 5.0

◆ callAPI()

auto OMQ::QorusSystemAPIHelperBase::callAPI ( string  api)

with this method you can call a method on the server, the arguments to the server method should follow the method name normally as arguments to this method

if an error message is returned, then an equivalent Qore-language exception is thrown

Parameters
apithe server method name to call
Returns
returns the value returned by the server

◆ callAPIArgs()

auto OMQ::QorusSystemAPIHelperBase::callAPIArgs ( string  api,
auto  args,
bool  literal = False 
)

with this method you can call a method on the server and give the argument list directly as a list

if an error message is returned, then an equivalent Qore-language exception is thrown

Parameters
apithe server method name to call
argsthe argument or argument list to give to the method
literalif True then the object will not try to prepend "omq.system." to the method name if it does not have any "." characters in it
Returns
returns the value returned by the server

◆ callAPIArgsWithInfo()

auto OMQ::QorusSystemAPIHelperBase::callAPIArgsWithInfo ( reference< hash< auto > >  info,
string  api,
auto  args,
bool  literal = False 
)

with this method you can call a method on the server and give the argument list directly as a list and it also requires a reference to a hash as the first argument, which will return technical information about the call

if an error message is returned, then an equivalent Qore-language exception is thrown

Parameters
infoa reference to a hash that will be returned with technical information about the call (request and response headers, actual request and response messages, etc)
apithe server method name to call
argsthe argument or argument list to give to the method
literalif True then the object will not try to prepend "omq.system." to the method name if it does not have any "." characters in it
Returns
returns the value returned by the server

◆ constructor()

OMQ::QorusSystemAPIHelperBase::constructor ( *hash< auto >  n_opts,
*code  n_init 
)

creates the object based on the options passed

Parameters
n_optsoptional hash with the following keys:
  • timeout
  • connect_timeout
  • http_version
  • url
  • max_redirects
  • proxy
n_initan optional initialization closure to be called with the RPC object as the sole argument
See also
ValidClientAPIOpts

◆ forceYamlRpc()

OMQ::QorusSystemAPIHelperBase::forceYamlRpc ( )

forces the use of the (proprietary) YAML-RPC protocol

Note
YAML-RPC is the preferred protocol when communicating with Qorus servers

◆ getConnectTimeout()

*date OMQ::QorusSystemAPIHelperBase::getConnectTimeout ( )

gets the connect timeout as a relative date/time value

Since
Qorus 3.1.0.p16

◆ getDefaultHeaders()

hash< auto > OMQ::QorusSystemAPIHelperBase::getDefaultHeaders ( )

returns the hash of default headers to sent in all requests

Example:
hash<auto> h = omqapi.getDefaultHeaders();
Returns
the hash of default headers to sent in all requests
Note
default headers can be set in the constructor and in addDefaultHeaders()
See also
addDefaultHeaders()
Since
Qorus 5.0

◆ getTimeout()

*date OMQ::QorusSystemAPIHelperBase::getTimeout ( )

gets the send/receive I/O timeout as a relative date/time value

Since
Qorus 3.1.0.p16

◆ setOptions()

OMQ::QorusSystemAPIHelperBase::setOptions ( hash< auto >  opts)

sets connection options

Parameters
optsoptional hash with the following keys: timeout, connect_timeout, http_version, url, max_redirects, proxy

The documentation for this class was generated from the following file: