Comment on page
Script API: Http
Functions to execute http requests.
This page describes StackState version 4.1.
The StackState 4.1 version range is End of Life (EOL) and no longer supported. We encourage customers still running the 4.1 version range to upgrade to a more recent release.
Sometimes it may be useful to process the retrieved topology or telemetry data using an external tool. For example, to perform analysis using a custom Python script, a cloud service or an Machine Learning framework. StackState can call out to any external service via HTTP using the functions in this script API.
Submit HTTP get request.
Args:
uri
- uri of the HTTP server.
Builder methods:
.param(name: String, value: String)
- specify the query..header(name: String, value: String)
- specify the header
Return type:
- Async: HttpScriptApiTextResponse or HttpScriptApiJsonResponse if
.jsonResponse()
is used.
Example:
Http.get("http://localhost:8080/api/service")
.timeout("30s")
.param("name", "value")
.header("name", "value")
Submit HTTP put request.
Args:
uri
- uri of the HTTP server.
Builder methods:
.param(name: String, value: String)
- specify the query..header(name: String, value: String)
- specify the header..contentType(contentType: String)
- specify the content type (e.g. "application/text")..textRequest(text: String)
- specify the text of the request..jsonRequest(json: Goovy.lang.Closures)
- specify the json of the request. This will wrap the given closure with a JsonBuilder.jsonBody()
- get the body of the json response..jsonResponse()
- get the json response..textResponse()
- get the text response.
Return type:
AsyncScriptResult[HttpScriptApiTextResponse]
orAsyncScriptResult[HttpScriptApiJsonResponse]
if.jsonResponse()
is used.
Example:
Http.put("http://localhost:8080/api/service")
.timeout("30s")
.param("name", "value")
.header("name", "value")
.contentType("application/text")
.textRequest("{'property', 'value'}")
.jsonResponse()
Submit HTTP post request.
Args:
uri
- uri of the HTTP server.
Builder methods:
.param(name: String, value: String)
- specify the query..header(name: String, value: String)
- specify the header..contentType(contentType: String)
- specify the content type (e.g. "application/text")..textRequest(text: String)
- specify the text of the request..jsonRequest(json: Goovy.lang.Closures)
- specify the json of the request. This will wrap the given closure with a JsonBuilder.jsonBody()
- get the body of the json response..jsonResponse()
- get the json response..textResponse()
- get the text response.
Return type:
AsyncScriptResult[HttpScriptApiTextResponse]
orAsyncScriptResult[HttpScriptApiJsonResponse]
if.jsonResponse()
is used.
Example:
Http.post("http://localhost:8080/api/service")
.timeout("30s")
.param("name", "value")
.header("name", "value")
.jsonRequest {
basicProperty "value"
objectProperty {
basicProperty 42.0
}
listProperty (["list item"])
}.jsonBody()
Submit HTTP delete request.
Args:
uri
- uri of the HTTP server.
Builder methods:
.param(name: String, value: String)
- specify the query..header(name: String, value: String)
- specify the header
Return type:
AsyncScriptResult[HttpScriptApiTextResponse]
orAsyncScriptResult[HttpScriptApiJsonResponse]
if.jsonResponse()
is used.
Example:
Http.delete("http://localhost:8080/api/service")
.timeout("30s")
.param("name", "value")
.header("name", "value")
Submit HTTP options request.
Http.options("http://localhost:8080/api/service")
.timeout("30s")
.param("name", "value")
.header("name", "value")
Submit HTTP patch request.
Args:
uri
- uri of the HTTP server.
Builder methods:
.param(name: String, value: String)
- specify the query..header(name: String, value: String)
- specify the header..contentType(contentType: String)
- specify the content type (e.g. "application/text")..textRequest(text: String)
- specify the text of the request..jsonRequest(json: Goovy.lang.Closures)
- specify the json of the request. This will wrap the given closure with a JsonBuilder.jsonBody()
- get the body of the json response..jsonResponse()
- get the json response..textResponse()
- get the text response.
Return type:
AsyncScriptResult[HttpScriptApiTextResponse]
orAsyncScriptResult[HttpScriptApiJsonResponse]
if.jsonResponse()
is used.
Example:
Http.patch("http://localhost:8080/api/service")
.timeout("30s")
.param("name", "value")
.header("name", "value")
.textRequest("{'property', 'value'}")
Submit HTTP head request.
Args:
uri
- uri of the HTTP server.
Builder methods:
.param(name: String, value: String)
- specify the query..header(name: String, value: String)
- specify the header
Return type:
AsyncScriptResult[HttpScriptApiTextResponse]
orAsyncScriptResult[HttpScriptApiJsonResponse]
if.jsonResponse()
is used.
Example:
Http.head("http://localhost:8080/api/service")
.timeout("30s")
.param("name", "value")
.header("name", "value")
Last modified 2yr ago