flip_api.utils.http
HTTP utilities for internal service-to-service calls on the central hub.
Used exclusively by the FL service to communicate with FL Net API endpoints (e.g. flip-fl-api-net-1:8000). These are plain HTTP calls between co-located Docker services — no TLS required.
NOT used for hub↔trust communication, which is handled via the task polling system (trusts poll the hub; see private_services/trust_tasks.py).
Functions
|
Perform an HTTP GET request to the specified URL with optional request ID for tracing. |
|
Perform an HTTP POST request to the specified URL with optional request ID for tracing. |
|
Perform an HTTP DELETE request to the specified URL with optional request ID for tracing. |
Module Contents
- flip_api.utils.http.http_get(url: str, request_id: str | None = None) Any
Perform an HTTP GET request to the specified URL with optional request ID for tracing.
- Parameters:
url (str) – The URL to GET.
request_id (str | None) – Optional value for the
x-request-idheader used for distributed tracing.
- Returns:
Parsed JSON body when the response is JSON; otherwise the raw response text.
- Return type:
Any
- Raises:
httpx.RequestError – If the request cannot be sent (connection, timeout, etc.).
httpx.HTTPStatusError – If the response status is 4xx/5xx (via
raise_for_status).
- flip_api.utils.http.http_post(url: str, request_id: str | None = None, data: dict | None = None, timeout: float | None = None) Any
Perform an HTTP POST request to the specified URL with optional request ID for tracing.
- Parameters:
url (str) – The URL to POST to.
request_id (str | None) – Optional value for the
x-request-idheader used for distributed tracing.data (dict | None) – JSON-serialisable body to send.
timeout (float | None) – Optional request timeout in seconds. When None, httpx defaults are used.
- Returns:
Parsed JSON body when the response is JSON; otherwise the raw response text.
- Return type:
Any
- Raises:
httpx.RequestError – If the request cannot be sent (connection, timeout, etc.).
httpx.HTTPStatusError – If the response status is 4xx/5xx (via
raise_for_status).
- flip_api.utils.http.http_delete(url: str, request_id: str | None = None) Any
Perform an HTTP DELETE request to the specified URL with optional request ID for tracing.
- Parameters:
url (str) – The URL to DELETE.
request_id (str | None) – Optional value for the
x-request-idheader used for distributed tracing.
- Returns:
Parsed JSON body when the response is JSON; otherwise the raw response text.
- Return type:
Any
- Raises:
httpx.RequestError – If the request cannot be sent (connection, timeout, etc.).
httpx.HTTPStatusError – If the response status is 4xx/5xx (via
raise_for_status).