coarnotify.http =============== .. py:module:: coarnotify.http .. autoapi-nested-parse:: HTTP layer interface and default implementation using requests lib Classes ------- .. autoapisummary:: coarnotify.http.HttpLayer coarnotify.http.HttpResponse coarnotify.http.RequestsHttpLayer coarnotify.http.RequestsHttpResponse Module Contents --------------- .. py:class:: HttpLayer Interface for the HTTP layer This defines the methods which need to be implemented in order for the client to fully operate .. py:method:: get(url: str, headers: dict = None, *args, **kwargs) -> HttpResponse :abstractmethod: Make an HTTP GET request to the supplied URL with the given headers `args` and `kwargs` can be used to pass implementation-specific parameters :param url: the request URL :param headers: HTTP headers as a dict to include in the request :param args: argument list to pass on to the implementation :param kwargs: keyword arguments to pass on to the implementation :return: HttpResponse .. py:method:: post(url: str, data: str, headers: dict = None, *args, **kwargs) -> HttpResponse :abstractmethod: Make an HTTP POST request to the supplied URL with the given body data, and headers `args` and `kwargs` can be used to pass implementation-specific parameters :param url: the request URL :param data: the body data :param headers: HTTP headers as a dict to include in the request :param args: argument list to pass on to the implementation :param kwargs: keyword arguments to pass on to the implementation :return: HttpResponse .. py:class:: HttpResponse Interface for the HTTP response object This defines the methods which need to be implemented in order for the client to fully operate .. py:method:: header(header_name: str) -> str :abstractmethod: Get the value of a header from the response :param header_name: the name of the header :return: the header value .. py:property:: status_code :type: int :abstractmethod: Get the status code of the response :return: the status code .. py:class:: RequestsHttpLayer Bases: :py:obj:`HttpLayer` Implementation of the HTTP layer using the requests library. This is the default implementation used when no other implementation is supplied .. py:method:: get(url: str, headers: dict = None, *args, **kwargs) -> RequestsHttpResponse Make an HTTP GET request to the supplied URL with the given headers `args` and `kwargs` can be used to pass additional parameters to the `requests.get` method, such as authentication credentials, etc. :param url: the request URL :param headers: HTTP headers as a dict to include in the request :param args: argument list to pass on to requests.get :param kwargs: keyword arguments to pass on to requests.get :return: HttpResponse .. py:method:: post(url: str, data: str, headers: dict = None, *args, **kwargs) -> RequestsHttpResponse Make an HTTP POST request to the supplied URL with the given body data, and headers `args` and `kwargs` can be used to pass additional parameters to the `requests.post` method, such as authentication credentials, etc. :param url: the request URL :param data: the body data :param headers: HTTP headers as a dict to include in the request :param args: argument list to pass on to requests.post :param kwargs: keyword arguments to pass on to requests.post :return: RequestsHttpResponse .. py:class:: RequestsHttpResponse(resp: requests.Response) Bases: :py:obj:`HttpResponse` Implementation fo the HTTP response object using the requests library This wraps the requests response object and provides the interface required by the client :param resp: response object from the requests library .. py:method:: header(header_name: str) -> str Get the value of a header from the response :param header_name: the name of the header :return: the header value .. py:property:: requests_response :type: requests.Response Get the original requests response object .. py:property:: status_code :type: int Get the status code of the response :return: the status code