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,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.
"""Transfer agent pool commands."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class AgentPools(base.Group):
"""Manage on-premise transfer agent pools."""

View File

@@ -0,0 +1,90 @@
# -*- 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 to create a Transfer Service agent pool."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.transfer import agent_pools_util
from googlecloudsdk.api_lib.util import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.transfer import agent_pools_flag_util
from googlecloudsdk.command_lib.transfer import name_util
@base.UniverseCompatible
class Create(base.Command):
"""Create a Transfer Service agent pool."""
# pylint:disable=line-too-long
detailed_help = {
'DESCRIPTION':
"""\
Create an agent pool -- a group of agents used to connect to a source or
destination filesystem.
""",
'EXAMPLES':
"""\
To create an agent pool with name 'my-pool', display name 'daily backups',
and no bandwidth limit, run:
$ {command} my-pool --display-name='daily backups'
To create an agent pool with name 'my-pool', display name 'daily backups',
and a bandwidth limit of 50 MB/s, run:
$ {command} my-pool --display-name="daily backups" --bandwidth-limit=50
"""
}
# pylint:enable=line-too-long
@staticmethod
def Args(parser):
agent_pools_flag_util.setup_parser(parser)
parser.add_argument(
'--no-async',
action='store_true',
help='Block other tasks in your terminal until the pool has been'
' created. If not included, pool creation will run asynchronously.')
def Run(self, args):
client = apis.GetClientInstance('transfer', 'v1')
messages = apis.GetMessagesModule('transfer', 'v1')
formatted_agent_pool_name = name_util.add_agent_pool_prefix(args.name)
agent_pool_id = name_util.remove_agent_pool_prefix(args.name)
agent_pool_project = name_util.get_agent_pool_project_from_string(
formatted_agent_pool_name)
agent_pool_object = messages.AgentPool(
displayName=args.display_name, name=formatted_agent_pool_name)
if args.bandwidth_limit:
agent_pool_object.bandwidthLimit = messages.BandwidthLimit(
limitMbps=args.bandwidth_limit)
initial_result = client.projects_agentPools.Create(
messages.StoragetransferProjectsAgentPoolsCreateRequest(
agentPool=agent_pool_object,
agentPoolId=agent_pool_id,
projectId=agent_pool_project))
if args.no_async:
final_result = agent_pools_util.block_until_created(
formatted_agent_pool_name)
else:
final_result = initial_result
return final_result

View File

@@ -0,0 +1,64 @@
# -*- 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 to delete transfer agent pools."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.util import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.transfer import name_util
@base.UniverseCompatible
class Delete(base.Command):
"""Delete a Transfer Service agent pool."""
# pylint:disable=line-too-long
detailed_help = {
'DESCRIPTION':
"""\
Delete an agent pool. Note that before you can delete a pool, all
the pool's agents must be stopped, its associated jobs must be disabled,
and there must be no associated in-progress transfer operations.
""",
'EXAMPLES':
"""\
To delete agent pool 'foo', run:
$ {command} foo
To check if there are active operations associated with a pool before
deleting it, scroll through the results of:
$ {grandparent_command} operations list --format=yaml --operation-statuses=in_progress
"""
}
# pylint:enable=line-too-long
@staticmethod
def Args(parser):
parser.add_argument('name', help='The name of the job you want to delete.')
def Run(self, args):
client = apis.GetClientInstance('transfer', 'v1')
messages = apis.GetMessagesModule('transfer', 'v1')
formatted_agent_pool_name = name_util.add_agent_pool_prefix(args.name)
client.projects_agentPools.Delete(
messages.StoragetransferProjectsAgentPoolsDeleteRequest(
name=formatted_agent_pool_name))

View File

@@ -0,0 +1,53 @@
# -*- 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 to get details about a specific agent pool."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.transfer import agent_pools_util
from googlecloudsdk.calliope import base
from googlecloudsdk.core.resource import resource_printer
@base.UniverseCompatible
class Describe(base.Command):
"""Get details about a specific agent pool."""
detailed_help = {
'DESCRIPTION':
"""\
Get details about a specific agent pool.
""",
'EXAMPLES':
"""\
To monitor an agent pool, run:
$ {command} NAME
""",
}
@staticmethod
def Args(parser):
parser.add_argument(
'name', help='The name of the agent pool you want to describe.')
def Display(self, args, resources):
del args # Unsued.
resource_printer.Print(resources, 'json')
def Run(self, args):
return agent_pools_util.api_get(args.name)

View File

@@ -0,0 +1,102 @@
# -*- 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 to list transfer agent pools."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import json
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.util import apis
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.transfer import list_util
from googlecloudsdk.command_lib.transfer import name_util
from googlecloudsdk.core import properties
from googlecloudsdk.core.resource import resource_printer
@base.UniverseCompatible
class List(base.Command):
"""List Transfer Service transfer agent pools."""
detailed_help = {
'DESCRIPTION':
"""\
List Transfer Service transfer pools in a given project to show their
configurations.
""",
'EXAMPLES':
"""\
To list all agent pools in your current project, run:
$ {command}
To list agent pools named "foo" and "bar" in your project, run:
$ {command} --names=foo,bar
To list all information about jobs 'foo' and 'bar' formatted as JSON, run:
$ {command} --names=foo,bar --format=json
""",
}
@staticmethod
def Args(parser):
list_util.add_common_list_flags(parser)
parser.add_argument(
'--names',
type=arg_parsers.ArgList(),
metavar='NAMES',
help='The names of the agent pools you want to list. Separate multiple'
' names with commas (e.g., --name=foo,bar). If not specified, all'
' agent pools in your current project will be listed.')
def Display(self, args, resources):
"""API response display logic."""
resource_printer.Print(resources, args.format or 'yaml')
def Run(self, args):
"""Command execution logic."""
client = apis.GetClientInstance('transfer', 'v1')
messages = apis.GetMessagesModule('transfer', 'v1')
if args.names:
formatted_agent_pool_names = name_util.add_agent_pool_prefix(args.names)
else:
formatted_agent_pool_names = None
filter_dictionary = {
'agentPoolNames': formatted_agent_pool_names,
}
filter_string = json.dumps(filter_dictionary)
resources_iterator = list_pager.YieldFromList(
client.projects_agentPools,
messages.StoragetransferProjectsAgentPoolsListRequest(
filter=filter_string,
projectId=properties.VALUES.core.project.Get()),
batch_size=args.page_size,
batch_size_attribute='pageSize',
field='agentPools',
limit=args.limit,
)
list_util.print_transfer_resources_iterator(resources_iterator,
self.Display, args)

View File

@@ -0,0 +1,96 @@
# -*- 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 to update a Transfer Service agent pool."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.util import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.transfer import agent_pools_flag_util
from googlecloudsdk.command_lib.transfer import name_util
@base.UniverseCompatible
class Update(base.Command):
"""Update a Transfer Service agent pool."""
# pylint:disable=line-too-long
detailed_help = {
'DESCRIPTION':
"""\
Update an agent pool.
""",
'EXAMPLES':
"""\
To remove the bandwidth limit for agent pool 'foo', run:
$ {command} foo --clear-bandwidth-limit
To remove the display name for agent pool 'foo', run:
$ {command} foo --clear-display-name
To update the bandwidth limit for agent pool 'foo' to 100 MB/s, run:
$ {command} foo --bandwidth-limit=100
To update the display name for agent pool 'foo' to 'example name', run:
$ {command} foo --display-name="example name"
"""
}
# pylint:enable=line-too-long
@staticmethod
def Args(parser):
agent_pools_flag_util.setup_parser(parser)
parser.add_argument(
'--clear-display-name',
action='store_true',
help='Remove the display name from the agent pool.')
parser.add_argument(
'--clear-bandwidth-limit',
action='store_true',
help="Remove the agent pool's bandwidth limit, which enables the pool's"
' agents to use all bandwidth available to them.')
def Run(self, args):
client = apis.GetClientInstance('transfer', 'v1')
messages = apis.GetMessagesModule('transfer', 'v1')
agent_pool_object = messages.AgentPool()
update_mask_list = []
if args.bandwidth_limit or args.clear_bandwidth_limit:
update_mask_list.append('bandwidth_limit')
if args.bandwidth_limit:
agent_pool_object.bandwidthLimit = messages.BandwidthLimit(
limitMbps=args.bandwidth_limit)
if args.display_name or args.clear_display_name:
update_mask_list.append('display_name')
agent_pool_object.displayName = args.display_name
if update_mask_list:
update_mask = ','.join(update_mask_list)
else:
update_mask = None
formatted_agent_pool_name = name_util.add_agent_pool_prefix(args.name)
return client.projects_agentPools.Patch(
messages.StoragetransferProjectsAgentPoolsPatchRequest(
agentPool=agent_pool_object,
name=formatted_agent_pool_name,
updateMask=update_mask))