http_request
This building block interacts with HTTP and HTTPS web services and supports Digest, Basic and WSSE HTTP authentication mechanisms. It is not related to artifacts.
actions:
- name: INTERACT WITH HTTP
short_name: HTTP
steps:
- name: TEST STEP FOR INTERACT WITH HTTP
short_name: HTTP_TEST
properties:
- key: template
value: http_request
- key: var_http_request
value: my_var_http_request
is_artifact: False
In this example, the value of the var_http_request
property is
my_var_http_request
, but it can be any other string.
To run correctly, this building block requires environment variables. Indicate them in a .yml file. Indicate The generic environment variables for the Ansible and Python building blocks and adapt their values to your target z/OS environment. Indicate also the variables that are specific to this building block.
The Ansible and Python common environment variables
If you specify the var_http_request
property in a step of the deployment method,
you must assign the values to its corresponding variable (my_var_http_request
in the example) in an Ansible or a Python environment variables file. The variables that you include in my_var_http_request
depend on the type of request.
get
method:my_var_http_request:
method: "get"
url: "http://url/myfile"
dest: "my_destination_folder"
return_content: False
url_username: "your_username"
url_password: "your_password"
http_request
building block: - body
-
String
The body of the HTTP request or response to the web service.
- client_cert
-
Path
PEM formatted certificate chain file to be used for SSL client authentication.
This file can also include the key as well, and if the key is included, client_cert is not required.
- client_key
-
Path
PEM formatted file that contains your private key to be used for SSL client authentication.
If client_cert contains both the certificate and the key, this variable is not required.
- delay
-
Integer
Number of seconds to wait before the request is run.
- dest
-
Path
A path to download the file to (if appropriate). If dest is a directory, the basename of the file on the remote server will be used.
See Return values for more information.
- headers
-
Dictionary
Custom HTTP headers for a request in the format of a YAML hash.
- method
-
String
Default:GET
The HTTP method of the request or response.
The method is not restricted at the module level but it must be a valid method accepted by the service that handles the request.
- retries
-
Integer
Maximum number of execution attempts if the status code is not reached.
- return_content
-
Boolean
Default:False
Whether or not to return the body of the response as a
content
key in the dictionary result no matter it succeeded or failed.See Return values for more information.
- src
-
Path
Path to the file to be submitted to the remote server. It cannot be used with body.
- status_code
-
Integer (list or elements)
Default:[200]
A list of valid, numeric, HTTP status codes that signifies success of the request.
- timeout
-
Integer
Default:30
The socket level timeout in seconds.
- url
-
String
RequiredHTTP or HTTPS URL in the form
(http|https)://host.domain[:port]/path
. - url_password
-
String
A password for the module to use for
Digest
,Basic
, orWSSE
authentication. - url_username
-
String
A username for the module to use for
Digest
,Basic
, orWSSE
authentication. - validate_certs
-
Boolean
Default:False
If this variable is set to
false
, SSL certificates will not be validated.
var_http_request
property in the step of the
deployment method, then the values of the default http_request_default variable
from an Ansible or a Python environment variables file are
used. http_request_default:
method: "post"
url: "http://url"
body: "<request><create><parameter name='CSD'></parameter><attributes name=MYPGM' csdgroup='MYCSD'></attributes></create></request>"
headers: "{'Content-Type': 'application/xml'}"
return_content: True
url_username: "your_username"
url_password: "your_password"
Return values
The result of each building block task is displayed in the evidence file, in The results level that is embedded in step_result.
- For Ansible, the
content
return value is not generated in the evidences. - For Python, the request response body can be managed with either of the following two variables:
- With the return_content variable.
If this variable is set to
True
, theresponse
return value in the evidences contains the request response body. If this variable is set toFalse
, theresponse
field in the evidences does not contain the request response body. - With the dest variable.
If this variable is set in the building block, the file or folder that it points to contains the request response body and the
response
return value contains the path of the dest attribute (even if return_content is set toTrue
).
- With the return_content variable.