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,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The operations command group for the Cloud API Gateways CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Operations(base.Group):
"""Manage operations for Cloud API Gateways.
Commands for managing operations for Google API Gateways.
"""

View File

@@ -0,0 +1,71 @@
# -*- 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.
"""`gcloud api-gateway operations cancel` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.api_gateway import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.api_gateway import operations_util
from googlecloudsdk.command_lib.api_gateway import resource_args
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Cancel(base.Command):
"""Cancel a Cloud API Gateway operation."""
detailed_help = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
"""\
To cancel a Cloud API Gateway operation named ``NAME'' in the ``us-central1''
region, run:
$ {command} NAME --location=us-central1
To cancel a Cloud API Gateway operation with a resource name of ``RESOURCE'',
run:
$ {command} RESOURCE
"""
}
@staticmethod
def Args(parser):
resource_args.AddOperationResourceArgs(parser, 'cancel')
def Run(self, args):
client = operations.OperationsClient()
operation_ref = args.CONCEPTS.operation.Parse()
console_io.PromptContinue(
message='The operation [{}] will be cancelled.'.format(
operation_ref.RelativeName()),
throw_if_unattended=True,
cancel_on_no=True)
client.Cancel(operation_ref)
operations_util.PrintOperationResultWithWaitEpilogue(
operation_ref,
'Operation cancellation requested')

View File

@@ -0,0 +1,60 @@
# -*- 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.
"""`gcloud api-gateway operations describe` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.api_gateway import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.api_gateway import resource_args
from googlecloudsdk.core import exceptions
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Describe(base.DescribeCommand):
"""Show details about the Cloud API Gateway operation."""
detailed_help = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
"""\
To describe a Cloud API Gateway operation named ``NAME'' in the ``us-central1''
region, run:
$ {command} NAME --location=us-central1
To describe a Cloud API Gateway operation with a resource name of ``RESOURCE'',
run:
$ {command} RESOURCE
"""
}
@staticmethod
def Args(parser):
resource_args.AddOperationResourceArgs(parser, 'describe')
def Run(self, args):
client = operations.OperationsClient()
operation_ref = args.CONCEPTS.operation.Parse()
return client.Get(operation_ref)

View File

@@ -0,0 +1,77 @@
# -*- 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.
"""`gcloud api-gateway operations list` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.api_gateway import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.api_gateway import resource_args
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class List(base.ListCommand):
"""List API Gateway operations."""
detailed_help = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
"""\
To list all Cloud API Gateway operations, run:
$ {command}
To list all Cloud API Gateway operations in the ``us-central1'' region, run:
$ {command} --location=us-central1
"""
}
@staticmethod
def Args(parser):
# --sort-by and --uri are inherited for all ListCommands but are not
# implemented here.
base.SORT_BY_FLAG.RemoveFromParser(parser)
base.URI_FLAG.RemoveFromParser(parser)
resource_args.AddLocationResourceArg(parser,
'operations will be listed from',
default='-')
parser.display_info.AddFormat("""
table(
name.segment(5):label=OPERATION_ID,
name.segment(3):label=LOCATION,
done,
metadata.requestedCancellation:label=CANCELLED,
metadata.createTime.date(),
metadata.verb,
metadata.target
)
""")
parser.display_info.AddCacheUpdater(None)
def Run(self, args):
parent_ref = args.CONCEPTS.location.Parse()
return operations.OperationsClient().List(parent_ref.RelativeName(),
filters=args.filter,
limit=args.limit,
page_size=args.page_size)

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.
"""`gcloud api-gateway operations wait` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.api_gateway import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.api_gateway import resource_args
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Wait(base.Command):
"""Wait for a Cloud API Gateway operation to complete."""
detailed_help = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
"""\
To wait for a Cloud API Gateway operation named ``NAME'' in the ``us-central1''
region, run:
$ {command} NAME --location=us-central1
To wait for a Cloud API Gateway operation with a resource name of ``RESOURCE'',
run:
$ {command} RESOURCE
"""
}
@staticmethod
def Args(parser):
resource_args.AddOperationResourceArgs(parser, 'poll')
def Run(self, args):
client = operations.OperationsClient()
operation_ref = args.CONCEPTS.operation.Parse()
# To give a better message for already-completed operations, get the
# operation here and check if it's already completed.
operation = client.Get(operation_ref)
if operation.done:
msg_prefix = 'Operation has already completed.'
else:
# No need to check for the result, errors and timeouts are handled already
client.WaitForOperation(operation_ref)
msg_prefix = 'Operation completed successfully.'
log.status.Print('{} Use the following command for more details:\n\n'
'gcloud api-gateway operations describe {}\n'.format(
msg_prefix,
operation_ref.RelativeName()))