Secret Views

Secret API views.

Their responses are built from smarter.apps.secret.contract.models.SecretApiSecret, a Secret’s metadata without its value, which the Smarter api’s OpenAPI document publishes.

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

Bases: ContractListMixin, SmarterAdminListAPIView

Class for secret list views.

contract_model

alias of SecretApiSecret

dispatch(request, *args, **kwargs)[source]

Dispatch the request, and log it.

Parameters:

request (HttpRequest) – The request.

Returns:

The response, or 403 when the request has no user, which makes an admin decorator raise AttributeError.

get_queryset()[source]

The Secrets that belong to any of the requesting user’s accounts.

item(row)[source]

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

serializer_class

alias of SecretSerializer

setup(request, *args, **kwargs)[source]

Setup the view.

This is called by Django before dispatch() and is used to set up the view for the request.

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

Bases: SmarterAdminAPIView

Class for secret views.

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

Return the Secret, without its value.

Parameters:
  • request (Request) – The request.

  • secret_id (int) – The Secret’s id, from the url.

Returns:

The Secret, as a SecretApiSecret.

Raises:

Http404 – when no Secret of the user’s accounts has this id.

get_queryset()[source]

The Secrets that belong to any of the requesting user’s accounts.

post(request, secret_id, *args, **kwargs)[source]

Same as get().

Smarter detail views are also served by POST.

serializer_class

alias of SecretSerializer

smarter.apps.secret.api.v1.views.secrets_for_user(user)[source]

The Secrets that belong to any of the user’s accounts.

Return type:

QuerySet[Secret]

smarter.apps.secret.api.v1.views.should_log(level)[source]

Check if logging should be done based on the waffle switch.