craft_store.endpoints module

Endpoint definitions for different services.

craft_store.endpoints.CHARMHUB: Final = Endpoints(namespace='charm', whoami='/v1/tokens/whoami', tokens='/v1/tokens', tokens_exchange='/v1/tokens/exchange', list_releases_model=<class 'craft_store.models.charm_list_releases_model.ListReleasesModel'>, valid_package_types=['charm', 'bundle'], upload='/unscanned-upload/', tokens_refresh=None)

Charmhub set of supported endpoints.

class craft_store.endpoints.Endpoints(namespace, whoami, tokens, tokens_exchange, list_releases_model, valid_package_types, upload='/unscanned-upload/', tokens_refresh=None)[source]

Bases: object

Endpoints used to make requests to a store.

Parameters
  • namespace (str) – the namespace to use for endpoints.

  • whoami (str) – path to the whoami API.

  • upload (str) – path used for uploading.

  • tokens (str) – path to the tokens API.

  • tokens_exchange (str) – path to the tokens_exchange API.

  • tokens_refresh (Optional[str]) – path to the tokens_refresh API.

  • list_releases_model (Type[MarshableModel]) – list_releases response model.

  • valid_package_types (Sequence[str]) –

get_releases_endpoint(name)[source]

Return the slug to the releases endpoint.

Parameters

name (str) –

Return type

str

get_revisions_endpoint(name)[source]

Return the slug to the revisions endpoint.

Parameters

name (str) –

Return type

str

get_token_request(*, permissions, description, ttl, channels=None, packages=None)[source]

Return a properly formatted request for a token request.

Permissions can be selected from craft_store.attenuations

Parameters
  • permissions (Sequence[str]) – a list of permissions to use.

  • description (str) – description that identifies the client.

  • ttl (int) – time to live for the requested token.

  • packages (Optional[Sequence[Package]]) – a sequence of Package to limit the requested token to.

  • channels (Optional[Sequence[str]]) – a sequence of channels to limit the requested token to.

Return type

Dict[str, Any]

static get_upload_id(result)[source]

Return the upload ID for a given result.

Parameters

result (Dict[str, Any]) – the result from an upload request.

Return type

str

list_releases_model: Type[craft_store.models._base_model.MarshableModel]
namespace: str
tokens: str
tokens_exchange: str
tokens_refresh: Optional[str] = None
upload: str = '/unscanned-upload/'
valid_package_types: Sequence[str]
whoami: str
class craft_store.endpoints.Package(package_name, package_type)[source]

Bases: object

Representation of a package name and type.

Parameters
  • package_name (str) –

  • package_type (str) –

package_name: str
package_type: str
craft_store.endpoints.SNAP_STORE: Final = _SnapStoreEndpoints(namespace='snap', whoami='/api/v2/tokens/whoami', tokens='/api/v2/tokens', tokens_exchange='/api/v2/tokens/exchange', list_releases_model=<class 'craft_store.models.snap_list_releases_model.ListReleasesModel'>, valid_package_types=['snap'], upload='/unscanned-upload/', tokens_refresh=None)

Snap Store set of supported endpoints.

craft_store.endpoints.U1_SNAP_STORE: Final = _SnapStoreEndpoints(namespace='snap', whoami='/api/v2/tokens/whoami', tokens='/dev/api/acl/', tokens_exchange='/api/v2/tokens/discharge', list_releases_model=<class 'craft_store.models.snap_list_releases_model.ListReleasesModel'>, valid_package_types=['snap'], upload='/unscanned-upload/', tokens_refresh='/api/v2/tokens/refresh')

Ubuntu One compatible Snap Store set of supported endpoints.