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,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 gRPC 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 TargetGrpcProxies(base.Group):
"""List, create, and delete target gRPC proxies."""
TargetGrpcProxies.category = base.NETWORKING_CATEGORY
TargetGrpcProxies.detailed_help = {
'brief': 'Manage Compute Engine target gRPC proxy resources.',
'DESCRIPTION': 'List, create, and delete target gRPC proxies.',
}

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 grpc 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 grpc 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 grpc proxy.
description: |
*{command}* exports the configuration for a Compute Engine target grpc proxy.
Target grpc 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 grpc 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 grpc proxy, run:
$ {command} my-target-grpc-proxy
To export the configuration for a target grpc proxy to a file, run:
$ {command} my-target-grpc-proxy --path=/path/to/dir/
To export the configuration for a target grpc proxy in Terraform
HCL format, run:
$ {command} my-target-grpc-proxy --resource-format=terraform
To export the configurations for all target grpc proxies within a
project, run:
$ {command} --all
arguments:
resource:
help_text: Target grpc proxy to export the configuration for.
spec: !REF googlecloudsdk.command_lib.compute.resources:target_grpc_proxy

View File

@@ -0,0 +1,94 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 gRPC 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.calliope import base
from googlecloudsdk.command_lib.compute import scope as compute_scope
from googlecloudsdk.command_lib.compute.target_grpc_proxies import flags
from googlecloudsdk.command_lib.compute.target_grpc_proxies import target_grpc_proxies_utils
from googlecloudsdk.command_lib.compute.url_maps import flags as url_map_flags
def _DetailedHelp():
return {
'brief':
'Create a target gRPC proxy.',
'DESCRIPTION':
"""\
*{command}* is used to create target gRPC proxies. A target gRPC proxy is
a component of load balancers intended for load balancing gRPC traffic.
Global forwarding rules reference a target gRPC proxy. The Target gRPC
proxy references a URL map which specifies how traffic routes to gRPC
backend services.
""",
'EXAMPLES':
"""\
If there is an already-created URL map with the name URL_MAP, create a
global target gRPC proxy pointing to this map by running:
$ {command} PROXY_NAME --url-map=URL_MAP
To create a proxy with a textual description, run:
$ {command} PROXY_NAME --url-map=URL_MAP --description="default proxy"
""",
}
class Create(base.CreateCommand):
"""Create a target gRPC proxy."""
URL_MAP_ARG = None
TARGET_GRPC_PROXY_ARG = None
detailed_help = _DetailedHelp()
@classmethod
def Args(cls, parser):
cls.TARGET_GRPC_PROXY_ARG = flags.TargetGrpcProxyArgument()
cls.TARGET_GRPC_PROXY_ARG.AddArgument(parser, operation_type='create')
cls.URL_MAP_ARG = url_map_flags.UrlMapArgumentForTargetProxy(
proxy_type='gRPC')
cls.URL_MAP_ARG.AddArgument(parser)
parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT)
parser.display_info.AddCacheUpdater(flags.TargetGrpcProxiesCompleter)
flags.AddDescription(parser)
flags.AddValidateForProxyless(parser)
def Run(self, args):
"""Issue a Target gRPC Proxy Insert request."""
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
target_grpc_proxy_ref = self.TARGET_GRPC_PROXY_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
url_map_ref = target_grpc_proxies_utils.ResolveTargetGrpcProxyUrlMap(
args, self.URL_MAP_ARG, target_grpc_proxy_ref, holder.resources)
client = holder.client
target_grpc_proxy = client.messages.TargetGrpcProxy(
description=args.description,
name=target_grpc_proxy_ref.Name(),
urlMap=url_map_ref.SelfLink(),
validateForProxyless=args.validate_for_proxyless)
request = client.messages.ComputeTargetGrpcProxiesInsertRequest(
project=target_grpc_proxy_ref.project,
targetGrpcProxy=target_grpc_proxy)
collection = client.apitools_client.targetGrpcProxies
return client.MakeRequests([(collection, 'Insert', request)])

View File

@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 gRPC 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_grpc_proxies import flags
def _DetailedHelp():
return {
'brief':
'Delete one or more target gRPC proxy.',
'DESCRIPTION':
"""\
*{command}* deletes one or more target gRPC proxies.
""",
'EXAMPLES':
"""\
Delete a global target gRPC proxy by running:
$ {command} PROXY_NAME
""",
}
def _Run(holder, target_grpc_proxy_refs):
"""Issues requests necessary to delete Target gRPC Proxies."""
client = holder.client
utils.PromptForDeletion(target_grpc_proxy_refs)
requests = []
for target_grpc_proxy_ref in target_grpc_proxy_refs:
requests.append((client.apitools_client.targetGrpcProxies, 'Delete',
client.messages.ComputeTargetGrpcProxiesDeleteRequest(
**target_grpc_proxy_ref.AsDict())))
return client.MakeRequests(requests)
class Delete(base.DeleteCommand):
"""Delete one or more target gRPC proxies."""
TARGET_GRPC_PROXY_ARG = None
detailed_help = _DetailedHelp()
@classmethod
def Args(cls, parser):
cls.TARGET_GRPC_PROXY_ARG = flags.TargetGrpcProxyArgument(plural=True)
cls.TARGET_GRPC_PROXY_ARG.AddArgument(parser, operation_type='delete')
parser.display_info.AddCacheUpdater(flags.TargetGrpcProxiesCompleter)
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
target_grpc_proxy_refs = self.TARGET_GRPC_PROXY_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
return _Run(holder, target_grpc_proxy_refs)

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 gRPC 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.calliope import base
from googlecloudsdk.command_lib.compute import scope as compute_scope
from googlecloudsdk.command_lib.compute.target_grpc_proxies import flags
def _DetailedHelp():
return {
'brief':
'Display detailed information about a target gRPC proxy.',
'DESCRIPTION':
"""\
*{command}* displays all data associated with a Compute Engine
target gRPC proxy.
""",
'EXAMPLES':
"""\
To describe a global target gRPC proxy, run:
$ {command} PROXY_NAME
""",
}
def _Run(holder, target_grpc_proxy_ref):
"""Issues requests necessary to describe Target gRPC Proxies."""
client = holder.client
request = client.messages.ComputeTargetGrpcProxiesGetRequest(
**target_grpc_proxy_ref.AsDict())
collection = client.apitools_client.targetGrpcProxies
return client.MakeRequests([(collection, 'Get', request)])[0]
class Describe(base.DescribeCommand):
"""Display detailed information about a target gRPC proxy."""
TARGET_GRPC_PROXY_ARG = None
detailed_help = _DetailedHelp()
@classmethod
def Args(cls, parser):
cls.TARGET_GRPC_PROXY_ARG = flags.TargetGrpcProxyArgument()
cls.TARGET_GRPC_PROXY_ARG.AddArgument(parser, operation_type='describe')
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
target_grpc_proxy_ref = self.TARGET_GRPC_PROXY_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
return _Run(holder, target_grpc_proxy_ref)

View File

@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Export ssl policies command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import sys
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import scope as compute_scope
from googlecloudsdk.command_lib.compute.target_grpc_proxies import flags
from googlecloudsdk.command_lib.export import util as export_util
from googlecloudsdk.core.util import files
def _Describe(holder, target_grpc_proxy_ref):
client = holder.client
request = client.messages.ComputeTargetGrpcProxiesGetRequest(
**target_grpc_proxy_ref.AsDict())
collection = client.apitools_client.targetGrpcProxies
return client.MakeRequests([(collection, 'Get', request)])[0]
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Export(base.Command):
"""Export a target gRPC proxy."""
TARGET_GRPC_PROXY_ARG = None
@classmethod
def GetApiVersion(cls):
"""Returns the API version based on the release track."""
if cls.ReleaseTrack() == base.ReleaseTrack.ALPHA:
return 'alpha'
elif cls.ReleaseTrack() == base.ReleaseTrack.BETA:
return 'beta'
return 'v1'
@classmethod
def GetSchemaPath(cls, for_help=False):
"""Returns the resource schema path."""
return export_util.GetSchemaPath(
'compute', cls.GetApiVersion(), 'TargetGrpcProxy', for_help=for_help)
@classmethod
def Args(cls, parser):
cls.TARGET_GRPC_PROXY_ARG = flags.TargetGrpcProxyArgument()
cls.TARGET_GRPC_PROXY_ARG.AddArgument(parser, operation_type='export')
export_util.AddExportFlags(parser, cls.GetSchemaPath(for_help=True))
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
target_grpc_proxy_ref = self.TARGET_GRPC_PROXY_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
target_grpc_proxy = _Describe(holder, target_grpc_proxy_ref)
if args.destination:
with files.FileWriter(args.destination) as stream:
export_util.Export(
message=target_grpc_proxy,
stream=stream,
schema_path=self.GetSchemaPath())
else:
export_util.Export(
message=target_grpc_proxy,
stream=sys.stdout,
schema_path=self.GetSchemaPath())

View File

@@ -0,0 +1,124 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Import target command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from apitools.base.py import exceptions as apitools_exceptions
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import exceptions as compute_exceptions
from googlecloudsdk.command_lib.compute import scope as compute_scope
from googlecloudsdk.command_lib.compute.target_grpc_proxies import flags
from googlecloudsdk.command_lib.export import util as export_util
from googlecloudsdk.core import yaml_validator
from googlecloudsdk.core.console import console_io
def _Describe(holder, target_grpc_proxy_ref):
client = holder.client
request = client.messages.ComputeTargetGrpcProxiesGetRequest(
**target_grpc_proxy_ref.AsDict())
collection = client.apitools_client.targetGrpcProxies
return client.MakeRequests([(collection, 'Get', request)])[0]
def _Create(holder, target_grpc_proxy, target_grpc_proxy_ref):
client = holder.client
request = client.messages.ComputeTargetGrpcProxiesInsertRequest(
project=target_grpc_proxy_ref.project, targetGrpcProxy=target_grpc_proxy)
collection = client.apitools_client.targetGrpcProxies
return client.MakeRequests([(collection, 'Insert', request)])[0]
def _Patch(client, target_grpc_proxy_ref, target_grpc_proxy):
"""Make target gRPC proxy patch request."""
request = client.messages.ComputeTargetGrpcProxiesPatchRequest(
project=target_grpc_proxy_ref.project,
targetGrpcProxy=target_grpc_proxy_ref.Name(),
targetGrpcProxyResource=target_grpc_proxy)
collection = client.apitools_client.targetGrpcProxies
return client.MakeRequests([(collection, 'Patch', request)])[0]
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Import(base.UpdateCommand):
"""Import a target gRPC proxy."""
TARGET_GRPC_PROXY_ARG = None
@classmethod
def GetApiVersion(cls):
"""Returns the API version based on the release track."""
if cls.ReleaseTrack() == base.ReleaseTrack.ALPHA:
return 'alpha'
elif cls.ReleaseTrack() == base.ReleaseTrack.BETA:
return 'beta'
return 'v1'
@classmethod
def GetSchemaPath(cls, for_help=False):
"""Returns the resource schema path."""
return export_util.GetSchemaPath(
'compute', cls.GetApiVersion(), 'TargetGrpcProxy', for_help=for_help)
@classmethod
def Args(cls, parser):
cls.TARGET_GRPC_PROXY_ARG = flags.TargetGrpcProxyArgument()
cls.TARGET_GRPC_PROXY_ARG.AddArgument(parser, operation_type='import')
export_util.AddImportFlags(parser, cls.GetSchemaPath(for_help=True))
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
target_grpc_proxy_ref = self.TARGET_GRPC_PROXY_ARG.ResolveAsResource(
args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
data = console_io.ReadFromFileOrStdin(args.source or '-', binary=False)
try:
target_grpc_proxy = export_util.Import(
message_type=client.messages.TargetGrpcProxy,
stream=data,
schema_path=self.GetSchemaPath())
except yaml_validator.ValidationError as e:
raise compute_exceptions.ValidationError(str(e))
# Get existing target gRPC proxy.
try:
target_grpc_proxy_old = _Describe(holder, target_grpc_proxy_ref)
except apitools_exceptions.HttpError as error:
if error.status_code != 404:
raise error
# Target gRPC proxy does not exit, create a new one.
return _Create(holder, target_grpc_proxy, target_grpc_proxy_ref)
if target_grpc_proxy_old == target_grpc_proxy:
return
console_io.PromptContinue(
message=('Target Grpc Proxy [{0}] will be overwritten.').format(
target_grpc_proxy_ref.Name()),
cancel_on_no=True)
# Populate id and fingerprint fields. These two fields are manually
# removed from the schema files.
target_grpc_proxy.id = target_grpc_proxy_old.id
target_grpc_proxy.fingerprint = target_grpc_proxy_old.fingerprint
return _Patch(client, target_grpc_proxy_ref, target_grpc_proxy)

View File

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 gRPC 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
from googlecloudsdk.command_lib.compute.target_grpc_proxies import flags
def _Args(parser):
parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT)
lister.AddBaseListerArgs(parser)
parser.display_info.AddCacheUpdater(flags.TargetGrpcProxiesCompleter)
def _Run(args, holder):
"""Issues requests necessary to list Target gRPC Proxies."""
client = holder.client
request_data = lister.ParseNamesAndRegexpFlags(args, holder.resources)
list_implementation = lister.GlobalLister(
client, client.apitools_client.targetGrpcProxies)
return lister.Invoke(request_data, list_implementation)
class List(base.ListCommand):
"""List target gRPC proxies."""
detailed_help = base_classes.GetGlobalListerHelp('target gRPC proxies')
@classmethod
def Args(cls, parser):
_Args(parser)
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
return _Run(args, holder)