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]

Extend DRF dispatch() to add authentication checks and logging.

Parameters:

request (Request) – The incoming HTTP request.

Returns:

The HTTP response generated by the view.

Return type:

HttpResponse

Raises:
  • AuthenticationFailed – Raised when authentication fails.

  • SmarterTokenAuthenticationError – Raised for errors specific to SmarterTokenAuthentication.

get_queryset()[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)

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.

get_queryset()[source]
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

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

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