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,38 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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.ALPHA,
base.ReleaseTrack.BETA,
base.ReleaseTrack.GA,
)
class BigtableV2(base.Group):
"""Manage your Cloud Bigtable storage."""
category = base.DATABASES_CATEGORY
def Filter(self, context, args):
# TODO(b/190525916): Determine if command group works with project number
base.RequireProjectID(args)
del context, args
base.DisableUserProjectQuota()

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 app profiles command group for bigtable."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.core import properties
class AppProfiles(base.Group):
"""Manage Cloud Bigtable app profiles."""

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 app profile 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 app profile configurations."""

View File

@@ -0,0 +1,38 @@
release_tracks: [ALPHA]
command_type: CONFIG_EXPORT
help_text:
brief: Export the configuration for a Cloud Bigtable app profile.
description: |
*{command}* exports the configuration for a Cloud Bigtable app profile.
App profile 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
app profiles within the project.
Specifying `--path` allows you to export the configuration(s) to
a local directory.
examples: |
To export the configuration for an app profile, run:
$ {command} my-app-profile
To export the configuration for an app profile to a file, run:
$ {command} my-app-profile --path=/path/to/dir/
To export the configuration for an app profile in Terraform
HCL format, run:
$ {command} my-app-profile --resource-format=terraform
To export the configurations for all app profiles within a
project, run:
$ {command} --all
arguments:
resource:
help_text: App profile to export the configuration for.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:app_profile

View File

@@ -0,0 +1,253 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 app profiles create command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from apitools.base.py.exceptions import HttpError
from googlecloudsdk.api_lib.bigtable import app_profiles
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class CreateAppProfile(base.CreateCommand):
"""Create a new Bigtable app profile."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To create an app profile with a multi-cluster routing policy, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any
To create an app profile with a single-cluster routing policy which
routes all requests to `my-cluster-id`, run:
$ {command} my-single-cluster-app-profile --instance=my-instance-id --route-to=my-cluster-id
To create an app profile with a friendly description, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any --description="Routes requests for my use case"
To create an app profile with a request priority of PRIORITY_MEDIUM,
run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any --priority=PRIORITY_MEDIUM
To create an app profile with row-affinity routing enabled, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any --row-affinity
To create an app profile with Data Boost enabled which bills usage to the host project, run:
$ {command} my-app-profile-id --instance=my-instance-id --data-boost --data-boost-compute-billing-owner=HOST_PAYS
"""),
}
@staticmethod
def Args(parser):
arguments.AddAppProfileResourceArg(parser, 'to create')
(
arguments.ArgAdder(parser)
.AddDescription('app profile', required=False)
.AddAppProfileRouting()
.AddIsolation()
.AddForce('create')
)
def _CreateAppProfile(self, app_profile_ref, args):
"""Creates an AppProfile with the given arguments.
Args:
app_profile_ref: A resource reference of the new app profile.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Raises:
ConflictingArgumentsException,
OneOfArgumentsRequiredException:
See app_profiles.Create(...)
Returns:
Created app profile resource object.
"""
return app_profiles.Create(
app_profile_ref,
cluster=args.route_to,
description=args.description,
multi_cluster=args.route_any,
restrict_to=args.restrict_to,
transactional_writes=args.transactional_writes,
row_affinity=args.row_affinity,
priority=args.priority,
data_boost=args.data_boost,
data_boost_compute_billing_owner=args.data_boost_compute_billing_owner,
force=args.force,
)
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.
Raises:
ConflictingArgumentsException,
OneOfArgumentsRequiredException:
See _CreateAppProfile(...)
Returns:
Created resource.
"""
app_profile_ref = args.CONCEPTS.app_profile.Parse()
try:
result = self._CreateAppProfile(app_profile_ref, args)
except HttpError as e:
util.FormatErrorMessages(e)
else:
log.CreatedResource(app_profile_ref.Name(), kind='app profile')
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateAppProfileBeta(CreateAppProfile):
"""Create a new Bigtable app profile."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To create an app profile with a multi-cluster routing policy, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any
To create an app profile with a single-cluster routing policy which
routes all requests to `my-cluster-id`, run:
$ {command} my-single-cluster-app-profile --instance=my-instance-id --route-to=my-cluster-id
To create an app profile with a friendly description, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any --description="Routes requests for my use case"
To create an app profile with a request priority of PRIORITY_MEDIUM,
run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any --priority=PRIORITY_MEDIUM
To create an app profile with Data Boost enabled which bills usage to the host project, run:
$ {command} my-app-profile-id --instance=my-instance-id --data-boost --data-boost-compute-billing-owner=HOST_PAYS
To create an app profile with row-affinity routing enabled, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any --row-affinity
"""),
}
@staticmethod
def Args(parser):
arguments.AddAppProfileResourceArg(parser, 'to create')
(
arguments.ArgAdder(parser)
.AddDescription('app profile', required=False)
.AddAppProfileRouting()
.AddIsolation()
.AddForce('create')
)
def _CreateAppProfile(self, app_profile_ref, args):
"""Creates an AppProfile with the given arguments.
Args:
app_profile_ref: A resource reference of the new app profile.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Raises:
ConflictingArgumentsException,
OneOfArgumentsRequiredException:
See app_profiles.Create(...)
Returns:
Created app profile resource object.
"""
return app_profiles.Create(
app_profile_ref,
cluster=args.route_to,
description=args.description,
multi_cluster=args.route_any,
restrict_to=args.restrict_to,
transactional_writes=args.transactional_writes,
row_affinity=args.row_affinity,
priority=args.priority,
data_boost=args.data_boost,
data_boost_compute_billing_owner=args.data_boost_compute_billing_owner,
force=args.force,
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAppProfileAlpha(CreateAppProfileBeta):
"""Create a new Bigtable app profile."""
@staticmethod
def Args(parser):
arguments.AddAppProfileResourceArg(parser, 'to create')
(
arguments.ArgAdder(parser)
.AddDescription('app profile', required=False)
.AddAppProfileRouting()
.AddIsolation()
.AddForce('create')
)
def _CreateAppProfile(self, app_profile_ref, args):
"""Creates an AppProfile with the given arguments.
Args:
app_profile_ref: A resource reference of the new app profile.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Raises:
ConflictingArgumentsException,
OneOfArgumentsRequiredException:
See app_profiles.Create(...)
Returns:
Created app profile resource object.
"""
return app_profiles.Create(
app_profile_ref,
cluster=args.route_to,
description=args.description,
multi_cluster=args.route_any,
restrict_to=args.restrict_to,
transactional_writes=args.transactional_writes,
row_affinity=args.row_affinity,
priority=args.priority,
data_boost=args.data_boost,
data_boost_compute_billing_owner=args.data_boost_compute_billing_owner,
force=args.force,
)

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 app profiles delete command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from apitools.base.py.exceptions import HttpError
from googlecloudsdk.api_lib.bigtable import app_profiles
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
class DeleteAppProfile(base.DeleteCommand):
"""Delete a Bigtable app profile."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To delete an app profile, run:
$ {command} my-app-profile-id --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
arguments.AddAppProfileResourceArg(parser, 'to delete')
arguments.ArgAdder(parser).AddForce('delete')
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.
"""
app_profile_ref = args.CONCEPTS.app_profile.Parse()
console_io.PromptContinue(
'You are about to delete app profile: [{}]'.format(
app_profile_ref.Name()),
throw_if_unattended=True,
cancel_on_no=True)
try:
response = app_profiles.Delete(app_profile_ref, force=args.force)
except HttpError as e:
util.FormatErrorMessages(e)
else:
log.DeletedResource(app_profile_ref.Name(), 'app profile')
return response

View File

@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 app profiles describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import app_profiles
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
class DescribeAppProfile(base.DescribeCommand):
"""Describe an existing Bigtable app profile."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To view an app profile's description, run:
$ {command} my-app-profile-id --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddAppProfileResourceArg(parser, 'to describe')
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.
"""
app_profile_ref = args.CONCEPTS.app_profile.Parse()
return app_profiles.Describe(app_profile_ref)

View File

@@ -0,0 +1,184 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 app profiles list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import app_profiles
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
def _TransformAppProfileToRoutingInfo(app_profile):
"""Extracts the routing info from the app profile."""
if ('singleClusterRouting' in app_profile and
'clusterId' in app_profile['singleClusterRouting']):
return app_profile['singleClusterRouting']['clusterId']
elif 'multiClusterRoutingUseAny' in app_profile:
if 'clusterIds' in app_profile['multiClusterRoutingUseAny']:
return ','.join(app_profile['multiClusterRoutingUseAny']['clusterIds'])
return 'MULTI_CLUSTER_USE_ANY'
return ''
def _TransformAppProfileToIsolationMode(app_profile):
"""Extracts the isolation mode from the app profile."""
if 'dataBoostIsolationReadOnly' in app_profile:
return 'DATA_BOOST_ISOLATION_READ_ONLY'
return 'STANDARD_ISOLATION'
def _TransformAppProfileToStandardIsolationPriority(app_profile):
"""Extracts the Data Boot compute billing owner from the app profile."""
if 'dataBoostIsolationReadOnly' in app_profile:
return ''
elif (
'standardIsolation' in app_profile
and 'priority' in app_profile['standardIsolation']
):
return app_profile['standardIsolation']['priority']
else:
return 'PRIORITY_HIGH'
def _TransformAppProfileToDataBoostComputeBillingOwner(app_profile):
"""Extracts the Data Boot compute billing owner from the app profile."""
if (
'dataBoostIsolationReadOnly' in app_profile
and 'computeBillingOwner' in app_profile['dataBoostIsolationReadOnly']
):
return app_profile['dataBoostIsolationReadOnly']['computeBillingOwner']
else:
return ''
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ListAppProfilesGA(base.ListCommand):
"""List Bigtable app profiles."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To list all app profiles for an instance, run:
$ {command} --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
arguments.AddInstanceResourceArg(parser, 'to list app profiles for')
parser.display_info.AddTransforms({
'routingInfo': _TransformAppProfileToRoutingInfo,
})
# ROUTING is a oneof SingleClusterRouting, MultiClusterRoutingUseAny.
# Combine into a single ROUTING column in the table.
parser.display_info.AddFormat("""
table(
name.basename():sort=1,
description:wrap,
routingInfo():wrap:label=ROUTING,
singleClusterRouting.allowTransactionalWrites.yesno("Yes"):label=TRANSACTIONAL_WRITES
)
""")
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.
"""
instance_ref = args.CONCEPTS.instance.Parse()
return app_profiles.List(instance_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListAppProfilesBeta(ListAppProfilesGA):
"""List Bigtable app profiles."""
@staticmethod
def Args(parser):
arguments.AddInstanceResourceArg(parser, 'to list app profiles for')
parser.display_info.AddTransforms({
'routingInfo': _TransformAppProfileToRoutingInfo,
'isolationMode': _TransformAppProfileToIsolationMode,
'standardIsolationPriority': (
_TransformAppProfileToStandardIsolationPriority
),
'dataBoostComputeBillingOwner': (
_TransformAppProfileToDataBoostComputeBillingOwner
),
})
# ROUTING is a oneof SingleClusterRouting, MultiClusterRoutingUseAny.
# Combine into a single ROUTING column in the table.
parser.display_info.AddFormat("""
table(
name.basename():sort=1,
description:wrap,
routingInfo():wrap:label=ROUTING,
singleClusterRouting.allowTransactionalWrites.yesno("Yes"):label=TRANSACTIONAL_WRITES,
isolationMode():label=ISOLATION_MODE,
standardIsolationPriority():label=STANDARD_ISOLATION_PRIORITY,
dataBoostComputeBillingOwner():label=DATA_BOOST_COMPUTE_BILLING_OWNER
)
""")
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAppProfilesAlpha(ListAppProfilesBeta):
"""List Bigtable app profiles."""
@staticmethod
def Args(parser):
arguments.AddInstanceResourceArg(parser, 'to list app profiles for')
parser.display_info.AddTransforms({
'routingInfo': _TransformAppProfileToRoutingInfo,
'isolationMode': _TransformAppProfileToIsolationMode,
'standardIsolationPriority': (
_TransformAppProfileToStandardIsolationPriority
),
'dataBoostComputeBillingOwner': (
_TransformAppProfileToDataBoostComputeBillingOwner
),
})
# ROUTING is a oneof SingleClusterRouting, MultiClusterRoutingUseAny.
# Combine into a single ROUTING column in the table.
parser.display_info.AddFormat("""
table(
name.basename():sort=1,
description:wrap,
routingInfo():wrap:label=ROUTING,
singleClusterRouting.allowTransactionalWrites.yesno("Yes"):label=TRANSACTIONAL_WRITES,
isolationMode():label=ISOLATION_MODE,
standardIsolationPriority():label=STANDARD_ISOLATION_PRIORITY,
dataBoostComputeBillingOwner():label=DATA_BOOST_COMPUTE_BILLING_OWNER
)
""")

View File

@@ -0,0 +1,270 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 app profiles update command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from apitools.base.py.exceptions import HttpError
from googlecloudsdk.api_lib.bigtable import app_profiles
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class UpdateAppProfile(base.CreateCommand):
"""Update a Bigtable app profile."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To update an app profile to use a multi-cluster routing policy, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any
To update an app profile to use a single-cluster routing policy that
routes all requests to `my-cluster-id` and allows transactional
writes, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-to=my-cluster-id --transactional-writes
To update the description for an app profile, run:
$ {command} my-app-profile-id --instance=my-instance-id --description="New description"
To update the request priority for an app profile to PRIORITY_LOW, run:
$ {command} my-app-profile-id --instance=my-instance-id --priority=PRIORITY_LOW
To update an app profile to enable row-affinity routing, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any --row-affinity
To update an app profile to enable Data Boost which bills usage to the host project, run:
$ {command} my-app-profile-id --instance=my-instance-id --data-boost --data-boost-compute-billing-owner=HOST_PAYS
"""),
}
@staticmethod
def Args(parser):
arguments.AddAppProfileResourceArg(parser, 'to update')
(
arguments.ArgAdder(parser)
.AddDescription('app profile', required=False)
.AddAppProfileRouting(required=False)
.AddIsolation()
.AddForce('update')
.AddAsync()
)
def _UpdateAppProfile(self, app_profile_ref, args):
"""Updates an AppProfile with the given arguments.
Args:
app_profile_ref: A resource reference of the new app profile.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Raises:
ConflictingArgumentsException,
OneOfArgumentsRequiredException:
See app_profiles.Update(...)
Returns:
Long running operation.
"""
return app_profiles.Update(
app_profile_ref,
cluster=args.route_to,
description=args.description,
multi_cluster=args.route_any,
restrict_to=args.restrict_to,
transactional_writes=args.transactional_writes,
row_affinity=args.row_affinity,
priority=args.priority,
data_boost=args.data_boost,
data_boost_compute_billing_owner=args.data_boost_compute_billing_owner,
force=args.force,
)
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.
Raises:
ConflictingArgumentsException,
OneOfArgumentsRequiredException:
See _UpdateAppProfile(...)
Returns:
Updated resource.
"""
app_profile_ref = args.CONCEPTS.app_profile.Parse()
try:
result = self._UpdateAppProfile(app_profile_ref, args)
except HttpError as e:
util.FormatErrorMessages(e)
else:
operation_ref = util.GetOperationRef(result)
if args.async_:
log.UpdatedResource(
operation_ref,
kind='bigtable app profile {0}'.format(app_profile_ref.Name()),
is_async=True,
)
return result
return util.AwaitAppProfile(
operation_ref,
'Updating bigtable app profile {0}'.format(app_profile_ref.Name()),
)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateAppProfileBeta(UpdateAppProfile):
"""Update a Bigtable app profile."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To update an app profile to use a multi-cluster routing policy, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any
To update an app profile to use a single-cluster routing policy that
routes all requests to `my-cluster-id` and allows transactional
writes, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-to=my-cluster-id --transactional-writes
To update the description for an app profile, run:
$ {command} my-app-profile-id --instance=my-instance-id --description="New description"
To update the request priority for an app profile to PRIORITY_LOW, run:
$ {command} my-app-profile-id --instance=my-instance-id --priority=PRIORITY_LOW
To update an app profile to enable Data Boost which bills usage to the host project, run:
$ {command} my-app-profile-id --instance=my-instance-id --data-boost --data-boost-compute-billing-owner=HOST_PAYS
To update an app profile to enable row-affinity routing, run:
$ {command} my-app-profile-id --instance=my-instance-id --route-any --row-affinity
"""),
}
@staticmethod
def Args(parser):
arguments.AddAppProfileResourceArg(parser, 'to update')
(
arguments.ArgAdder(parser)
.AddDescription('app profile', required=False)
.AddAppProfileRouting(required=False)
.AddIsolation()
.AddForce('update')
.AddAsync()
)
def _UpdateAppProfile(self, app_profile_ref, args):
"""Updates an AppProfile with the given arguments.
Args:
app_profile_ref: A resource reference of the new app profile.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Raises:
ConflictingArgumentsException,
OneOfArgumentsRequiredException:
See app_profiles.Update(...)
Returns:
Long running operation.
"""
return app_profiles.Update(
app_profile_ref,
cluster=args.route_to,
description=args.description,
multi_cluster=args.route_any,
restrict_to=args.restrict_to,
transactional_writes=args.transactional_writes,
row_affinity=args.row_affinity,
priority=args.priority,
data_boost=args.data_boost,
data_boost_compute_billing_owner=args.data_boost_compute_billing_owner,
force=args.force,
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAppProfileAlpha(UpdateAppProfileBeta):
"""Update a Bigtable app profile."""
@staticmethod
def Args(parser):
arguments.AddAppProfileResourceArg(parser, 'to update')
(
arguments.ArgAdder(parser)
.AddDescription('app profile', required=False)
.AddAppProfileRouting(
required=False,
)
.AddIsolation()
.AddForce('update')
.AddAsync()
)
def _UpdateAppProfile(self, app_profile_ref, args):
"""Updates an AppProfile with the given arguments.
Args:
app_profile_ref: A resource reference of the new app profile.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Raises:
ConflictingArgumentsException,
OneOfArgumentsRequiredException:
See app_profiles.Update(...)
Returns:
Long running operation.
"""
return app_profiles.Update(
app_profile_ref,
cluster=args.route_to,
description=args.description,
multi_cluster=args.route_any,
restrict_to=args.restrict_to,
transactional_writes=args.transactional_writes,
row_affinity=args.row_affinity,
priority=args.priority,
data_boost=args.data_boost,
data_boost_compute_billing_owner=args.data_boost_compute_billing_owner,
force=args.force,
)

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 Authorized Views command group for Cloud Bigtable."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class AuthorizedViews(base.Group):
"""Manage Cloud Bigtable Authorized Views."""

View File

@@ -0,0 +1,35 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Add an IAM policy binding to a Cloud Bigtable authorized view.
description: |
Add an IAM policy binding to a Cloud Bigtable authorized view. 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 authorized view `my-authorized-view` in instance `my-instance` and table `my-table`, run:
$ {command} my-authorized-view --instance=`my-instance` --table=`my-table` --member=`user:test-user@gmail.com` --role=`roles/editor`
To add an IAM policy binding which expires at the end of the year 2020 for the role of
`roles/bigtable.admin` and the user `test-user@gmail.com` with authorized view `my-authorized-view`
in instance `my-instance` and table `my-table`, run:
$ {command} my-authorized-view --instance=`my-instance` --table=`my-table` --member=`user:test-user@gmail.com` --role=`roles/bigtable.admin` --condition=`expression=request.time < timestamp("2021-01-01T00:00:00Z"),title=expires_end_of_2020,description=Expires at midnight on 2020-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.authorizedViews
arguments:
resource:
help_text: Cloud Bigtable authorized view to add the IAM policy binding to.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:authorized_view

View File

@@ -0,0 +1,61 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Create a new Cloud Bigtable authorized view.
description: Create a new Cloud Bigtable authorized view.
examples: |
To create an authorized view `my-authorized-view` in instance `my-instance` and table
`my-table`, using the definition file `authorized_view.json`:
$ {command} my-authorized-view --instance=test-instance --table=test-table --definition-file=authorized_view.json
To create an authorized view `my-authorized-view` in instance `my-instance` and table
`my-table`, using the pre-encoded definition file `authorized_view_pre_encoded.json`:
$ {command} my-authorized-view --instance=test-instance --table=test-table --definition-file=authorized_view_pre_encoded.json --pre-encoded
request:
collection: bigtableadmin.projects.instances.tables.authorizedViews
method: create
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.authorized_views:ModifyCreateAuthorizedViewRequest
arguments:
resource:
help_text: Cloud Bigtable authorized view to create.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:authorized_view
params:
- arg_name: definition-file
help_text: |
Path to a JSON or YAML file containing a valid authorized view protobuf.
The `name` field is ignored. The name is deduced from the other command line arguments.
Example:
{
"subsetView":
{
"rowPrefixes": ["store1#"],
"familySubsets":
{
"column_family_name":
{
"qualifiers":["address"],
"qualifierPrefixes":["tel"]
}
}
},
"deletionProtection": true
}
- arg_name: pre-encoded
type: bool
default: false
help_text: |
By default, Base64 encoding is applied to all binary fields ("rowPrefixes", "qualifiers" and
"qualifierPrefixes") in the JSON or YAML definition file.
Use this to indicate that all binary fields are already Base64-encoded and should be used
directly.
async:
collection: bigtableadmin.operations

View File

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

View File

@@ -0,0 +1,19 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Describe a Cloud Bigtable authorized view.
description: Describe a Cloud Bigtable authorized view.
examples: |
To describe the authorized view `my-authorized-view` in instance `my-instance` and table
`my-table`:
$ {command} my-authorized-view --instance=test-instance --table=test-table
request:
collection: bigtableadmin.projects.instances.tables.authorizedViews
method: get
arguments:
resource:
help_text: Cloud Bigtable authorized view to describe.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:authorized_view

View File

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

View File

@@ -0,0 +1,21 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: List all authorized views of a Cloud Bigtable table.
description: List all authorized views of a Cloud Bigtable table.
examples: |
To list the authorized views in instance `my-instance` and table `my-table`:
$ {command} --instance=test-instance --table=test-table
request:
collection: bigtableadmin.projects.instances.tables.authorizedViews
method: list
response:
id_field: name
arguments:
resource:
help_text: Cloud Bigtable table for which to list all authorized views.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table

View File

@@ -0,0 +1,35 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Remove an IAM policy binding from a Cloud Bigtable authorized view.
description: |
Remove an IAM policy binding from a Cloud Bigtable authorized view. 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 authorized view `my-authorized-view` in instance `my-instance` and table `my-table`, run:
$ {command} my-authorized-view --instance=`my-instance` --table=`my-table` --member=`user:test-user@gmail.com` --role=`roles/editor`
To remove an IAM policy binding which expires at the end of the year 2020 for the role of
`roles/bigtable.admin` and the user `test-user@gmail.com` with authorized view `my-authorized-view`
in instance `my-instance` and cluster `my-cluster`, run:
$ {command} my-authorized-view --instance=`my-instance` --table=`my-table` --member=`user:test-user@gmail.com` --role=`roles/bigtable.admin` --condition=`expression=request.time < timestamp("2021-01-01T00:00:00Z"),title=expires_end_of_2020,description=Expires at midnight on 2020-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.authorizedViews
arguments:
resource:
help_text: Cloud Bigtable authorized view to remove the IAM policy binding from.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:authorized_view

View File

@@ -0,0 +1,28 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Set an IAM policy on a Cloud Bigtable authorized view.
description: |
Set an IAM policy on a Cloud Bigtable authorized view.
examples: |
To set the IAM policy from file `my-policy` on the authorized view `my-authorized-view` in
instance `my-instance` and table `my-table`, run:
$ {command} my-authorized-view --instance=`my-instance` --table=`my-table` my-policy
See https://cloud.google.com/iam/docs/managing-policies for more information.
request:
collection: bigtableadmin.projects.instances.tables.authorizedViews
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 authorized view to set the IAM policy on.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:authorized_view
iam:
policy_version: 3

View File

@@ -0,0 +1,77 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Update an existing Cloud Bigtable authorized view.
description: Update an existing Cloud Bigtable authorized view.
examples: |
To update the authorized view `my-authorized-view` in instance `my-instance` and table
`my-table`, using the definition file `authorized_view.json`:
$ {command} my-authorized-view --instance=test-instance --table=test-table --definition-file=authorized_view.json
To update the authorized view `my-authorized-view` in instance `my-instance` and table
`my-table`, using the pre-encoded definition file `authorized_view_pre_encoded.json`:
$ {command} my-authorized-view --instance=test-instance --table=test-table --definition-file=authorized_view_pre_encoded.json --pre-encoded
To update the authorized view `my-authorized-view` in instance `my-instance` and table
`my-table`, using the definition file `authorized_view.json` and skip the prompt to proceed or
cancel the update:
$ {command} my-authorized-view --instance=test-instance --table=test-table --definition-file=authorized_view.json --no-interactive
request:
collection: bigtableadmin.projects.instances.tables.authorizedViews
method: patch
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.authorized_views:ModifyUpdateAuthorizedViewRequest
arguments:
resource:
help_text: Cloud Bigtable authorized view to update.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:authorized_view
params:
- arg_name: definition-file
help_text: |
Path to a JSON or YAML file containing a valid authorized view protobuf.
The `name` field is ignored. The name is deduced from the other command line arguments.
Example:
{
"subsetView":
{
"rowPrefixes": ["store1"],
"familySubsets":
{
"column_family_name":
{
"qualifiers":["address"],
"qualifierPrefixes":["tel"]
}
}
},
"deletionProtection": true
}
- arg_name: interactive
type: bool
default: true
help_text: |
If provided, a diff is displayed with a prompt to proceed or cancel the update.
- arg_name: pre-encoded
type: bool
default: false
help_text: |
By default, Base64 encoding is applied to all binary fields ("rowPrefixes", "qualifiers" and
"qualifierPrefixes") in the JSON or YAML definition file.
Use this to indicate that all binary fields are already Base64-encoded and should be used
directly.
- arg_name: ignore-warnings
type: bool
default: false
help_text: |
If true, changes that make the authorized view more restrictive are allowed.
async:
collection: bigtableadmin.operations

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 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 backups 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.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Backups(base.Group):
"""Manage Cloud Bigtable backups."""

View File

@@ -0,0 +1,33 @@
help_text:
brief: Add an IAM policy binding to a Cloud Bigtable Backup.
description: |
Add an IAM policy binding to a Cloud Bigtable Backup. 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 backup `my-backup` in instance `my-instance` and cluster `my-cluster`, run:
$ {command} my-backup --instance=`my-instance` --cluster=`my-cluster` --member=`user:test-user@gmail.com` --role=`roles/editor`
To add an IAM policy binding which expires at the end of the year 2020 for the role of
`roles/bigtable.admin` and the user `test-user@gmail.com` with backup `my-backup`
in instance `my-instance` and cluster `my-cluster`, run:
$ {command} my-backup --instance=`my-instance` --cluster=`my-cluster` --member=`user:test-user@gmail.com` --role=`roles/bigtable.admin` --condition=`expression=request.time < timestamp("2021-01-01T00:00:00Z"),title=expires_end_of_2020,description=Expires at midnight on 2020-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.clusters.backups
arguments:
resource:
help_text: Cloud Bigtable Backup to add the IAM policy binding to.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:backup

View File

@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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 backups copy command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import backups
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 Copy(base.Command):
"""Copy a Cloud Bigtable backup to a new backup."""
detailed_help = {
'DESCRIPTION': textwrap.dedent("""
This command creates a copy of a Cloud Bigtable backup.
"""),
'EXAMPLES': textwrap.dedent("""\
To copy a backup within the same project, run:
$ {command} --source-instance=SOURCE_INSTANCE --source-cluster=SOURCE_CLUSTER --source-backup=SOURCE_BACKUP --destination-instance=DESTINATION_INSTANCE --destination-cluster=DESTINATION_CLUSTER --destination-backup=DESTINATION_BACKUP --expiration-date=2023-09-01T10:49:41Z
To copy a backup to a different project, run:
$ {command} --source-backup=projects/SOURCE_PROJECT/instances/SOURCE_INSTANCE/clusters/SOURCE_CLUSTER/backups/SOURCE_BACKUP --destination-backup=projects/DESTINATION_PROJECT/instances/DESTINATION_INSTANCE/clusters/DESTINATION_CLUSTER/backups/DESTINATION_BACKUP --expiration-date=2022-08-01T10:49:41Z
To set retention period and run asyncronously, run:
$ {command} --source-backup=projects/SOURCE_PROJECT/instances/SOURCE_INSTANCE/clusters/SOURCE_CLUSTER/backups/SOURCE_BACKUP --destination-backup=projects/DESTINATION_PROJECT/instances/DESTINATION_INSTANCE/clusters/DESTINATION_CLUSTER/backups/DESTINATION_BACKUP --retention-period=2w --async
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddCopyBackupResourceArgs(parser)
group_parser = parser.add_argument_group(mutex=True, required=True)
group_parser.add_argument(
'--expiration-date',
help=(
'Expiration time of the backup, must be at least 6 hours and at '
'most 30 days from the time the source backup is created. See '
'`$ gcloud topic datetimes` for information on date/time formats.'
),
)
group_parser.add_argument(
'--retention-period',
help=(
'Retention period of the backup relative from now, must be at least'
' 6 hours and at most 30 days from the time the source backup is'
' created. See `$ gcloud topic datetimes` for information on'
' duration formats.'
),
)
base.ASYNC_FLAG.AddToParser(parser)
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.
"""
source_backup_ref = args.CONCEPTS.source.Parse()
destination_backup_ref = args.CONCEPTS.destination.Parse()
op = backups.CopyBackup(source_backup_ref, destination_backup_ref, args)
operation_ref = util.GetOperationRef(op)
if args.async_:
log.status.Print('Copy request issued from [{}] to [{}]\n'
'Check operation [{}] for status.'.format(
source_backup_ref.RelativeName(),
destination_backup_ref.RelativeName(), op.name))
return op
op_result = util.AwaitBackup(
operation_ref, 'Waiting for operation [{}] to complete'.format(op.name))
if op.error is None:
log.CreatedResource(op_result)
return op_result

View File

@@ -0,0 +1,86 @@
- release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Creates a backup of a Cloud Bigtable table.
description: Creates a backup of a Cloud Bigtable table.
examples: |
To create a backup `BACKUP_NAME` asyncronously from table `TABLE_NAME` which expires at
`2019-03-30T10:49:41Z`, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--table=TABLE_NAME --expiration-date=2019-03-30T10:49:41Z --async
To create a backup `BACKUP_NAME` syncronously from table `TABLE_NAME` which expires in 2 weeks
from now, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--table=TABLE_NAME --retention-period=2w
To create a hot backup `BACKUP_NAME` from table `TABLE_NAME` which expires in 2 weeks
from now, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--table=TABLE_NAME --retention-period=2w --backup-type=HOT
To create a hot backup `BACKUP_NAME` from table `TABLE_NAME` which will be converted to a
standard backup at `2019-03-31T10:49:41Z` and expires in 2 weeks from now, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--table=TABLE_NAME --retention-period=2w --backup-type=HOT
--hot-to-standard-time=2019-03-31T10:49:41Z
To create a hot backup `BACKUP_NAME` from table `TABLE_NAME` which will be converted to a
standard backup in 1 week from now and expires in 2 weeks from now, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--table=TABLE_NAME --retention-period=2w --backup-type=HOT
--hot-to-standard-time=+P1w
request:
collection: bigtableadmin.projects.instances.clusters.backups
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.backups:ModifyCreateRequest
arguments:
params:
- api_field: backup.sourceTable
arg_name: table
required: true
help_text: ID of the table from which the backup will be created.
- group:
mutex: true
required: true
params:
- arg_name: expiration-date
api_field: backup.expireTime
help_text: |
Absolute expiration time of the backup. From the time the request is received, must be:
- At least 6 hours in the future
- At most 90 days in the future
See `$ gcloud topic datetimes` for information on date/time formats.
- arg_name: retention-period
api_field: backup.expireTime
help_text: |
Retention period of the backup relative from now; must be:
- At least 6 hours
- At most 90 days
See `$ gcloud topic datetimes` for information on duration formats.
- arg_name: backup-type
api_field: backup.backupType
help_text: |
Type of the backup; whether the backup is a standard backup or a hot backup.
- arg_name: hot-to-standard-time
api_field: backup.hotToStandardTime
help_text: |
Time at which a hot backup will be converted to a standard backup relative from now; must
be:
- At least 24 hours
Only applies for hot backups. See `$ gcloud topic datetimes` for information on date/time
formats.
resource:
help_text: The Cloud Bigtable backup to create.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:backup
async:
collection: bigtableadmin.operations

View File

@@ -0,0 +1,15 @@
help_text:
brief: Delete an existing backup.
description: Delete an existing backup.
examples: |
To delete a backup, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
request:
collection: bigtableadmin.projects.instances.clusters.backups
arguments:
resource:
help_text: Cloud Bigtable backup to delete.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:backup

View File

@@ -0,0 +1,15 @@
help_text:
brief: Retrieves information about a backup.
description: Retrieves information about a backup.
examples: |
To describe a backup, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
request:
collection: bigtableadmin.projects.instances.clusters.backups
arguments:
resource:
help_text: Cloud Bigtable backup to describe.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:backup

View File

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

View File

@@ -0,0 +1,116 @@
# -*- 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 backups list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import resources
def _GetUriFunction(resource):
return resources.REGISTRY.ParseRelativeName(
resource.name,
collection='bigtableadmin.projects.instances.clusters.backups').SelfLink()
def _TransformCluster(resource):
"""Get Cluster ID from backup name."""
# backup name is in the format of:
# projects/{}/instances/{}/clusters/{}/backups/{}
backup_name = resource.get('name')
results = backup_name.split('/')
cluster_name = results[-3]
return cluster_name
class ListBackups(base.ListCommand):
"""List existing Bigtable backups."""
detailed_help = {
'DESCRIPTION':
textwrap.dedent("""
List existing Bigtable backups.
"""),
'EXAMPLES':
textwrap.dedent("""
To list all backups in an instance, run:
$ {command} --instance=INSTANCE_NAME
To list all backups in a cluster, run:
$ {command} --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddBackupResourceArg(parser, 'to list backups for')
parser.display_info.AddFormat("""
table(
name.basename():sort=1:label=NAME,
cluster():label=CLUSTER,
sourceTable.basename():label=TABLE,
expireTime:label=EXPIRE_TIME,
state
)
""")
parser.display_info.AddUriFunc(_GetUriFunction)
parser.display_info.AddTransforms({'cluster': _TransformCluster})
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_ref = args.CONCEPTS.instance.Parse()
cluster_ref = args.CONCEPTS.cluster.Parse()
if cluster_ref:
cluster_str = cluster_ref.RelativeName()
elif instance_ref:
if args.IsSpecified('cluster'):
cluster_str = instance_ref.RelativeName() + '/clusters/' + args.cluster
else:
cluster_str = instance_ref.RelativeName() + '/clusters/-'
else:
raise exceptions.InvalidArgumentException('--instance',
'--instance must be specified')
msg = (
util.GetAdminMessages()
.BigtableadminProjectsInstancesClustersBackupsListRequest(
parent=cluster_str))
for backup in list_pager.YieldFromList(
cli.projects_instances_clusters_backups,
msg,
field='backups',
batch_size_attribute=None):
yield backup

View File

@@ -0,0 +1,33 @@
help_text:
brief: Remove an IAM policy binding from a Cloud Bigtable Backup.
description: |
Remove an IAM policy binding from a Cloud Bigtable Backup. 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 backup `my-backup` in instance `my-instance` and cluster `my-cluster`, run:
$ {command} my-backup --instance=`my-instance` --cluster=`my-cluster` --member=`user:test-user@gmail.com` --role=`roles/editor`
To remove an IAM policy binding which expires at the end of the year 2020 for the role of
`roles/bigtable.admin` and the user `test-user@gmail.com` with backup `my-backup`
in instance `my-instance` and cluster `my-cluster`, run:
$ {command} my-backup --instance=`my-instance` --cluster=`my-cluster` --member=`user:test-user@gmail.com` --role=`roles/bigtable.admin` --condition=`expression=request.time < timestamp("2021-01-01T00:00:00Z"),title=expires_end_of_2020,description=Expires at midnight on 2020-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.clusters.backups
arguments:
resource:
help_text: Cloud Bigtable Backup to remove the IAM policy binding from.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:backup

View File

@@ -0,0 +1,26 @@
help_text:
brief: Set an IAM policy on a Cloud Bigtable Backup.
description: |
Set an IAM policy on a Cloud Bigtable Backup.
examples: |
To set the IAM policy from file `my-policy` on the backup `my-backup` in
instance `my-instance` and cluster `my-cluster`, run:
$ {command} my-backup --instance=`my-instance` --cluster=`my-cluster` my-policy
See https://cloud.google.com/iam/docs/managing-policies for more information.
request:
collection: bigtableadmin.projects.instances.clusters.backups
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 Backup to set the IAM policy on.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:backup
iam:
policy_version: 3

View File

@@ -0,0 +1,58 @@
help_text:
brief: |
Update a backup, only supported for the following fields: --expiration-date and --retention-period.
description: |
Update a backup, only supported for the following fields: --expiration-date and --retention-period.
examples: |
To update the expire time of backup `BACKUP_NAME` to 7 days from now, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--retention-period=7d
To update the hot-to-standard time of backup `BACKUP_NAME` to `2019-03-31T10:49:41Z`, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--hot-to-standard-time=2019-03-31T10:49:41Z
To update the hot-to-standard time of backup `BACKUP_NAME` to 7 days from now, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--hot-to-standard-time=+P7d
To clear the hot-to-standard time of backup `BACKUP_NAME`, run:
$ {command} BACKUP_NAME --instance=INSTANCE_NAME --cluster=CLUSTER_NAME
--hot-to-standard-time=''
request:
collection: bigtableadmin.projects.instances.clusters.backups
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.backups:ResetDefaultMaskField
- googlecloudsdk.api_lib.bigtable.backups:AddBackupFieldsToUpdateMask
arguments:
resource:
help_text: Cloud Bigtable backup to update.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:backup
params:
- group:
mutex: true
params:
- arg_name: expiration-date
api_field: backup.expireTime
help_text: |
Absolute expiration time of the backup; must be at least 6 hours and at most 90 days from
backup creation time. See `$ gcloud topic datetimes` for information on date/time formats.
See `$ gcloud bigtable backups describe` for creation time.
- arg_name: retention-period
api_field: backup.expireTime
help_text: |
Retention period of the backup relative from now; must be at least 6 hours and at most 90
days from backup creation time. See `$ gcloud topic datetimes` for information on duration
formats. See `$ gcloud bigtable backups describe` for creation time.
- arg_name: hot-to-standard-time
api_field: backup.hotToStandardTime
help_text: |
Time at which a hot backup will be converted to a standard backup; must be at least 24 hours
from backup creation time. Only applies for hot backups. See `$ gcloud topic datetimes` for
information on date/time formats. See `$ gcloud bigtable backups describe` for creation time.

View File

@@ -0,0 +1,26 @@
# -*- 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
class Clusters(base.Group):
"""Manage Cloud Bigtable clusters."""

View File

@@ -0,0 +1,119 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 for bigtable clusters create."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import clusters
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.command_lib.util.apis import arg_utils
from googlecloudsdk.core import log
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class CreateCluster(base.CreateCommand):
"""Create a bigtable cluster."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To add a cluster in zone `us-east1-c` to the instance with id
`my-instance-id`, run:
$ {command} my-cluster-id --instance=my-instance-id --zone=us-east1-c
To add a cluster with `10` nodes, run:
$ {command} my-cluster-id --instance=my-instance-id --zone=us-east1-c --num-nodes=10
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddClusterResourceArg(parser, 'to describe')
arguments.ArgAdder(
parser
).AddClusterZone().AddAsync().AddScalingArgsForClusterCreate().AddClusterNodeScalingFactor()
arguments.AddKmsKeyResourceArg(parser, 'cluster')
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.
"""
cluster = self._Cluster(args)
cluster_ref = args.CONCEPTS.cluster.Parse()
operation = clusters.Create(cluster_ref, cluster)
operation_ref = util.GetOperationRef(operation)
if args.async_:
log.CreatedResource(
operation_ref.RelativeName(),
kind='bigtable cluster {0}'.format(cluster_ref.Name()),
is_async=True)
return
return util.AwaitCluster(
operation_ref,
'Creating bigtable cluster {0}'.format(cluster_ref.Name()))
def _Cluster(self, args):
msgs = util.GetAdminMessages()
storage_type = (
msgs.Cluster.DefaultStorageTypeValueValuesEnum.STORAGE_TYPE_UNSPECIFIED
)
node_scaling_factor = arg_utils.ChoiceToEnum(
args.node_scaling_factor,
msgs.Cluster.NodeScalingFactorValueValuesEnum,
)
cluster = msgs.Cluster(
serveNodes=args.num_nodes,
nodeScalingFactor=node_scaling_factor,
location=util.LocationUrl(args.zone),
defaultStorageType=storage_type)
kms_key = arguments.GetAndValidateKmsKeyName(args)
if kms_key:
cluster.encryptionConfig = msgs.EncryptionConfig(kmsKeyName=kms_key)
if (args.autoscaling_min_nodes is not None or
args.autoscaling_max_nodes is not None or
args.autoscaling_cpu_target is not None or
args.autoscaling_storage_target is not None):
cluster.clusterConfig = clusters.BuildClusterConfig(
autoscaling_min=args.autoscaling_min_nodes,
autoscaling_max=args.autoscaling_max_nodes,
autoscaling_cpu_target=args.autoscaling_cpu_target,
autoscaling_storage_target=args.autoscaling_storage_target)
# serveNodes must be set to None or 0 to enable Autoscaling.
# go/cbt-autoscaler-api
cluster.serveNodes = None
return cluster

View File

@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 for bigtable clusters delete."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import clusters
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
class DeleteCluster(base.DeleteCommand):
"""Delete a bigtable cluster."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To delete a cluster, run:
$ {command} my-cluster-id --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddClusterResourceArg(parser, 'to delete')
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.
"""
cluster_ref = args.CONCEPTS.cluster.Parse()
console_io.PromptContinue(
'You are about to delete cluster: [{0}]'.format(cluster_ref.Name()),
throw_if_unattended=True,
cancel_on_no=True)
response = clusters.Delete(cluster_ref)
log.DeletedResource(cluster_ref.Name(), 'cluster')
return response

View File

@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 clusters describe 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
class DescribeCluster(base.DescribeCommand):
"""Describe an existing Bigtable cluster."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To view a cluster's description, run:
$ {command} my-cluster-id --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddClusterResourceArg(parser, 'to describe')
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()
cluster_ref = args.CONCEPTS.cluster.Parse()
msg = util.GetAdminMessages(
).BigtableadminProjectsInstancesClustersGetRequest(
name=cluster_ref.RelativeName())
return cli.projects_instances_clusters.Get(msg)

View File

@@ -0,0 +1,94 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 clusters list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
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 resources
def _GetUriFunction(resource):
return resources.REGISTRY.ParseRelativeName(
resource.name,
collection='bigtableadmin.projects.instances.clusters').SelfLink()
class ListClusters(base.ListCommand):
"""List existing Bigtable clusters."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To list all clusters in an instance, run:
$ {command} --instances=my-instance-id
To list all clusters in multiple instances, run:
$ {command} --instances=my-instance-id,my-other-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddInstancesResourceArg(parser, 'to list clusters for')
parser.display_info.AddFormat("""
table(
name.segment(3):sort=1:label=INSTANCE,
name.basename():sort=2:label=NAME,
location.basename():label=ZONE,
serveNodes:label=NODES,
defaultStorageType:label=STORAGE,
state
)
""")
parser.display_info.AddUriFunc(_GetUriFunction)
parser.display_info.AddCacheUpdater(arguments.InstanceCompleter)
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

View File

@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 clusters update command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import clusters
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA,
base.ReleaseTrack.ALPHA)
class UpdateCluster(base.UpdateCommand):
"""Update a Bigtable cluster's number of nodes."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To update a cluster to `10` nodes, run:
$ {command} my-cluster-id --instance=my-instance-id --num-nodes=10
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddClusterResourceArg(parser, 'to update')
(arguments.ArgAdder(parser).AddAsync().AddScalingArgsForClusterUpdate())
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:
None
"""
return self._Run(args)
def _Run(self, args):
"""Implements Run() with different possible features flags."""
cluster_ref = args.CONCEPTS.cluster.Parse()
operation = clusters.PartialUpdate(
cluster_ref,
nodes=args.num_nodes,
autoscaling_min=args.autoscaling_min_nodes,
autoscaling_max=args.autoscaling_max_nodes,
autoscaling_cpu_target=args.autoscaling_cpu_target,
autoscaling_storage_target=args.autoscaling_storage_target,
disable_autoscaling=args.disable_autoscaling)
if not args.async_:
operation_ref = util.GetOperationRef(operation)
return util.AwaitCluster(
operation_ref,
'Updating bigtable cluster {0}'.format(cluster_ref.Name()))
log.UpdatedResource(
cluster_ref.Name(), kind='cluster', is_async=args.async_)
return None

View File

@@ -0,0 +1,27 @@
# -*- 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.
"""The hottablets 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 HotTablets(base.Group):
"""Manage Cloud Bigtable hot tablets."""

View File

@@ -0,0 +1,102 @@
# -*- 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.
"""bigtable hottablets command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
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.util import times
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA,
base.ReleaseTrack.ALPHA)
class ListHotTablets(base.ListCommand):
"""List hot tablets in a Cloud Bigtable cluster."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
Search for hot tablets in the past 24 hours:
$ {command} my-cluster-id --instance=my-instance-id
Search for hot tablets with start and end times by minute:
$ {command} my-cluster-id --instance=my-instance-id --start-time="2018-08-12 03:30:00" --end-time="2018-08-13 17:00:00"
Search for hot tablets with start and end times by day:
$ {command} my-cluster-id --instance=my-instance-id --start-time=2018-01-01 --end-time=2018-01-05
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddClusterResourceArg(parser, 'to list hot tablets for')
arguments.AddStartTimeArgs(parser, 'to search for hot tablets')
arguments.AddEndTimeArgs(parser, 'to search for hot tablets')
# Define how the output should look like in a table.
# Display startTime and endTime up to second precision.
# `sort=1:reverse` sorts the display order of hot tablets by cpu usage.
parser.display_info.AddFormat("""
table(
tableName.basename():label=TABLE,
nodeCpuUsagePercent:label=CPU_USAGE:sort=1:reverse,
startTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'):label=START_TIME,
endTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'):label=END_TIME,
startKey:label=START_KEY,
endKey:label=END_KEY
)
""")
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()
# cluster_ref: A resource reference to the cluster to search for hottablets.
cluster_ref = args.CONCEPTS.cluster.Parse()
# Create a ListHotTablets Request and send through Admin Client.
msg = (
util.GetAdminMessages()
.BigtableadminProjectsInstancesClustersHotTabletsListRequest(
parent=cluster_ref.RelativeName(),
startTime=args.start_time and times.FormatDateTime(args.start_time),
endTime=args.end_time and times.FormatDateTime(args.end_time)))
for hot_tablet in list_pager.YieldFromList(
cli.projects_instances_clusters_hotTablets,
msg,
field='hotTablets',
batch_size_attribute=None):
yield hot_tablet

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 instances command group for bigtable."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Instances(base.Group):
"""Manage Cloud Bigtable instances."""

View File

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

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 instance 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 instance configurations."""

View File

@@ -0,0 +1,38 @@
release_tracks: [ALPHA]
command_type: CONFIG_EXPORT
help_text:
brief: Export the configuration for a Cloud Bigtable instance.
description: |
*{command}* exports the configuration for a Cloud Bigtable instance.
Instance 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
instances within the project.
Specifying `--path` allows you to export the configuration(s) to
a local directory.
examples: |
To export the configuration for an instance, run:
$ {command} my-instance
To export the configuration for an instance to a file, run:
$ {command} my-instance --path=/path/to/dir/
To export the configuration for an instance in Terraform
HCL format, run:
$ {command} my-instance --resource-format=terraform
To export the configurations for all instances within a
project, run:
$ {command} --all
arguments:
resource:
help_text: Instance to export the configuration for.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:instance

View File

@@ -0,0 +1,279 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 instances create command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import clusters
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class CreateInstance(base.CreateCommand):
"""Create a new Bigtable instance."""
_support_tags = False
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To create an instance with id `my-instance-id` with a cluster located
in `us-east1-c`, run:
$ {command} my-instance-id --display-name="My Instance" --cluster-config=id=my-cluster-id,zone=us-east1-c
To create an instance with multiple clusters, run:
$ {command} my-instance-id --display-name="My Instance" --cluster-config=id=my-cluster-id-1,zone=us-east1-c --cluster-config=id=my-cluster-id-2,zone=us-west1-c,nodes=3
To create an instance with `HDD` storage and `10` nodes, run:
$ {command} my-hdd-instance --display-name="HDD Instance" --cluster-storage-type=HDD --cluster-config=id=my-cluster-id,zone=us-east1-c,nodes=10
"""),
}
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
(
arguments.ArgAdder(parser)
.AddInstanceDisplayName(required=True)
.AddClusterConfig()
.AddDeprecatedCluster()
.AddDeprecatedClusterZone()
.AddDeprecatedClusterNodes()
.AddClusterStorage()
.AddAsync()
.AddDeprecatedInstanceType()
)
if cls._support_tags:
arguments.ArgAdder(parser).AddTags()
arguments.AddInstanceResourceArg(parser, 'to create', positional=True)
parser.display_info.AddCacheUpdater(arguments.InstanceCompleter)
def Run(self, args):
"""Executes the instances create 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.
"""
return self._Run(args)
def _Run(self, args):
"""Implements Run() with different possible features flags."""
cli = util.GetAdminClient()
ref = args.CONCEPTS.instance.Parse()
# TODO(b/153576330): This is a workaround for inconsistent collection names.
parent_ref = resources.REGISTRY.Create(
'bigtableadmin.projects', projectId=ref.projectsId)
msgs = util.GetAdminMessages()
instance_type = msgs.Instance.TypeValueValuesEnum(args.instance_type)
new_clusters = self._Clusters(args)
clusters_properties = []
for cluster_id, cluster in sorted(new_clusters.items()):
clusters_properties.append(
msgs.CreateInstanceRequest.ClustersValue.AdditionalProperty(
key=cluster_id, value=cluster))
msg = msgs.CreateInstanceRequest(
instanceId=ref.Name(),
parent=parent_ref.RelativeName(),
instance=msgs.Instance(
displayName=args.display_name,
type=instance_type,
tags=self._Tags(args),
),
clusters=msgs.CreateInstanceRequest.ClustersValue(
additionalProperties=clusters_properties
),
)
result = cli.projects_instances.Create(msg)
operation_ref = util.GetOperationRef(result)
if args.async_:
log.CreatedResource(
operation_ref.RelativeName(),
kind='bigtable instance {0}'.format(ref.Name()),
is_async=True)
return result
return util.AwaitInstance(
operation_ref, 'Creating bigtable instance {0}'.format(ref.Name()))
def _Clusters(self, args):
"""Get the clusters configs from command arguments.
Args:
args: the argparse namespace from Run().
Returns:
A dict mapping from cluster id to msg.Cluster.
"""
msgs = util.GetAdminMessages()
storage_type = msgs.Cluster.DefaultStorageTypeValueValuesEnum(
args.cluster_storage_type.upper())
if args.cluster_config is not None:
if (args.cluster is not None
or args.cluster_zone is not None
or args.cluster_num_nodes is not None):
raise exceptions.InvalidArgumentException(
'--cluster-config --cluster --cluster-zone --cluster-num-nodes',
'Use --cluster-config or the combination of --cluster, '
'--cluster-zone and --cluster-num-nodes to specify cluster(s), not '
'both.')
self._ValidateClusterConfigArgs(args.cluster_config)
new_clusters = {}
for cluster_dict in args.cluster_config:
nodes = cluster_dict.get('nodes', 1)
node_scaling_factor = cluster_dict.get(
'node-scaling-factor',
msgs.Cluster.NodeScalingFactorValueValuesEnum(
msgs.Cluster.NodeScalingFactorValueValuesEnum.NODE_SCALING_FACTOR_1X
),
)
cluster = msgs.Cluster(
serveNodes=nodes,
nodeScalingFactor=node_scaling_factor,
defaultStorageType=storage_type,
# TODO(b/36049938): switch location to resource
# when b/29566669 is fixed on API
location=util.LocationUrl(cluster_dict['zone']))
if 'kms-key' in cluster_dict:
cluster.encryptionConfig = msgs.EncryptionConfig(
kmsKeyName=cluster_dict['kms-key'])
if ('autoscaling-min-nodes' in cluster_dict or
'autoscaling-max-nodes' in cluster_dict or
'autoscaling-cpu-target' in cluster_dict):
# autoscaling-storage-target is optional.
if 'autoscaling-storage-target' in cluster_dict:
storage_target = cluster_dict['autoscaling-storage-target']
else:
storage_target = None
cluster.clusterConfig = clusters.BuildClusterConfig(
autoscaling_min=cluster_dict['autoscaling-min-nodes'],
autoscaling_max=cluster_dict['autoscaling-max-nodes'],
autoscaling_cpu_target=cluster_dict['autoscaling-cpu-target'],
autoscaling_storage_target=storage_target)
# serveNodes must be set to None or 0 to enable Autoscaling.
# go/cbt-autoscaler-api
cluster.serveNodes = None
new_clusters[cluster_dict['id']] = cluster
return new_clusters
elif args.cluster is not None:
if args.cluster_zone is None:
raise exceptions.InvalidArgumentException(
'--cluster-zone', '--cluster-zone must be specified.')
cluster = msgs.Cluster(
serveNodes=arguments.ProcessInstanceTypeAndNodes(args),
# nodeScalingFactor is not supported in deprecated workflow
defaultStorageType=storage_type,
nodeScalingFactor=msgs.Cluster.NodeScalingFactorValueValuesEnum(
msgs.Cluster.NodeScalingFactorValueValuesEnum.NODE_SCALING_FACTOR_1X
),
# TODO(b/36049938): switch location to resource
# when b/29566669 is fixed on API
location=util.LocationUrl(args.cluster_zone))
return {args.cluster: cluster}
else:
raise exceptions.InvalidArgumentException(
'--cluster --cluster-config',
'Use --cluster-config to specify cluster(s).',
)
def _ValidateClusterConfigArgs(self, cluster_config):
"""Validates arguments in cluster-config as a repeated dict."""
# Validate cluster-config of each cluster.
for cluster_dict in cluster_config:
if ('autoscaling-min-nodes' in cluster_dict or
'autoscaling-max-nodes' in cluster_dict or
'autoscaling-cpu-target' in cluster_dict or
'autoscaling-storage-target' in cluster_dict):
# nodes and autoscaling args are mutual exclusive.
if 'nodes' in cluster_dict:
raise exceptions.InvalidArgumentException(
'--autoscaling-min-nodes --autoscaling-max-nodes '
'--autoscaling-cpu-target --autoscaling-storage-target',
'At most one of nodes | autoscaling-min-nodes '
'autoscaling-max-nodes autoscaling-cpu-target '
'autoscaling-storage-target may be specified in --cluster-config')
# To enable autoscaling, all related args must be set.
if ('autoscaling-min-nodes' not in cluster_dict or
'autoscaling-max-nodes' not in cluster_dict or
'autoscaling-cpu-target' not in cluster_dict):
raise exceptions.InvalidArgumentException(
'--autoscaling-min-nodes --autoscaling-max-nodes '
'--autoscaling-cpu-target', 'All of --autoscaling-min-nodes '
'--autoscaling-max-nodes --autoscaling-cpu-target must be set to '
'enable Autoscaling.')
@classmethod
def _Tags(cls, args, tags_arg_name='tags'):
"""Get the tags from command arguments.
Args:
args: the argparse namespace from Run().
tags_arg_name: the name of the tags argument.
Returns:
A dict mapping from tag key to tag value.
"""
if not cls._support_tags:
return None
tags = getattr(args, tags_arg_name)
if not tags:
return None
tags_message = util.GetAdminMessages().Instance.TagsValue
# Sorted for test stability.
return tags_message(
additionalProperties=[
tags_message.AdditionalProperty(key=key, value=value)
for key, value in sorted(tags.items())
]
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateInstanceAlpha(CreateInstance):
"""Create a new Bigtable instance."""
_support_tags = True

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 instances delete 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.console import console_io
class DeleteInstance(base.DeleteCommand):
"""Delete an existing Bigtable instance."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To delete an instance, run:
$ {command} my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddInstancesResourceArg(parser, 'to delete', positional=True)
parser.display_info.AddCacheUpdater(arguments.InstanceCompleter)
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

View File

@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 instances describe 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 properties
from googlecloudsdk.core import resources
class DescribeInstance(base.DescribeCommand):
"""Describe an existing Bigtable instance."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To view an instance's description, run:
$ {command} my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddInstanceResourceArg(parser, 'to describe', positional=True)
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()
ref = resources.REGISTRY.Parse(
args.instance,
params={
'projectsId': properties.VALUES.core.project.GetOrFail,
},
collection='bigtableadmin.projects.instances')
msg = util.GetAdminMessages().BigtableadminProjectsInstancesGetRequest(
name=ref.RelativeName())
instance = cli.projects_instances.Get(msg)
return instance

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 for bigtable instances get-iam-policy."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import instances
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
class GetIamPolicy(base.ListCommand):
"""Get the IAM policy for a Cloud Bigtable instance."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To print the IAM policy for an instance, run:
$ {command} my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddInstanceResourceArg(
parser, 'to get the IAM policy for', positional=True)
base.URI_FLAG.RemoveFromParser(parser)
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:
A IAM policy message.
"""
instance_ref = util.GetInstanceRef(args.instance)
return instances.GetIamPolicy(instance_ref)

View File

@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 instances list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.core import properties
from googlecloudsdk.core import resources
def _GetUriFunction(resource):
return util.GetInstanceRef(resource.name).SelfLink()
class ListInstances(base.ListCommand):
"""List existing Bigtable instances."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To list all instances, run:
$ {command}
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
parser.display_info.AddFormat("""
table(
name.basename():sort=1,
displayName,
state
)
""")
parser.display_info.AddUriFunc(_GetUriFunction)
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()
project_ref = resources.REGISTRY.Parse(
properties.VALUES.core.project.Get(required=True),
collection='bigtableadmin.projects')
msg = util.GetAdminMessages().BigtableadminProjectsInstancesListRequest(
parent=project_ref.RelativeName())
return list_pager.YieldFromList(
cli.projects_instances,
msg,
field='instances',
batch_size_attribute=None)

View File

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

View File

@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 for bigtable instances set-iam-policy."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.command_lib.bigtable import iam
from googlecloudsdk.command_lib.iam import iam_util
class SetIamPolicy(base.Command):
"""Set the IAM policy for a Cloud Bigtable instance."""
detailed_help = iam_util.GetDetailedHelpForSetIamPolicy(
'instance', example_id='my-instance-id', use_an=True)
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddInstanceResourceArg(
parser, 'to set the IAM policy for', positional=True)
iam_util.AddArgForPolicyFile(parser)
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:
A IAM policy message.
"""
instance_ref = util.GetInstanceRef(args.instance)
result = iam.SetInstanceIamPolicy(instance_ref, args.policy_file)
iam_util.LogSetIamPolicy(instance_ref.Name(), 'instance')
return result

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

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*- #
# Copyright 2016 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 instances update command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import util as bigtable_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
class UpdateInstance(base.UpdateCommand):
"""Modify an existing Bigtable instance."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To update the display name for an instance, run:
$ {command} my-instance-id --display-name="Updated Instance Name"
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.ArgAdder(parser).AddInstanceDisplayName()
arguments.AddInstanceResourceArg(parser, 'to update', positional=True)
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

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 instances upgrade command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.api_lib.bigtable import instances
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
class UpgradeInstance(base.UpdateCommand):
"""Upgrade an existing instance's type from development to production."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To upgrade a `DEVELOPMENT` instance to `PRODUCTION`, run:
$ {command} my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.ArgAdder(parser).AddAsync()
arguments.AddInstanceResourceArg(parser, 'to upgrade', positional=True)
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:
op_ref = resources.REGISTRY.ParseRelativeName(
op.name, collection='bigtableadmin.operations')
message = 'Upgrading bigtable instance {0}'.format(args.instance)
result = util.AwaitInstance(op_ref, message)
log.UpdatedResource(args.instance, kind='instance', is_async=args.async_)
return result

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 logical views command group for Bigtable."""
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class LogicalViews(base.Group):
"""Manage Bigtable logical views."""

View File

@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 logical views create command."""
import textwrap
from apitools.base.py import exceptions
from googlecloudsdk.api_lib.bigtable import logical_views
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
HttpError = exceptions.HttpError
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class CreateLogicalView(base.CreateCommand):
"""Create a new Bigtable logical view."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To create a logical view, run:
$ {command} my-logical-view-id --instance=my-instance-id --query="SELECT my-column-family FROM my-table"
"""),
}
@staticmethod
def Args(parser):
arguments.AddLogicalViewResourceArg(parser, 'to create')
arguments.ArgAdder(parser).AddViewQuery(
required=True
).AddAsync().AddDeletionProtection()
def _CreateLogicalView(self, logical_view_ref, args):
"""Creates a logical view with the given arguments.
Args:
logical_view_ref: A resource reference of the new logical view.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
Created logical view resource object.
"""
return logical_views.Create(
logical_view_ref, args.query, args.deletion_protection
)
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:
Created resource.
"""
logical_view_ref = args.CONCEPTS.logical_view.Parse()
operation = self._CreateLogicalView(logical_view_ref, args)
if not args.async_:
operation_ref = util.GetOperationRef(operation)
return util.AwaitLogicalView(
operation_ref,
'Creating logical view {0}'.format(logical_view_ref.Name()),
)
log.CreatedResource(
logical_view_ref.Name(), kind='logical view', is_async=args.async_
)
return None

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 logical views delete command."""
import textwrap
from apitools.base.py import exceptions
from googlecloudsdk.api_lib.bigtable import logical_views
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
HttpError = exceptions.HttpError
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class DeleteLogicalView(base.DeleteCommand):
"""Delete a Bigtable logical view."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To delete a logical view, run:
$ {command} my-logical-view-id --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
arguments.AddLogicalViewResourceArg(parser, 'to delete')
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.
"""
logical_view_ref = args.CONCEPTS.logical_view.Parse()
console_io.PromptContinue(
f'You are about to delete logical view: [{logical_view_ref.Name()}]',
throw_if_unattended=True,
cancel_on_no=True,
)
try:
response = logical_views.Delete(logical_view_ref)
except HttpError as e:
util.FormatErrorMessages(e)
else:
log.DeletedResource(logical_view_ref.Name(), 'logical view')
return response

View File

@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 logical views describe command."""
import textwrap
from googlecloudsdk.api_lib.bigtable import logical_views
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class DescribeLogicalView(base.DescribeCommand):
"""Describe an existing Bigtable logical view."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To view a logical view's description, run:
$ {command} my-logical-view-id --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddLogicalViewResourceArg(parser, 'to describe')
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.
"""
logical_view_ref = args.CONCEPTS.logical_view.Parse()
return logical_views.Describe(logical_view_ref)

View File

@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 logical views list command."""
import textwrap
from googlecloudsdk.api_lib.bigtable import logical_views
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
@base.DefaultUniverseOnly
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class ListLogicalViews(base.ListCommand):
"""List existing Bigtable logical views."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To list all logical views for an instance, run:
$ {command} --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddInstanceResourceArg(parser, 'to list logical views for')
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.
"""
instance_ref = args.CONCEPTS.instance.Parse()
return logical_views.List(instance_ref)

View File

@@ -0,0 +1,94 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 logical views list command."""
import textwrap
from googlecloudsdk.api_lib.bigtable import logical_views
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class UpdateLogicalView(base.UpdateCommand):
"""Update a Bigtable logical view."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To update a logical view to a new query, run:
$ {command} my-logical-view-id --instance=my-instance-id --query="SELECT my-column-family2 FROM my-table"
To enable deletion protection on a logical view, run:
$ {command} my-logical-view-id --instance=my-instance-id --deletion-protection
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddLogicalViewResourceArg(parser, 'to update')
# At least one of query or deletion_protection must be specified.
update_group = parser.add_group(required=True)
arg_adder = arguments.ArgAdder(update_group)
arg_adder.AddDeletionProtection()
arg_adder.AddViewQuery()
arguments.ArgAdder(parser).AddAsync()
def _UpdateLogicalView(self, logical_view_ref, args):
"""Updates a logical view with the given arguments.
Args:
logical_view_ref: A resource reference of the new logical view.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
Long running operation.
"""
return logical_views.Update(
logical_view_ref, args.query, args.deletion_protection
)
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:
Updated resource.
"""
logical_view_ref = args.CONCEPTS.logical_view.Parse()
operation = self._UpdateLogicalView(logical_view_ref, args)
if not args.async_:
operation_ref = util.GetOperationRef(operation)
return util.AwaitLogicalView(
operation_ref,
'Updating logical view {0}'.format(logical_view_ref.Name()),
)
log.UpdatedResource(
logical_view_ref.Name(), kind='logical view', is_async=args.async_
)
return None

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 materialized views command group for Bigtable."""
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class MaterializedViews(base.Group):
"""Manage Bigtable materialized views."""

View File

@@ -0,0 +1,99 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 materialized views create command."""
import textwrap
from apitools.base.py import exceptions
from googlecloudsdk.api_lib.bigtable import materialized_views
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.calliope import parser_extensions
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
from googlecloudsdk.generated_clients.apis.bigtableadmin.v2 import bigtableadmin_v2_messages
HttpError = exceptions.HttpError
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class CreateMaterializedView(base.CreateCommand):
"""Create a new Bigtable materialized view."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To create a materialized view, run:
$ {command} my-materialized-view-id --instance=my-instance-id --query="SELECT my-column-family FROM my-table --deletion-protection=false"
"""),
}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor) -> None:
arguments.AddMaterializedViewResourceArg(parser, 'to create')
arguments.ArgAdder(parser).AddViewQuery(
required=True
).AddDeletionProtection().AddAsync()
def _CreateMaterializedView(
self,
materialized_view_ref: resources.Resource,
args: parser_extensions.Namespace,
) -> bigtableadmin_v2_messages.MaterializedView:
"""Creates a materialized view with the given arguments.
Args:
materialized_view_ref: A resource reference of the new materialized view.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
Created materialized view resource object.
"""
return materialized_views.Create(
materialized_view_ref, args.query, args.deletion_protection
)
def Run(
self, args: parser_extensions.Namespace
) -> bigtableadmin_v2_messages.MaterializedView:
"""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:
Created resource.
"""
materialized_view_ref = args.CONCEPTS.materialized_view.Parse()
operation = self._CreateMaterializedView(materialized_view_ref, args)
if not args.async_:
operation_ref = util.GetOperationRef(operation)
return util.AwaitMaterializedView(
operation_ref,
'Creating materialized view {0}'.format(materialized_view_ref.Name()),
)
log.CreatedResource(
materialized_view_ref.Name(),
kind='materialized view',
is_async=args.async_,
)
return None

View File

@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 materialized views delete command."""
import textwrap
from apitools.base.py import exceptions
from googlecloudsdk.api_lib.bigtable import materialized_views
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.calliope import parser_extensions
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
HttpError = exceptions.HttpError
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class DeleteMaterializedView(base.DeleteCommand):
"""Delete a Bigtable materialized view."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To delete a materialized view, run:
$ {command} my-materialized-view-id --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
arguments.AddMaterializedViewResourceArg(parser, 'to delete')
def Run(
self, args: parser_extensions.Namespace
) -> None:
"""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.
"""
materialized_view_ref = args.CONCEPTS.materialized_view.Parse()
console_io.PromptContinue(
'You are about to delete materialized view:'
f' [{materialized_view_ref.Name()}]',
throw_if_unattended=True,
cancel_on_no=True,
)
try:
materialized_views.Delete(materialized_view_ref)
except HttpError as e:
util.FormatErrorMessages(e)
else:
log.DeletedResource(materialized_view_ref.Name(), 'materialized view')

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 materialized views describe command."""
import textwrap
from googlecloudsdk.api_lib.bigtable import materialized_views
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_extensions
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.generated_clients.apis.bigtableadmin.v2 import bigtableadmin_v2_messages
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class DescribeMaterializedView(base.DescribeCommand):
"""Describe an existing Bigtable materialized view."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To get back information related to a view's schema (for example, description), run:
$ {command} my-materialized-view-id --instance=my-instance-id --view=schema
or (because schema is the default view) simply:
$ {command} my-materialized-view-id --instance=my-instance-id
To get back information related to the view's replication state, run:
$ {command} my-materialized-view-id --instance=my-instance-id --view=replication
To get back all information for the view, run:
$ {command} my-materialized-view-id --instance=my-instance-id --view=full
"""),
}
@staticmethod
def Args(parser) -> None:
"""Register flags for this command."""
arguments.AddMaterializedViewResourceArg(parser, 'to describe')
arguments.AddViewOverMaterializedView(parser)
def Run(
self, args: parser_extensions.Namespace
) -> bigtableadmin_v2_messages.MaterializedView:
"""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.
"""
materialized_view_ref = args.CONCEPTS.materialized_view.Parse()
return materialized_views.Describe(materialized_view_ref, view=args.view)

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 materialized views list command."""
import textwrap
from typing import Generator
from googlecloudsdk.api_lib.bigtable import materialized_views
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.calliope import parser_extensions
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.generated_clients.apis.bigtableadmin.v2 import bigtableadmin_v2_messages
@base.DefaultUniverseOnly
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class ListMaterializedViews(base.ListCommand):
"""List existing Bigtable materialized views."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To list all materialized views for an instance, run:
$ {command} --instance=my-instance-id
You may also specify what information to return by supplying the `--view` flag, such as:
$ {command} --instance=my-instance-id --view=schema
Currently, only the schema view is supported for this command. This is the default view, and it returns information about the schemas of your materialized views.
"""),
}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor) -> None:
"""Register flags for this command."""
arguments.AddInstanceResourceArg(parser, 'to list materialized views for')
arguments.AddViewOverMaterializedView(parser)
def Run(
self, args: parser_extensions.Namespace
) -> Generator[bigtableadmin_v2_messages.MaterializedView, None, None]:
"""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.
"""
instance_ref = args.CONCEPTS.instance.Parse()
return materialized_views.List(instance_ref, view=args.view)

View File

@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 materialized views update command."""
import textwrap
from typing import Optional
from apitools.base.py import exceptions
from googlecloudsdk.api_lib.bigtable import materialized_views
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.calliope import parser_extensions
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
from googlecloudsdk.generated_clients.apis.bigtableadmin.v2 import bigtableadmin_v2_messages
HttpError = exceptions.HttpError
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class UpdateMaterializedView(base.UpdateCommand):
"""Update a Bigtable materialized view."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To update a materialized view, run:
$ {command} my-materialized-view-id --instance=my-instance-id --deletion-protection=true
"""),
}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor) -> None:
arguments.AddMaterializedViewResourceArg(parser, 'to update')
arguments.ArgAdder(parser).AddDeletionProtection(True).AddAsync()
def _UpdateMaterializedView(
self,
materialized_view_ref: resources.Resource,
args: parser_extensions.Namespace,
) -> bigtableadmin_v2_messages.MaterializedView:
"""Updates a materialized view with the given arguments.
Args:
materialized_view_ref: A resource reference of the new materialized view.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
Updated materialized view resource object.
"""
return materialized_views.Update(
materialized_view_ref, args.deletion_protection
)
def Run(
self, args: parser_extensions.Namespace
) -> Optional[bigtableadmin_v2_messages.MaterializedView]:
"""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:
Updated resource.
"""
materialized_view_ref = args.CONCEPTS.materialized_view.Parse()
operation = self._UpdateMaterializedView(materialized_view_ref, args)
if not args.async_:
operation_ref = util.GetOperationRef(operation)
return util.AwaitMaterializedView(
operation_ref,
'Updating materialized view {0}'.format(materialized_view_ref.Name()),
)
log.UpdatedResource(
materialized_view_ref.Name(),
kind='materialized view',
is_async=args.async_,
)
return None

View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 memory layer command group for cloud bigtable."""
from googlecloudsdk.calliope import base
@base.UniverseCompatible
@base.Hidden # TODO: b/447212097 - Remove hidden once the feature is GA.
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class MemoryLayers(base.Group):
"""Manage Cloud Bigtable memory layers."""

View File

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 memory layer describe command."""
import textwrap
from googlecloudsdk.api_lib.bigtable import memory_layers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeMemoryLayer(base.DescribeCommand):
"""Describe a Bigtable memory layer."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To view a memory layer's description, run:
$ {command} my-cluster-id --instance=my-instance-id
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddClusterResourceArg(parser, 'of the memory layer to describe')
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.
"""
del self # Unused.
cluster_ref = args.CONCEPTS.cluster.Parse()
return memory_layers.Describe(cluster_ref)

View File

@@ -0,0 +1,107 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 memory layer update command."""
import textwrap
from googlecloudsdk.api_lib.bigtable import memory_layers
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.bigtable import arguments
from googlecloudsdk.core import log
def _UpdateMemoryLayer(cluster_ref, args):
"""Updates a cluster memory layer with the given arguments.
Args:
cluster_ref: A resource reference of the cluster to update.
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
Long running operation.
"""
if args.disable:
return memory_layers.Disable(cluster_ref)
else: # args.fixed_capacity must be true due to mutually exclusive group
storage_size_gib = args.fixed_capacity.get('storage-size-gib')
max_request_units_per_second = args.fixed_capacity.get(
'max-request-units-per-second'
)
return memory_layers.Update(
cluster_ref,
storage_size_gib=storage_size_gib,
max_request_units_per_second=max_request_units_per_second,
)
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateMemoryLayer(base.UpdateCommand):
"""Update a Bigtable memory layer."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To enable or resize a memory layer, run:
$ {command} my-cluster-id --instance=my-instance-id --fixed-capacity=storage-size-gib=16,max-request-units-per-second=200000
To disable a memory layer, run:
$ {command} my-cluster-id --instance=my-instance-id --disable
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddClusterResourceArg(parser, 'of the memory layer to update')
# We need one of these two mutually exclusive groups:
# --disable
# --fixed-capacity
update_group = parser.add_mutually_exclusive_group(required=True)
arguments.ArgAdder(update_group).AddMemoryLayerFixedCapacity()
arguments.ArgAdder(update_group).AddMemoryLayerDisable()
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:
Updated resource.
"""
del self # Unused.
cluster_ref = args.CONCEPTS.cluster.Parse()
operation = _UpdateMemoryLayer(cluster_ref, args)
if not args.async_:
operation_ref = util.GetOperationRef(operation)
return util.AwaitMemoryLayer(
operation_ref,
f'Updating memory layer for cluster [{cluster_ref.Name()}]',
)
log.UpdatedResource(
cluster_ref.RelativeName() + '/memoryLayer',
kind='memory layer',
is_async=args.async_,
)
return None

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 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 operations command group for Cloud Bigtable."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Operations(base.Group):
"""Manage Cloud Bigtable operations."""

View File

@@ -0,0 +1,20 @@
- help_text:
brief: |
Describe a Cloud Bigtable operation.
description: |
Describe a Cloud Bigtable operation.
examples: |
To view details for operation `OPERATION_ID`, run:
$ {command} OPERATION_ID
request:
collection: bigtableadmin.operations
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.operations:ModifyDescribeRequest
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.bigtable.resources:operation
help_text: |
Cloud Bigtable operation to describe.

View File

@@ -0,0 +1,125 @@
# -*- 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 operations list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.bigtable import util
from googlecloudsdk.calliope import actions
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):
return resources.REGISTRY.ParseRelativeName(
resource.name,
collection='bigtableadmin.operations').SelfLink()
def _TransformOperationName(resource):
"""Get operation name without project prefix."""
# operation name is in the format of:
# operations/projects/{}/instances/{}/.../locations/{}/operations/{}
operation_name = resource.get('name')
results = operation_name.split('/')
short_name = '/'.join(results[3:])
return short_name
@base.DefaultUniverseOnly
class ListOperations(base.ListCommand):
"""List Cloud Bigtable operations."""
detailed_help = {
'DESCRIPTION': textwrap.dedent("""\
List Cloud Bigtable operations.
"""),
'EXAMPLES': textwrap.dedent("""\
To list all operations for the default project, run:
$ {command}
To list all operations for instance INSTANCE_NAME, run:
$ {command} --instance=INSTANCE_NAME
To fail the command if any location is unreachable, run:
$ {command} --return-partial-success=false
"""),
}
@staticmethod
def Args(parser):
"""Register flags for this command."""
arguments.AddInstanceResourceArg(parser,
'to list operations for',
required=False)
base.Argument(
'--return-partial-success',
default=True,
help=textwrap.dedent("""\
If true, operations that are reachable are returned as normal, and
those that are unreachable are returned in the `unreachable` field of
the response. If false, the command will fail if any location is unreachable.
"""),
).AddToParser(parser)
parser.display_info.AddFormat("""
table(
name():label=NAME,
done,
metadata.firstof(startTime, requestTime, progress.start_time).date():label=START_TIME:sort=1:reverse,
metadata.firstof(endTime, finishTime, progress.end_time).date():label=END_TIME
)
""")
parser.display_info.AddUriFunc(_GetUriFunction)
parser.display_info.AddTransforms({'name': _TransformOperationName})
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()
ref_name = 'operations/' + resources.REGISTRY.Parse(
properties.VALUES.core.project.Get(required=True),
collection='bigtableadmin.projects').RelativeName()
if args.IsSpecified('instance'):
ref_name = ref_name + '/instances/' + args.instance
msg = (
util.GetAdminMessages()
.BigtableadminOperationsProjectsOperationsListRequest(
name=ref_name,
returnPartialSuccess=args.return_partial_success))
return list_pager.YieldFromList(
cli.operations_projects_operations,
msg,
field='operations',
batch_size_attribute=None)

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 Schema Bundles command group for Bigtable."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class SchemaBundles(base.Group):
"""Manage Bigtable schema bundles."""

View File

@@ -0,0 +1,35 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Add an IAM policy binding to a Bigtable schema bundle.
description: |
Add an IAM policy binding to a Bigtable schema bundle. 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 `222larabrown@gmail.com`
with schema bundle `my-schema-bundle` in instance `my-instance` and table `my-table`, run:
$ {command} my-schema-bundle --instance=`my-instance` --table=`my-table` --member=`user:222larabrown@gmail.com` --role=`roles/editor`
To add an IAM policy binding which expires at the end of the year 2025 for the role of
`roles/bigtable.admin` and the user `222larabrown@gmail.com` with schema bundle `my-schema-bundle`
in instance `my-instance` and table `my-table`, run:
$ {command} my-schema-bundle --instance=`my-instance` --table=`my-table` --member=`user:222larabrown@gmail.com` --role=`roles/bigtable.admin` --condition=`expression=request.time < timestamp("2021-01-01T00:00:00Z"),title=expires_end_of_2020,description=Expires at midnight on 2020-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.schemaBundles
arguments:
resource:
help_text: Bigtable schema bundle to add the IAM policy binding to.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:schema_bundle

View File

@@ -0,0 +1,36 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Create a new Bigtable schema bundle.
description: Create a new Bigtable schema bundle.
examples: |
To create a schema bundle `my-schema-bundle` in instance `my-instance` and table
`my-table`, using the descriptor file `my-descriptor-file.pb`:
$ {command} my-schema-bundle --instance=test-instance --table=test-table --proto-descriptors-file=my-descriptor-file.pb
request:
collection: bigtableadmin.projects.instances.tables.schemaBundles
method: create
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.schema_bundles:ModifyCreateSchemaBundleRequest
arguments:
resource:
help_text: Bigtable schema bundle to create.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:schema_bundle
params:
- arg_name: proto-descriptors-file
api_field: schemaBundle.protoSchema.protoDescriptors
required: true
help_text: |
Path of a file that contains a protobuf-serialized `google.protobuf.FileDescriptorSet` message. If specified, the schema bundle contains the protobuf schema.
To generate the file, install and run `protoc` with the following command:
protoc --proto_path=IMPORT_PATH --include_imports --descriptor_set_out=DESCRIPTOR_OUTPUT_LOCATION path/to/file.proto
where the --proto_path option specificies where to look for .proto files when resolving import directives (the current directory is used if you do not provide a value),
and the --descriptor_set_out option specifies where you want the generated FileDescriptorSet to be written.
async:
collection: bigtableadmin.operations

View File

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

View File

@@ -0,0 +1,23 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Describe a Bigtable schema bundle.
description: Describe a Bigtable schema bundle.
examples: |
To describe the schema bundle `my-schema-bundle` in instance `my-instance` and table
`my-table`:
$ {command} my-schema-bundle --instance=test-instance --table=test-table
request:
collection: bigtableadmin.projects.instances.tables.schemaBundles
method: get
response:
modify_response_hooks:
- googlecloudsdk.api_lib.bigtable.schema_bundles:PrintParsedProtoDescriptorsInGetResponse
arguments:
resource:
help_text: Bigtable schema bundle to describe.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:schema_bundle

View File

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

View File

@@ -0,0 +1,25 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: List all schema bundles of a Bigtable table.
description: List all schema bundles of a Bigtable table.
examples: |
To list the schema bundles in instance `my-instance` and table `my-table`:
$ {command} --instance=my-instance --table=my-table
To list all schema bundles that match the given filter:
$ {command} --instance=my-instance --table=my-table --filter="name=( `NAME` ... )"
request:
collection: bigtableadmin.projects.instances.tables.schemaBundles
method: list
response:
id_field: name
arguments:
resource:
help_text: Bigtable table for which to list all schema bundles.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:table

View File

@@ -0,0 +1,35 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Remove an IAM policy binding from a Bigtable schema bundle.
description: |
Remove an IAM policy binding from a Bigtable schema bundle. 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 `222larabrown@gmail.com`
with schema bundle `my-schema-bundle` in instance `my-instance` and table `my-table`, run:
$ {command} my-schema-bundle --instance=`my-instance` --table=`my-table` --member=`user:222larabrown@gmail.com` --role=`roles/editor`
To remove an IAM policy binding which expires at the end of the year 2025 for the role of
`roles/bigtable.admin` and the user `222larabrown@gmail.com` with schema bundle `my-schema-bundle`
in instance `my-instance` and table `my-table`, run:
$ {command} my-schema-bundle --instance=`my-instance` --table=`my-table` --member=`user:222larabrown@gmail.com` --role=`roles/bigtable.admin` --condition=`expression=request.time < timestamp("2021-01-01T00:00:00Z"),title=expires_end_of_2020,description=Expires at midnight on 2020-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.schemaBundles
arguments:
resource:
help_text: Bigtable schema bundle to remove the IAM policy binding from.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:schema_bundle

View File

@@ -0,0 +1,28 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Set an IAM policy on a Bigtable schema bundle.
description: |
Set an IAM policy on a Bigtable schema bundle.
examples: |
To set the IAM policy from file `my-policy` on the schema bundle `my-schema-bundle` in
instance `my-instance` and table `my-table`, run:
$ {command} my-schema-bundle --instance=`my-instance` --table=`my-table` my-policy
See https://cloud.google.com/iam/docs/managing-policies for more information.
request:
collection: bigtableadmin.projects.instances.tables.schemaBundles
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: Bigtable schema bundle to set the IAM policy on.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:schema_bundle
iam:
policy_version: 3

View File

@@ -0,0 +1,41 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Update an existing Bigtable schema bundle.
description: Update an existing Bigtable schema bundle.
examples: |
To update a schema bundle `my-schema-bundle` in instance `my-instance` and table
`my-table`, using the descriptor file `my-descriptor-file.pb`:
$ {command} my-schema-bundle --instance=my-instance --table=my-table --proto-descriptors-file=my-descriptor-file.pb
request:
collection: bigtableadmin.projects.instances.tables.schemaBundles
method: patch
modify_request_hooks:
- googlecloudsdk.api_lib.bigtable.schema_bundles:ModifyUpdateSchemaBundleRequest
arguments:
resource:
help_text: Bigtable schema bundle to update.
spec: !REF googlecloudsdk.command_lib.bigtable.resources:schema_bundle
params:
- arg_name: proto-descriptors-file
api_field: schemaBundle.protoSchema.protoDescriptors
required: true
help_text: |
Path of a file that contains a protobuf-serialized `google.protobuf.FileDescriptorSet` message. If specified, the schema bundle contains the protobuf schema.
To generate the file, install and run `protoc` with the following command:
protoc --proto_path=IMPORT_PATH --include_imports --descriptor_set_out=DESCRIPTOR_OUTPUT_LOCATION path/to/file.proto
where the --proto_path option specificies where to look for .proto files when resolving import directives (the current directory is used if you do not provide a value),
and the --descriptor_set_out option specifies where you want the generated FileDescriptorSet to be written.
- arg_name: ignore-warnings
type: bool
default: false
help_text: |
If true, backwards incompatible changes will be allowed.
async:
collection: bigtableadmin.operations