1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
13 from toscaparser.elements.statefulentitytype import StatefulEntityType
16 class ArtifactTypeDef(StatefulEntityType):
17 '''TOSCA built-in artifacts type.'''
19 def __init__(self, atype, custom_def=None):
20 super(ArtifactTypeDef, self).__init__(atype, self.ARTIFACT_PREFIX,
23 self.properties = None
24 if self.PROPERTIES in self.defs:
25 self.properties = self.defs[self.PROPERTIES]
26 self.parent_artifacts = self._get_parent_artifacts()
28 def _get_parent_artifacts(self):
30 parent_artif = self.parent_type
32 while parent_artif != 'tosca.artifacts.Root':
33 artifacts[parent_artif] = self.TOSCA_DEF[parent_artif]
34 parent_artif = artifacts[parent_artif]['derived_from']
38 def parent_type(self):
39 '''Return an artifact this artifact is derived from.'''
40 return self.derived_from(self.defs)
42 def get_artifact(self, name):
43 '''Return the definition of an artifact field by name.'''
45 return self.defs[name]