Models
Models of the infrastructure app.
InfrastructureResource is the ledger of the platform’s cloud resources: DNS zones and
records, TLS certificates, and billable Kubernetes resources that the platform creates, and the
Kubernetes cluster that it runs on, i.e. the cluster, its add-ons, node groups, nodes, volumes,
load balancers, ingresses and cert-manager certificates, which the inventory discovers, see
smarter.apps.infrastructure.services.inventory. The receivers of the infrastructure
signals keep it, see smarter.apps.infrastructure.receivers, so that what the platform has
provisioned, and what it costs, can be audited without asking each cloud.
- class smarter.apps.infrastructure.models.InfrastructureResource(*args, **kwargs)[source]
Bases:
TimestampedModelA cloud resource that the platform created or discovered, and whether it still exists.
- Parameters:
id (Unknown) – Primary key: ID
created_at (Unknown) – Created at
updated_at (Unknown) – Updated at
provider (Unknown) – Provider. The cloud provider, e.g. aws.
service (Unknown) – Service. The infrastructure service, e.g. dns.
resource_type (Unknown) – Resource type. The kind of resource, e.g. dns.zone.
resource_name (Unknown) – Resource name. The resource’s name, e.g. example.com.
resource_id (Unknown) – Resource id. The provider’s id of the resource, if any.
billable (Unknown) – Billable. Whether the provider bills for the resource.
status (Unknown) – Status
destroyed_at (Unknown) – Destroyed at
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- exception NotUpdated
Bases:
ObjectNotUpdated,DatabaseError
- class Status(*values)[source]
Bases:
TextChoicesWhether the resource exists.
- ACTIVE = 'active'
- DESTROYED = 'destroyed'
- billable
-
Billable. Whether the provider bills for the resource.
- Type:
Type
- created_at
-
Created at
Timestamp indicating when the model instance was created.
This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.
- Type:
Type
- destroyed_at
-
Destroyed at
- Type:
Type
- get_status_display(*, field=<django.db.models.CharField: status>)
Shows the label of the
status. Seeget_FOO_display()for more information.
- id: int
-
Primary key: ID
The row’s primary key, which Django adds to every concrete model. Declared, without a value, only so that type checkers know it: Django ignores a bare annotation.
- Type:
Type
- objects = <django.db.models.Manager object>
- classmethod record_created(provider, service, resource_type, resource_name, resource_id=None, billable=False)[source]
Record that a resource was created, or updated.
A resource that is already active is updated, rather than recorded twice.
- Return type:
- classmethod record_destroyed(provider, service, resource_type, resource_name, resource_id=None, billable=False)[source]
Record that a resource was destroyed.
A resource that the ledger does not know, e.g. one created before it existed, is recorded as destroyed.
- Return type:
- updated_at
-
Updated at
Timestamp indicating when the model instance was last updated.
This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.
- Type:
Type
Serializers of the infrastructure app.
- class smarter.apps.infrastructure.serializers.InfrastructureResourceSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerSerializer of the ledger of cloud resources,
InfrastructureResource, with camelCase field names.Example usage:
from smarter.apps.infrastructure.serializers import InfrastructureResourceSerializer data = InfrastructureResourceSerializer(resource).data