Generic REST Client¶
The Generic REST client is called by TransipRestClient to do the actual requests in a generalized way. This class is reusable for other specific REST Clients
-
class
transip_rest_client.generic_rest_client.
GenericRestClient
(base_url: str, user: str, timeout: int = 10, headers: dict = None)[source]¶ Generic REST client
-
delete_request
(endpoint, params, expected_http_codes=None, extra_headers=None)[source]¶ Create a payload and send a new post request to the given url
Parameters: - endpoint (str) – portion of the endpoint for the service
- params (dict) – a valid data object
- expected_http_codes (list) – expected codes for the request
- extra_headers (dict) – extra http headers needed for this request
Returns: The response offered by the requests library when using get
-
get_request
(endpoint: str, params: dict, expected_http_codes: list = None, extra_headers: dict = None)[source]¶ Create a payload and send a new post request to the given url
Parameters: - endpoint (str) – portion of the endpoint for the service
- params (dict) – a valid data object
- expected_http_codes (list) – expected codes for the request
- extra_headers (dict) – extra http headers needed for this request
Returns: The response offered by the requests library when using get
-
patch_request
(endpoint, params, expected_http_codes=None, extra_headers=None)[source]¶ Create a payload and send a new post request to the given url
Parameters: - endpoint (str) – portion of the endpoint for the service
- params (dict) – a valid data object
- expected_http_codes (list) – expected codes for the request
- extra_headers (dict) – extra http headers needed for this request
Returns: The response offered by the requests library when using get
-
post_request
(endpoint: str, params: dict, expected_http_codes: list = None, extra_headers: dict = None)[source]¶ Create a payload and send a new post request to the given url
Parameters: - endpoint (str) – portion of the endpoint for the service
- params (dict) – a valid data object
- expected_http_codes (list) – expected codes for the request
- extra_headers (dict) – extra http headers needed for this request
Returns: The response offered by the requests library when using get
-
put_request
(endpoint, params, expected_http_codes=None, extra_headers=None)[source]¶ Create a payload and send a new post request to the given url
Parameters: - endpoint (str) – portion of the endpoint for the service
- params (dict) – a valid data object
- expected_http_codes (list) – expected codes for the request
- extra_headers (dict) – extra http headers needed for this request
Returns: The response offered by the requests library when using get
-
-
exception
transip_rest_client.generic_rest_client.
RequestFailureException
(*args, url='', response=None, **kwargs)[source]¶ Raised when the request did not succeed, and we know nothing happened in the remote side. From a businness-logic point of view, the operation the client was supposed to perform did NOT happen