Async ApiKey

This module provides functionality for working with async apikeys.

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

Bases: AsyncBase

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

Initialize an apikey instance.

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient 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

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

[async] Get a list of apikeys

Parameters:

api (AsyncGeoboxClient) – The AsyncGeoboxClient 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[AsyncApiKey]

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.apikey import AsyncApiKey
>>> async with AsyncGeoboxClient() as client:
>>>     apikeys = await AsyncApiKey.get_apikeys(client)
or
>>>     apikeys = await client.get_apikeys()
async classmethod create_apikey(api, name, user_id=None)[source]

[async] Create an ApiKey

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient 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.aio import AsyncGeoboxClient
>>> from geobox.aio.apikey import AsyncApiKey
>>> async with AsyncGeoboxClient() as client:
>>>     apikey = await AsyncApiKey.create_apikey(client, name='test')
or
>>>     apikey = await client.create_apikey(name='test')
async classmethod get_apikey(api, key_id)[source]

[async] Get an ApiKey

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

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

Returns:

the ApiKey object

Return type:

ApiKey

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.apikey import AsyncApiKey
>>> async with AsyncGeoboxClient() as client:
>>>     apikey = await AsyncApiKey.get_apikey(client, key_id=1)
or
>>>     apikey = await client.get_apikey(key_id=1)
async classmethod get_apikey_by_name(api, name, user_id=None)[source]

[async] Get an ApiKey by name

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient 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.aio import AsyncGeoboxClient
>>> from geobox.aio.apikey import AsyncApiKey
>>> async with AsyncGeoboxClient() as client:
>>>     apikey = await AsyncApiKey.get_apikey_by_name(client, name='test')
or
>>>     apikey = await client.get_apikey_by_name(name='test')
async update(name, user_id=None)[source]

[async] 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.aio import AsyncGeoboxClient
>>> from geobox.aio.apikey import AsyncApiKey
>>> async with AsyncGeoboxClient() as client:
>>>     apikey = await AsyncApiKey.get_apikey(client, key_id=1)
>>>     await apikey.update(name="updated_name")
async delete()[source]

[async] Delete the ApiKey.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.apikey import AsyncApiKey
>>> async with AsyncGeoboxClient() as client:
>>>     apikey = await AsyncApiKey.get_apikey(client, key_id=1)
>>>     await apikey.delete()
async revoke()[source]

[async] Revoke an ApiKey

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.apikey import AsyncApiKey
>>> async with AsyncGeoboxClient() as client:
>>>     apikey = await AsyncApiKey.get_apikey(client, key_id=1)
>>>     await apikey.revoke()
Return type:

None

async grant()[source]

[async] Grant an ApiKey

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.apikey import AsyncApiKey
>>> async with AsyncGeoboxClient() as client:
>>>     apikey = await AsyncApiKey.get_apikey(client, key_id=1)
>>>     await apikey.grant()
Return type:

None