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,43 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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 reading and manipulating target TCP proxies."""
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 TargetTCPProxies(base.Group):
"""List, create, and delete target TCP proxies."""
TargetTCPProxies.category = base.NETWORKING_CATEGORY
TargetTCPProxies.detailed_help = {
'DESCRIPTION': """
List, create, and delete target TCP proxies for proxy Network Load
Balancers.
For more information about target TCP proxies, see the
[proxy Network Load Balancer documentation](https://cloud.google.com/load-balancing/docs/tcp/).
See also: [Target TCP proxies API](https://cloud.google.com/compute/docs/reference/rest/v1/targetTcpProxies).
""",
}

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 target tcp proxy 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 target tcp proxy configurations."""

View File

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

View File

@@ -0,0 +1,148 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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 creating target TCP proxies."""
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 target_proxies_utils
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import scope as compute_scope
from googlecloudsdk.command_lib.compute.backend_services import (
flags as backend_service_flags)
from googlecloudsdk.command_lib.compute.target_tcp_proxies import flags
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a target TCP proxy."""
BACKEND_SERVICE_ARG = None
TARGET_TCP_PROXY_ARG = None
@classmethod
def Args(cls, parser):
target_proxies_utils.AddProxyHeaderRelatedCreateArgs(parser)
cls.BACKEND_SERVICE_ARG = (
backend_service_flags.BackendServiceArgumentForTargetTcpProxy(
allow_regional=True
)
)
cls.BACKEND_SERVICE_ARG.AddArgument(parser)
cls.TARGET_TCP_PROXY_ARG = flags.TargetTcpProxyArgument(allow_regional=True)
cls.TARGET_TCP_PROXY_ARG.AddArgument(parser, operation_type='create')
flags.AddProxyBind(parser)
parser.add_argument(
'--description',
help='An optional, textual description for the target TCP proxy.')
parser.display_info.AddCacheUpdater(flags.TargetTcpProxiesCompleter)
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
if not (args.backend_service_region or args.global_backend_service):
# infer scope from proxy if not explicitly specified
args.backend_service_region = getattr(args, 'region', None)
args.global_backend_service = getattr(args, 'global', None)
backend_service_ref = self.BACKEND_SERVICE_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
target_tcp_proxy_ref = self.TARGET_TCP_PROXY_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
messages = holder.client.messages
if args.proxy_header:
proxy_header = messages.TargetTcpProxy.ProxyHeaderValueValuesEnum(
args.proxy_header)
else:
proxy_header = (messages.TargetTcpProxy.ProxyHeaderValueValuesEnum.NONE)
target_tcp_proxy = messages.TargetTcpProxy(
description=args.description,
name=target_tcp_proxy_ref.Name(),
proxyHeader=proxy_header,
service=backend_service_ref.SelfLink())
if args.proxy_bind is not None:
target_tcp_proxy.proxyBind = args.proxy_bind
return self._MakeRequest(target_tcp_proxy_ref, target_tcp_proxy, holder)
def _MakeRequest(self, target_tcp_proxy_ref, target_tcp_proxy, holder):
if target_tcp_proxy_ref.Collection() == 'compute.regionTargetTcpProxies':
return self._MakeRegionalRequest(target_tcp_proxy_ref, target_tcp_proxy,
holder)
return self._MakeGlobalRequest(target_tcp_proxy_ref, target_tcp_proxy,
holder)
def _MakeRegionalRequest(self, target_tcp_proxy_ref, target_tcp_proxy,
holder):
client = holder.client.apitools_client
messages = holder.client.messages
request = messages.ComputeRegionTargetTcpProxiesInsertRequest(
project=target_tcp_proxy_ref.project,
targetTcpProxy=target_tcp_proxy,
region=target_tcp_proxy_ref.region)
errors = []
resources = holder.client.MakeRequests(
[(client.regionTargetTcpProxies, 'Insert', request)], errors)
if errors:
utils.RaiseToolException(errors)
return resources
def _MakeGlobalRequest(self, target_tcp_proxy_ref, target_tcp_proxy, holder):
client = holder.client.apitools_client
messages = holder.client.messages
request = messages.ComputeTargetTcpProxiesInsertRequest(
project=target_tcp_proxy_ref.project, targetTcpProxy=target_tcp_proxy)
errors = []
resources = holder.client.MakeRequests(
[(client.targetTcpProxies, 'Insert', request)], errors)
if errors:
utils.RaiseToolException(errors)
return resources
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class CreateAlphaBeta(Create):
pass
Create.detailed_help = {
'brief':
'Create a target TCP proxy',
'DESCRIPTION':
"""
*{command}* is used to create target TCP proxies. A target
TCP proxy is referenced by one or more forwarding rules which
define which packets the proxy is responsible for routing. The
target TCP proxy points to a backend service which handle the
actual requests.
""",
}

View File

@@ -0,0 +1,86 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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 deleting target TCP proxies."""
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.calliope import base
from googlecloudsdk.command_lib.compute import scope as compute_scope
from googlecloudsdk.command_lib.compute.target_tcp_proxies import flags
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete target TCP proxy."""
TARGET_TCP_PROXY_ARG = None
@classmethod
def Args(cls, parser):
cls.TARGET_TCP_PROXY_ARG = flags.TargetTcpProxyArgument(
plural=True, allow_regional=True
)
cls.TARGET_TCP_PROXY_ARG.AddArgument(parser, operation_type='delete')
parser.display_info.AddCacheUpdater(flags.TargetTcpProxiesCompleter)
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
refs = self.TARGET_TCP_PROXY_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
utils.PromptForDeletion(refs)
client = holder.client.apitools_client
messages = holder.client.messages
requests = []
for ref in refs:
if ref.Collection() == 'compute.regionTargetTcpProxies':
requests.append((client.regionTargetTcpProxies, 'Delete',
messages.ComputeRegionTargetTcpProxiesDeleteRequest(
project=ref.project,
region=ref.region,
targetTcpProxy=ref.Name())))
else:
requests.append((client.targetTcpProxies, 'Delete',
messages.ComputeTargetTcpProxiesDeleteRequest(
project=ref.project, targetTcpProxy=ref.Name())))
errors = []
resources = holder.client.MakeRequests(requests, errors)
if errors:
utils.RaiseToolException(errors)
return resources
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class DeleteAlphaBeta(Delete):
pass
Delete.detailed_help = {
'brief':
'Delete target TCP proxies',
'DESCRIPTION':
"""\
*{command}* deletes one or more target TCP proxies.
""",
}

View File

@@ -0,0 +1,95 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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 describing target TCP proxies."""
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.calliope import base
from googlecloudsdk.command_lib.compute import scope as compute_scope
from googlecloudsdk.command_lib.compute.target_tcp_proxies import flags
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Display detailed information about a target TCP proxy."""
TARGET_TCP_PROXY_ARG = None
@classmethod
def Args(cls, parser):
cls.TARGET_TCP_PROXY_ARG = flags.TargetTcpProxyArgument(allow_regional=True)
cls.TARGET_TCP_PROXY_ARG.AddArgument(parser, operation_type='describe')
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
ref = self.TARGET_TCP_PROXY_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
return self._MakeRequest(ref, holder)
def _MakeRequest(self, ref, holder):
if ref.Collection() == 'compute.regionTargetTcpProxies':
return self._MakeRegionalRequest(ref, holder)
return self._MakeGlobalRequest(ref, holder)
def _MakeRegionalRequest(self, ref, holder):
client = holder.client.apitools_client
messages = holder.client.messages
request = messages.ComputeRegionTargetTcpProxiesGetRequest(
project=ref.project, targetTcpProxy=ref.Name(), region=ref.region)
errors = []
resources = holder.client.MakeRequests(
[(client.regionTargetTcpProxies, 'Get', request)], errors)
if errors:
utils.RaiseToolException(errors)
return resources[0]
def _MakeGlobalRequest(self, ref, holder):
client = holder.client.apitools_client
messages = holder.client.messages
request = messages.ComputeTargetTcpProxiesGetRequest(
project=ref.project, targetTcpProxy=ref.Name())
errors = []
resources = holder.client.MakeRequests(
[(client.targetTcpProxies, 'Get', request)], errors)
if errors:
utils.RaiseToolException(errors)
return resources[0]
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class DescribeAlphaBeta(Describe):
pass
Describe.detailed_help = {
'brief':
'Display detailed information about a target TCP proxy',
'DESCRIPTION':
"""\
*{command}* displays all data associated with a target TCP proxy
in a project.
""",
}

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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 listing target TCP proxies."""
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 lister
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List target TCP proxies."""
@staticmethod
def Args(parser):
parser.display_info.AddFormat("""
table(
name,
region.basename(),
proxyHeader,
service.basename()
)
""")
lister.AddMultiScopeListerFlags(parser, regional=True, global_=True)
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
request_data = lister.ParseMultiScopeFlags(args, holder.resources)
list_implementation = lister.MultiScopeLister(
client,
regional_service=client.apitools_client.regionTargetTcpProxies,
global_service=client.apitools_client.targetTcpProxies,
aggregation_service=client.apitools_client.targetTcpProxies)
return lister.Invoke(request_data, list_implementation)
List.detailed_help = base_classes.GetGlobalRegionalListerHelp(
'target TCP proxies')

View File

@@ -0,0 +1,106 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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 updating target TCP proxies."""
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 target_proxies_utils
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.compute.backend_services import (
flags as backend_service_flags)
from googlecloudsdk.command_lib.compute.target_tcp_proxies import flags
class Update(base.SilentCommand):
"""Update a target TCP proxy."""
BACKEND_SERVICE_ARG = None
TARGET_TCP_PROXY_ARG = None
@classmethod
def Args(cls, parser):
target_proxies_utils.AddProxyHeaderRelatedUpdateArgs(parser)
cls.BACKEND_SERVICE_ARG = (
backend_service_flags.BackendServiceArgumentForTargetTcpProxy(
required=False))
cls.BACKEND_SERVICE_ARG.AddArgument(parser)
cls.TARGET_TCP_PROXY_ARG = flags.TargetTcpProxyArgument()
cls.TARGET_TCP_PROXY_ARG.AddArgument(parser, operation_type='update')
def Run(self, args):
if not (args.proxy_header or args.backend_service):
raise exceptions.OneOfArgumentsRequiredException(
['--backend-service', '--proxy-header'],
'You must specify at least one of [--backend-service] or '
'[--proxy-header].')
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
requests = []
target_tcp_proxy_ref = self.TARGET_TCP_PROXY_ARG.ResolveAsResource(
args, holder.resources)
client = holder.client.apitools_client
messages = holder.client.messages
if args.backend_service:
backend_service_ref = self.BACKEND_SERVICE_ARG.ResolveAsResource(
args, holder.resources)
requests.append(
(client.targetTcpProxies,
'SetBackendService',
messages.ComputeTargetTcpProxiesSetBackendServiceRequest(
project=target_tcp_proxy_ref.project,
targetTcpProxy=target_tcp_proxy_ref.Name(),
targetTcpProxiesSetBackendServiceRequest=(
messages.TargetTcpProxiesSetBackendServiceRequest(
service=backend_service_ref.SelfLink())))))
if args.proxy_header:
proxy_header = (messages.TargetTcpProxiesSetProxyHeaderRequest.
ProxyHeaderValueValuesEnum(args.proxy_header))
requests.append(
(client.targetTcpProxies,
'SetProxyHeader',
messages.ComputeTargetTcpProxiesSetProxyHeaderRequest(
project=target_tcp_proxy_ref.project,
targetTcpProxy=target_tcp_proxy_ref.Name(),
targetTcpProxiesSetProxyHeaderRequest=(
messages.TargetTcpProxiesSetProxyHeaderRequest(
proxyHeader=proxy_header)))))
errors = []
resources = holder.client.MakeRequests(requests, errors)
if errors:
utils.RaiseToolException(errors)
return resources
Update.detailed_help = {
'brief': 'Update a target TCP proxy',
'DESCRIPTION': """\
*{command}* is used to change the backend service or proxy header
of existing target TCP proxies. A target TCP proxy is referenced
by one or more forwarding rules which define which packets the
proxy is responsible for routing. The target TCP proxy in turn
points to a backend service which will handle the requests. """,
}