feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The main command group for bigtable."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA,
base.ReleaseTrack.ALPHA)
class Tables(base.Group):
"""Query Cloud Bigtable tables."""

View File

@@ -0,0 +1,33 @@
release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Add an IAM policy binding to a Cloud Bigtable table.
description: |
Add an IAM policy binding to a Cloud Bigtable table. One binding consists of a member,
a role, and an optional condition.
examples: |
To add an IAM policy binding for the role of `roles/editor` for the user `test-user@gmail.com`
with table `my-table` in instance `my-instance`, run:
$ {command} my-table --instance=`my-instance` --member=`user:test-user@gmail.com` --role=`roles/editor`
To add an IAM policy binding which expires at the end of the year 2019 for the role of
`roles/bigtable.admin` and the user `test-user@gmail.com` with table `my-table` in instance `my-instance`, run:
$ {command} my-table --instance=`my-instance` --member=`user:test-user@gmail.com` --role=`roles/bigtable.admin` --condition=`expression=request.time < timestamp("2020-01-01T00:00:00Z"),title=expires_end_of_2019,description=Expires at midnight on 2019-12-31`
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
iam:
enable_condition: true
policy_version: 3
get_iam_policy_version_path: getIamPolicyRequest.options.requestedPolicyVersion
request:
collection: bigtableadmin.projects.instances.tables
arguments:
resource:
help_text: Cloud Bigtable table to add the IAM policy binding to.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for managing Cloud Bigtable table configurations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Config(base.Group):
"""Manage Cloud Bigtable table configurations."""

View File

@@ -0,0 +1,38 @@
release_tracks: [ALPHA]
command_type: CONFIG_EXPORT
help_text:
brief: Export the configuration for a Cloud Bigtable table.
description: |
*{command}* exports the configuration for a Cloud Bigtable table.
Table configurations can be exported in
Kubernetes Resource Model (krm) or Terraform HCL formats. The
default format is `krm`.
Specifying `--all` allows you to export the configurations for all
tables within the project.
Specifying `--path` allows you to export the configuration(s) to
a local directory.
examples: |
To export the configuration for a table, run:
$ {command} my-table
To export the configuration for a table to a file, run:
$ {command} my-table --path=/path/to/dir/
To export the configuration for a table in Terraform
HCL format, run:
$ {command} my-table --resource-format=terraform
To export the configurations for all tables within a
project, run:
$ {command} --all
arguments:
resource:
help_text: Table to export the configuration for.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table

View File

@@ -0,0 +1,125 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Create a new Cloud Bigtable table.
description: Create a new Cloud Bigtable table.
examples: |
To create a table `my-table` in instance `my-instance` with a column family `my-family`, run:
$ {command} my-table --instance=my-instance --column-families="my-family"
To create a table that has a column family named `my-instance`, a garbage collection policy
that lets data expire after 864,000 seconds, and initial table splits on row keys `car` and `key`, run:
$ {command} my-table --instance=my-instance --column-families="my-family:maxage=864000s" --splits=car,key
To create a table `my-table` in instance `my-instance` that lets data in column family `my-family1`
expire after 10 days and keeps a maximum of 5 cells per column in column family `my-family-2` if the data is less than 5 days old, run:
$ {command} my-table --instance=my-instance --column-families="my-family-1:maxage=10d,my-family-2:maxversions=5||maxage=5d"
To create a table `my-table` that has one column family `my-family` that lets data expire after 10 days, and to enable a change stream
for the table to be kept for 7 days, run:
$ {command} my-table --instance=my-instance --column-families="my-family:maxage=10d" --change-stream-retention-period=7d
To create a deletion-protected table `my-table` in instance `my-instance` with a column family `my-family`, run:
$ {command} my-table --instance=my-instance --column-families="my-family" --deletion-protection
To create a table `my-table` without deletion protection in instance `my-instance` with a column family `my-family`, run:
$ {command} my-table --instance=my-instance --column-families="my-family" --no-deletion-protection
To create a table `my-table` with the default automated backup policy (retention_period=7d, frequency=1d) enabled in instance `my-instance` with a column family `my-family`, run:
$ {command} my-table --instance=my-instance --column-families="my-family" --enable-automated-backup
To create a table `my-table` with a custom automated backup policy configured to retain backups for 30 days in instance `my-instance` with a column family `my-family`, run:
$ {command} my-table --instance=my-instance --column-families="my-family" --automated-backup-retention_period=30d
request:
collection: bigtableadmin.projects.instances.tables
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.tables:UpdateRequestWithInput
- googlecloudsdk.api_lib.bigtable.tables:HandleAutomatedBackupPolicyCreateTableArgs
- googlecloudsdk.api_lib.bigtable.tables:HandleRowKeySchemaCreateTableArgs
arguments:
resource:
help_text: Cloud Bigtable table to create.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table
additional_arguments_hook: googlecloudsdk.api_lib.bigtable.tables:AddAutomatedBackupPolicyCreateTableArgs
params:
- api_field: createTableRequest.table.columnFamilies
arg_name: column-families
required: true
type: "arg_list"
help_text: |
A double-quote (`"`) wrapped list of family name and corresponding garbage collection rules
concatenated by `:`, where the rules are optional. For example:
`"family_1,family_2:maxage=5d&&maxversions=2,family_3:maxage=10d||maxversions=5"`
processor: googlecloudsdk.api_lib.bigtable.tables:ParseColumnFamilies
- api_field: createTableRequest.initialSplits
arg_name: splits
help_text: |
Row keys where the table should initially be split. For example: `car,key`
type: "arg_list"
processor: googlecloudsdk.api_lib.bigtable.tables:MakeSplits
- api_field: createTableRequest.table.changeStreamConfig.retentionPeriod
arg_name: change-stream-retention-period
help_text: |
The length of time to retain change stream data for the table, in the range of
[1 day, 7 days]. Acceptable units are days (d), hours (h), minutes (m), and seconds (s).
Passing in a value for this option enables a change stream for the table. Examples: `5d` or
`48h`.
processor: googlecloudsdk.api_lib.bigtable.tables:ParseChangeStreamRetentionPeriod
- api_field: createTableRequest.table.tieredStorageConfig.infrequentAccess.includeIfOlderThan
arg_name: tiered-storage-infrequent-access-older-than
release_tracks: [ALPHA, BETA]
help_text: |
The age at which data should be moved to infrequent access storage.
See `$ gcloud topic datetimes` for information on absolute duration formats.
processor: googlecloudsdk.api_lib.bigtable.tables:ParseTieredStorageConfigDuration
- api_field: createTableRequest.table.deletionProtection
arg_name: deletion-protection
type: bool
help_text: |
Once specified, the table is deletion protected.
- arg_name: row-key-schema-definition-file
required: false
help_text: |
The row key schema for the table. The schema is defined in a YAML or JSON file, equivalent
to the StructType protobuf message.
Example YAML:
```yaml
encoding:
delimitedBytes:
delimiter: '#'
fields:
- fieldName: field1
type:
bytesType:
encoding:
raw: {}
- fieldName: field2
type:
bytesType:
encoding:
raw: {}
```
- arg_name: row-key-schema-pre-encoded-bytes
type: bool
default: false
required: false
help_text: |
By default, Base64 encoding is applied to all binary fields in the YAML/JSON file (for
example, `encoding.delimitedBytes.delimiter`).
Use this to indicate that all binary fields are already encoded in the YAML/JSON file and
should not be encoded again.

View File

@@ -0,0 +1,17 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Delete a Cloud Bigtable table.
description: Delete a Cloud Bigtable table.
examples: |
To delete the table `my-table` in instance `my-instance`, run:
$ {command} my-table --instance=my-instance
request:
collection: bigtableadmin.projects.instances.tables
method: delete
arguments:
resource:
help_text: Cloud Bigtable table to delete.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table

View File

@@ -0,0 +1,41 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Retrieve information about a table.
description: Retrieve information about a table.
examples: |
To describe a table, run:
$ {command} TABLE_NAME --instance=INSTANCE_NAME
request:
collection: bigtableadmin.projects.instances.tables
arguments:
resource:
help_text: Cloud Bigtable table to describe.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table
params:
- api_field: view
arg_name: view
help_text: The view to be applied to the returned table's fields.
default: schema
choices: # Enum is mapped to keep VIEW_UNSPECIFIED invisible from user.
- arg_value: name
enum_value: NAME_ONLY
help_text: Only populates `name`.
- arg_value: schema
enum_value: SCHEMA_VIEW
help_text: Only populates `name` and fields related to the table's schema.
- arg_value: replication
enum_value: REPLICATION_VIEW
help_text: Only populates `name` and fields related to the table's replication.
- arg_value: encryption
enum_value: ENCRYPTION_VIEW
help_text: Only populates `name` and fields related to the table's encryption status.
- arg_value: stats
enum_value: STATS_VIEW
help_text: Only populates `name` and fields related to the table's statistics (e.g. TableStats and ColumnFamilyStats).
- arg_value: full
enum_value: FULL
help_text: Populates all fields.

View File

@@ -0,0 +1,24 @@
release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Get an IAM policy on a Cloud Bigtable table.
description: |
Get an IAM policy on a Cloud Bigtable table.
examples: |
To get the IAM policy on the table `my-table` in instance `my-instance`, run:
$ {command} my-table --instance=`my-instance`
See https://cloud.google.com/iam/docs/managing-policies for more information.
request:
collection: bigtableadmin.projects.instances.tables
arguments:
resource:
help_text: Cloud Bigtable table to get the IAM policy for.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table
iam:
policy_version: 3
get_iam_policy_version_path: getIamPolicyRequest.options.requestedPolicyVersion

View File

@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""bigtable tables list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import properties
from googlecloudsdk.core import resources
def _GetUriFunction(resource):
table_ref = resources.REGISTRY.ParseRelativeName(
resource.name,
collection='bigtableadmin.projects.instances.tables')
return table_ref.SelfLink()
class ListInstances(base.ListCommand):
"""List existing Bigtable instance tables.
## EXAMPLES
To list all tables in an instance, run:
$ {command} --instances=INSTANCE_NAME
To list all tables in several instances, run:
$ {command} --instances=INSTANCE_NAME1,INSTANCE_NAME2
"""
@staticmethod
def Args(parser):
"""Register flags for this command."""
parser.display_info.AddFormat("""
table(
name.basename():sort=1
)
""")
parser.display_info.AddUriFunc(_GetUriFunction)
arguments.ArgAdder(parser).AddInstance(
positional=False, required=True, multiple=True)
def Run(self, args):
cli = util.GetAdminClient()
msgs = util.GetAdminMessages()
instances = args.instances
results = []
for instance in instances:
instance_ref = resources.REGISTRY.Parse(
instance,
params={'projectsId': properties.VALUES.core.project.GetOrFail},
collection='bigtableadmin.projects.instances')
request = msgs.BigtableadminProjectsInstancesTablesListRequest(
parent=instance_ref.RelativeName(),)
for table in list_pager.YieldFromList(
cli.projects_instances_tables,
request,
field='tables',
batch_size_attribute=None):
results.append(table)
return results

View File

@@ -0,0 +1,33 @@
release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Remove an IAM policy binding from a Cloud Bigtable table.
description: |
Remove an IAM policy binding from a Cloud Bigtable table. One binding consists of a member,
a role, and an optional condition.
examples: |
To remove an IAM policy binding for the role of `roles/editor` for the user `test-user@gmail.com`
with table `my-table` in instance `my-instance`, run:
$ {command} my-table --instance=`my-instance` --member=`user:test-user@gmail.com` --role=`roles/editor`
To remove an IAM policy binding which expires at the end of the year 2019 for the role of
`roles/bigtable.admin` and the user `test-user@gmail.com` with table `my-table` in instance `my-instance`, run:
$ {command} my-table --instance=`my-instance` --member=`user:test-user@gmail.com` --role=`roles/bigtable.admin` --condition=`expression=request.time < timestamp("2020-01-01T00:00:00Z"),title=expires_end_of_2019,description=Expires at midnight on 2019-12-31`
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
iam:
enable_condition: true
policy_version: 3
get_iam_policy_version_path: getIamPolicyRequest.options.requestedPolicyVersion
request:
collection: bigtableadmin.projects.instances.tables
arguments:
resource:
help_text: Cloud Bigtable table to remove the IAM policy binding from.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table

View File

@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""bigtable tables restore command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
class RestoreTables(base.RestoreCommand):
"""Restore a Cloud Bigtable backup to a new table."""
detailed_help = {
'DESCRIPTION':
textwrap.dedent("""
This command restores a Cloud Bigtable backup to a new table.
"""),
'EXAMPLES':
textwrap.dedent("""
To restore table 'table2' from backup 'backup1', run:
$ {command} --source-instance=instance1 --source-cluster=cluster1 --source=backup1 --destination-instance=instance1 --destination=table2
To restore table 'table2' from backup 'backup1' in a different project, run:
$ {command} --source=projects/project1/instances/instance1/clusters/cluster1/backups/backup1 --destination=projects/project2/instances/instance2/tables/table2
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddTableRestoreResourceArg(parser)
arguments.ArgAdder(parser).AddAsync()
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()
backup_ref = args.CONCEPTS.source.Parse() # backup
table_ref = args.CONCEPTS.destination.Parse() # table
restore_request = msgs.RestoreTableRequest(
# Full backup name.
backup=backup_ref.RelativeName(),
# Table id
tableId=table_ref.Name())
msg = (msgs.BigtableadminProjectsInstancesTablesRestoreRequest(
# The name of the instance in which to create the restored table.
parent=table_ref.Parent().RelativeName(),
restoreTableRequest=restore_request))
operation = cli.projects_instances_tables.Restore(msg)
operation_ref = util.GetOperationRef(operation)
if args.async_:
log.CreatedResource(
operation_ref.RelativeName(),
kind='bigtable table {0}'.format(table_ref.Name()),
is_async=True)
return
return util.AwaitTable(
operation_ref,
'Creating bigtable table {0}'.format(table_ref.Name()))

View File

@@ -0,0 +1,27 @@
release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Set an IAM policy on a Cloud Bigtable table.
description: |
Set an IAM policy on a Cloud Bigtable table.
examples: |
To set the IAM policy from file `my-policy` on the table `my-table` in
instance `my-instance`, run:
$ {command} my-table --instance=`my-instance` my-policy
See https://cloud.google.com/iam/docs/managing-policies for more information.
request:
collection: bigtableadmin.projects.instances.tables
modify_request_hooks:
- googlecloudsdk.command_lib.iam.hooks:UseMaxRequestedPolicyVersion:api_field=setIamPolicyRequest.policy.version
- googlecloudsdk.command_lib.iam.hooks:AddVersionToUpdateMaskIfNotPresent:update_mask_path=setIamPolicyRequest.updateMask
arguments:
resource:
help_text: Cloud Bigtable table to set the IAM policy on.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table
iam:
policy_version: 3

View File

@@ -0,0 +1,20 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Undelete a previously deleted Cloud Bigtable table.
description: Undelete a previously deleted Cloud Bigtable table.
examples: |
To undelete the table `my-table` in instance `my-instance`, run:
$ {command} my-table --instance=my-instance
request:
collection: bigtableadmin.projects.instances.tables
method: undelete
arguments:
resource:
help_text: Cloud Bigtable table to undelete.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table
async:
collection: bigtableadmin.operations

View File

@@ -0,0 +1,106 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Update an existing Cloud Bigtable table.
description: Update an existing new Cloud Bigtable table with the specified configuration.
examples: |
To enable deletion protection, run:
$ {command} my-table --instance=my-instance --deletion-protection
To disable deletion protection, run:
$ {command} my-table --instance=my-instance --no-deletion-protection
To enable a change stream with a retention period of 1 day, or to update your table's change stream retention period to 1 day, run:
$ {command} my-table --instance=my-instance --change-stream-retention-period=1d
To disable a change stream, run:
$ {command} my-table --instance=my-instance --clear-change-stream-retention-period
To enable the default automated backup policy on a table, or update a table to use the default policy (retention_period=7d, frequency=1d), run:
$ {command} my-table --instance=my-instance --enable-automated-backup
To disable automated backup: run:
$ {command} my-table --instance=my-instance --disable-automated-backup
To enable or update a custom automated backup policy and configure it to retain backups for 30 days, run:
$ {command} my-table --instance=my-instance --automated-backup-retention_period=30d
request:
collection: bigtableadmin.projects.instances.tables
method: patch
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.tables:HandleChangeStreamArgs
- googlecloudsdk.api_lib.bigtable.tables:HandleAutomatedBackupPolicyUpdateTableArgs
- googlecloudsdk.api_lib.bigtable.tables:HandleTieredStorageArgs
- googlecloudsdk.api_lib.bigtable.tables:RefreshUpdateMask
- googlecloudsdk.api_lib.bigtable.tables:HandleRowKeySchemaUpdateTableArgs
arguments:
resource:
help_text: Cloud Bigtable table to update.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table
additional_arguments_hook: googlecloudsdk.api_lib.bigtable.tables:AddAdditionalArgsAlphaBeta
GA:
additional_arguments_hook: googlecloudsdk.api_lib.bigtable.tables:AddAdditionalArgs
params:
- api_field: table.deletionProtection
arg_name: deletion-protection
type: bool
help_text: |
Once specified, the table is deletion protected.
- arg_name: row-key-schema-pre-encoded-bytes
type: bool
help_text: |
By default, Base64 encoding is applied to all binary fields in the YAML/JSON file (for example,
`encoding.delimitedBytes.delimiter`).
Use this to indicate that all binary fields are already encoded in the YAML/JSON file and
should not be encoded again.
This field is only used when `row-key-schema-definition-file` is set. It is ignored if
`clear-row-key-schema` is set.
- group:
help_text: |
Whether to update or clear the row key schema in the updated table. Only one of these
flags can be set.
required: false
mutex: true
params:
- arg_name: row-key-schema-definition-file
help_text: |
The row key schema for the table. The schema is defined in a YAML or JSON file, equivalent
to the StructType protobuf message.
Example YAML:
```yaml
encoding:
delimitedBytes:
delimiter: '#'
fields:
- fieldName: field1
type:
bytesType:
encoding:
raw: {}
- fieldName: field2
type:
bytesType:
encoding:
raw: {}
```
- arg_name: clear-row-key-schema
type: bool
help_text: |
Whether to clear the row key schema in the updated table.
async:
collection: bigtableadmin.operations