Module fusion_platform.models.credit

Credit model class file.

author: Matthew Casey

© Digital Content Analysis Technology Ltd

Classes

class Credit (session, schema=None)
Expand source code
class Credit(Model):
    """
    Credit model class providing attributes and methods to manipulate credit item details.
    """

    # Override the schema.
    _SCHEMA = CreditSchema()

    # Override the base model class name.
    _BASE_MODEL_CLASS_NAME = 'Organisation'  # A string to prevent circular imports.

    # Base path.
    _PATH_BASE = '/organisations/{organisation_id}/credits/{credit_id}'

    # Override the standard model paths.
    _PATH_GET = _PATH_BASE

Credit model class providing attributes and methods to manipulate credit item details.

Initialises the object.

Args

session
The linked session object for interfacing with the Fusion Platform®.
schema
The optional schema to use instead of the schema defined by the class.

Ancestors

  • Model
  • fusion_platform.base.Base

Instance variables

prop attributes

Inherited from: Model.attributes

Returns

The model attributes as a dictionary.

Methods

def delete(self)

Inherited from: Model.delete

Attempts to delete the model object. This assumes the model is deleted using a DELETE RESTful request …

def get(self, **kwargs)

Inherited from: Model.get

Gets the model object by loading it from the Fusion Platform®. Uses the model's current id and base model id for the get unless …

def to_csv(self, exclude=None)

Inherited from: Model.to_csv

Converts the model attributes into a CSV string …

def update(self, **kwargs)

Inherited from: Model.update

Attempts to update the model object with the given values. For models which have not been persisted, the relevant fields are updated without …

class CreditSchema (*,
only: types.StrSequenceOrSet | None = None,
exclude: types.StrSequenceOrSet = (),
many: bool | None = None,
load_only: types.StrSequenceOrSet = (),
dump_only: types.StrSequenceOrSet = (),
partial: bool | types.StrSequenceOrSet | None = None,
unknown: types.UnknownOption | None = None)
Expand source code
class CreditSchema(Schema):
    """
    Schema class for credit model.

    Each credit model has the following fields (and nested fields):

    .. include::credit.md
    """
    id = fields.UUID(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.

    created_at = fields.DateTime(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.
    updated_at = fields.DateTime(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.

    organisation_id = fields.UUID(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.
    # Removed lock.

    any_credits = fields.Decimal(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.
    cloud_storage_credits = fields.Decimal(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.
    registry_storage_credits = fields.Decimal(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.
    runtime_any_credits = fields.Decimal(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.
    runtime_ssds = fields.List(fields.Nested(CreditSsdsSchema()), allow_none=True, metadata={'read_only': True})  # Changed to prevent this being updated.

    spend = fields.List(fields.Nested(CreditMonthlySpendSchema()), allow_none=True, metadata={'read_only': True})  # Changed to prevent this being updated.

    class Meta:
        """
        When loading an object, make sure we exclude any unknown fields, rather than raising an exception, and put fields in their definition order.
        """
        unknown = EXCLUDE

Schema class for credit model.

Each credit model has the following fields (and nested fields):

  • id: The unique identifier for the record.
  • created_at: When was the record created?
  • updated_at: When was the record last updated?
  • organisation_id: The owning organisation.
  • any_credits: How many credits does the organisation have which can be used for anything?
  • cloud_storage_credits: How many credits does the organisation have which can be used just for cloud storage?
  • registry_storage_credits: How many credits does the organisation have which can be used just for registry storage?
  • runtime_any_credits: How many credits does the organisation have which can be used just for runtime, but for any SSD?
  • runtime_ssds: Specifies the credits available for specific SSDs.
    • ssds: The list of SSDs for which the corresponding credits apply.
    • credits: How many credits does the organisation have which can be used just for the corresponding list of credits?
  • spend: The historic monthly spend of credits.
    • month: The month associated with the spend.
    • credits: How many credits were spent in this month?

Ancestors

  • marshmallow.schema.Schema

Class variables

var OPTIONS_CLASS : type

Defines defaults for marshmallow.Schema.Meta.

var TYPE_MAPPING : dict[type, type[Field]]

The type of the None singleton.

var dict_class : type[dict]

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

var error_messages : dict[str, str]

The type of the None singleton.