Standard Library HTTP Actions
send_http_request
std::send_http_request
makes an HTTP request to the given URL and exports the response.
Inputs
- Name
url
- Required
- required
- Type
- string
- Description
The URL for the request. Supported schemes are http and https.
- Name
body
- Required
- optional
- Type
- string
- Description
The request body as a string or json object.
- Name
method
- Required
- optional
- Type
- string
- Description
The HTTP Method for the request. Allowed methods are a subset of methods defined in RFC7231: GET, HEAD, and POST. POST support is only intended for read-only URLs, such as submitting a search.
- Name
timeout_ms
- Required
- optional
- Type
- integer
- Description
The request timeout in milliseconds.
- Name
headers
- Required
- optional
- Type
- object
- Description
A map of request header field names and values. This is an object type containing the keys:
- Name
pre_condition
- Required
- optional
- Type
- map
- Description
Pre-conditions are assertions that are evaluated before a command is executed. They can be used to determine if the command should be executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:
-
behavior: The behavior if the pre-condition assertion does not pass. Possible values are:
- halt (default): Throws an error and halts execution of the runbook
- log: Logs a warning and continues execution of the runbook
- skip: Skips execution of this command and all downstream commands
-
assertion: The assertion to check to determine if the pre-condition behavior should be executed. This value should evaluate to a boolean, or the
std::assert_eq
and other assertions from the standard library can be used.
-
- Name
post_condition
- Required
- optional
- Type
- map
- Description
Post-conditions are assertions that are evaluated after a command is executed. They can be used to determine if the command should be re-executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:
-
retries: If the post-condition assertion fails, the number of times to re-execute the command before executing the post-condition behavior. The default is 0.
-
backoff_ms: If the post-condition assertion fails, the number of milliseconds to wait before re-executing the command. If not specified, the default is 1000 milliseconds (1 second).
-
behavior: The behavior if the post-condition assertion does not pass. Possible values are:
- halt (default): Throws an error and halts execution of the runbook
- log: Logs a warning and continues execution of the runbook
- skip: Skips execution of this command and all downstream commands
- continue: Continues execution without any action
-
assertion: The assertion to check to determine if the command should be re-executed or if the post-condition behavior should be executed. This value should evaluate to a boolean, or the
std::assert_eq
and other assertions from the standard library can be used.
-
Outputs
When the send_http_request
action is successfully executed, the following outputs are attached to the action
- Name
response_body
- Type
- string
- Description
The response body returned as a string.
- Name
status_code
- Type
- integer
- Description
The HTTP response status code.
Example using send_http_request
action "example" "std::send_http_request" {
url = "https://example.com"
}
output "status" {
value = action.example.status_code
}
// > status: 200