Connection Views

smarter.apps.plugin.views.connection This module contains views to implement the card-style list view in the Smarter Dashboard.

class smarter.apps.plugin.views.connection.ConnectionDetailView(*args, **kwargs)[source]

Bases: DocsBaseView

Renders the detail view for a Smarter dashboard connection.

This view renders a detailed manifest for a specific connection, including its configuration and metadata, in YAML format. It is intended for authenticated users and provides error handling for missing or unsupported connection kinds and names.

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

  • args (tuple) – Additional positional arguments.

  • kwargs (dict) – Keyword arguments, must include ‘name’ (connection name) and ‘kind’ (connection type).

Returns:

Rendered HTML page with connection manifest details, or a 404 error page if the connection is not found or parameters are invalid.

Return type:

HttpResponse

Note

The connection name and kind must be provided and valid. Otherwise, a “not found” response is returned.

See also

ConnectionBase for connection metadata retrieval. ApiV1CliDescribeApiView for API details.

Example usage:

GET /connection/detail/?name=my_connection&kind=custom
connection: Optional[ConnectionBase] = None
get(request, *args, **kwargs)[source]

Handle GET requests to render the connection manifest detail view. This method processes the incoming request to retrieve the specified connection’s manifest details and renders them in a user-friendly format. It performs validation on the provided connection name and kind, retrieves the connection metadata, and handles any errors that may arise during this process.

Process: 1. Extract and validate ‘name’ and ‘kind’ from kwargs. 2. Retrieve the connection metadata using the provided name and user context. 3. If the connection is found, call the API view to get the connection details 4. Convert the JSON response to YAML format for better readability. 5. Render the connection manifest detail template with the retrieved data. 6. Handle any errors that occur during the process and return appropriate error responses.

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

  • args (tuple) – Additional positional arguments.

  • kwargs (dict) – Keyword arguments, must include ‘name’ (connection name) and ‘kind’ (connection type).

Returns:

Rendered HTML page with connection manifest details, or an error response if the connection is not found or parameters are invalid.

Return type:

HttpResponse

template_path: Optional[str] = 'plugin/manifest_detail.html'
class smarter.apps.plugin.views.connection.ConnectionListView(*args, **kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

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

This view displays all connections available to the authenticated user as cards, providing a summary and quick access to connection details.

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

  • args (tuple) – Additional positional arguments.

  • kwargs (dict) – Additional keyword arguments.

Returns:

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

Return type:

HttpResponse

See also

ConnectionBase for connection metadata and retrieval.

Example usage:

GET /connection/list/
connections: list[ConnectionBase]
get(request, *args, **kwargs)[source]

Handle GET requests and return a cleaned HttpResponse.

Parameters:

request (HttpRequest) – The HTTP request object.

Returns:

An HttpResponse with the cleaned HTML content.

Return type:

HttpResponse

template_path: str = 'plugin/connection_list.html'
smarter.apps.plugin.views.connection.should_log(level)[source]

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