QueryREST
Step facilitates REST interactions and will return the returned data dictionary and specified headers as data to the next step
Added in version 1.0.0.
Friendly name:
Deprecated: Query RESTStep class:
base_steps_syncpack.steps.QueryREST.QueryRESTStep version:
1.2.7Required parameters:
method,prefix_url
Parameters
Name |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
number |
no |
|
QueryREST specific retry setting. If the query fails with a different status code than expected, dictates how many times the query will be retried. |
|
enum |
yes |
– |
HTTP method to perform Example: |
|
string |
yes |
– |
used with relative_url to create the full URL. Example: |
|
string |
no |
– |
the REST username Example: |
|
string |
no |
– |
the REST password Example: |
|
number |
no |
– |
If this has a constant response, what you expect it to be. Example: |
|
json |
no |
|
Header dictionary for the REST command. Example: |
|
boolean |
no |
|
If true, use the input data as payload for executing the HTTP method. |
|
json |
no |
– |
the payload for a POST command. Example: |
|
number |
no |
|
The max number of records to fetch in one REST call. |
|
number |
no |
– |
The value that is specified in the url to indicate where to start grabbing data. For example: ?offset=50. Example: |
|
number |
no |
|
The value that is specified in the url to indicate the max number of records to return in this REST call. For example: ?limit=1000. Example: |
|
string |
no |
|
If the data is set in chunks, the field name in the response that indicates how many rows were returned. |
|
string |
no |
|
If the data is set in chunks, the field name in the response that indicates how many total rows for this object. |
|
string |
no |
|
The field in the response that contains the data for the arrays of rows returned. |
|
string |
no |
– |
The type of object this is (device, ticket, etc.). This value is stored in the object under the key OBJECT_TYPE_KEY. Example: |
|
array of strings |
no |
– |
An array of names from the header to capture in the output. Example: |
|
string |
no |
– |
The URL suffix Example: |
|
boolean |
no |
|
Set to to see some special/extra debug messages Example: |
|
boolean |
no |
|
Set this to perform a rest query to a URI generated from input data from each element in the input_data. The input variables can be referenced from the relative_url parameter, but not prefix_url |
|
number |
no |
|
Time in seconds to wait for HTTP Connect Response. |
|
number |
no |
|
Time in seconds to wait for HTTP Read Response. |
Every step also accepts the platform parameters common to all steps – see Platform parameters.
Dependencies
Inherits from:
QueryREST->BaseStep->SerializableSyncPack modules:
base_steps_syncpack.util.status_code_errorsExternal packages:
future,ipaascommon,ipaascore,requests,requests_oauthlib,six,urllib3
Warning
Deprecated. execute() logs a warning directing you to
GetREST, PostREST or DeleteREST. Documented
for the benefit of workflows that still use it — see
Deprecated steps.
Behaviour
Unlike the current REST steps, this one does not extend
Shared parameters: HTTPBaseStep. It extends BaseStep directly and declares its own
full parameter set, which is why its table above duplicates names you will also
find on the shared HTTP page. The two sets are not interchangeable.
The practical consequence: authentication is limited to HTTP Basic. There is no OAuth, no bearer token and no mTLS on this step. Those are the reasons to move off it.
Outputs
save_data_for_next_step(all_data), which is one of:
a list of row dicts extracted from
result_key, paged for chunked GETs;a plain list, when the response is already a list;
the full response dict, when the structure does not match
result_key.
On error it saves {"http_code": ..., "headers": ..., "body": ...} before
raising.
Notes
chunk_name_for_pos_in_urlandchunk_name_for_max_in_urlare declared as number parameters here, even though the values are URL parameter names. The equivalents on Shared parameters: HTTPBaseStep are strings.object_typehas no analogue on the modern steps; it is stored under the platform’sOBJECT_TYPE_KEY.query_retriesretries when the status code differs fromexpected_http_response, so it does nothing unless that is also set.
API
- class base_steps_syncpack.steps.QueryREST.QueryREST
Bases:
BaseStep- execute()
Main Query rest logic
- Returns:
- query_with_url_and_payload_from_input()
Attempts to query with the url and payload from the previous step input. This will really only work if the payload and url are using variable substitution.
- Returns:
- query_with_url_generated_from_input()
Iterates over data from previous steps, and generates a relative url for each. Then executes that command.
- Returns:
- query_with_payload_from_input()
Performs the specified rest query with the specific payload coming in from user.
- Returns:
- make_rest_call(request_func, url, headers, out_payload, verify=False, basic_auth=None, allow_redirects=True, stream=False, expected_http_response=None, connect_timeout=20, read_timeout=20, max_retry_attempts=0)
Method which will retry a REST request until it is successful, or until it has failed 5 times. On a successful query, it will return the response. If there’s any failure (unexpected status code, requests exception, max retries, etc) A StepFailedException will be raised.
- Parameters:
request_func – REST method to execute
url – URL to query
headers – headers
out_payload – data for request
verify – whether to verify
basic_auth – authentication for request
allow_redirects – allow_redirects for requests module
stream – stream option from requests module
expected_http_response – expected http response for validation
connect_timeout – number of seconds to wait for the remote server to provide a response before raising exception
read_timeout – number of seconds to wait for the remote server to reply.
max_retry_attempts – how many times the call can be retried
- Return response:
the Request response