Module fusion_platform.models.service

Service model class file.

author: Matthew Casey

© Digital Content Analysis Technology Ltd

Classes

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

    # Override the schema.
    _SCHEMA = ServiceSchema()

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

    # Base path.
    _PATH_BASE = '/organisations/{organisation_id}/services/{service_id}'

    # Override the standard model paths.
    _PATH_DELETE = _PATH_BASE
    _PATH_GET = _PATH_BASE
    _PATH_PATCH = _PATH_BASE

Service model class providing attributes and methods to manipulate service 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 ServiceSchema (*,
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 ServiceSchema(Schema):
    """
    Schema class for service model.

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

    .. include::service.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.
    ssd_id = fields.UUID(required=True)

    version = fields.Integer(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.
    approval_status = fields.String(required=True, metadata={'read_only': True})  # Changed to prevent this being updated.
    # Removed latest.
    featured = fields.String(allow_none=True)
    # Removed dispatcher.
    show_in_latest = fields.Boolean(allow_none=True)  # Changed to optional.
    name = fields.String(required=True)

    categories = fields.List(fields.String(required=True), required=True)
    keywords = fields.List(fields.String(required=True), required=True)

    image_id = fields.UUID(required=True)

    definition = fields.List(fields.Nested(ServiceDefinitionSchema()), allow_none=True)
    group_aggregators = fields.List(fields.Nested(ServiceGroupAggregatorSchema()), allow_none=True)
    actions = fields.List(fields.Nested(ServiceActionSchema()), allow_none=True)
    urls = fields.List(fields.Url(required=True), allow_none=True)
    cidrs = fields.List(fields.String(required=True), allow_none=True)

    input_expressions = fields.List(fields.Nested(ServiceInputExpressionSchema()), allow_none=True)
    input_validations = fields.List(fields.Nested(ServiceValidationSchema()), allow_none=True)
    option_expressions = fields.List(fields.Nested(ServiceOptionExpressionSchema()), allow_none=True)
    option_validations = fields.List(fields.Nested(ServiceValidationSchema()), allow_none=True)

    license_id = fields.UUID(required=True)

    charge_expression_platform = fields.String(allow_none=True)  # Changed to optional.
    charge_expression_owner = fields.String(allow_none=True)  # Changed to optional.

    organisations = fields.List(fields.UUID(required=True), allow_none=True)
    organisation_charge_expressions = fields.List(fields.Nested(ServiceOrganisationChargeExpressionSchema()), allow_none=True)
    geographic_regions = fields.List(fields.String(required=True), allow_none=True)

    # Removed creator.
    # Removed approver.

    # Removed search.

    documentation_summary = fields.String(required=True)
    documentation_description = fields.String(required=True)
    documentation_assumptions = fields.String(required=True)
    documentation_performance = fields.String(required=True)
    documentation_actions = fields.String(required=True)
    documentation_inputs = fields.List(fields.String(required=True), allow_none=True)  # Added pseudo-parameter.
    documentation_outputs = fields.List(fields.String(required=True), allow_none=True)  # Added pseudo-parameter.
    documentation_options = fields.List(fields.String(required=True), allow_none=True)  # Added pseudo-parameter.

    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 service model.

Each service 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.
  • ssd_id: The SSD for which this service is a version.
  • version: The version number for the SSD that this service represents.
  • approval_status: The approval status for this service.
  • featured: Is this a featured service?
  • show_in_latest: Should this service be listed in the list of latest versions of services?
  • name: The name of the service.
  • categories: The list of categories linked to this service.
  • keywords: The list of keywords linked to this service.
  • image_id: The image which forms the core of the service.
  • definition: The service definition which links together this SSD with any other constituent SSD.
    • ssd_id: The SSD which is being linked into this service.
    • output: The output from the SSD being linked.
    • linkages: The list of linkages which consume the output.
      • ssd_id: The SSD which is being linked into this service.
      • input: The input to the SSD being linked.
  • group_aggregators: The list of aggregators which are run when all executions in a group have completed.
    • aggregator_ssd_id: The SSD executed to aggregate the outputs from a group.
    • output_ssd_id: The SSD whose outputs are used by the aggregator.
    • outputs: The list of outputs from the output SSD used by the aggregator.
    • options: The options for this aggregator.
      • ssd_id: The SSD for this option.
      • name: The name of the option.
      • value: The value for the option.
  • actions: The custom actions associated with the service.
    • name: The name of the value.
    • values: The values required for the action.
      • name: The name of the value.
      • required: Is the value required for the action?
      • data_type: The data type associated with the value.
      • default: The optional default value.
      • validation: The optional validation. This must be supplied for date/time and constrained values.
      • constant: Is this value constant and therefore cannot be changed?
      • ssd_id: The SSD from which this value is taken.
      • output: The output from the SSD being used for the value.
      • selector: The selector from the SSD output being used for the value.
      • expression: The expression used to calculate the value.
      • value: The actual value.
      • url: The URL which can be used to obtain the value.
      • advanced: Is this value for advanced usage?
      • title: The title for the value.
      • description: The description of the value.
    • url: The URL which can be executed to receive the value of the action.
    • title: The title for the action.
    • description: The description of the action.
  • urls:
  • cidrs:
  • input_expressions: The list of expressions which are applied to the inputs of the service.
    • lhs_ssd_id: The SSD associated with the left-hand side of the input expression.
    • lhs_input: The input associated with the left-hand side of the input expression.
    • expression: The expression linking the left- and right-hand sides of the input expression.
    • rhs_ssd_id: The SSD associated with the right-hand side of the input expression.
    • rhs_input: The input associated with the right-hand side of the input expression.
  • input_validations: The list of validation expressions which are applied to the inputs of the service.
    • expression: The expression used for validation.
    • message: The message associated with the validation which is used when the validation fails.
  • option_expressions: The list of expressions which are applied to the options of the service.
    • lhs_ssd_id: The SSD associated with the left-hand side of the option expression.
    • lhs_name: The option name associated with the left-hand side of the option expression.
    • expression: The expression used to calculate the option value.
  • option_validations: The list of validation expressions which are applied to the options of the service.
    • expression: The expression used for validation.
    • message: The message associated with the validation which is used when the validation fails.
  • license_id: The license which must be agreed with in order to execute the service.
  • charge_expression_platform: The expression used to calculate the charge in FPUs levied for the platform.
  • charge_expression_owner: The expression used to calculate the charge in FPUs levied for the owner of the service.
  • organisations: The optional whitelist of organisations who can use this service.
  • organisation_charge_expressions: For the whitelisted organisations, these provide the optional charge expressions to be applied.
    • id: The owning organisation.
    • platform: The expression used to calculate the charge in FPUs levied for the platform.
    • owner: The expression used to calculate the charge in FPUs levied for the owner of the service.
  • geographic_regions: The optional list of geographic regions from which this service can be used.
  • documentation_summary: The documentation summary of the service.
  • documentation_description: The documentation description of the service.
  • documentation_assumptions: Any documented assumptions that underlie the service.
  • documentation_performance: Notes on service performance.
  • documentation_actions: The documentation for the custom actions for the service.
  • documentation_inputs: The inputs to the service.
  • documentation_outputs: The outputs from the service.
  • documentation_options: The service options.

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.