Views
PluginMeta views.
- class smarter.apps.llmtool.api.v1.views.PluginCloneView(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedAPIViewPlugin clone view for smarter api.
- post(request, plugin_id, new_name)[source]
Clone a plugin under a new name, and redirect to the clone.
- Parameters:
request (
ASGIRequest) – The request.plugin_id – The id of the plugin to clone, from the url.
new_name – The clone’s name, from the url.
- Returns:
A redirect to
/plugins/<new id>/, or an error response.
- class smarter.apps.llmtool.api.v1.views.PluginListView(*args, **kwargs)[source]
Bases:
ContractListMixin,SmarterAuthenticatedListAPIViewPlugins list view for smarter api.
- contract_model
alias of
PluginApiPluginMeta
- get_queryset()[source]
Return the plugins that the requesting user has ownership permission for, newest first.
- item(row)[source]
A plugin of the response, whose
canDeleteis the requesting user’s.
- serializer_class
alias of
PluginMetaSerializer
- class smarter.apps.llmtool.api.v1.views.PluginUploadView(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedAPIViewPlugin view for smarter api.
- static parse_yaml_file(data)[source]
Parse a plugin manifest, as YAML or else JSON.
- Parameters:
data – The manifest: a YAML or JSON string or bytes, or an already parsed dict or list, which is returned as is.
- Returns:
The parsed manifest.
- Raises:
SmarterValueError – If the data is neither YAML nor JSON.
- parser_class = (<class 'rest_framework.parsers.FileUploadParser'>,)
- post(request)[source]
Create a plugin from the YAML or JSON manifest in the request body.
- Parameters:
request (
ASGIRequest) – The request.- Returns:
The response of
create_plugin().
- put(request)[source]
Create a plugin from the YAML or JSON manifest in the request body.
- Parameters:
request (
ASGIRequest) – The request.- Returns:
The response of
create_plugin().
- class smarter.apps.llmtool.api.v1.views.PluginView(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedAPIViewPlugin view for smarter api.
- delete(request, plugin_id)[source]
Delete a plugin.
- Parameters:
request (
ASGIRequest) – The request.plugin_id – The plugin’s id, from the url.
- Returns:
The response of
delete_plugin().
- get(request, plugin_id)[source]
Return a plugin’s manifest, if the
ALLOW_API_GETwaffle switch is active.- Parameters:
request (
ASGIRequest) – The request.plugin_id – The plugin’s id, from the url.
- Returns:
The response of
get_plugin(), or 405 if the switch is inactive.
- patch(request, plugin_id=None)[source]
Update a plugin from the manifest in the request body.
- post(request, plugin_id=None)[source]
Update the plugin with the given id from the manifest in the request body, or create one if no id is given.
- put(request, plugin_id=None)[source]
Update the plugin with the given id from the manifest in the request body, or create one if no id is given.
- smarter.apps.llmtool.api.v1.views.create_plugin(request, data=None)[source]
Create a plugin from a json representation in the body of the request.
- smarter.apps.llmtool.api.v1.views.delete_plugin(request, plugin_id)[source]
Delete a plugin by id.
- Parameters:
request – The request.
plugin_id – The id of the plugin to delete.
- Returns:
A redirect to the plugins list, or an error response.
- smarter.apps.llmtool.api.v1.views.get_plugin(request, plugin_id)[source]
Get a plugin’s manifest, by id, if the user may read the plugin.
A plugin that the user may not read is not found, so that the plugins of other accounts are not disclosed. Errors are Django REST framework’s
{"detail": ...}.