ai_api_client_sdk.helpers.rest_client
index
/data/jenkins/workspace/ndation_ai-api-client-sdk_master/ai_api_client_sdk/helpers/rest_client.py

 
Modules
       
humps
json
requests

 
Classes
       
builtins.object
RestClient

 
class RestClient(builtins.object)
    RestClient(base_url: str, get_token: Callable[[], str], resource_group: str = None)
 
RestClient is the class implemented for sending the requests to the server.
 
:param base_url: Base URL of the server. Should include the base path as well. (i.e., "<base_url>/scenarios" should
    work)
:type base_url: str
:param get_token: the function which returns the Bearer token, when called
:type get_token: Callable[[], str]
:param resource_group: The default resource group which will be used while sending the requests to the server,
    defaults to None
:type resource_group: str
 
  Methods defined here:
__init__(self, base_url: str, get_token: Callable[[], str], resource_group: str = None)
Initialize self.  See help(type(self)) for accurate signature.
delete(self, path: str, params: Dict[str, str] = None, resource_group: str = None) -> dict
Sends a DELETE request to the server.
 
:param path: path of the endpoint the request should be sent to
:type path: str
:param params: parameters of the request, defaults to None
:type params: Dict[str, str], optional
:param resource_group: Resource Group which the request should be sent on behalf. Either this, or the
    resource_group property of this class should be set.
:type resource_group: str
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIAuthorizationException` if a 401 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPINotFoundException` if a 404 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIPreconditionFailedException` if a 412 response is received from
    the server
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIRequestException` if an unexpected exception occurs while
    trying to send a request to the server
:return: The JSON response from the server (The keys decamelized)
:rtype: dict
get(self, path: str, params: Dict[str, str] = None, resource_group: str = None) -> Union[dict, int]
Sends a GET request to the server.
 
:param path: path of the endpoint the request should be sent to
:type path: str
:param params: parameters of the request, defaults to None
:type params: Dict[str, str], optional
:param resource_group: Resource Group which the request should be sent on behalf. Either this, or the
    resource_group property of this class should be set.
:type resource_group: str
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIAuthorizationException` if a 401 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPINotFoundException` if a 404 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIPreconditionFailedException` if a 412 response is received from
    the server
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIRequestException` if an unexpected exception occurs while
    trying to send a request to the server
:return: The JSON response from the server (The keys decamelized)
:rtype: Union[dict, int]
patch(self, path: str, body: Dict[str, Union[str, dict]], resource_group: str = None) -> dict
Sends a PATCH request to the server.
 
:param path: path of the endpoint the request should be sent to
:type path: str
:param body: body of the request, defaults to None
:type body: Dict[str, str], optional
:param resource_group: Resource Group which the request should be sent on behalf. Either this, or the
    resource_group property of this class should be set.
:type resource_group: str
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIAuthorizationException` if a 401 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPINotFoundException` if a 404 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIPreconditionFailedException` if a 412 response is received from
    the server
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIRequestException` if an unexpected exception occurs while
    trying to send a request to the server
:return: The JSON response from the server (The keys decamelized)
:rtype: dict
post(self, path: str, body: Dict[str, Union[str, dict]] = None, resource_group: str = None) -> dict
Sends a POST request to the server.
 
:param path: path of the endpoint the request should be sent to
:type path: str
:param body: body of the request, defaults to None
:type body: Dict[str, str], optional
:param resource_group: Resource Group which the request should be sent on behalf. Either this, or the
    resource_group property of this class should be set.
:type resource_group: str
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIAuthorizationException` if a 401 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPINotFoundException` if a 404 response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIPreconditionFailedException` if a 412 response is received from
    the server
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
    server
:raises: class:`ai_api_client_sdk.exception.AIAPIRequestException` if an unexpected exception occurs while
    trying to send a request to the server
:return: The JSON response from the server (The keys decamelized)
:rtype: dict

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Data
        Callable = typing.Callable
Dict = typing.Dict
Union = typing.Union