Supportive handles for API

dynacrop.api_handles module

class dynacrop.api_handles.APIObject(id: Optional[int] = None, ext_data: Optional[dict] = None)

Metaclass for various endpoints of the API.

__dir__() list

Default dir() implementation.

__getattr__(item: str) Any

An override for getattr.

Parameters

item (str) – Attribute to be found from the object

Raises

AttributeError – If attribute not found.

Returns

APIObject’s attribute.

Return type

Any

__setattr__(key: str, value: str)

An override for setattr.

Parameters
  • key (str) – The name of the attribute.

  • value (str) – The value of the attribute.

Raises

AttributeError – If accessed a non-editable attribute .

classmethod get(id: Optional[int] = None) dynacrop.api_handles.APIObject

Acquires APIObject instatiated into one of the DynaCrop API endpoints.

Parameters

id (int) – ID of an endpoint request.

Returns

APIObject made to an API endpoint.

Return type

APIObject

classmethod create(**kwargs) dynacrop.api_handles.APIObject

Creates APIObject later instatiated into one of the DynaCrop API endpoints.

Parameters

kwargs (Optional[str]) –

Returns

APIObject made to an API endpoint.

Return type

APIObject

delete()

Deletes APIObject from the API.

classmethod list() Iterator[dynacrop.api_handles.APIObject]

Fetches APIObjects in bulk as an iterator.

Returns

Iterator of APIObjects.

Return type

APIObjectIterator

is_ready() bool

Checks whether the request is ready.

Returns

Is ready statement.

Return type

bool

is_failed() bool

Checks whether the request failed.

Returns

Failure statement.

Return type

bool

block_till_completed(polling_interval: int = 1)

Suspends the code execution until the request response is returned as finished/with error/with no data.

Args:

polling_interval (int, optional): Time to wait between checking iterations. Defaults to 1.

refresh()

Updates response data.

__eq__(other: object) bool

Compares two instantiated endpoints (APIObjects).

Parameters

other (APIObject) – Another APIObject to compare.

Returns

Comparation statement.

Return type

bool

class dynacrop.api_handles.APIObjectIterator(cls: Type[dynacrop.api_handles.APIObject])

Iterator for listing existing APIObjects.

map_to_correct_instance(endpoint_data: dict) dynacrop.api_handles.APIObject

Maps an APIObject (like ProcessingRequest) to a correct child if necessary.

Parameters

endpoint_data (dict) – Data of the API endpoint/object.

Returns

Profound APIObject instance.

Return type

APIObject

__iter__() dynacrop.api_handles.APIObjectIterator

Returns iterator.

Returns

The iterator.

Return type

APIObjectIterator

__next__() dynacrop.api_handles.APIObject

Acquires next object on the page within pagination. Automatically calls next page if necessary.

Raises

StopIteration – When there are no more results to iterate over.

Returns

APIObject made to an API endpoint.

Return type

APIObject