def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() # Prompt for zone if it is not specified version = args.version if not version: version = '' zone = args.zone if not zone: zone = '' options = args.options if not options: options = {} labels = args.labels if not labels: labels = {} enable_stackdriver_logging = args.enable_stackdriver_logging if not enable_stackdriver_logging: enable_stackdriver_logging = False enable_stackdriver_monitoring = args.enable_stackdriver_monitoring if not enable_stackdriver_monitoring: enable_stackdriver_monitoring = False edition_mapper = arg_utils.ChoiceEnumMapper( 'edition_enum', df.Datafusion().messages.Instance.TypeValueValuesEnum) edition = edition_mapper.GetEnumForChoice(args.edition) instance = datafusion.messages.Instance( zone=zone, type=edition, version=version, enableStackdriverLogging=enable_stackdriver_logging, enableStackdriverMonitoring=enable_stackdriver_monitoring, options=encoding.DictToAdditionalPropertyMessage( options, datafusion.messages.Instance.OptionsValue, True), labels=encoding.DictToAdditionalPropertyMessage( labels, datafusion.messages.Instance.LabelsValue, True)) req = datafusion.messages.DatafusionProjectsLocationsInstancesCreateRequest( instance=instance, instanceId=instance_ref.Name(), parent=instance_ref.Parent().RelativeName()) operation = datafusion.client.projects_locations_instances.Create(req) if args.async_: log.CreatedResource(instance_ref.RelativeName(), kind='instance', is_async=True) return operation else: waiter.WaitFor( operation_poller.OperationPoller(), operation.name, 'Waiting for [{}] to complete. This may take several minutes.'. format(operation.name), wait_ceiling_ms=df.OPERATION_TIMEOUT) log.CreatedResource(instance_ref.RelativeName(), kind='instance', is_async=False)
def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() if not args.namespace: get_request = datafusion.messages.DatafusionProjectsLocationsInstancesGetIamPolicyRequest( resource=instance_ref.RelativeName()) iam_policy = datafusion.client.projects_locations_instances.GetIamPolicy( get_request) else: get_request = datafusion.messages.DatafusionProjectsLocationsInstancesNamespacesGetIamPolicyRequest( resource='%s/namespaces/%s' % (instance_ref.RelativeName(), args.namespace)) iam_policy = datafusion.client.projects_locations_instances_namespaces.GetIamPolicy( get_request) iam_util.AddBindingToIamPolicy(datafusion.messages.Binding, iam_policy, args.member, args.role) results = data_fusion_iam_util.DoSetIamPolicy(instance_ref, args.namespace, iam_policy, datafusion.messages, datafusion.client) return results
def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() request = datafusion.messages.DatafusionProjectsLocationsInstancesRestartRequest( name=instance_ref.RelativeName()) operation = datafusion.client.projects_locations_instances.Restart( request) if args. async: log.CreatedResource(instance_ref.RelativeName(), kind='instance', is_async=True) return operation else: waiter.WaitFor( operation_poller.OperationPoller(), operation.name, 'Waiting for [{}] to complete. This may take several minutes.'. format(operation.name), wait_ceiling_ms=df.OPERATION_TIMEOUT) log.CreatedResource(instance_ref.RelativeName(), kind='instance', is_async=False)
def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() name = instance_ref.RelativeName() req = datafusion.messages.DatafusionProjectsLocationsInstancesDeleteRequest( name=instance_ref.RelativeName()) console_io.PromptContinue(message="'{0}' will be deleted".format(name), cancel_on_no=True, cancel_string='Deletion aborted by user.', throw_if_unattended=True) operation = datafusion.client.projects_locations_instances.Delete(req) log.status.write('Deleting [{0}] with operation [{1}].'.format( instance_ref.RelativeName(), operation.name)) if args.async_: return operation else: waiter.WaitFor( operation_poller.OperationPoller(), operation.name, 'Waiting for [{}] to complete. This may take several minutes'. format(operation.name))
def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() results = SetIamPolicyFromFile(instance_ref, args.namespace, args.policy_file, datafusion.messages, datafusion.client) return results
def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() request = datafusion.messages.DatafusionProjectsLocationsInstancesGetRequest( name=instance_ref.RelativeName()) instance = datafusion.client.projects_locations_instances.Get(request) return instance
def Run(self, args): datafusion = df.Datafusion() operation_ref = args.CONCEPTS.operation.Parse() req = datafusion.messages.DatafusionProjectsLocationsOperationsGetRequest( name=operation_ref.RelativeName()) operation = datafusion.client.projects_locations_operations.Get(req) waiter.WaitFor(operation_poller.OperationPoller(), operation.name, 'Waiting for [{}] to complete.'.format(operation.name), wait_ceiling_ms=self.WAIT_CEILING_MS)
def Run(self, args): datafusion = df.Datafusion() location_ref = args.CONCEPTS.location.Parse() request = datafusion.messages.DatafusionProjectsLocationsInstancesListRequest( parent=location_ref.RelativeName()) return list_pager.YieldFromList( datafusion.client.projects_locations_instances, request, limit=args.limit, field='instances', batch_size=args.page_size, batch_size_attribute='pageSize')
def Run(self, args): datafusion = df.Datafusion() op_ref = args.CONCEPTS.operation.Parse() console_io.PromptContinue(message="'{0}' will be deleted".format( op_ref.Name()), cancel_on_no=True, cancel_string='Deletion aborted by user.', throw_if_unattended=True) req = datafusion.messages.DatafusionProjectsLocationsOperationsDeleteRequest( name=op_ref.RelativeName()) datafusion.client.projects_locations_operations.Delete(req) log.DeletedResource(op_ref.RelativeName(), kind='operation')
def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() if not args.namespace: request = datafusion.messages.DatafusionProjectsLocationsInstancesGetIamPolicyRequest( resource=instance_ref.RelativeName()) iam_policy = datafusion.client.projects_locations_instances.GetIamPolicy( request) return iam_policy else: request = datafusion.messages.DatafusionProjectsLocationsInstancesNamespacesGetIamPolicyRequest( resource='%s/namespaces/%s' % (instance_ref.RelativeName(), args.namespace)) iam_policy = datafusion.client.projects_locations_instances_namespaces.GetIamPolicy( request) return iam_policy
def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() labels = args.labels or {} enable_stackdriver_logging = args.enable_stackdriver_logging or False enable_stackdriver_monitoring = args.enable_stackdriver_monitoring or False version = args.version instance = datafusion.messages.Instance( name=instance_ref.RelativeName(), version=version, enableStackdriverLogging=enable_stackdriver_logging, enableStackdriverMonitoring=enable_stackdriver_monitoring, labels=encoding.DictToAdditionalPropertyMessage( labels, datafusion.messages.Instance.LabelsValue, True)) request = datafusion.messages.DatafusionProjectsLocationsInstancesPatchRequest( instance=instance, name=instance_ref.RelativeName()) operation = datafusion.client.projects_locations_instances.Patch( request) if args.async_: log.CreatedResource(instance_ref.RelativeName(), kind='instance', is_async=True) return operation else: waiter.WaitFor( operation_poller.OperationPoller(), operation.name, 'Waiting for [{}] to complete. This may take several minutes.'. format(operation.name), wait_ceiling_ms=df.OPERATION_TIMEOUT) log.UpdatedResource(instance_ref.RelativeName(), kind='instance', is_async=False)
def Run(self, args): datafusion = df.Datafusion() instance_ref = args.CONCEPTS.instance.Parse() # Prompt for zone if it is not specified zone = args.zone if not zone: holder = compute_base.ComputeApiHolder(self.ReleaseTrack()) _, zone = scope_prompter.PromptForScope( resource_name='instance', underspecified_names=[instance_ref.Name()], scopes=[compute_scope.ScopeEnum.ZONE], default_scope=None, scope_lister=flags.GetDefaultScopeLister(holder.client)) options = args.options if not options: options = {} labels = args.labels if not labels: labels = {} enable_stackdriver_logging = args.enable_stackdriver_logging if not enable_stackdriver_logging: enable_stackdriver_logging = False enable_stackdriver_monitoring = args.enable_stackdriver_monitoring if not enable_stackdriver_monitoring: enable_stackdriver_monitoring = False edition = args.edition.upper() if edition == 'ENTERPRISE': edition = datafusion.messages.Instance.TypeValueValuesEnum.ENTERPRISE else: edition = datafusion.messages.Instance.TypeValueValuesEnum.BASIC instance = datafusion.messages.Instance( zone=zone, type=edition, enableStackdriverLogging=enable_stackdriver_logging, enableStackdriverMonitoring=enable_stackdriver_monitoring, options=encoding.DictToAdditionalPropertyMessage( options, datafusion.messages.Instance.OptionsValue, True), labels=encoding.DictToAdditionalPropertyMessage( labels, datafusion.messages.Instance.LabelsValue, True)) req = datafusion.messages.DatafusionProjectsLocationsInstancesCreateRequest( instance=instance, instanceId=instance_ref.Name(), parent=instance_ref.Parent().RelativeName()) operation = datafusion.client.projects_locations_instances.Create(req) if args.async: log.CreatedResource( instance_ref.RelativeName(), kind='instance', is_async=True) return operation else: waiter.WaitFor( operation_poller.OperationPoller(), operation.name, 'Waiting for [{}] to complete. This may take several minutes.'.format( operation.name), wait_ceiling_ms=df.OPERATION_TIMEOUT) log.CreatedResource( instance_ref.RelativeName(), kind='instance', is_async=False)
def __init__(self): super(OperationPoller, self).__init__( df.Datafusion().client.projects_locations_operations, lambda x: x)