Secret Views

This module contains views to implement the React.

Secret list view in the Smarter Dashboard.

class smarter.apps.secret.views.listview.api.SecretListApiCloneView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Clone a secret for the authenticated user.

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

Handle POST requests to clone an existing Secret.

Validates input parameters, checks for the existence of the Secret to be cloned, and creates a new Secret with the specified name. Invalidates the cache for the user’s LLMClients after cloning.

Parameters:
  • request (HttpRequest) – The HTTP request object containing the parameters for cloning.

  • args – Additional positional arguments (not used).

  • kwargs

    Additional keyword arguments, including:

    • secret_id (str): The ID of the Secret to be cloned.

    • new_name (str): The new name for the cloned Secret.

Returns:

A JsonResponse containing the serialized data of the newly cloned Secret if successful, or an error message if the cloning fails.

Return type:

JsonResponse

class smarter.apps.secret.views.listview.api.SecretListApiDeleteView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Delete a secret for the authenticated user.

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

Handle POST requests to delete an existing Secret.

Validates input parameters, checks for the existence of the Secret to be deleted, and deletes the Secret if it exists. Invalidates the cache for the user’s LLMClients after deletion.

Parameters:
  • request (HttpRequest) – The HTTP request object containing the parameters for deletion.

  • args – Additional positional arguments (not used).

  • kwargs

    Additional keyword arguments, including:

    • secret_id (str): The ID of the Secret to be deleted.

Returns:

A JsonResponse indicating the success or failure of the deletion.

Return type:

JsonResponse

class smarter.apps.secret.views.listview.api.SecretListApiRenameView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Rename a secret for the authenticated user.

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

Handle POST requests to rename an existing Secret.

Validates input parameters, checks for the existence of the Secret to be renamed, and renames the Secret if it exists. Invalidates the cache for the user’s LLMClients after renaming.

Parameters:
  • request (HttpRequest) – The HTTP request object containing the parameters for renaming.

  • args – Additional positional arguments (not used).

  • kwargs

    Additional keyword arguments, including:

    • secret_id (str): The ID of the Secret to be renamed.

    • new_name (str): The new name for the Secret.

Returns:

A JsonResponse indicating the success or failure of the renaming.

Return type:

JsonResponse

class smarter.apps.secret.views.listview.api.SecretListApiView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Render the secret list view for the Smarter Workbench web console.

This view displays all secrets available to the authenticated user as cards, providing a quick overview and access to secret details.

Parameters:
  • request (ASGIRequest) – Django HTTP request object.

  • args (tuple) – Additional positional arguments.

  • kwargs (dict) – Additional keyword arguments.

Returns:

Rendered HTML page with a card for each secret, or a 404 error page if the user is not authenticated.

Return type:

HttpResponse

post(request, *args, **kwargs)[source]
Return type:

Union[JsonResponse, SmarterHttpResponseNotFound]