Base

Inheritance diagram of musify.libraries.remote.core.base

Core abstract classes for the Remote module.

These define the foundations of any remote object or item.

Classes:

RemoteObject(response[, api, skip_checks])

Generic base class for remote objects.

RemoteItem(response[, api, skip_checks])

Generic base class for remote items.

class musify.libraries.remote.core.base.RemoteObject(response, api=None, skip_checks=False)

Bases: RemoteResponse, Generic

Generic base class for remote objects. Extracts key data from a remote API JSON response.

Parameters:
  • response (dict[str, Any]) – The remote API JSON response

  • api (T (default: None)) – The instantiated and authorised API object for this source type.

Attributes:

uri

URI (Uniform Resource Indicator) is the unique identifier for this item/collection.

has_uri

Does this item/collection have a valid URI that is not a local URI.

response

The API response for this object

kind

The type of remote object this class represents

api

The RemoteAPI to call when reloading

Methods:

load(value, api, *args, **kwargs)

Generate a new object of this class, calling all required endpoints to get a complete set of data for this item type.

reload(*args, **kwargs)

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

abstract property uri: str

URI (Uniform Resource Indicator) is the unique identifier for this item/collection.

abstract property has_uri: bool

Does this item/collection have a valid URI that is not a local URI.

property response: dict[str, Any]

The API response for this object

abstract property kind: RemoteObjectType

The type of remote object this class represents

api

The RemoteAPI to call when reloading

abstract async classmethod load(value, api, *args, **kwargs)

Generate a new object of this class, calling all required endpoints to get a complete set of data for this item type.

value may be:
  • A string representing a URL/URI/ID.

  • A remote API JSON response for a collection with a valid ID value under an id key.

  • An object of the same type as this collection. The remote API JSON response will be used to load a new object.

Parameters:
  • value (GenericAlias[RemoteResponse]) – The value representing some remote object. See description for allowed value types.

  • api (RemoteAPI) – An authorised API object to load the object from.

Return type:

Self

abstract async reload(*args, **kwargs)

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

Return type:

None

class musify.libraries.remote.core.base.RemoteItem(response, api=None, skip_checks=False)

Bases: RemoteObject, MusifyItem

Generic base class for remote items. Extracts key data from a remote API JSON response.

Attributes:

api

The RemoteAPI to call when reloading

api

The RemoteAPI to call when reloading