Utils

Utility functions for bosdyn-orbit

bosdyn.orbit.utils.get_api_token() str[source]

Obtains an API token from either an environment variable or terminal input

Returns

api_token: the API token obtained from the instance

bosdyn.orbit.utils.get_latest_created_at_for_run_events(client: bosdyn.orbit.client.Client, params: Dict = {}) datetime[source]

Given a dictionary of query params, returns the max created at time for run events

Parameters:
  • client – the client for the web API

  • params – the query params associated with the get request

Raises:
  • RequestExceptions – exceptions thrown by the Requests library

  • UnauthenticatedClientError – indicates that the client is not authenticated properly

Returns:

The max created at time for run events in datetime

bosdyn.orbit.utils.get_latest_run_capture_resources(client: bosdyn.orbit.client.Client, params: Dict = {}) List[source]

Given a dictionary of query params, returns the latest run capture resources in json format

Parameters:
  • client – the client for Orbit web API

  • params – the query params associated with the get request

Raises:
  • RequestExceptions – exceptions thrown by the Requests library

  • UnauthenticatedClientError – indicates that the client is not authenticated properly

Returns:

A list of resources obtained from a RESTful endpoint

bosdyn.orbit.utils.get_latest_created_at_for_run_captures(client: bosdyn.orbit.client.Client, params: Dict = {}) datetime[source]

Given a dictionary of query params, returns the max created at time for run captures

Parameters:
  • client – the client for Orbit web API

  • params – the query params associated with the get request

Raises:
  • RequestExceptions – exceptions thrown by the Requests library

  • UnauthenticatedClientError – indicates that the client is not authenticated properly

Returns:

The max created at time for run captures in datetime

bosdyn.orbit.utils.get_latest_run_resource(client: bosdyn.orbit.client.Client, params: Dict = {}) List[source]

Given a dictionary of query params, returns the latest run resource in json format

Parameters:
  • client – the client for Orbit web API

  • params – the query params associated with the get request

Raises:
  • RequestExceptions – exceptions thrown by the Requests library

  • UnauthenticatedClientError – indicates that the client is not authenticated properly

Returns:

A list corresponding to a run resource obtained from a RESTful endpoint in json

bosdyn.orbit.utils.get_latest_run_in_progress(client: bosdyn.orbit.client.Client, params: Dict = {}) List[source]

Given a dictionary of query params, returns the latest running resource in json format

Parameters:
  • client – the client for Orbit web API

  • params – the query params associated with the get request

Raises:
  • RequestExceptions – exceptions thrown by the Requests library

  • UnauthenticatedClientError – indicates that the client is not authenticated properly

Returns:

A list corresponding to a run obtained from a RESTful endpoint in json

bosdyn.orbit.utils.get_latest_end_time_for_runs(client: bosdyn.orbit.client.Client, params: Dict = {}) datetime[source]

Given a dictionary of query params, returns the max end time for runs

Parameters:
  • client – the client for Orbit web API

  • params – the query params associated with the get request

Raises:
  • RequestExceptions – exceptions thrown by the Requests library

  • UnauthenticatedClientError – indicates that the client is not authenticated properly

Returns:

The max end time for runs in datetime

bosdyn.orbit.utils.write_image(img_raw, image_fp: str) None[source]

Given a raw image and a desired output directory, writes the image to a file

Parameters:
  • img_raw (Raw image object) – the input raw image

  • image_fp – the output filepath for the image

bosdyn.orbit.utils.data_capture_urls_from_run_events(client: bosdyn.orbit.client.Client, run_events: List, list_of_channel_names: List = None) List[source]

Given run events and list of desired channel names, returns the list of data capture urls

Parameters:
  • client – the client for Orbit web API

  • run_events – a json representation of run events obtained from a RESTful endpoint

  • list_of_channel_names – a list of channel names associated with the desired data captures. Defaults to None which returns all the available channels.

Returns:

a list of urls

Return type:

data_urls

bosdyn.orbit.utils.data_capture_url_from_run_capture_resources(client: bosdyn.orbit.client.Client, run_capture_resources: List, list_of_channel_names: List = None) List[source]

Given run capture resources and list of desired channel names, returns the list of data capture urls

Parameters:
  • client – the client for Orbit web API

  • run_capture_resources – a list of resources obtained from a RESTful endpoint

  • list_of_channel_names – a list of channel names associated with the desired data captures. Defaults to None which returns all the available channels.

Returns:

a list of urls

Return type:

data_urls

bosdyn.orbit.utils.get_action_names_from_run_events(run_events: Dict) List[source]

Given run events, returns a list of action names

Parameters:

run_events – a representation of run events obtained from a RESTful endpoint

Returns:

a list of action names

Return type:

action_names

bosdyn.orbit.utils.datetime_from_isostring(datetime_isostring: str) datetime[source]

Returns the datetime representation of the iso string representation of time

Parameters:

datetime_isostring – the iso string representation of time

Returns:

The datetime representation of the iso string representation of time

bosdyn.orbit.utils.validate_webhook_payload(payload: Dict, signature_header: str, secret: str, max_age_ms: int = 300000) None[source]

Verifies that the webhook payload came from

Parameters:
  • payload – the JSON body of the webhooks req

  • signature_header – the value of the signature header

  • secret – the configured secret value for this webhook

  • max_age_ms – the maximum age of the message before it’s considered invalid (default is 5 minutes)

Raises:

bosdyn.orbit.exceptions.WebhookSignatureVerificationError – thrown if the webhook signature is invalid