def Run(self, args): dataproc = dp.Dataproc(self.ReleaseTrack()) msgs = dataproc.messages # Generate uuid for request. instance_id = uuid.uuid4().hex regions_ref = util.ParseRegion(dataproc) # Read template from YAML file and validate it using a schema. with files.FileReader(args.file) as stream: template = util.ReadYaml(message_type=msgs.WorkflowTemplate, stream=stream, schema_path=V1_BETA2_SCHEMA_PATH) # Send instantiate inline request. request = \ msgs.DataprocProjectsRegionsWorkflowTemplatesInstantiateInlineRequest( instanceId=instance_id, parent=regions_ref.RelativeName(), workflowTemplate=template) operation = \ dataproc.client.projects_regions_workflowTemplates.InstantiateInline( request) if args. async: log.status.Print('Instantiating with operation [{0}].'.format( operation.name)) return operation = util.WaitForWorkflowTemplateOperation(dataproc, operation) return operation
def Run(self, args): dataproc = dp.Dataproc(self.ReleaseTrack()) msgs = dataproc.messages # Generate uuid for request. instance_id = uuid.uuid4().hex regions_ref = dp_util.ParseRegion(dataproc) # Read template from YAML file and validate it using a schema. data = console_io.ReadFromFileOrStdin(args.file or '-', binary=False) template = export_util.Import(message_type=msgs.WorkflowTemplate, stream=data, schema_path=export_util.GetSchemaPath( 'dataproc', api_version='v1beta2', message_name='WorkflowTemplate')) # Send instantiate inline request. request = \ msgs.DataprocProjectsRegionsWorkflowTemplatesInstantiateInlineRequest( instanceId=instance_id, parent=regions_ref.RelativeName(), workflowTemplate=template) operation = \ dataproc.client.projects_regions_workflowTemplates.InstantiateInline( request) if args.async_: log.status.Print('Instantiating with operation [{0}].'.format( operation.name)) return operation = dp_util.WaitForWorkflowTemplateOperation( dataproc, operation) return operation
def Run(self, args): dataproc = dp.Dataproc(self.ReleaseTrack()) msgs = dataproc.messages # Generate uuid for request. instance_id = uuid.uuid4().hex regions_ref = util.ParseRegion(dataproc) # Read template from YAML file. template = util.ReadYaml(args.file, msgs.WorkflowTemplate) # Send instantiate inline request. request = \ msgs.DataprocProjectsRegionsWorkflowTemplatesInstantiateInlineRequest( instanceId=instance_id, parent=regions_ref.RelativeName(), workflowTemplate=template) operation = \ dataproc.client.projects_regions_workflowTemplates.InstantiateInline( request) if args. async: log.status.Print( 'Instantiating [{0}] with operation [{1}].'.format( template.id, operation.name)) return operation = util.WaitForWorkflowTemplateOperation(dataproc, operation) return operation
def Run(self, args): dataproc = dp.Dataproc(self.ReleaseTrack()) msgs = dataproc.messages # Generate uuid for request. instance_id = uuid.uuid4().hex regions_ref = dp_util.ParseRegion(dataproc) data = console_io.ReadFromFileOrStdin(args.file or '-', binary=False) template = export_util.Import(message_type=msgs.WorkflowTemplate, stream=data) # Send instantiate inline request. request = \ msgs.DataprocProjectsRegionsWorkflowTemplatesInstantiateInlineRequest( parent=regions_ref.RelativeName(), workflowTemplate=template) if dataproc.api_version == 'v1': # Deprecated field in v1beta2 request.requestId = instance_id else: # new field not in v1 request.instanceId = instance_id operation = \ dataproc.client.projects_regions_workflowTemplates.InstantiateInline( request) if args.async_: log.status.Print('Instantiating with operation [{0}].'.format( operation.name)) return operation = dp_util.WaitForWorkflowTemplateOperation( dataproc, operation) return operation
def Run(self, args): dataproc = dp.Dataproc(self.ReleaseTrack()) msgs = dataproc.messages # Generate uuid for request. instance_id = uuid.uuid4().hex regions_ref = dp_util.ParseRegion(dataproc) if args.file.startswith('gs://'): data = storage_helpers.ReadObject(args.file) else: data = console_io.ReadFromFileOrStdin(args.file, binary=False) template = export_util.Import( message_type=msgs.WorkflowTemplate, stream=data) # Send instantiate inline request. request = \ msgs.DataprocProjectsRegionsWorkflowTemplatesInstantiateInlineRequest( parent=regions_ref.RelativeName(), workflowTemplate=template) request.requestId = instance_id operation = \ dataproc.client.projects_regions_workflowTemplates.InstantiateInline( request) if args.async_: log.status.Print('Instantiating with operation [{0}].'.format( operation.name)) return operation = dp_util.WaitForWorkflowTemplateOperation(dataproc, operation) return operation
def Run(self, args): dataproc = dp.Dataproc(self.ReleaseTrack()) messages = dataproc.messages regions = util.ParseRegion(dataproc) request = messages.DataprocProjectsRegionsAutoscalingPoliciesListRequest( parent=regions.RelativeName()) return list_pager.YieldFromList( dataproc.client.projects_regions_autoscalingPolicies, request, limit=args.limit, field='policies', batch_size=args.page_size, batch_size_attribute='pageSize')
def Run(self, args): dataproc = dp.Dataproc(self.ReleaseTrack()) messages = dataproc.messages template_ref = util.ParseWorkflowTemplates(args.template, dataproc) regions_ref = util.ParseRegion(dataproc) workflow_template = messages.WorkflowTemplate( id=args.template, name=template_ref.RelativeName(), labels=labels_util.ParseCreateArgs( args, messages.WorkflowTemplate.LabelsValue)) request = messages.DataprocProjectsRegionsWorkflowTemplatesCreateRequest( parent=regions_ref.RelativeName(), workflowTemplate=workflow_template) template = dataproc.client.projects_regions_workflowTemplates.Create( request) return template