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,46 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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 tasks command group for the Batch API CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
DETAILED_HELP = {
'DESCRIPTION': """
The gcloud batch tasks command group lets you describe and list Batch tasks.
With Batch, you can utilize the fully managed service to schedule, queue, and
execute batch jobs on Google's infrastructure.
For more information about Batch, see the
[Batch overview](https://cloud.google.com/batch)
and the
[Batch documentation](https://cloud.google.com/batch/docs/).
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Tasks(base.Group):
"""Manage Batch task resources."""
detailed_help = DETAILED_HELP
category = base.BATCH_CATEGORY

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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 details for a specified Batch task."""
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.batch import tasks
from googlecloudsdk.api_lib.util import exceptions
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.batch import resource_args
class Describe(base.DescribeCommand):
"""Show details of a task.
This command can fail for the following reasons:
* The task specified does not exist.
* The active account does not have permission to access the given task.
## EXAMPLES
To print details of the task with name
`projects/foo/locations/us-central1/jobs/bar/taskGroups/group0/tasks/0`, run:
$ {command}
projects/foo/locations/us-central1/jobs/bar/taskGroups/group0/tasks/0
"""
@staticmethod
def Args(parser):
resource_args.AddTaskResourceArgs(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = tasks.TasksClient(release_track)
task_ref = args.CONCEPTS.task.Parse()
try:
return client.Get(task_ref)
except apitools_exceptions.HttpNotFoundError as e:
raise exceptions.HttpException(
e, error_format='Could not fetch resource: {status_message}.')

View File

@@ -0,0 +1,127 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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 tasks for a specified Batch job."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.batch import tasks
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.batch import resource_args
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
@base.UniverseCompatible
class List(base.ListCommand):
"""List tasks for a specified Batch job.
Currently, since Batch only supports one taskGroup, group0, the command
takes --job as the required argument and will list all tasks
in group0 of the job.
This command can fail for the following reasons:
* The job specified does not exist.
* The active account does not have permission to access the given job
## EXAMPLES
To print all tasks in the job with name
`projects/foo/locations/us-central1/jobs/bar`, run:
$ {command} --job projects/foo/locations/us-central1/jobs/bar
"""
@staticmethod
def Args(parser):
resource_args.AddJobFlagResourceArgs(parser)
base.URI_FLAG.RemoveFromParser(parser)
parser.display_info.AddFormat('table(name, status.state)')
def Run(self, args):
release_track = self.ReleaseTrack()
client = tasks.TasksClient(release_track)
job_ref = args.CONCEPTS.job.Parse()
return list_pager.YieldFromList(
client.service,
client.messages.BatchProjectsLocationsJobsTaskGroupsTasksListRequest(
parent=job_ref.RelativeName() + '/taskGroups/group0',
pageSize=args.page_size,
filter=args.filter,
),
batch_size=args.page_size,
field='tasks',
limit=args.limit,
batch_size_attribute='pageSize',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.UniverseCompatible
class ListAlpha(base.ListCommand):
"""List tasks for a specified Batch job.
Currently, since Batch only supports one taskGroup, group0, the command
takes --job as the required argument and will list all tasks
in group0 of the job.
This command can fail for the following reasons:
* The job specified does not exist.
* The active account does not have permission to access the given job
## EXAMPLES
To print all tasks in the job with name
`projects/foo/locations/us-central1/jobs/bar`, run:
$ {command} --job projects/foo/locations/us-central1/jobs/bar
"""
@staticmethod
def Args(parser):
resource_args.AddJobFlagResourceArgs(parser)
base.URI_FLAG.RemoveFromParser(parser)
parser.display_info.AddFormat('table(name, status.state)')
def Run(self, args):
"""Alpha version method to list tasks for a specified Batch job.
Args:
args: The command line arguments of the list command including job
resource, page size, filter, limit and sort-by.
Returns:
The list of tasks for the job.
"""
release_track = self.ReleaseTrack()
client = tasks.TasksClient(release_track)
job_ref = args.CONCEPTS.job.Parse()
return list_pager.YieldFromList(
client.service,
client.messages.BatchProjectsLocationsJobsTaskGroupsTasksListRequest(
parent=job_ref.RelativeName() + '/taskGroups/group0',
pageSize=args.page_size,
),
batch_size=args.page_size,
field='tasks',
limit=args.limit,
batch_size_attribute='pageSize',
)