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 jobs commands."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class Jobs(base.Group):
"""Manage transfer jobs."""

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 Storagetransfer transfer job 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 Storagetransfer transfer job configurations."""

View File

@@ -0,0 +1,38 @@
release_tracks: [ALPHA]
command_type: CONFIG_EXPORT
help_text:
brief: Export the configuration for a Storagetransfer transfer job.
description: |
*{command}* exports the configuration for a Storagetransfer transfer job.
Transfer job 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
transfer jobs within the project.
Specifying `--path` allows you to export the configuration(s) to
a local directory.
examples: |
To export the configuration for a transfer job, run:
$ {command} my-transfer-job
To export the configuration for a transfer job to a file, run:
$ {command} my-transfer-job --path=/path/to/dir/
To export the configuration for a transfer job in Terraform
HCL format, run:
$ {command} my-transfer-job --resource-format=terraform
To export the configurations for all transfer jobs within a
project, run:
$ {command} --all
arguments:
resource:
help_text: Transfer job to export the configuration for.
spec: !REF googlecloudsdk.command_lib.transfer.resources:transfer_job

View File

@@ -0,0 +1,107 @@
# -*- 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 transfer jobs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.transfer import operations_util
from googlecloudsdk.api_lib.util import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.storage import storage_url
from googlecloudsdk.command_lib.transfer import jobs_apitools_util
from googlecloudsdk.command_lib.transfer import jobs_flag_util
from googlecloudsdk.core import log
@base.UniverseCompatible
class Create(base.Command):
"""Create a Transfer Service transfer job."""
# pylint:disable=line-too-long
detailed_help = {
'DESCRIPTION':
"""\
Create a Transfer Service transfer job, allowing you to transfer data to
Google Cloud Storage on a one-time or recurring basis.
""",
'EXAMPLES':
"""\
To create a one-time, immediate transfer job to move data from Google
Cloud Storage bucket "foo" into the "baz" folder in Cloud Storage bucket
"bar", run:
$ {command} gs://foo gs://bar/baz/
To create a transfer job to move data from an Amazon S3 bucket called
"foo" to a Google Cloud Storage bucket named "bar" that runs every day
with custom name "my-test-job", run:
$ {command} s3://foo gs://bar --name=my-test-job --source-creds-file=/examplefolder/creds.txt --schedule-repeats-every=1d
To create a one-time, immediate transfer job to move data between Google
Cloud Storage buckets "foo" and "bar" with filters to include objects that
start with prefixes "baz" and "qux"; and objects modified in the 24 hours
before the transfer started, run:
$ {command} gs://foo gs://bar/ --include-prefixes=baz,qux --include-modified-after-relative=1d
To create a one-time, immediate transfer job to move data from a directory
with absolute path "/foo/bar/" in the filesystem associated with
agent pool "my-pool" into Google Cloud Storage bucket "example-bucket",
run:
$ {command} posix:///foo/bar/ gs://example-bucket --source-agent-pool=my-pool
"""
}
# pylint:enable=line-too-long
@classmethod
def Args(cls, parser):
jobs_flag_util.setup_parser(parser, release_track=cls.ReleaseTrack())
def Run(self, args):
is_hdfs_source = args.source.startswith(
storage_url.ProviderPrefix.HDFS.value
)
is_posix_source = args.source.startswith(
storage_url.ProviderPrefix.POSIX.value
)
is_posix_destination = args.destination.startswith(
storage_url.ProviderPrefix.POSIX.value
)
if (is_hdfs_source or is_posix_source) and not args.source_agent_pool:
raise ValueError(
'Missing agent pool. Please add --source-agent-pool flag.')
if is_posix_destination and not args.destination_agent_pool:
raise ValueError(
'Missing agent pool. Please add --destination-agent-pool flag.')
if (is_posix_source and is_posix_destination and
not args.intermediate_storage_path):
raise ValueError('Missing intermediate storage path.'
' Please add --intermediate-storage-path flag.')
client = apis.GetClientInstance('transfer', 'v1')
messages = apis.GetMessagesModule('transfer', 'v1')
result = client.transferJobs.Create(
jobs_apitools_util.generate_transfer_job_message(args, messages))
if args.no_async:
log.status.Print('Created job: {}'.format(result.name))
operations_util.block_until_done(job_name=result.name)
return result

View File

@@ -0,0 +1,59 @@
# -*- 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 jobs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.transfer import jobs_util
from googlecloudsdk.api_lib.util import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.transfer import name_util
from googlecloudsdk.core import properties
@base.UniverseCompatible
class Delete(base.Command):
"""Delete a Transfer Service transfer job."""
detailed_help = {
'DESCRIPTION':
"""\
Delete a Transfer Service transfer job.
""",
'EXAMPLES':
"""\
To delete job 'foo', run:
$ {command} foo
"""
}
@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_job_name = name_util.add_job_prefix(args.name)
client.transferJobs.Delete(
messages.StoragetransferTransferJobsDeleteRequest(
jobName=formatted_job_name,
projectId=properties.VALUES.core.project.Get()))
# Display metadata of job with status updated to `DELETED`.
return jobs_util.api_get(args.name)

View File

@@ -0,0 +1,61 @@
# -*- 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 on a transfer job."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.transfer import jobs_util
from googlecloudsdk.calliope import base
from googlecloudsdk.core.resource import resource_printer
@base.UniverseCompatible
class Describe(base.Command):
"""Get configuration and latest operation details about transfer job."""
detailed_help = {
'DESCRIPTION':
"""\
Get configuration and latest operation details about a specific transfer
job.
""",
'EXAMPLES':
"""\
To describe a job, run:
$ {command} JOB-NAME
If you're looking for recent error details, use the "latestOperationName"
returned by this command as input to the "operations describe" command:
$ {command} JOB-NAME --format="json(latestOperationName)"
$ {grandparent_command} operations describe OPERATION-NAME
""",
}
@staticmethod
def Args(parser):
parser.add_argument(
'name', help='The name of the job you want to describe.')
def Display(self, args, resources):
del args # Unsued.
resource_printer.Print(resources, 'json')
def Run(self, args):
return jobs_util.api_get(args.name)

View File

@@ -0,0 +1,175 @@
# -*- 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 jobs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import enum
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
class JobType(enum.Enum):
"""The type of the job."""
TRANSFER = 'transfer'
REPLICATION = 'replication'
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.Command):
"""List Transfer Service transfer jobs."""
detailed_help = {
'DESCRIPTION':
"""\
List Transfer Service transfer jobs in a given project to show their
configurations and latest operations.
""",
'EXAMPLES':
"""\
To list all jobs in your current project, run:
$ {command}
To list all disabled jobs in your project, run:
$ {command} --job-statuses=disabled
To list jobs 'foo' and 'bar', run:
$ {command} --job-names=foo,bar
To list all information about all jobs formatted as JSON, run:
$ {command} --format=json
To list all information about jobs 'foo' and 'bar' formatted as YAML, run:
$ {command} --job-names=foo,bar --format=YAML
""",
}
@staticmethod
def Args(parser):
parser.SetSortArgs(False)
list_util.add_common_list_flags(parser)
parser.add_argument(
'--job-names',
type=arg_parsers.ArgList(),
metavar='JOB_NAMES',
help='The names of the jobs you want to list. Separate multiple job'
' names with commas (e.g., --job-names=foo,bar). If not specified,'
' all jobs will be listed.')
parser.add_argument(
'--job-statuses',
type=arg_parsers.ArgList(),
metavar='JOB_STATUSES',
help='List only jobs with the statuses you specify.'
" Options include 'enabled', 'disabled', 'deleted' (case"
' insensitive). Separate multiple statuses with commas (e.g.,'
' --job-statuses=enabled,deleted). If not specified, all jobs will'
' be listed.')
parser.add_argument(
'--expand-table',
action='store_true',
help='Include additional table columns (job name, source, destination,'
' frequency, lastest operation name, job status) in command output.'
' Tip: increase the size of your terminal before running the command.')
parser.add_argument(
'--job-type',
choices=[JobType.TRANSFER.value, JobType.REPLICATION.value],
default=JobType.TRANSFER.value,
help='The type of the job you want to list.',
)
def Display(self, args, resources):
"""API response display logic."""
if args.expand_table:
# Removes unwanted "transferJobs/" and "transferOperations/" prefixes.
format_string = """table(
name.slice(13:).join(sep=''),
firstof(transferSpec, replicationSpec).firstof(
gcsDataSource, awsS3DataSource, httpDataSource,
azureBlobStorageDataSource, posixDataSource, hdfsDataSource
).firstof(
bucketName, listUrl, container, rootDirectory, path
).trailoff(45):label=SOURCE,
firstof(transferSpec, replicationSpec).firstof(
gcsDataSink, posixDataSink
).firstof(
bucketName, rootDirectory
).trailoff(45):label=DESTINATION,
latestOperationName.slice(19:).join(sep=''),
status)
"""
else:
format_string = """table(
name.slice(13:).join(sep=''),
latestOperationName.slice(19:).join(sep=''))
"""
resource_printer.Print(resources, args.format or format_string)
def Run(self, args):
"""Command execution logic."""
client = apis.GetClientInstance('transfer', 'v1')
messages = apis.GetMessagesModule('transfer', 'v1')
if args.job_names:
formatted_job_names = name_util.add_job_prefix(args.job_names)
else:
formatted_job_names = None
job_statuses = args.job_statuses or None
filter_dictionary = {
'jobNames': formatted_job_names,
'jobStatuses': job_statuses,
'projectId': properties.VALUES.core.project.Get(),
}
if args.job_type == JobType.REPLICATION.value:
# Filter to list replication jobs.
filter_dictionary['dataBackend'] = 'QUERY_REPLICATION_CONFIGS'
filter_string = json.dumps(filter_dictionary)
resources_iterator = list_pager.YieldFromList(
client.transferJobs,
messages.StoragetransferTransferJobsListRequest(filter=filter_string),
batch_size=args.page_size,
batch_size_attribute='pageSize',
field='transferJobs',
limit=args.limit,
)
list_util.print_transfer_resources_iterator(resources_iterator,
self.Display, args)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List Transfer Service transfer jobs."""
@staticmethod
def Args(parser):
List.Args(parser)

View File

@@ -0,0 +1,59 @@
# -*- 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 monitor the last operation of a transfer job."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.transfer import jobs_util
from googlecloudsdk.api_lib.transfer import operations_util
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class Monitor(base.Command):
"""Track progress in real time for a transfer job's latest operation."""
detailed_help = {
'DESCRIPTION':
"""\
Track progress in real time for a transfer job's latest operation.
""",
'EXAMPLES':
"""\
To monitor a job, run:
$ {command} JOB-NAME
If you're looking for recent error details, use the "Operation name"
returned by this command as input to the "operations describe" command:
$ {command} JOB-NAME
$ {grandparent_command} operations describe OPERATION-NAME
""",
}
@staticmethod
def Args(parser):
parser.add_argument(
'name',
help='The name of the job you want to monitor'
" (you'll see details for the job's latest operation).")
def Run(self, args):
operation_name = jobs_util.block_until_operation_created(args.name)
operations_util.display_monitoring_view(operation_name)

View File

@@ -0,0 +1,71 @@
# -*- 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 run transfer jobs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.transfer import operations_util
from googlecloudsdk.api_lib.util import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.transfer import name_util
from googlecloudsdk.core import properties
@base.UniverseCompatible
class Run(base.Command):
"""Run a Transfer Service transfer job."""
# pylint:disable=line-too-long
detailed_help = {
'DESCRIPTION':
"""\
Run a Transfer Service transfer job.
""",
'EXAMPLES':
"""\
To run job 'foo', run:
$ {command} foo
"""
}
@staticmethod
def Args(parser):
parser.add_argument('name', help='The name of the job you want to run.')
parser.add_argument(
'--no-async',
action='store_true',
help=(
'Blocks other tasks in your terminal until the transfer operation'
' has completed. If not included, tasks will run asynchronously.'))
def Run(self, args):
client = apis.GetClientInstance('transfer', 'v1')
messages = apis.GetMessagesModule('transfer', 'v1')
formatted_name = name_util.add_job_prefix(args.name)
result = client.transferJobs.Run(
messages.StoragetransferTransferJobsRunRequest(
jobName=formatted_name,
runTransferJobRequest=messages.RunTransferJobRequest(
projectId=properties.VALUES.core.project.Get())))
if args.no_async:
operations_util.block_until_done(operation_name=result.name)
return result

View File

@@ -0,0 +1,194 @@
# -*- 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 transfer jobs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.transfer import jobs_util
from googlecloudsdk.api_lib.util import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.transfer import jobs_apitools_util
from googlecloudsdk.command_lib.transfer import jobs_flag_util
def _clear_fields(args, messages, job):
"""Removes fields from TransferJob based on clear flags."""
if args.clear_description:
job.description = None
if args.clear_source_creds_file:
if getattr(job.transferSpec, 'awsS3DataSource', None):
job.transferSpec.awsS3DataSource.awsAccessKey = None
job.transferSpec.awsS3DataSource.roleArn = None
if getattr(job.transferSpec, 'azureBlobStorageDataSource', None):
job.transferSpec.azureBlobStorageDataSource.azureCredentials = None
if args.clear_event_stream:
if job.replicationSpec:
# Do not clear the event stream for replication job.
raise ValueError('Cannot clear event stream for replication job.')
job.eventStream = None
if args.clear_schedule:
job.schedule = None
if args.clear_source_agent_pool:
job.transferSpec.sourceAgentPoolName = None
if args.clear_destination_agent_pool:
job.transferSpec.sinkAgentPoolName = None
if args.clear_intermediate_storage_path:
job.transferSpec.gcsIntermediateDataLocation = None
if args.clear_manifest_file:
job.transferSpec.transferManifest = None
if getattr(job.transferSpec, 'awsS3DataSource', None):
if getattr(args, 'clear_s3_cloudfront_domain', None):
job.transferSpec.awsS3DataSource.cloudfrontDomain = None
object_conditions, transfer_options = None, None
if job.transferSpec:
# It is a transfer job.
object_conditions = getattr(job.transferSpec, 'objectConditions', None)
transfer_options = getattr(job.transferSpec, 'transferOptions', None)
elif job.replicationSpec:
# Otherwise, it's a replication job.
object_conditions = getattr(job.replicationSpec, 'objectConditions', None)
transfer_options = getattr(job.replicationSpec, 'transferOptions', None)
if object_conditions:
if args.clear_include_prefixes:
object_conditions.includePrefixes = []
if args.clear_exclude_prefixes:
object_conditions.excludePrefixes = []
if args.clear_include_modified_before_absolute:
object_conditions.lastModifiedBefore = None
if args.clear_include_modified_after_absolute:
object_conditions.lastModifiedSince = None
if args.clear_include_modified_before_relative:
object_conditions.minTimeElapsedSinceLastModification = None
if args.clear_include_modified_after_relative:
object_conditions.maxTimeElapsedSinceLastModification = None
if object_conditions == messages.ObjectConditions():
if job.transferSpec:
job.transferSpec.objectConditions = None
else:
job.replicationSpec.objectConditions = None
if transfer_options:
if args.clear_delete_from:
transfer_options.deleteObjectsFromSourceAfterTransfer = None
transfer_options.deleteObjectsUniqueInSink = None
if args.clear_delete_from:
transfer_options.deleteObjectsFromSourceAfterTransfer = None
transfer_options.deleteObjectsUniqueInSink = None
if transfer_options.metadataOptions:
existing_metadata_options = transfer_options.metadataOptions
new_metadata_options = existing_metadata_options
if args.clear_preserve_metadata:
new_metadata_options = messages.MetadataOptions()
if (existing_metadata_options.storageClass != messages.MetadataOptions
.StorageClassValueValuesEnum.STORAGE_CLASS_PRESERVE):
# Maintain custom values that aren't the preserve flag.
new_metadata_options.storageClass = (
existing_metadata_options.storageClass)
if args.clear_custom_storage_class:
new_metadata_options.storageClass = None
if new_metadata_options == messages.MetadataOptions():
transfer_options.metadataOptions = None
else:
transfer_options.metadataOptions = new_metadata_options
if transfer_options == messages.TransferOptions():
if job.transferSpec:
job.transferSpec.transferOptions = None
else:
job.replicationSpec.transferOptions = None
if args.clear_notification_config:
job.notificationConfig = None
if args.clear_notification_event_types:
job.notificationConfig.eventTypes = []
if args.clear_log_config:
job.loggingConfig = None
if getattr(job.transferSpec, 'awsS3CompatibleDataSource', None):
if args.clear_source_endpoint:
job.transferSpec.awsS3CompatibleDataSource.endpoint = None
if args.clear_source_signing_region:
job.transferSpec.awsS3CompatibleDataSource.region = None
s3_compatible_metadata = getattr(job.transferSpec.awsS3CompatibleDataSource,
's3Metadata', None)
if s3_compatible_metadata:
if args.clear_source_auth_method:
s3_compatible_metadata.authMethod = None
if args.clear_source_list_api:
s3_compatible_metadata.listApi = None
if args.clear_source_network_protocol:
s3_compatible_metadata.protocol = None
if args.clear_source_request_model:
s3_compatible_metadata.requestModel = None
if s3_compatible_metadata == messages.S3CompatibleMetadata():
job.transferSpec.awsS3CompatibleDataSource.s3Metadata = None
@base.UniverseCompatible
class Update(base.Command):
"""Update a Transfer Service transfer job."""
# pylint:disable=line-too-long
detailed_help = {
'DESCRIPTION':
"""\
Update a Transfer Service transfer job.
""",
'EXAMPLES':
"""\
To disable transfer job 'foo', run:
$ {command} foo --status=disabled
To remove the schedule for transfer job 'foo' so that it will only run
when you manually start it, run:
$ {command} foo --clear-schedule
To clear the values from the `include=prefixes` object condition in
transfer job 'foo', run:
$ {command} foo --clear-include-prefixes
"""
}
@classmethod
def Args(cls, parser):
jobs_flag_util.setup_parser(
parser, is_update=True, release_track=cls.ReleaseTrack()
)
def Run(self, args):
client = apis.GetClientInstance('transfer', 'v1')
messages = apis.GetMessagesModule('transfer', 'v1')
existing_job = jobs_util.api_get(args.name)
_clear_fields(args, messages, existing_job)
return client.transferJobs.Patch(
jobs_apitools_util.generate_transfer_job_message(
args, messages, existing_job=existing_job))