def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ # TODO(b/73365914) remove after deprecation period display_name = args.display_name or args.description cli = bigtable_util.GetAdminClient() ref = resources.REGISTRY.Parse( args.instance, params={ 'projectsId': properties.VALUES.core.project.GetOrFail, }, collection='bigtableadmin.projects.instances') parent_ref = resources.REGISTRY.Create('bigtableadmin.projects', projectId=ref.projectsId) msgs = bigtable_util.GetAdminMessages() msg = msgs.CreateInstanceRequest( instanceId=ref.Name(), parent=parent_ref.RelativeName(), instance=msgs.Instance( # TODO(b/73365914) replace with args.display_name after deprecation displayName=display_name, type=msgs.Instance.TypeValueValuesEnum(args.instance_type)), clusters=msgs.CreateInstanceRequest. ClustersValue(additionalProperties=[ msgs.CreateInstanceRequest.ClustersValue.AdditionalProperty( key=args.cluster, value=msgs.Cluster( serveNodes=args.cluster_num_nodes, defaultStorageType=( msgs.Cluster.DefaultStorageTypeValueValuesEnum( args.cluster_storage_type.upper())), # TODO(b/36056455): switch location to resource # when b/29566669 is fixed on API location=bigtable_util.LocationUrl(args.cluster_zone))) ])) result = cli.projects_instances.Create(msg) operation_ref = resources.REGISTRY.ParseRelativeName( result.name, 'bigtableadmin.operations') if args. async: log.CreatedResource(operation_ref, kind='bigtable instance {0}'.format( ref.Name()), async=True) return result return bigtable_util.WaitForInstance( cli, operation_ref, 'Creating bigtable instance {0}'.format(ref.Name()))
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ op = instances.Upgrade(args.instance) if args. async: result = op else: client = util.GetAdminClient() op_ref = resources.REGISTRY.ParseRelativeName( op.name, collection='bigtableadmin.operations') message = 'Upgrading bigtable instance {0}'.format(args.instance) result = util.WaitForInstance(client, op_ref, message) log.UpdatedResource(args.instance, kind='instance', async=args. async)