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. """ cli = bigtable_util.GetAdminClient() ref = bigtable_util.GetInstanceRef(args.instance) parent_ref = resources.REGISTRY.Create( 'bigtableadmin.projects', projectId=ref.projectsId) msgs = bigtable_util.GetAdminMessages() instance_type = msgs.Instance.TypeValueValuesEnum(args.instance_type) num_nodes = arguments.ProcessInstanceTypeAndNodes(args, instance_type) msg = msgs.CreateInstanceRequest( instanceId=ref.Name(), parent=parent_ref.RelativeName(), instance=msgs.Instance( displayName=args.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=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 = bigtable_util.GetOperationRef(result) if args.async: log.CreatedResource( operation_ref, kind='bigtable instance {0}'.format(ref.Name()), is_async=True) return result return bigtable_util.AwaitInstance( operation_ref, 'Creating bigtable instance {0}'.format(ref.Name()))
def Upgrade(instance): """Upgrade development instance to production. Args: instance: str instance id to upgrade. Returns: Operation: the partial update's LRO response. """ client = util.GetAdminClient() msgs = util.GetAdminMessages() instance_ref = util.GetInstanceRef(instance) instance = msgs.Instance(type=msgs.Instance.TypeValueValuesEnum.PRODUCTION) return client.projects_instances.PartialUpdateInstance( msgs.BigtableadminProjectsInstancesPartialUpdateInstanceRequest( instance=instance, name=instance_ref.RelativeName(), updateMask='type'))
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. """ cli = util.GetAdminClient() msgs = util.GetAdminMessages() for instance in args.instance: should_continue = console_io.PromptContinue( message='Delete instance {}. Are you sure?'.format(instance)) if should_continue: ref = util.GetInstanceRef(instance) msg = msgs.BigtableadminProjectsInstancesDeleteRequest( name=ref.RelativeName()) cli.projects_instances.Delete(msg) return None
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. """ cli = bigtable_util.GetAdminClient() ref = bigtable_util.GetInstanceRef(args.instance) msgs = bigtable_util.GetAdminMessages() instance = cli.projects_instances.Get( msgs.BigtableadminProjectsInstancesGetRequest( name=ref.RelativeName())) instance.state = None # must be unset when calling Update if args.display_name: instance.displayName = args.display_name instance = cli.projects_instances.Update(instance) log.UpdatedResource(instance.name, kind='instance') return instance
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. Yields: Some value that we want to have printed later. """ cli = util.GetAdminClient() instance_refs = args.CONCEPTS.instances.Parse() if not args.IsSpecified('instances'): instance_refs = [util.GetInstanceRef('-')] for instance_ref in instance_refs: msg = (util.GetAdminMessages(). BigtableadminProjectsInstancesClustersListRequest( parent=instance_ref.RelativeName())) for cluster in list_pager.YieldFromList( cli.projects_instances_clusters, msg, field='clusters', batch_size_attribute=None): yield cluster
def SetUp(self): self.instance_ref = util.GetInstanceRef('my-instance')
def SetUp(self): self.clusters_list_mock = self.client.projects_instances_clusters.List self.instance_ref = util.GetInstanceRef('theinstance')
def _GetUriFunction(resource): return util.GetInstanceRef(resource.name).SelfLink()
def SetUp(self): self.backups_list_mock = self.client.projects_instances_clusters_backups.List self.instance_ref = util.GetInstanceRef('theinstance') self.cluster_ref1 = util.GetClusterRef('theinstance', 'cluster1') self.cluster_ref2 = util.GetClusterRef('theinstance', 'cluster2') self.table_ref = util.GetTableRef('theinstance', 'thetable')