filip.clients package

Clients to interact with FIWARE’s APIs

Subpackages

Submodules

filip.clients.base_http_client module

Base http client module

class filip.clients.base_http_client.BaseHttpClient(url: Url | str | None = None, *, session: Session | None = None, fiware_header: Dict | FiwareHeader | None = None, **kwargs)[source]

Bases: object

Base client for all derived api-clients.

Parameters:
  • session – request session object. This is required for reusing the same connection

  • reuse_session (bool) –

  • fiware_header – Fiware header object required for multi tenancy

  • **kwargs – Optional arguments that request takes.

close() None[source]

Close http session :returns: None

delete(url: str, **kwargs) Response[source]

Sends a DELETE request either using the provided session or the single session.

Parameters:
  • url (str) – URL for the new Request object.

  • **kwargs – Optional arguments that request takes.

Returns:

request.Response

property fiware_headers: FiwareHeader

Get fiware header

Returns:

FiwareHeader

property fiware_service: str

Get current fiware service :returns: str

property fiware_service_path: str

Get current fiware service path :returns: str

get(url: str, params: Dict | List[Tuple] | ByteString | None = None, **kwargs) Response[source]

Sends a GET request either using the provided session or the single session.

Parameters:
  • url (str) – URL for the new Request object.

  • params (optional) – (optional) Dictionary, list of tuples or bytes to send in the query string for the Request.

  • **kwargs – Optional arguments that request takes.

Returns:

requests.Response

head(url: str, params: Dict | List[Tuple] | ByteString | None = None, **kwargs) Response[source]

Sends a HEAD request either using the provided session or the single session.

Parameters:
  • url (str) – URL for the new Request object.

  • params (optional) – Dictionary, list of tuples or bytes to send in the query string for the Request.

  • **kwargs – Optional arguments that request takes.

Returns:

requests.Response

property headers

Return current session headers :returns: dict with headers

log_error(err: RequestException, msg: str | None = None) None[source]

Outputs the error messages from the client request function. If additional information is available in the server response this will be forwarded to the logging output.

Note

The user is responsible to setup the logging system

Parameters:
  • err – Request Error

  • msg – error message from calling function

Returns:

None

options(url: str, **kwargs) Response[source]

Sends an OPTIONS request either using the provided session or the single session.

Parameters:
  • url (str) –

  • **kwargs – Optional arguments that request takes.

Returns:

requests.Response

patch(url: str, data: Dict | ByteString | List[Tuple] | IO | str | None = None, json: Dict | None = None, **kwargs) Response[source]

Sends a PATCH request either using the provided session or the single session.

Parameters:
  • url – URL for the new Request object.

  • data (Union[Dict, ByteString, List[Tuple], IO]) – Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.

  • json (Dict) – A JSON serializable Python object to send in the body of the Request..

  • **kwargs – Optional arguments that request takes.

Returns:

request.Response

post(url: str, data: Dict | ByteString | List[Tuple] | IO | str | None = None, json: Dict | None = None, **kwargs) Response[source]

Sends a POST request either using the provided session or the single session.

Parameters:
  • url – URL for the new Request object.

  • data – Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.

  • json – A JSON serializable Python object to send in the body of the Request.

  • **kwargs – Optional arguments that request takes.

Returns:

put(url: str, data: Dict | ByteString | List[Tuple] | IO | str | None = None, json: Dict | None = None, **kwargs) Response[source]

Sends a PUT request either using the provided session or the single session.

Parameters:
  • url – URL for the new Request object.

  • data (Union[Dict, ByteString, List[Tuple], IO]) – Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.

  • json (Dict) – A JSON serializable Python object to send in the body of the Request..

  • **kwargs – Optional arguments that request takes.

Returns:

request.Response