def Run(self, args): """Run 'types create'. Args: args: argparse.Namespace, The arguments that this command was invoked with. Raises: HttpException: An http error response was received while executing api request. """ composite_type_ref = composite_types.GetReference( self.resources, args.name) update_labels_dict = labels_util.GetUpdateLabelsDictFromArgs(args) labels = dm_labels.UpdateLabels([], self.messages.CompositeTypeLabelEntry, update_labels=update_labels_dict) template_contents = composite_types.TemplateContentsFor( self.messages, args.template) composite_type = self.messages.CompositeType( name=args.name, description=args.description, status=args.status, templateContents=template_contents, labels=labels) request = self.messages.DeploymentmanagerCompositeTypesInsertRequest( project=composite_type_ref.project, compositeType=composite_type) dm_write.Execute(self.client, self.messages, self.resources, request, args. async, self.client.compositeTypes.Insert, LogResource)
def testTemplateContentsFor_NotTemplate(self): with self.assertRaisesRegex( exceptions.Error, 'No path or name for a config, template, or ' 'composite type was specified.'): composite_types.TemplateContentsFor(self.messages, '')
def testTemplateContentsFor(self): template_path = self.GetTestFilePath('simple.jinja') actual_template = composite_types.TemplateContentsFor( self.messages, template_path) self.assertEqual(self.GetExpectedSimpleTemplate(), actual_template)