diff --git a/storage/transfer_service/aws_request.py b/storage/transfer_service/aws_request.py index e1e4d4eba02..ef6f6e6fa00 100644 --- a/storage/transfer_service/aws_request.py +++ b/storage/transfer_service/aws_request.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + # Copyright 2015, Google, Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -10,20 +12,26 @@ # 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. -# + # [START all] +"""Command-line sample that creates a one-time transfer from Amazon S3 to +Google Cloud Storage. + +This sample is used on this page: + + https://cloud.google.com/storage/transfer/create-transfer + +For more information, see README.md. +""" + import argparse import datetime import json -import logging from apiclient import discovery from oauth2client.client import GoogleCredentials -logging.basicConfig(level=logging.DEBUG) - - # [START main] def main(description, project_id, day, month, year, hours, minutes, source_bucket, access_key, secret_access_key, sink_bucket): @@ -69,13 +77,14 @@ def main(description, project_id, day, month, year, hours, minutes, } result = storagetransfer.transferJobs().create(body=transfer_job).execute() - logging.info('Returned transferJob: %s', json.dumps(result, indent=4)) + print('Returned transferJob: {}'.format( + json.dumps(result, indent=4))) # [END main] if __name__ == '__main__': parser = argparse.ArgumentParser( - description='Create a one-off transfer from Amazon S3 to Google Cloud ' - 'Storage.') + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('description', help='Transfer description.') parser.add_argument('project_id', help='Your Google Cloud project ID.') parser.add_argument('date', help='Date YYYY/MM/DD.') @@ -102,5 +111,4 @@ def main(description, project_id, day, month, year, hours, minutes, args.access_key, args.secret_access_key, args.sink_bucket) - # [END all] diff --git a/storage/transfer_service/create_client.py b/storage/transfer_service/create_client.py index c5e0a16434d..d93294a00f6 100644 --- a/storage/transfer_service/create_client.py +++ b/storage/transfer_service/create_client.py @@ -10,20 +10,13 @@ # 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. -# -# [START all] -import logging +# [START all] from apiclient import discovery from oauth2client.client import GoogleCredentials -CLOUD_SCOPES = 'https://www.googleapis.com/auth/cloud-platform' - def create_transfer_client(): - """Create a transfer client.""" - - logging.getLogger().setLevel(logging.DEBUG) credentials = GoogleCredentials.get_application_default() return discovery.build('storagetransfer', 'v1', credentials=credentials) # [END all] diff --git a/storage/transfer_service/nearline_request.py b/storage/transfer_service/nearline_request.py index 8339a6f8036..2821c21e989 100644 --- a/storage/transfer_service/nearline_request.py +++ b/storage/transfer_service/nearline_request.py @@ -10,20 +10,27 @@ # 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. -# + # [START all] + +"""Command-line sample that creates a one-time transfer from Google Cloud +Storage standard class to the Nearline storage class." + +This sample is used on this page: + + https://cloud.google.com/storage/transfer/create-transfer + +For more information, see README.md. +""" + import argparse import datetime import json -import logging from apiclient import discovery from oauth2client.client import GoogleCredentials -logging.basicConfig(level=logging.DEBUG) - - # [START main] def main(description, project_id, day, month, year, hours, minutes, source_bucket, sink_bucket): @@ -67,13 +74,14 @@ def main(description, project_id, day, month, year, hours, minutes, } result = storagetransfer.transferJobs().create(body=transfer_job).execute() - logging.info('Returned transferJob: %s', json.dumps(result, indent=4)) + print('Returned transferJob: {}'.format( + json.dumps(result, indent=4))) # [END main] if __name__ == '__main__': parser = argparse.ArgumentParser( - description='Create a transfer from the Google Cloud Storage Standard ' - 'class to the Nearline Storage class.') + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('description', help='Transfer description.') parser.add_argument('project_id', help='Your Google Cloud project ID.') parser.add_argument('date', help='Date YYYY/MM/DD.') @@ -95,5 +103,4 @@ def main(description, project_id, day, month, year, hours, minutes, time.minute, args.source_bucket, args.sink_bucket) - # [END all] diff --git a/storage/transfer_service/transfer_check.py b/storage/transfer_service/transfer_check.py index 4841ff40b48..70834e676e9 100644 --- a/storage/transfer_service/transfer_check.py +++ b/storage/transfer_service/transfer_check.py @@ -1,3 +1,5 @@ +#!/usr/bin/env + # Copyright 2015, Google, Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -10,19 +12,25 @@ # 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. -# + # [START all] + +"""Command-line sample that checks the status of an in-process transfer. + +This sample is used on this page: + + https://cloud.google.com/storage/transfer/create-transfer + +For more information, see README.md. +""" + import argparse import json -import logging from apiclient import discovery from oauth2client.client import GoogleCredentials -logging.basicConfig(level=logging.DEBUG) - - # [START main] def main(project_id, job_name): """Review the transfer operations associated with a transfer job.""" @@ -38,19 +46,18 @@ def main(project_id, job_name): result = storagetransfer.transferOperations().list( name="transferOperations", filter=filterString).execute() - logging.info('Result of transferOperations/list: %s', - json.dumps(result, indent=4, sort_keys=True)) + print('Result of transferOperations/list: {}'.format( + json.dumps(result, indent=4, sort_keys=True))) # [END main] if __name__ == '__main__': parser = argparse.ArgumentParser( - description='Review the transfer operations associated with a ' - 'transfer job.') + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('project_id', help='Your Google Cloud project ID.') parser.add_argument('job_name', help='Your job name.') args = parser.parse_args() main(args.project_id, args.job_name) - # [END all]