API Reference

Provider api/v1/providers views.

Providers are created and updated by applying manifests, with smarter apply, so these views only read them:

  • GET providers/: the active Providers that the user may read.

  • GET providers/<name>/: an active Provider that the user may read.

  • GET providers/<name>/models/: the active models of that Provider.

  • GET providers/<name>/models/<model_name>/: one active model of that Provider.

A Provider or model that does not exist, is inactive, or belongs to another account answers 404, so that the Providers of other accounts are not disclosed.

The responses are built from the models of smarter.apps.provider.contract.models, which the Smarter api’s OpenAPI document publishes.

class smarter.apps.provider.api.v1.views.provider.ProviderApiViewSet(*args, **kwargs)[source]

Bases: ProviderViewBase

An active Provider that the user may read.

get(request, *args, name, **kwargs)[source]

Return the Provider.

Parameters:
  • request (Request) – The api request.

  • name (str) – The Provider’s name.

Returns:

A 200 response whose body is the Provider, as a ProviderApiProvider.

Raises:

Http404 – If no active Provider with this name is readable by the user.

serializer_class

alias of ProviderSerializer

class smarter.apps.provider.api.v1.views.provider.ProviderModelApiViewSet(*args, **kwargs)[source]

Bases: ProviderViewBase

An active model of an active Provider that the user may read.

get(request, *args, name, model_name, **kwargs)[source]

Return the model.

Parameters:
  • request (Request) – The api request.

  • name (str) – The Provider’s name.

  • model_name (str) – The model’s name.

Returns:

A 200 response whose body is the model, as a ProviderApiModel.

Raises:

Http404 – If the Provider, or an active model of it with this name, is not found.

serializer_class

alias of ProviderModelSerializer

class smarter.apps.provider.api.v1.views.provider.ProviderModelsApiViewSet(*args, **kwargs)[source]

Bases: ProviderViewBase

The active models of an active Provider that the user may read.

get(request, *args, name, **kwargs)[source]

Return the Provider’s active models, ordered by name.

Parameters:
  • request (Request) – The api request.

  • name (str) – The Provider’s name.

Returns:

A 200 response whose body is a list of ProviderApiModel.

Raises:

Http404 – If no active Provider with this name is readable by the user.

serializer_class

alias of ProviderModelSerializer

class smarter.apps.provider.api.v1.views.provider.ProviderViewBase(*args, **kwargs)[source]

Bases: SmarterAuthenticatedAPIView

Base class for views of one Provider, identified by its name.

get_provider() returns the Provider only if it is active and the user may read it. Otherwise it raises Http404. Provider names are unique per account, so when the user may read several Providers of that name, their own account’s wins.

get_provider(request, name)[source]

Return the active Provider with this name that the user may read.

When several match, the oldest one of the user’s own account wins, else the oldest one.

Parameters:
  • request (Request) – The api request, whose user’s read permission is applied.

  • name (str) – The Provider’s name.

Return type:

Provider

Returns:

The Provider.

Raises:

Http404 – If no active Provider with this name is readable by the user.

class smarter.apps.provider.api.v1.views.provider.ProvidersApiViewSet(*args, **kwargs)[source]

Bases: ContractListMixin, SmarterAuthenticatedListAPIView

The active Providers that the user may read.

contract_model

alias of ProviderApiProvider

get_queryset(*args, **kwargs)[source]

Return the active Providers that the requesting user may read.

Return type:

QuerySet

Returns:

The readable Providers queryset.

item(row)[source]

A Provider of the response, whose canDelete is the requesting user’s.

serializer_class

alias of ProviderSerializer

smarter.apps.provider.api.v1.views.provider.readable_providers(request)[source]

Return the active Providers that the request’s user may read.

Parameters:

request (Request) – The authenticated request.

Return type:

QuerySet

Returns:

The Providers, ordered by name.