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,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,
)