Communications
The JS Communications object can be used in user customizable scripts within CYBERQUEST Data Transformation Service (DTS) and in Alerts. This Object can be called using subobjects, such as:
HttpRequest
This class is a wrapper that encapsulates the http client on specific targets (windowsagent, etc.).
All methods that send requests will return a uniform formatted response, along with the status code or potential errors.
Usage:
config = {
method: 'post',
data: null,
withCredentials: false, // default
CredentialsType: 'plain', // default [encrypted,plain,managed]
timeout: 60000, // default is `60` seconds in milliseconds
rejectUnauthorized: false, //default to check for ssl certificate
auth: { //or the GUID for managed credentials auth:23F08431-2C0E-CC1B-5CBE-0677E5FFAD7B
username: 'user',
password: 'pass'//for plain text, or the encrypted password for encrypted method
},
headers: {},
cookies: []
};
HttpRequest.get
HttpRequest.get(url, config=null)
- HttpResponse
HttpRequest.post
HttpRequest.post(url, data, config=null)
- HttpResponse
HttpRequest.put
HttpRequest.put(url, data, config=null)
- HttpResponse
HttpRequest.delete
HttpRequest.delete(url, config=null)
- HttpResponse
HttpRequest.head
HttpRequest.head(url, config=null)
- HttpResponse
HttpResponse
Properties:
- int statusCode
- string data - The raw response body
- Array headers - The response headers
HttpResponse.asJson()
Parses the response body as JSON.
HttpResponse.asXml()
Parses the response body as XML.
Notification.sendMessage
Parameters:
- text - this is the message of the notification
- type - what platform the notification is sent to (
email
by default, can be sent toslack
orteams
as well) - additionalParamateres (
url
mandatory,subjectData
optional,to
optional)
Taking into account the type
parameter of the sendMessage
method, the module will select the appropriate particular class, instantiate it under its own rules and dispatch the notification.
Usage:
CQ.Communications.sendMessage(message,platform(slak/teams/email),objectConfiguration{url:"",to:"optional",subjectData:"optional"})