class CapabilityDefinition(ExtensiblePresentation): """ A capability definition defines a named, typed set of data that can be associated with Node Type or Node Template to describe a transparent capability or feature of the software component the node describes. See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca /TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html #DEFN_ELEMENT_CAPABILITY_DEFN>`__ """ @field_validator( type_validator('capability type', convert_shorthand_to_full_type_name, 'capability_types')) @primitive_field(str, required=True) def type(self): """ The required name of the Capability Type the capability definition is based upon. :type: :obj:`basestring` """ @object_field(Description) def description(self): """ The optional description of the Capability definition. :type: :class:`Description` """ @object_dict_field(PropertyDefinition) def properties(self): """ An optional list of property definitions for the Capability definition. :type: {:obj:`basestring`: :class:`PropertyDefinition`} """ @object_dict_field(AttributeDefinition) def attributes(self): """ An optional list of attribute definitions for the Capability definition. :type: {:obj:`basestring`: :class:`AttributeDefinition`} """ @field_validator( list_type_validator('node type', convert_shorthand_to_full_type_name, 'node_types')) @primitive_list_field(str) def valid_source_types(self): """ An optional list of one or more valid names of Node Types that are supported as valid sources of any relationship established to the declared Capability Type. :type: [:obj:`basestring`] """ @field_getter(data_type_class_getter(Range)) @primitive_field() def occurrences(self): """ The optional minimum and maximum occurrences for the capability. By default, an exported Capability should allow at least one relationship to be formed with it with a maximum of ``UNBOUNDED`` relationships. Note: the keyword ``UNBOUNDED`` is also supported to represent any positive integer. ARIA NOTE: The spec seems wrong here: the implied default should be ``[0,UNBOUNDED]``, not ``[1,UNBOUNDED]``, otherwise it would imply that at 1 least one relationship *must* be formed. :type: :class:`Range` """ @cachedmethod def _get_type(self, context): return get_type_by_full_or_shorthand_name(context, self.type, 'capability_types') @cachedmethod def _get_parent(self, context): container_parent = self._container._get_parent(context) container_parent_capabilities = container_parent._get_capabilities(context) \ if container_parent is not None else None return container_parent_capabilities.get(self._name) \ if container_parent_capabilities is not None else None
class GroupTemplate(ExtensiblePresentation): """ A group definition defines a logical grouping of node templates, typically for management purposes, but is separate from the application's topology template. See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca /TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html #DEFN_ELEMENT_GROUP_DEF>`__ """ @field_validator( type_validator('group type', convert_name_to_full_type_name, 'group_types')) @primitive_field(str, required=True) def type(self): """ The required name of the group type the group definition is based upon. :type: :obj:`basestring` """ @object_field(Description) def description(self): """ The optional description for the group definition. :type: :class:`Description` """ @object_dict_field(PropertyAssignment) def properties(self): """ An optional list of property value assignments for the group definition. :type: {:obj:`basestring`: :class:`PropertyAssignment`} """ @field_validator( list_type_validator('node template', 'topology_template', 'node_templates')) @primitive_list_field(str) def members(self): """ The optional list of one or more node template names that are members of this group definition. :type: [:obj:`basestring`] """ @object_dict_field(InterfaceAssignment) def interfaces(self): """ An optional list of named interface definitions for the group definition. :type: {:obj:`basestring`: :class:`InterfaceDefinition`} """ @cachedmethod def _get_type(self, context): return get_type_by_name(context, self.type, 'group_types') @cachedmethod def _get_property_values(self, context): return FrozenDict( get_assigned_and_defined_parameter_values(context, self, 'property')) @cachedmethod def _get_interfaces(self, context): return FrozenDict( get_template_interfaces(context, self, 'group definition')) def _validate(self, context): super(GroupTemplate, self)._validate(context) self._get_property_values(context) self._get_interfaces(context)
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 <http://docs.oasis-open.org/tosca /TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html #DEFN_ENTITY_RELATIONSHIP_TYPE>`__ """ @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` """ @object_field(Version) def version(self): """ An optional version for the Relationship Type definition. :type: :class:`Version` """ @object_field(Description) def description(self): """ An optional description for the Relationship Type. :type: :class:`Description` """ @object_dict_field(PropertyDefinition) def properties(self): """ An optional list of property definitions for the Relationship Type. :type: {:obj:`basestring`: :class:`PropertyDefinition`} """ @object_dict_field(AttributeDefinition) def attributes(self): """ An optional list of attribute definitions for the Relationship Type. :type: {:obj:`basestring`: :class:`AttributeDefinition`} """ @object_dict_field(InterfaceDefinition) def interfaces(self): """ An optional list of interface definitions interfaces supported by the Relationship Type. :type: {:obj:`basestring`: :class:`InterfaceDefinition`} """ @field_validator( list_type_validator('capability type', convert_name_to_full_type_name, 'capability_types')) @primitive_list_field(str) def valid_target_types(self): """ An optional list of one or more names of Capability Types that are valid targets for this relationship. :type: [:obj:`basestring`] """ @cachedmethod def _get_parent(self, context): return get_parent_presentation(context, self, convert_name_to_full_type_name, 'relationship_types') @cachedmethod def _is_descendant(self, context, the_type): if the_type is None: return False elif the_type._name == self._name: return True return self._is_descendant(context, the_type._get_parent(context)) @cachedmethod def _get_properties(self, context): return FrozenDict( get_inherited_parameter_definitions(context, self, 'properties')) @cachedmethod def _get_attributes(self, context): return FrozenDict( get_inherited_parameter_definitions(context, self, 'attributes')) @cachedmethod def _get_interfaces(self, context): return FrozenDict( get_inherited_interface_definitions(context, self, 'relationship type')) def _validate(self, context): super(RelationshipType, self)._validate(context) self._get_properties(context) self._get_attributes(context) self._get_interfaces(context) def _dump(self, context): self._dump_content( context, ('description', 'version', 'derived_from', 'valid_target_types', 'properties', 'attributes', 'interfaces'))
class GroupType(ExtensiblePresentation): """ A Group Type defines logical grouping types for nodes, typically for different management purposes. Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology of an application, yet can have capabilities and the ability to attach policies and interfaces that can be applied (depending on the group type) to its member nodes. Conceptually, group definitions allow the creation of logical "membership" relationships to nodes in a service template that are not a part of the application's explicit requirement dependencies in the topology template (i.e. those required to actually get the application deployed and running). Instead, such logical membership allows for the introduction of things such as group management and uniform application of policies (i.e., requirements that are also not bound to the application itself) to the group's members. See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca /TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html #DEFN_ENTITY_GROUP_TYPE>`__ """ @field_validator( derived_from_validator(convert_name_to_full_type_name, 'group_types')) @primitive_field(str) def derived_from(self): """ An optional parent Group Type name the Group Type derives from. :type: :obj:`basestring` """ @object_field(Version) def version(self): """ An optional version for the Group Type definition. :type: :class:`Version` """ @object_field(Description) def description(self): """ The optional description for the Group Type. :type: :class:`Description` """ @object_dict_field(PropertyDefinition) def properties(self): """ An optional list of property definitions for the Group Type. :type: {:obj:`basestring`: :class:`PropertyDefinition`} """ @field_validator( list_type_validator('node type', convert_name_to_full_type_name, 'node_types')) @primitive_list_field(str) def members(self): """ An optional list of one or more names of Node Types that are valid (allowed) as members of the Group Type. Note: This can be viewed by TOSCA Orchestrators as an implied relationship from the listed members nodes to the group, but one that does not have operational lifecycle considerations. For example, if we were to name this as an explicit Relationship Type we might call this "MemberOf" (group). :type: [:obj:`basestring`] """ @object_dict_field(InterfaceDefinition) def interfaces(self): """ An optional list of interface definitions supported by the Group Type. :type: {:obj:`basestring`: :class:`InterfaceDefinition`} """ @cachedmethod def _get_parent(self, context): return get_parent_presentation(context, self, convert_name_to_full_type_name, 'group_types') @cachedmethod def _is_descendant(self, context, the_type): if the_type is None: return False elif the_type._name == self._name: return True return self._is_descendant(context, the_type._get_parent(context)) @cachedmethod def _get_properties(self, context): return FrozenDict( get_inherited_parameter_definitions(context, self, 'properties')) @cachedmethod def _get_interfaces(self, context): return FrozenDict( get_inherited_interface_definitions(context, self, 'group type')) def _validate(self, context): super(GroupType, self)._validate(context) self._get_properties(context) self._get_interfaces(context) def _dump(self, context): self._dump_content(context, ('description', 'version', 'derived_from', 'members', 'properties', 'interfaces'))
class CapabilityType(ExtensiblePresentation): """ A Capability Type is a reusable entity that describes a kind of capability that a Node Type can declare to expose. Requirements (implicit or explicit) that are declared as part of one node can be matched to (i.e., fulfilled by) the Capabilities declared by another node. See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca /TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html #DEFN_ENTITY_CAPABILITY_TYPE>`__ """ @field_validator( derived_from_validator(convert_name_to_full_type_name, 'capability_types')) @primitive_field(str) def derived_from(self): """ An optional parent capability type name this new Capability Type derives from. :type: :obj:`basestring` """ @object_field(Version) def version(self): """ An optional version for the Capability Type definition. :type: :class:`Version` """ @object_field(Description) def description(self): """ An optional description for the Capability Type. :type: :class:`Description` """ @object_dict_field(PropertyDefinition) def properties(self): """ An optional list of property definitions for the Capability Type. ARIA NOTE: The spec says 'list', but the examples are all of dicts. :type: {:obj:`basestring`: :class:`PropertyDefinition`} """ @object_dict_field(AttributeDefinition) def attributes(self): """ An optional list of attribute definitions for the Capability Type. :type: {:obj:`basestring`: :class:`AttributeDefinition`} """ @field_validator( list_type_validator('node type', convert_name_to_full_type_name, 'node_types')) @primitive_list_field(str) def valid_source_types(self): """ An optional list of one or more valid names of Node Types that are supported as valid sources of any relationship established to the declared Capability Type. :type: [:obj:`basestring`] """ @cachedmethod def _get_parent(self, context): return get_parent_presentation(context, self, convert_name_to_full_type_name, 'capability_types') @cachedmethod def _is_descendant(self, context, other_type): """returns True iff `other_type` is a descendant of the represented capability type""" if other_type is None: return False elif other_type._name == self._name: return True return self._is_descendant(context, other_type._get_parent(context)) @cachedmethod def _get_properties(self, context): return FrozenDict( get_inherited_parameter_definitions(context, self, 'properties')) @cachedmethod def _get_valid_source_types(self, context): return get_inherited_valid_source_types(context, self) def _validate(self, context): super(CapabilityType, self)._validate(context) self._get_properties(context) def _dump(self, context): self._dump_content(context, ('description', 'version', 'derived_from', 'valid_source_types', 'properties', 'attributes'))