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, ABC, 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 (TypeVar(T, bound= RemoteAPI | None) (default: None)) – The instantiated and authorised API object for this source type.

Attributes:

uri

The URI of this item/collection.

has_uri

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

url

The API URL of this item/collection.

url_ext

The external URL of this item/collection.

response

The API response for this object

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

The URI of this item/collection.

abstract property has_uri: bool

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

abstract property url: str

The API URL of this item/collection.

abstract property url_ext: str | None

The external URL of this item/collection.

property response: dict[str, Any]

The API response for this object

api

The RemoteAPI to call when reloading

abstract 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 (str | Mapping[str, Any] | 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 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, ABC

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