Skip to main content

Module maxar_platform.session

Provides

Communication with the APIs through a single global session object using the Python Requests library. The session object provides:

  • Retries
  • Error Handling
  • wraps up API Key and OAuth2 sessions into a single session
  • Uses API Keys preferentially if both authentication methods are configured
  • Credentials are read from envvars only
  • an interactive login form

If you must store credentials in a file, see the dotenv package and be careful not to commit the file into source control!

Reference

https://developers.maxar.com/docs/authentication/

Variables

session : A session instance, ready to use

Functions

paginated_request(method, url, key, sort='asc', limit=None, **params) : A paginated request wrapper

Parameters
----------
method: str
Request method for requests to use, i.e. "get", "post", etc
url: str
URL of endpoint to fetch from
key:
Name of key in the response to find the returned objects. Usually this is just 'data'

Keywords
--------
sort: str
Sort order, either 'asc' or 'desc'
limit: int
Limit of number of objects total objects to fetch

Returns
-------
list of objects
The objects from all the paginated requests are returned as a single list

setenv(api_key=None, username=None, password=None) : Set any of the three envvars used for authentication

Keywords
----------
api_key: str, optional
API Key if used
username: str, optional
Username, use with `password`
password: str, optional
Password, use with `username`

unsetenv() : Unset all of the envvars used for authentication

Classes

MaxarSession() : A Session wrapper that provides a single point of entry

If available, will try to use a Key session first.

To use this object to use a specific authentication, the key and OAuth sessions are available under the
key_session and oauth_session attributes.

This module provides an initalized instance under the name 'session'

### Methods

`login(self)`
: An interactive login for terminal or notebook use when envvars are not configured

`reload(self)`
: Reloads the underlying sessions, for instance if envvars have changed