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.

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.

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 models.

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.

Return type:

Provider

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]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

Return type:

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.