gapic-generator-python
gapic-generator-python copied to clipboard
FR(storage-transfer): Export Required Protobufs if Required By Library
Is your feature request related to a problem? Please describe.
Required protobufs should be exported directly if required by the library. Currently, google.protobuf
must be imported in order to be used - this isn't ergonomic and requires a bit of digging to determine how to retrieve the desired type.
Example: Duration
is required for certain configurations, such as min_time_elapsed_since_last_modification
:
from google.protobuf.duration_pb2 import Duration
transfer_job_request = storage_transfer.CreateTransferJobRequest({
'transfer_job': {
'project_id': project_id,
'description': description,
'status': storage_transfer.TransferJob.Status.ENABLED,
'schedule': {
'schedule_start_date': {
'day': start_date.day,
'month': start_date.month,
'year': start_date.year
}
},
'transfer_spec': {
'gcs_data_source': {
'bucket_name': source_bucket,
},
'gcs_data_sink': {
'bucket_name': sink_bucket,
},
'object_conditions': {
'min_time_elapsed_since_last_modification': Duration(
seconds=2592000 # 30 days
)
},
'transfer_options': {
'delete_objects_from_source_after_transfer': True
}
}
}
})
Describe the solution you'd like
Required protobufs should be exported. It should be (or similar to):
from google.cloud.storage_transfer import Duration
Describe alternatives you've considered
The only alternative is to import from google.protobuf.duration_pb2
:
from google.protobuf.duration_pb2 import Duration
Transferred issue to monorepo as this is a feature request to the storage-transfer python client - required protobufs should be exported directly if required by the library cc @danielbankhead
Moving to gapic-generator-python
as this feature request is for the code generator.