Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self._get_interfaces(context)
def _dump(self, context):
self._dump_content(context, (
'description',
'version',
'derived_from',
'valid_target_types',
'properties',
'attributes',
'interfaces'))
@has_fields
@implements_specification('3.6.8', 'tosca-simple-1.0')
class NodeType(ExtensiblePresentation):
"""
A Node Type is a reusable entity that defines the type of one or more Node Templates. As such, a
Node Type defines the structure of observable properties via a Properties Definition, the
Requirements and Capabilities of the node as well as its supported interfaces.
See the `TOSCA Simple Profile v1.0 cos01 specification `__
"""
@field_validator(derived_from_validator(convert_name_to_full_type_name, 'node_types'))
@primitive_field(str)
def derived_from(self):
"""
An optional parent Node Type name this new Node Type derives from.
if the_type is not None else None
interface_definition = interface_definitions.get(self._name) \
if interface_definitions is not None else None
return interface_definition._get_type(context) \
if interface_definition is not None else None
def _validate(self, context):
super(InterfaceAssignment, self)._validate(context)
if self.operations:
for operation in self.operations.itervalues(): # pylint: disable=no-member
operation._validate(context)
@short_form_field('type')
@has_fields
class RelationshipAssignment(ExtensiblePresentation):
"""
Relationship assignment.
"""
@field_validator(relationship_template_or_type_validator)
@primitive_field(str)
def type(self):
"""
The optional reserved keyname used to provide the name of the Relationship Type for the
requirement assignment's relationship keyname.
ARIA NOTE: this can also be a relationship template name.
:type: :obj:`basestring`
"""
def _get_inputs(self, context):
return FrozenDict(get_and_override_input_definitions_from_type(context, self))
@cachedmethod
def _get_operations(self, context):
return FrozenDict(get_and_override_operation_definitions_from_type(context, self))
def _validate(self, context):
super(InterfaceDefinition, self)._validate(context)
self._get_inputs(context)
self._get_operations(context)
@short_form_field('type')
@has_fields
class RelationshipDefinition(ExtensiblePresentation):
"""
Relationship definition.
"""
@field_validator(type_validator('relationship type', convert_name_to_full_type_name,
'relationship_types'))
@primitive_field(str, required=True)
def type(self):
"""
The optional reserved keyname used to provide the name of the Relationship Type for the
requirement definition's relationship keyname.
ARIA NOTE: the spec shows this as a required field.
:type: :obj:`basestring`
"""
def node_template(self):
return str(self._raw[0])
@property
@cachedmethod
def capability(self):
return str(self._raw[1])
def _validate(self, context):
super(SubstitutionMappingsCapability, self)._validate(context)
validate_substitution_mappings_capability(context, self)
@has_fields
@implements_specification('2.10', 'tosca-simple-1.0')
class SubstitutionMappings(ExtensiblePresentation):
"""
Substitution mappings.
"""
@field_validator(type_validator('node type', convert_name_to_full_type_name, 'node_types'))
@primitive_field(str, required=True)
def node_type(self):
"""
:type: :obj:`basestring`
"""
@object_dict_field(SubstitutionMappingsRequirement)
def requirements(self):
"""
:type: {:obj:`basestring`: :class:`SubstitutionMappingsRequirement`}
"""
super(InterfaceType, self)._validate(context)
self._get_inputs(context)
self._get_operations(context)
def _dump(self, context):
self._dump_content(context, (
'description',
'version',
'derived_from',
'inputs',
'operations'))
@has_fields
@implements_specification('3.6.9', 'tosca-simple-1.0')
class RelationshipType(ExtensiblePresentation):
"""
A Relationship Type is a reusable entity that defines the type of one or more relationships
between Node Types or Node Templates.
See the `TOSCA Simple Profile v1.0 cos01 specification `__
"""
@field_validator(derived_from_validator(convert_name_to_full_type_name, 'relationship_types'))
@primitive_field(str)
def derived_from(self):
"""
An optional parent Relationship Type name the Relationship Type derives from.
:type: :obj:`basestring`
The required data type for the parameter.
Note: This keyname is required for a TOSCA Property definition, but is not for a TOSCA
Parameter definition.
ARIA NOTE: the spec must be mistaken: inputs should have this field requires, only outputs
have it as optional.
:type: :obj:`basestring`
"""
@short_form_field('implementation')
@has_fields
@implements_specification('3.5.13-1', 'tosca-simple-1.0')
class OperationDefinition(ExtensiblePresentation):
"""
An operation definition defines a named function or procedure that can be bound to an
implementation artifact (e.g., a script).
See the `TOSCA Simple Profile v1.0 cos01 specification `__
"""
@object_field(Description)
def description(self):
"""
The optional description string for the associated named operation.
:type: :class:`Description`
"""
from .modeling.policies import get_inherited_targets
from .modeling.parameters import get_inherited_parameter_definitions
from .modeling.requirements import get_inherited_requirement_definitions
from .presentation.extensible import ExtensiblePresentation
from .presentation.field_getters import data_type_class_getter
from .presentation.field_validators import (data_type_derived_from_validator,
data_type_constraints_validator,
data_type_properties_validator,
list_node_type_or_group_type_validator)
from .presentation.types import convert_name_to_full_type_name
@has_fields
@implements_specification('3.6.3', 'tosca-simple-1.0')
class ArtifactType(ExtensiblePresentation):
"""
An Artifact Type is a reusable entity that defines the type of one or more files that are used
to define implementation or deployment artifacts that are referenced by nodes or relationships
on their operations.
See the `TOSCA Simple Profile v1.0 cos01 specification `__
"""
@field_validator(derived_from_validator(convert_name_to_full_type_name, 'artifact_types'))
@primitive_field(str)
def derived_from(self):
"""
An optional parent Artifact Type name the Artifact Type derives from.
self._get_attributes(context)
def _dump(self, context):
self._dump_content(context, (
'description',
'version',
'derived_from',
'valid_source_types',
'properties',
'attributes'))
@allow_unknown_fields
@has_fields
@implements_specification('3.6.4', 'tosca-simple-1.0')
class InterfaceType(ExtensiblePresentation):
"""
An Interface Type is a reusable entity that describes a set of operations that can be used to
interact with or manage a node or relationship in a TOSCA topology.
See the `TOSCA Simple Profile v1.0 cos01 specification `__
"""
@field_validator(derived_from_validator(convert_name_to_full_type_name, 'interface_types'))
@primitive_field(str)
def derived_from(self):
"""
An optional parent Interface Type name this new Interface Type derives from.
:type: :obj:`basestring`
@object_dict_field(PropertyDefinition)
def inputs(self):
"""
The optional list of input property definitions available to all defined operations for
interface definitions that are within TOSCA Node or Relationship Type definitions. This
includes when interface definitions are included as part of a Requirement definition in a
Node Type.
:type: {:obj:`basestring`: :class:`PropertyDefinition`}
"""
@allow_unknown_fields
@has_fields
@implements_specification('3.5.14-1', 'tosca-simple-1.0')
class InterfaceDefinition(ExtensiblePresentation):
"""
An interface definition defines a named interface that can be associated with a Node or
Relationship Type.
See the `TOSCA Simple Profile v1.0 cos01 specification `__
"""
@field_validator(type_validator('interface type', convert_name_to_full_type_name,
'interface_types'))
@primitive_field(str, required=True)
def type(self):
"""
ARIA NOTE: This field is not mentioned in the spec, but is implied.
type_name = self.type
if type_name is not None:
the_type = context.presentation.get_from_dict('service_template', 'topology_template',
'relationship_templates', type_name)
if the_type is not None:
return the_type, 'relationship_template'
the_type = get_type_by_name(context, type_name, 'relationship_types')
if the_type is not None:
return the_type, 'relationship_type'
return None, None
@short_form_field('node')
@has_fields
@implements_specification('3.7.2', 'tosca-simple-1.0')
class RequirementAssignment(ExtensiblePresentation):
"""
A Requirement assignment allows template authors to provide either concrete names of TOSCA
templates or provide abstract selection criteria for providers to use to find matching TOSCA
templates that are used to fulfill a named requirement's declared TOSCA Node Type.
See the `TOSCA Simple Profile v1.0 cos01 specification `__
"""
# The example in 3.7.2.2.2 shows unknown fields in addition to these, but is this a mistake?
@field_validator(capability_definition_or_type_validator)
@primitive_field(str)
def capability(self):
"""