Internal functions

This file mostly contains internal functions called by the API, so you're unlikely to ever use them.

async flightplandb.internal.request(method: str, path: str, return_format='native', ignore_statuses: List | None = None, params: Dict | None = None, json_data: Dict | None = None, key: str | None = None) Dict | bytes

General HTTP requests function for non-paginated results.

Parameters:
  • method (str) -- An HTTP request type. One of GET, POST, PATCH, or DELETE

  • path (str) -- The endpoint's path to which the request is being made

  • return_format (str, optional) -- The API response format, defaults to "native"

  • ignore_statuses (List, optional) -- Statuses (together with 200 OK) which don't raise an HTTPError, defaults to None

  • params (Dict, optional) -- Any other HTTP request parameters, defaults to None

  • json_data (Dict, optional) -- Custom JSON data to be formatted into the request body

  • key (str) -- API token, defaults to None (which makes it unauthenticated)

Returns:

A dataclass if return_format is "native", otherwise bytes

Return type:

Union[Dict, bytes]

Raises:
  • ValueError -- Invalid return_format option

  • HTTPError -- Invalid HTTP status in response

async flightplandb.internal.get_headers(key: str | None = None) CIMultiDict

Calls request() for request headers.

Parameters:

key (str, optional) -- API token, defaults to None (which makes it unauthenticated)

Returns:

A dict of headers, but the keys are case-insensitive.

Return type:

CaseInsensitiveDict

async flightplandb.internal.get(path: str, return_format='native', ignore_statuses: List | None = None, params: Dict | None = None, key: str | None = None) Dict | bytes

Calls request() for get requests.

Parameters:
  • path (str) -- The endpoint's path to which the request is being made

  • return_format (str, optional) -- The API response format, defaults to "native"

  • ignore_statuses (List, optional) -- Statuses (together with 200 OK) which don't raise an HTTPError, defaults to None

  • params (Dict, optional) -- Any other HTTP request parameters, defaults to None

  • key (str, optional) -- API token, defaults to None (which makes it unauthenticated)

Returns:

A dataclass if return_format is "native", otherwise bytes

Return type:

Union[Dict, bytes]

async flightplandb.internal.post(path: str, return_format='native', ignore_statuses: List | None = None, params: Dict | None = None, json_data: Dict | None = None, key: str | None = None) Dict | bytes

Calls request() for post requests.

Parameters:
  • path (str) -- The endpoint's path to which the request is being made

  • return_format (str, optional) -- The API response format, defaults to "native"

  • ignore_statuses (List, optional) -- Statuses (together with 200 OK) which don't raise an HTTPError, defaults to None

  • params (Dict, optional) -- Any other HTTP request parameters, defaults to None

  • json_data (Dict, optional) -- Custom JSON data to be formatted into the request body

  • key (str, optional) -- API token, defaults to None (which makes it unauthenticated)

Returns:

A dataclass if return_format is "native", otherwise bytes

Return type:

Union[Dict, bytes]

async flightplandb.internal.patch(path: str, return_format='native', ignore_statuses: List | None = None, params: Dict | None = None, json_data: Dict | None = None, key: str | None = None) Dict | bytes

Calls request() for patch requests.

Parameters:
  • path (str) -- The endpoint's path to which the request is being made

  • return_format (str, optional) -- The API response format, defaults to "native"

  • ignore_statuses (List, optional) -- Statuses (together with 200 OK) which don't raise an HTTPError, defaults to None

  • params (Dict, optional) -- Any other HTTP request parameters, defaults to None

  • json_data (Dict, optional) -- Custom JSON data to be formatted into the request body

  • key (str, optional) -- API token, defaults to None (which makes it unauthenticated)

Returns:

A dataclass if return_format is "native", otherwise bytes

Return type:

Union[Dict, bytes]

async flightplandb.internal.delete(path: str, return_format='native', ignore_statuses: List | None = None, params: Dict | None = None, key: str | None = None) Dict | bytes

Calls request() for delete requests.

Parameters:
  • path (str) -- The endpoint's path to which the request is being made

  • return_format (str, optional) -- The API response format, defaults to "native"

  • ignore_statuses (List, optional) -- Statuses (together with 200 OK) which don't raise an HTTPError, defaults to None

  • params (Dict, optional) -- Any other HTTP request parameters, defaults to None

  • key (str, optional) -- API token, defaults to None (which makes it unauthenticated)

Returns:

A dataclass if return_format is "native", otherwise bytes

Return type:

Union[Dict, bytes]

async flightplandb.internal.getiter(path: str, limit: int = 100, sort: str = 'created', ignore_statuses: List | None = None, params: Dict | None = None, key: str | None = None) AsyncIterable[Dict]

Get request() for paginated results.

Parameters:
  • path (str) -- The endpoint's path to which the request is being made

  • limit (int, optional) -- Maximum number of results to return, defaults to 100

  • sort (str, optional) -- Sort order to return results in. Valid sort orders are created, updated, popularity, and distance

  • ignore_statuses (List, optional) -- Statuses (together with 200 OK) which don't raise an HTTPError, defaults to None

  • params (Dict, optional) -- Any other HTTP request parameters, defaults to None

  • key (str, optional) -- API token, defaults to None (which makes it unauthenticated)

Returns:

An iterable of dicts. Return format cannot be specified.

Return type:

AsyncIterable[Dict]