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,27 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 command group for managing Cloud Composer operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Operations(base.Group):
"""Manage Cloud Composer operations."""
Operations.category = base.COMPOSER_CATEGORY

View File

@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 an operation."""
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.composer import operations_util as operations_api_util
from googlecloudsdk.api_lib.util import exceptions
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.composer import resource_args
from googlecloudsdk.command_lib.composer import util as command_util
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
DETAILED_HELP = {
'EXAMPLES':
"""\
To delete the operation ``operation-1'', run:
$ {command} operation-1
"""
}
class Delete(base.DeleteCommand):
"""Delete one or more completed Cloud Composer operations.
Delete operations that are done. If more than one operation is specified,
all deletes will be attempted. If any of the deletes fail, those operations
and their failure messages will be listed on the standard error, and the
command will exit with a non-zero status.
"""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
resource_args.AddOperationResourceArg(parser, 'to delete', plural=True)
def Run(self, args):
op_refs = args.CONCEPTS.operations.Parse()
console_io.PromptContinue(
message=command_util.ConstructList(
'Deleting the following operations: ', [
'[%s] in [%s]' % (op_ref.operationsId, op_ref.locationsId)
for op_ref in op_refs
]),
cancel_on_no=True,
cancel_string='Deletion aborted by user.',
throw_if_unattended=True)
encountered_errors = False
for op_ref in op_refs:
try:
operations_api_util.Delete(op_ref, release_track=self.ReleaseTrack())
failed = None
except apitools_exceptions.HttpError as e:
exc = exceptions.HttpException(e)
failed = exc.payload.status_message
encountered_errors = True
log.DeletedResource(
op_ref.RelativeName(), kind='operation', failed=failed)
if encountered_errors:
raise command_util.Error('Some deletions did not succeed.')

View File

@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 show metadata for an operation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.composer import operations_util as operations_api_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.composer import resource_args
DETAILED_HELP = {
'EXAMPLES':
"""\
To get details for the operation ``operation-1'', run:
$ {command} operation-1
"""
}
class Describe(base.DescribeCommand):
"""Get details about an asynchronous operation."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
resource_args.AddOperationResourceArg(parser, 'to describe')
def Run(self, args):
operation_ref = args.CONCEPTS.operation.Parse()
return operations_api_util.Get(
operation_ref, release_track=self.ReleaseTrack())

View File

@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 operations in a project and location."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.composer import operations_util as operations_api_util
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.composer import flags
from googlecloudsdk.command_lib.composer import resource_args
from googlecloudsdk.core import resources
DETAILED_HELP = {
'EXAMPLES':
"""\
To list the environment operations in locations ``us-central1'' and
``europe-west3'', run:
$ {command} --locations=us-central1,europe-west3
"""
}
@base.UniverseCompatible
class List(base.ListCommand):
"""Lists environment operations.
Prints a table containing the following columns:
* uuid
* type
* location
* target environment
* status
* last updated timestamp
"""
detailed_help = DETAILED_HELP
@staticmethod
def _GetUri(operation):
r = resources.REGISTRY.ParseRelativeName(
operation.name,
collection='composer.projects.locations.operations',
api_version='v1',
)
return r.SelfLink()
@staticmethod
def Args(parser):
resource_args.AddLocationResourceArg(
parser,
'in which to list operations.',
positional=False,
required=arg_parsers.ArgRequiredInUniverse(
default_universe=False, non_default_universe=True
),
plural=True,
help_supplement=(
'If not specified, the location stored in the property '
' [composer/location] will be used.'
),
)
parser.display_info.AddFormat(
'table[box]('
'name.segment(5):label=UUID,'
'metadata.operationType:label=TYPE,'
'name.segment(3):label=LOCATION,'
'metadata.resource.basename():label=TARGET_ENVIRONMENT,'
'metadata.state:label=STATE,'
'metadata.createTime:label=CREATE_TIME:reverse'
')')
parser.display_info.AddUriFunc(List._GetUri)
def Run(self, args):
location_refs = flags.FallthroughToLocationProperty(
args.CONCEPTS.locations.Parse(),
'--locations',
'One or more locations in which to list operations must be provided.')
return operations_api_util.List(
location_refs,
args.page_size,
limit=args.limit,
release_track=self.ReleaseTrack())

View File

@@ -0,0 +1,53 @@
# -*- 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.
"""Command to wait for operation completion."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.composer import operations_util as operations_api_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.composer import resource_args
DETAILED_HELP = {
'EXAMPLES':
"""\
To wait for the asynchronous operation ``operation-1'' in the
location ``us-central1'' to complete, run:
$ {command} operation-1 --location=us-central1
"""
}
class Wait(base.SilentCommand):
"""Wait for asynchronous operation to complete."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
resource_args.AddOperationResourceArg(parser, 'to wait for')
def Run(self, args):
operation_ref = args.CONCEPTS.operation.Parse()
operation = operations_api_util.Get(
operation_ref, release_track=self.ReleaseTrack())
operations_api_util.WaitForOperation(
operation,
'Waiting for [{}] to complete.'.format(operation.name),
release_track=self.ReleaseTrack())