Skip to content

Latest commit

 

History

History
161 lines (142 loc) · 5.53 KB

File metadata and controls

161 lines (142 loc) · 5.53 KB

WebService

An object that represents a combination of node and web service definition, that will be used for requests.

Instance attributes

id: int

Web service id

name: String

Web service name

description: String

Web service description

Instance methods

get(…​) ⇒ [class-webserviceresponse]

Execute GET request from agent on associated node. Associated node is the node on which getWebService method was executed. This node is used for macro expansion.

Table 1. Parameters

acceptCached

Boolean

Optional named parameter. If True, response stored in agent’s cache will be used. Default: false.

…​

Strings

Optional additional parameter(s) that will be used in web service definition to expand %1, %2…​ macro.

Return

Instance of [class-webserviceresponse] with request result.

webSvc = $node.getWebService("webSvcName");
result = webSvc.get();
println(result.document); // will print result

result = webSvc.get("additional", "parameters");
println(result.document); // will print result

result = webSvc.get(acceptCached: true, "additional", "parameters");
println(result.document); // will print result
delete(…​) ⇒ [class-webserviceresponse]

Execute DELETE request from agent on associated node. Associated node is the node on which getWebService method was executed. This node is used for macro expansion.

Table 2. Parameters

…​

Strings

Optional additional parameter(s) that will be used in web service definition to expand %1, %2…​ macro.

Return

Instance of [class-webserviceresponse] with request result.

webSvc = $node.getWebService("webSvcName");
result = webSvc.delete();
println(result.success); //will print "true" if request was successful or "false" otherwise

result = webSvc.delete("additional", "parameters");
println(result.success); //will print "true" if request was successful or "false" otherwise
patch(data, contentType, …​) ⇒ [class-webserviceresponse]

Execute PATCH request from agent on associated node. Associated node is the node on which getWebService method was executed. This node is used for macro expansion.

Table 3. Parameters

data

String or [class-jsonobject]

Data that will be set to the web service.

contentType

String

Optional parameter. Type of provided data that will be set to "Content-Type" header of request. Default type is "application/json".

…​

Strings

Optional additional parameter(s) that will be used in web service definition to expand %1, %2…​ macro.

Return

Instance of [class-webserviceresponse] with request result.

webSvc = $node.getWebService("webSvcName");

result = webSvc.patch("{ \"id\":10 }");
println(result.success); //will print "true" if request was successful or "false" otherwise
to
json = new JsonObject();
json.set("id", 42);
result = webSvc.patch(json,"application/json", "additional", "parameters");
println(result.success); //will print "true" if request was successful or "false" otherwise
post(data, contentType, …​) ⇒ [class-webserviceresponse]

Execute POST request from agent on associated node. Associated node is the node on which getWebService method was executed. This node is used for macro expansion.

Table 4. Parameters

data

String or [class-jsonobject]

Data that will be set to the web service.

contentType

String

Optional parameter. Type of provided data that will be set to "Content-Type" header of request. Default type is "application/json".

…​

Strings

Optional additional parameter(s) that will be used in web service definition to expand %1, %2…​ macro.

Return

Instance of [class-webserviceresponse] with request result.

webSvc = $node.getWebService("webSvcName");

result = webSvc.post("{ \"id\":10 }");
println(result.success);//will print "true" if request was successful or "false" otherwise

json = new JsonObject();
json.set("id", 42);
result = webSvc.post(json,"application/json", "additional", "parameters");
println(result.success); //will print "true" if request was successful or "false" otherwise
put(data, contentType, …​) ⇒ [class-webserviceresponse]

Execute PUT request from agent on associated node. Associated node is the node on which getWebService method was executed. This node is used for macro expansion.

Table 5. Parameters

data

String or [class-jsonobject]

Data that will be set to the web service.

contentType

String

Optional parameter. Type of provided data that will be set to "Content-Type" header of request. Default type is "application/json".

…​

Strings

Optional additional parameter(s) that will be used in web service definition to expand %1, %2…​ macro.

Return

Instance of [class-webserviceresponse] with request result.

webSvc = $node.getWebService("webSvcName");

result = webSvc.put("{ \"id\":10 }");
println(result.success); //will print "true" if request was successful or "false" otherwise

json = new JsonObject();
json.set("id", 42);
result = webSvc.put(json,"application/json", "additional", "parameters");
println(result.success); //will print "true" if request was successful or "false" otherwise