ListView API

This module contains views to implement the React Proxy list view in the Smarter Dashboard.

class smarter.apps.proxy.views.listview.api.ProxyListApiCloneView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Clone a proxy for the authenticated user.

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

Handle POST requests to clone an existing Proxy.

Validates input parameters, checks for the existence of the Proxy to be cloned, and creates a new Proxy with the specified name. Invalidates the cache for the user’s Proxies 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:

    • proxy_id (str): The ID of the Proxy to be cloned.

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

Returns:

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

Return type:

JsonResponse

class smarter.apps.proxy.views.listview.api.ProxyListApiDeleteView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Delete a proxy for the authenticated user.

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

Handle POST requests to delete an existing Proxy.

Validates input parameters, checks for the existence of the Proxy to be deleted, and deletes the Proxy 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:

    • proxy_id (str): The ID of the Proxy to be deleted.

Returns:

A JsonResponse indicating the success or failure of the deletion.

Return type:

JsonResponse

class smarter.apps.proxy.views.listview.api.ProxyListApiRenameView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Rename a proxy for the authenticated user.

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

Handle POST requests to rename an existing Proxy.

Validates input parameters, checks for the existence of the Proxy to be renamed, and renames the Proxy 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:

    • proxy_id (str): The ID of the Proxy to be renamed.

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

Returns:

A JsonResponse indicating the success or failure of the renaming.

Return type:

JsonResponse

class smarter.apps.proxy.views.listview.api.ProxyListApiView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

The JSON API of the web console’s Proxy list view.

Returns a page of the Proxies that the user owns, that are shared with them, or both, according to ownership_filter: owned, shared or all.

Query parameters: page, page_size and invalidate_cache.

Returns:

{"user": ..., "admin": ..., "objects": [...]}, where objects are serialized by ProxySerializer.

Return type:

JsonResponse

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

Union[JsonResponse, SmarterHttpResponseNotFound]