ApiKey

This module provides functionality for working with apikeys.

class ApiKey(api, key_id, data={})[source]

Bases: Base

Parameters:
BASE_ENDPOINT = 'apikeys/'
__init__(api, key_id, data={})[source]

Initialize an apikey instance.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • key_id (int) – The unique identifier for the apikey.

  • data (Dict, optional) – The data of the apikey.

__repr__()[source]

Return a string representation of the attachment.

Returns:

The string representation of the attachment.

Return type:

str

classmethod get_apikeys(api, **kwargs)[source]

Get a list of apikeys

Parameters:

api (GeoboxClient) – The GeoboxClient instance for making requests.

Keyword Arguments:
  • search (str) – search term for keyword-based searching among all textual fields.

  • order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.

  • skip (int) – Number of layers to skip. default is 0.

  • limit (int) – Maximum number of layers to return. default is 10.

  • user_id (int) – Specific user. privileges required.

Return type:

List[ApiKey]

Example

>>> from geobox import GeoboxClient
>>> from geobox.apikey import ApiKey
>>> client = GeoboxClient()
>>> apikeys = ApiKey.get_apikeys(client)
or
>>> apikeys = client.get_apikeys()
classmethod create_apikey(api, name, user_id=None)[source]

Create an ApiKey

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • name (str) – name of the key.

  • user_id (int, optional) – Specific user. privileges required.

Returns:

the apikey object

Return type:

ApiKey

Example

>>> from geobox import GeoboxClient
>>> from geobox.apikey import ApiKey
>>> client = GeoboxClient()
>>> apikey = ApiKey.create_apikey(client, name='test')
or
>>> apikey = client.create_apikey(name='test')
classmethod get_apikey(api, key_id)[source]

Get an ApiKey

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • key_id (str) – the id of the apikey.

Returns:

the ApiKey object

Return type:

ApiKey

Example

>>> from geobox import GeoboxClient
>>> from geobox.apikey import ApiKey
>>> client = GeoboxClient()
>>> apikey = ApiKey.get_apikey(client, key_id=1)
or
>>> apikey = client.get_apikey(key_id=1)
classmethod get_apikey_by_name(api, name, user_id=None)[source]

Get an ApiKey by name

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • name (str) – the name of the key to get

  • user_id (int, optional) – specific user. privileges required.

Returns:

returns the key if a key matches the given name, else None

Return type:

ApiKey | None

Example

>>> from geobox import GeoboxClient
>>> from geobox.apikey import ApiKey
>>> client = GeoboxClient()
>>> apikey = ApiKey.get_apikey_by_name(client, name='test')
or
>>> apikey = client.get_apikey_by_name(name='test')
update(name, user_id=None)[source]

Update an ApiKey

Parameters:
  • name (str) – the name of the key

  • user_id (int, optional) – Specific user. privileges required.

Returns:

Updated ApiKey data

Return type:

Dict

Example

>>> from geobox import GeoboxClient
>>> from geobox.apikey import ApiKey
>>> client = GeoboxClient()
>>> apikey = ApiKey.get_apikey(client, key_id=1)
>>> apikey.update(name="updated_name")
delete()[source]

Delete the ApiKey.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.apikey import ApiKey
>>> client = GeoboxClient()
>>> apikey = ApiKey.get_apikey(client, key_id=1)
>>> apikey.delete()
revoke()[source]

Revoke an ApiKey

Example

>>> from geobox import GeoboxClient
>>> from geobox.apikey import ApiKey
>>> client = GeoboxClient()
>>> apikey = ApiKey.get_apikey(client, key_id=1)
>>> apikey.revoke()
Return type:

None

grant()[source]

Grant an ApiKey

Example

>>> from geobox import GeoboxClient
>>> from geobox.apikey import ApiKey
>>> client = GeoboxClient()
>>> apikey = ApiKey.get_apikey(client, key_id=1)
>>> apikey.grant()
Return type:

None