Views

Views of the React Infrastructure Resource list in the Smarter web console.

The ledger, InfrastructureResource, describes the platform’s cloud infrastructure and what it costs, so it is for superusers only. It is written by the infrastructure signals’ receivers, so the list is read-only.

class smarter.apps.infrastructure.views.listview.InfrastructureResourceListApiView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

A page of the ledger’s resources that match the list’s filters, newest first, and a summary of all of them.

The request’s JSON body may have the filters of filter_resources(), and page, from 1, and pageSize, up to MAX_PAGE_SIZE. A page past the last is the last.

Response:

{
    "summary": {"total": 12, "active": 9, "activeBillable": 3, "destroyed": 3},
    "objects": [{"id": 12, "provider": "aws", "resourceType": "dns.zone", ...}],
    "pagination": {"page": 1, "pageSize": 50, "numPages": 1, "count": 9},
    "choices": {"providers": ["aws"], "resourceTypes": ["dns.record", "dns.zone"]}
}
property formatted_class_name: str

Returns a formatted string of the class name for logging purposes.

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

Return a page of the ledger’s resources that match the filters in the JSON body, and a summary.

Parameters:

request (ASGIRequest) – The request, whose JSON body has the filters, page and pageSize.

Return type:

JsonResponse

Returns:

The JSON response described above, or 403 Forbidden for a user who is not a superuser.

class smarter.apps.infrastructure.views.listview.InfrastructureResourceListView(**kwargs)[source]

Bases: ConsoleAppView

The Infrastructure Resource list page, /infrastructure/, which the single-page console serves (ADR-035).

The console renders @smarter/infrastructure-resource-list’s list at the page’s path for a superuser, and shows anyone else that the page is not found; the list calls InfrastructureResourceListApiView, which answers 403 Forbidden to a user who is not a superuser.

smarter.apps.infrastructure.views.listview.choices()[source]

The providers and resource types of the whole ledger, for the list’s filters.

Return type:

dict[str, list[str]]

smarter.apps.infrastructure.views.listview.filter_resources(body)[source]

The ledger’s resources that match the list’s filters, newest first.

Parameters:

body (dict[str, Any]) – The list’s request, whose filters are optional: status, active, destroyed or all; billableOnly; provider; resourceType, e.g. kubernetes.node; and text, which the resource’s name, type, id or service contains.

Return type:

QuerySet

Returns:

The matching resources.

smarter.apps.infrastructure.views.listview.summary()[source]

Counts of the ledger’s resources: in total, active, active and billable, and destroyed.

Return type:

dict[str, int]

Django URL patterns of the infrastructure app: the ledger of cloud resources.

how we got here:
  • /infrastructure/

class smarter.apps.infrastructure.urls.InfrastructureReverseNames[source]

Bases: object

Named URL patterns of the infrastructure app’s console pages.

The endpoint that the list page’s React app calls is in the web console’s api: see smarter.apps.infrastructure.api.web.urls.InfrastructureApiWebReverseNames.

listview = 'infrastructure_resource_list_view'
namespace = 'infrastructure'