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,44 @@
# -*- 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.
"""Commands for creating, reading, and manipulating VPN Gateways."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class VpnGateways(base.Group):
"""read and manipulate Highly Available VPN Gateways."""
# Placeholder to indicate that a detailed_help field exists and should
# be set outside the class definition.
detailed_help = None
category = base.NETWORKING_CATEGORY
VpnGateways.detailed_help = {
'DESCRIPTION': """
Read and manipulate highly available (HA) VPN gateways for Cloud VPN.
For more information about HA VPN gateways, see
[Cloud VPN overview](https://cloud.google.com//network-connectivity/docs/vpn/concepts/overview).
See also: [VPN Gateways API](https://cloud.google.com/compute/docs/reference/rest/v1/vpnGateways).
""",
}

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 Compute Engine vpn gateway 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 Compute Engine vpn gateway configurations."""

View File

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

View File

@@ -0,0 +1,221 @@
# -*- 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.
"""Command to create a new VPN gateway."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.vpn_gateways import vpn_gateways_utils
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import resource_manager_tags_utils
from googlecloudsdk.command_lib.compute.networks import flags as network_flags
from googlecloudsdk.command_lib.compute.vpn_gateways import flags
_VPN_GATEWAY_ARG = flags.GetVpnGatewayArgument()
_NETWORK_ARG = network_flags.NetworkArgumentForOtherResource("""\
A reference to a network to which the VPN gateway is attached.
""")
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.UniverseCompatible
class Create(base.CreateCommand):
"""Create a new Compute Engine Highly Available VPN gateway.
*{command}* creates a new Highly Available VPN gateway.
Highly Available VPN Gateway provides a means to create a VPN solution with a
higher availability SLA compared to Classic Target VPN Gateway.
Highly Available VPN gateways are simply referred to as VPN gateways in the
API documentation and gcloud commands.
A VPN Gateway can reference one or more VPN tunnels that connect it to
external VPN gateways or Cloud VPN Gateways.
"""
detailed_help = {'EXAMPLES': """\
To create a VPN gateway, run:
$ {command} my-vpn-gateway --region=us-central1 --network=default
"""}
_support_tagging_at_creation = False
@classmethod
def Args(cls, parser):
"""Set up arguments for this command."""
parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT)
_NETWORK_ARG.AddArgument(parser)
_VPN_GATEWAY_ARG.AddArgument(parser, operation_type='create')
if cls._support_tagging_at_creation:
parser.add_argument(
'--resource-manager-tags',
type=arg_parsers.ArgDict(),
metavar='KEY=VALUE',
help="""\
A comma-separated list of Resource Manager tags to apply to the VPN gateway.
""",
)
flags.GetDescriptionFlag().AddToParser(parser)
flags.GetInterconnectAttachmentsFlag().AddToParser(parser)
flags.GetStackType().AddToParser(parser)
flags.GetGatewayIpVersion().AddToParser(parser)
parser.display_info.AddCacheUpdater(flags.VpnGatewaysCompleter)
def _Run(self, args):
"""Issues the request to create a new VPN gateway."""
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
helper = vpn_gateways_utils.VpnGatewayHelper(holder)
messages = holder.client.messages
vpn_gateway_ref = _VPN_GATEWAY_ARG.ResolveAsResource(args, holder.resources)
network_ref = _NETWORK_ARG.ResolveAsResource(args, holder.resources)
params = None
vpn_interfaces_with_interconnect_attachments = None
if args.interconnect_attachments is not None:
vpn_interfaces_with_interconnect_attachments = (
self._mapInterconnectAttachments(
args,
holder.resources,
vpn_gateway_ref.region,
vpn_gateway_ref.project,
)
)
if self._support_tagging_at_creation:
if args.resource_manager_tags is not None:
params = self._CreateVpnGatewayParams(
messages, args.resource_manager_tags
)
vpn_gateway_to_insert = helper.GetVpnGatewayForInsert(
name=vpn_gateway_ref.Name(),
description=args.description,
network=network_ref.SelfLink(),
vpn_interfaces_with_interconnect_attachments=vpn_interfaces_with_interconnect_attachments,
stack_type=args.stack_type,
gateway_ip_version=args.gateway_ip_version,
support_tagging_at_creation=self._support_tagging_at_creation,
params=params,
)
operation_ref = helper.Create(vpn_gateway_ref, vpn_gateway_to_insert)
return helper.WaitForOperation(
vpn_gateway_ref, operation_ref, 'Creating VPN Gateway'
)
def _mapInterconnectAttachments(self, args, resources, region, project):
"""Returns dict {interfaceId : interconnectAttachmentUrl} based on initial order of names in input interconnectAttachmentName and region and project of VPN Gateway.
Args:
args: Namespace, argparse.Namespace.
resources: Generates resource references.
region: VPN Gateway region.
project: VPN Gateway project.
"""
attachment_refs = args.interconnect_attachments
if len(attachment_refs) == 1:
return {
0: flags.GetInterconnectAttachmentRef(
resources, attachment_refs[0], region, project
).SelfLink()
}
else:
return {
0: flags.GetInterconnectAttachmentRef(
resources, attachment_refs[0], region, project
).SelfLink(),
1: flags.GetInterconnectAttachmentRef(
resources, attachment_refs[1], region, project
).SelfLink(),
}
def _CreateVpnGatewayParams(self, messages, resource_manager_tags):
resource_manager_tags_map = (
resource_manager_tags_utils.GetResourceManagerTags(
resource_manager_tags
)
)
params = messages.VpnGatewayParams
additional_properties = [
params.ResourceManagerTagsValue.AdditionalProperty(key=key, value=value)
for key, value in sorted(resource_manager_tags_map.items())
]
return params(
resourceManagerTags=params.ResourceManagerTagsValue(
additionalProperties=additional_properties
)
)
def Run(self, args):
"""See base.CreateCommand."""
return self._Run(args)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a new Compute Engine Highly Available VPN gateway.
*{command}* creates a new Highly Available VPN gateway.
Highly Available VPN Gateway provides a means to create a VPN solution with a
higher availability SLA compared to Classic Target VPN Gateway.
Highly Available VPN gateways are simply referred to as VPN gateways in the
API documentation and gcloud commands.
A VPN Gateway can reference one or more VPN tunnels that connect it to
external VPN gateways or Cloud VPN Gateways.
"""
ROUTER_ARG = None
INSTANCE_ARG = None
_support_outer_vpn_ipv6 = True
_support_tagging_at_creation = False
@classmethod
def Args(cls, parser):
"""Set up arguments for this command."""
super(CreateBeta, cls).Args(parser)
def Run(self, args):
"""See base.CreateCommand."""
return self._Run(args)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(Create):
"""Create a new Compute Engine Highly Available VPN gateway.
*{command}* creates a new Highly Available VPN gateway.
Highly Available VPN Gateway provides a means to create a VPN solution with a
higher availability SLA compared to Classic Target VPN Gateway.
Highly Available VPN gateways are simply referred to as VPN gateways in the
API documentation and gcloud commands.
A VPN Gateway can reference one or more VPN tunnels that connect it to
external VPN gateways or Cloud VPN Gateways.
"""
ROUTER_ARG = None
INSTANCE_ARG = None
_support_tagging_at_creation = True
@classmethod
def Args(cls, parser):
"""Set up arguments for this command."""
super(CreateAlpha, cls).Args(parser)
def Run(self, args):
"""See base.CreateCommand."""
return self._Run(args)

View File

@@ -0,0 +1,83 @@
# -*- 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.
"""Command to delete VPN Gateways."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.api_lib.compute.operations import poller
from googlecloudsdk.api_lib.compute.vpn_gateways import vpn_gateways_utils
from googlecloudsdk.api_lib.util import waiter
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.vpn_gateways import flags
_VPN_GATEWAY_ARG = flags.GetVpnGatewayArgument(plural=True)
class DeleteBatchPoller(poller.BatchPoller):
def GetResult(self, operation_batch):
# For delete operations, once the operation status is DONE, there is
# nothing further to fetch.
return
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete Compute Engine Highly Available VPN Gateways.
*{command}* is used to delete one or more Compute Engine Highly
Available VPN Gateways. VPN Gateways can only be deleted when no VPN tunnels
refer to them.
Highly Available VPN Gateway provides a means to create a VPN solution with a
higher availability SLA compared to Classic Target VPN Gateway.
Highly Available VPN gateways are simply referred to as VPN gateways in the
API documentation and gcloud commands.
A VPN Gateway can reference one or more VPN tunnels that connect it to
external VPN gateways or Cloud VPN Gateways.
"""
detailed_help = {
'EXAMPLES':
"""\
To delete a VPN gateway, run:
$ {command} my-gateway --region=us-central1"""
}
@staticmethod
def Args(parser):
_VPN_GATEWAY_ARG.AddArgument(parser, operation_type='delete')
parser.display_info.AddCacheUpdater(flags.VpnGatewaysCompleter)
def Run(self, args):
"""Issues the request to delete a VPN Gateway."""
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
helper = vpn_gateways_utils.VpnGatewayHelper(holder)
client = holder.client.apitools_client
refs = _VPN_GATEWAY_ARG.ResolveAsResource(args, holder.resources)
utils.PromptForDeletion(refs)
operation_refs = [helper.Delete(ref) for ref in refs]
wait_message = 'Deleting VPN {}'.format(
('Gateways' if (len(operation_refs) > 1) else 'Gateway'))
operation_poller = DeleteBatchPoller(holder.client, client.vpnGateways)
return waiter.WaitFor(operation_poller,
poller.OperationBatch(operation_refs), wait_message)

View File

@@ -0,0 +1,66 @@
# -*- 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.
"""Command to describe VPN Gateways."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.vpn_gateways import vpn_gateways_utils
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.vpn_gateways import flags
_VPN_GATEWAY_ARG = flags.GetVpnGatewayArgument()
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Compute Engine Highly Available VPN Gateway.
*{command}* is used to display all data associated with a Compute Engine
Highly Available VPN Gateway in a project.
Highly Available VPN Gateway provides a means to create a VPN solution with a
higher availability SLA compared to Classic Target VPN Gateway.
Highly Available VPN gateways are simply referred to as VPN gateways in the
API documentation and gcloud commands.
A VPN Gateway can reference one or more VPN tunnels that connect it to
external VPN gateways or Cloud VPN Gateways.
"""
detailed_help = {
'EXAMPLES':
"""\
To describe a VPN gateway, run:
$ {command} my-gateway --region=us-central1"""
}
@staticmethod
def Args(parser):
_VPN_GATEWAY_ARG.AddArgument(parser, operation_type='describe')
def Run(self, args):
"""Issues the request to describe a VPN Gateway."""
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
helper = vpn_gateways_utils.VpnGatewayHelper(holder)
ref = _VPN_GATEWAY_ARG.ResolveAsResource(
args,
holder.resources,
scope_lister=compute_flags.GetDefaultScopeLister(holder.client))
return helper.Describe(ref)

View File

@@ -0,0 +1,66 @@
# -*- 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.
"""Command for getting the status of Compute Engine VPN Gateways."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.vpn_gateways import flags
class Describe(base.DescribeCommand):
"""Get status of a Compute Engine Highly Available VPN Gateway.
*{command}* is used to display high availability configuration status for the
Cloud VPN gateway, the command will show you the high availability
configuration status for VPN tunnels associated with each peer gateway
to which the Cloud VPN gateway is connected; the peer gateway could be either
a Cloud VPN gateway or an external VPN gateway.
"""
detailed_help = {
'EXAMPLES':
"""\
To get status of a VPN gateway, run:
$ {command} my-gateway --region=us-central1"""
}
VPN_GATEWAY_ARG = None
@staticmethod
def Args(parser):
Describe.VPN_GATEWAY_ARG = flags.GetVpnGatewayArgument()
Describe.VPN_GATEWAY_ARG.AddArgument(parser, operation_type='describe')
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
gateway_ref = Describe.VPN_GATEWAY_ARG.ResolveAsResource(
args,
holder.resources,
scope_lister=compute_flags.GetDefaultScopeLister(client))
request = client.messages.ComputeVpnGatewaysGetStatusRequest(
**gateway_ref.AsDict())
return client.MakeRequests([(client.apitools_client.vpnGateways,
'GetStatus', request)])[0]

View File

@@ -0,0 +1,67 @@
# -*- 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.
"""Command to list VPN Gateways."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import filter_rewrite
from googlecloudsdk.api_lib.compute import lister
from googlecloudsdk.api_lib.compute.vpn_gateways import vpn_gateways_utils
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.vpn_gateways import flags
from googlecloudsdk.core import properties
from googlecloudsdk.core.resource import resource_projection_spec
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.UniverseCompatible
class List(base.ListCommand):
"""List Compute Engine Highly Available VPN Gateways."""
detailed_help = {
'EXAMPLES':
"""\
To list all VPN gateways, run:
$ {command} --region=us-central1"""
}
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT)
lister.AddRegionsArg(parser)
def Run(self, args):
"""Issues the request to list all VPN Gateways."""
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
helper = vpn_gateways_utils.VpnGatewayHelper(holder)
project = properties.VALUES.core.project.GetOrFail()
display_info = args.GetDisplayInfo()
defaults = resource_projection_spec.ProjectionSpec(
symbols=display_info.transforms, aliases=display_info.aliases)
args.filter, filter_expr = filter_rewrite.Rewriter().Rewrite(
args.filter, defaults=defaults)
return helper.List(
project=project, filter_expr=filter_expr, regions=args.regions
)
List.detailed_help = base_classes.GetRegionalListerHelp(
'Highly Available VPN Gateways')

View File

@@ -0,0 +1,111 @@
# -*- 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.
"""Command to update labels for VPN gateways."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.vpn_gateways import vpn_gateways_utils
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions as calliope_exceptions
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.vpn_gateways import flags
from googlecloudsdk.command_lib.util.args import labels_util
_VPN_GATEWAY_ARG = flags.GetVpnGatewayArgument()
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
r"""Update a Compute Engine Highly Available VPN gateway.
*{command}* updates labels for a Compute Engine Highly Available VPN
gateway.
For example:
$ {command} example-gateway --region us-central1 \
--update-labels=k0=value1,k1=value2 --remove-labels=k3
will add/update labels ``k0'' and ``k1'' and remove labels with key ``k3''.
Labels can be used to identify the VPN gateway and to filter them as in
$ {parent_command} list --filter='labels.k1:value2'
To list existing labels
$ {parent_command} describe example-gateway --format="default(labels)"
"""
detailed_help = {
'EXAMPLES':
"""\
To update labels for a VPN gateway, run:
$ {command} my-gateway --region=us-central1 \
--update-labels=k0=value1,k1=value2"""
}
@classmethod
def Args(cls, parser):
"""Adds arguments to the supplied parser.
Args:
parser: The argparse parser to add arguments to.
"""
_VPN_GATEWAY_ARG.AddArgument(parser, operation_type='update')
labels_util.AddUpdateLabelsFlags(parser)
def Run(self, args):
"""Issues API requests to update a VPN Gateway.
Args:
args: argparse.Namespace, The arguments received by this command.
Returns:
[protorpc.messages.Message], A list of responses returned
by the compute API.
"""
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
messages = holder.client.messages
helper = vpn_gateways_utils.VpnGatewayHelper(holder)
vpn_gateway_ref = _VPN_GATEWAY_ARG.ResolveAsResource(
args,
holder.resources,
scope_lister=compute_flags.GetDefaultScopeLister(holder.client))
labels_diff = labels_util.Diff.FromUpdateArgs(args)
if not labels_diff.MayHaveUpdates():
raise calliope_exceptions.RequiredArgumentException(
'LABELS', 'At least one of --update-labels or '
'--remove-labels must be specified.')
vpn_gateway = helper.Describe(vpn_gateway_ref)
labels_update = labels_diff.Apply(
messages.RegionSetLabelsRequest.LabelsValue, vpn_gateway.labels)
if not labels_update.needs_update:
return vpn_gateway
operation_ref = helper.SetLabels(
vpn_gateway_ref, vpn_gateway.labelFingerprint, labels_update.labels)
return helper.WaitForOperation(
vpn_gateway_ref, operation_ref,
'Updating labels of VPN gateway [{0}]'.format(vpn_gateway_ref.Name()))