tcex.tcex_request module¶
TcEx Framework Request Module
-
class
tcex.tcex_request.TcExRequest(tcex, session=None)[source]¶ Bases:
objectWrapper on Python Requests Module with API logging.
-
add_header(key, val)[source]¶ Add a key value pair to header for this request.
Parameters: - key (str) – The header key
- val (str) – The header value
-
add_payload(key, val, append=False)[source]¶ Add a key value pair to payload for this request.
Parameters: - key (str) – The payload key.
- val (str) – The payload value.
- (bool, default (append) – False): Indicate whether the value should be appended or overwritten.
The “Authorization” header value for this request.
-
basic_auth¶ The basic auth settings for this request.
-
body¶ Return the POST/PUT body content for this request.
-
content_type¶ The Content-Type header value for this request.
-
files¶ Files setting for this request
-
headers¶ Return the header values for this request.
-
http_method¶ The HTTP method for this request.
-
json¶ Return the POST/PUT body content in JSON format for this request.
-
payload¶ The payload values for this request.
-
proxies¶ Return the proxy settings for the session.
-
send(stream=False)[source]¶ Send the HTTP request via Python Requests modules.
This method will send the request to the remote endpoint. It will try to handle temporary communications issues by retrying the request automatically.
Parameters: stream (bool) – Boolean to enable stream download. Returns: The Request response Return type: Requests.Response
-
set_basic_auth(username, password)[source]¶ Manually set basic auth in the header when normal method does not work.
-
timeout¶ The HTTP timeout value for this request.
-
url¶ The URL for this request.
-
user_agent¶ The the User-Agent header value for this request.
-
verify_ssl¶ Return the SSL validation setting for the session.
-
-
tcex.tcex_request.session_retry(retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504), session=None)[source]¶ Add retry to Requests Session
https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#urllib3.util.retry.Retry