keycloak.connection
===================

.. py:module:: keycloak.connection

.. autoapi-nested-parse::

   Connection manager module.



Classes
-------

.. autoapisummary::

   keycloak.connection.ConnectionManager


Module Contents
---------------

.. py:class:: ConnectionManager(base_url: str, headers: dict | None = None, timeout: int = 60, verify: bool = True, proxies: dict | None = None, cert: str | tuple | None = None, max_retries: int = 1, pool_maxsize: int | None = None)

   Represents a simple server connection.

   :param base_url: The server URL.
   :type base_url: str
   :param headers: The header parameters of the requests to the server.
   :type headers: dict
   :param timeout: Timeout to use for requests to the server.
   :type timeout: int
   :param verify: Boolean value to enable or disable certificate validation or a string
       containing a path to a CA bundle to use
   :type verify: Union[bool,str]
   :param proxies: The proxies servers requests is sent by.
   :type proxies: dict
   :param cert: An SSL certificate used by the requested host to authenticate the client.
       Either a path to an SSL certificate file, or two-tuple of
       (certificate file, key file).
   :type cert: Union[str,Tuple[str,str]]
   :param max_retries: The total number of times to retry HTTP requests.
   :type max_retries: int
   :param pool_maxsize: The maximum number of connections to save in the pool.
   :type pool_maxsize: int


   .. py:property:: base_url
      :type: str


      Return base url in use for requests to the server.

      :returns: Base URL
      :rtype: str



   .. py:property:: headers
      :type: dict


      Return header request to the server.

      :returns: Request headers
      :rtype: dict



   .. py:property:: timeout
      :type: int


      Return timeout in use for request to the server.

      :returns: Timeout
      :rtype: int



   .. py:property:: verify
      :type: bool


      Return verify in use for request to the server.

      :returns: Verify indicator
      :rtype: bool



   .. py:property:: cert
      :type: str | tuple


      Return client certificates in use for request to the server.

      :returns: Client certificate
      :rtype: Union[str,Tuple[str,str]]



   .. py:property:: pool_maxsize
      :type: int | None


      Return the maximum number of connections to save in the pool.

      :returns: Pool maxsize
      :rtype: int or None



   .. py:attribute:: _s


   .. py:attribute:: async_s


   .. py:method:: aclose() -> None
      :async:


      Close the async connection on delete.



   .. py:method:: __del__() -> None

      Del method.



   .. py:method:: param_headers(key: str) -> str | None

      Return a specific header parameter.

      :param key: Header parameters key.
      :type key: str
      :returns: If the header parameters exist, return its value.
      :rtype: str



   .. py:method:: clean_headers() -> None

      Clear header parameters.



   .. py:method:: exist_param_headers(key: str) -> bool

      Check if the parameter exists in the header.

      :param key: Header parameters key.
      :type key: str
      :returns: If the header parameters exist, return True.
      :rtype: bool



   .. py:method:: add_param_headers(key: str, value: str) -> None

      Add a single parameter inside the header.

      :param key: Header parameters key.
      :type key: str
      :param value: Value to be added.
      :type value: str



   .. py:method:: del_param_headers(key: str) -> None

      Remove a specific parameter.

      :param key: Key of the header parameters.
      :type key: str



   .. py:method:: raw_get(path: str, **kwargs: dict) -> requests.Response

      Submit get request to the path.

      :param path: Path for request.
      :type path: str
      :param kwargs: Additional arguments
      :type kwargs: dict
      :returns: Response the request.
      :rtype: Response
      :raises KeycloakConnectionError: HttpError Can't connect to server.



   .. py:method:: raw_post(path: str, data: dict, **kwargs: dict) -> requests.Response

      Submit post request to the path.

      :param path: Path for request.
      :type path: str
      :param data: Payload for request.
      :type data: dict
      :param kwargs: Additional arguments
      :type kwargs: dict
      :returns: Response the request.
      :rtype: Response
      :raises KeycloakConnectionError: HttpError Can't connect to server.



   .. py:method:: raw_put(path: str, data: dict, **kwargs: dict) -> requests.Response

      Submit put request to the path.

      :param path: Path for request.
      :type path: str
      :param data: Payload for request.
      :type data: dict
      :param kwargs: Additional arguments
      :type kwargs: dict
      :returns: Response the request.
      :rtype: Response
      :raises KeycloakConnectionError: HttpError Can't connect to server.



   .. py:method:: raw_delete(path: str, data: dict | None = None, **kwargs: dict) -> requests.Response

      Submit delete request to the path.

      :param path: Path for request.
      :type path: str
      :param data: Payload for request.
      :type data: dict | None
      :param kwargs: Additional arguments
      :type kwargs: dict
      :returns: Response the request.
      :rtype: Response
      :raises KeycloakConnectionError: HttpError Can't connect to server.



   .. py:method:: a_raw_get(path: str, **kwargs: dict) -> httpx.Response
      :async:


      Submit get request to the path.

      :param path: Path for request.
      :type path: str
      :param kwargs: Additional arguments
      :type kwargs: dict
      :returns: Response the request.
      :rtype: Response
      :raises KeycloakConnectionError: HttpError Can't connect to server.



   .. py:method:: a_raw_post(path: str, data: dict, **kwargs: dict) -> httpx.Response
      :async:


      Submit post request to the path.

      :param path: Path for request.
      :type path: str
      :param data: Payload for request.
      :type data: dict
      :param kwargs: Additional arguments
      :type kwargs: dict
      :returns: Response the request.
      :rtype: Response
      :raises KeycloakConnectionError: HttpError Can't connect to server.



   .. py:method:: a_raw_put(path: str, data: dict, **kwargs: dict) -> httpx.Response
      :async:


      Submit put request to the path.

      :param path: Path for request.
      :type path: str
      :param data: Payload for request.
      :type data: dict
      :param kwargs: Additional arguments
      :type kwargs: dict
      :returns: Response the request.
      :rtype: Response
      :raises KeycloakConnectionError: HttpError Can't connect to server.



   .. py:method:: a_raw_delete(path: str, data: dict | None = None, **kwargs: dict) -> httpx.Response
      :async:


      Submit delete request to the path.

      :param path: Path for request.
      :type path: str
      :param data: Payload for request.
      :type data: dict | None
      :param kwargs: Additional arguments
      :type kwargs: dict
      :returns: Response the request.
      :rtype: Response
      :raises KeycloakConnectionError: HttpError Can't connect to server.



   .. py:method:: _prepare_httpx_request_content(data: dict | str | None) -> dict
      :staticmethod:


      Create the correct request content kwarg to `httpx.AsyncClient.request()`.

      See https://www.python-httpx.org/compatibility/#request-content

      :param data: the request content
      :type data: dict | str | None
      :returns: A dict mapping the correct kwarg to the request content
      :rtype: dict



   .. py:method:: _filter_query_params(query_params: dict) -> dict
      :staticmethod:


      Explicitly filter query params with None values for compatibility.

      Httpx and requests differ in the way they handle query params with the value None,
      requests does not include params with the value None while httpx includes them as-is.

      :param query_params: the query params
      :type query_params: dict
      :returns: the filtered query params
      :rtype: dict



