Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

fix: incremental updates to datatransfer methods, updated automatic retry configuration #14

Merged
merged 2 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,100 @@ def schedule_transfer_runs(
request, retry=retry, timeout=timeout, metadata=metadata
)

def start_manual_transfer_runs(
self,
parent=None,
requested_time_range=None,
requested_run_time=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Start manual transfer runs to be executed now with schedule\_time equal
to current time. The transfer runs can be created for a time range where
the run\_time is between start\_time (inclusive) and end\_time
(exclusive), or for a specific run\_time.

Example:
>>> from google.cloud import bigquery_datatransfer_v1
>>>
>>> client = bigquery_datatransfer_v1.DataTransferServiceClient()
>>>
>>> response = client.start_manual_transfer_runs()

Args:
parent (str): Transfer configuration name in the form:
``projects/{project_id}/transferConfigs/{config_id}`` or
``projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}``.
requested_time_range (Union[dict, ~google.cloud.bigquery_datatransfer_v1.types.TimeRange]): Time range for the transfer runs that should be started.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.bigquery_datatransfer_v1.types.TimeRange`
requested_run_time (Union[dict, ~google.cloud.bigquery_datatransfer_v1.types.Timestamp]): Specific run\_time for a transfer run to be started. The
requested\_run\_time must not be in the future.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.bigquery_datatransfer_v1.types.Timestamp`
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
timeout (Optional[float]): The amount of time, in seconds, to wait
for the request to complete. Note that if ``retry`` is
specified, the timeout applies to each individual attempt.
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
that is provided to the method.

Returns:
A :class:`~google.cloud.bigquery_datatransfer_v1.types.StartManualTransferRunsResponse` instance.

Raises:
google.api_core.exceptions.GoogleAPICallError: If the request
failed for any reason.
google.api_core.exceptions.RetryError: If the request failed due
to a retryable error and retry attempts failed.
ValueError: If the parameters are invalid.
"""
# Wrap the transport method to add retry and timeout logic.
if "start_manual_transfer_runs" not in self._inner_api_calls:
self._inner_api_calls[
"start_manual_transfer_runs"
] = google.api_core.gapic_v1.method.wrap_method(
self.transport.start_manual_transfer_runs,
default_retry=self._method_configs["StartManualTransferRuns"].retry,
default_timeout=self._method_configs["StartManualTransferRuns"].timeout,
client_info=self._client_info,
)

# Sanity check: We have some fields which are mutually exclusive;
# raise ValueError if more than one is sent.
google.api_core.protobuf_helpers.check_oneof(
requested_time_range=requested_time_range,
requested_run_time=requested_run_time,
)

request = datatransfer_pb2.StartManualTransferRunsRequest(
parent=parent,
requested_time_range=requested_time_range,
requested_run_time=requested_run_time,
)
if metadata is None:
metadata = []
metadata = list(metadata)
try:
routing_header = [("parent", parent)]
except AttributeError:
pass
else:
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
routing_header
)
metadata.append(routing_metadata)

return self._inner_api_calls["start_manual_transfer_runs"](
request, retry=retry, timeout=timeout, metadata=metadata
)

def get_transfer_run(
self,
name,
Expand Down Expand Up @@ -1465,97 +1559,3 @@ def check_valid_creds(
return self._inner_api_calls["check_valid_creds"](
request, retry=retry, timeout=timeout, metadata=metadata
)

def start_manual_transfer_runs(
self,
parent=None,
requested_time_range=None,
requested_run_time=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Start manual transfer runs to be executed now with schedule\_time equal
to current time. The transfer runs can be created for a time range where
the run\_time is between start\_time (inclusive) and end\_time
(exclusive), or for a specific run\_time.

Example:
>>> from google.cloud import bigquery_datatransfer_v1
>>>
>>> client = bigquery_datatransfer_v1.DataTransferServiceClient()
>>>
>>> response = client.start_manual_transfer_runs()

Args:
parent (str): Transfer configuration name in the form:
``projects/{project_id}/transferConfigs/{config_id}`` or
``projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}``.
requested_time_range (Union[dict, ~google.cloud.bigquery_datatransfer_v1.types.TimeRange]): Time range for the transfer runs that should be started.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.bigquery_datatransfer_v1.types.TimeRange`
requested_run_time (Union[dict, ~google.cloud.bigquery_datatransfer_v1.types.Timestamp]): Specific run\_time for a transfer run to be started. The
requested\_run\_time must not be in the future.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.bigquery_datatransfer_v1.types.Timestamp`
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
timeout (Optional[float]): The amount of time, in seconds, to wait
for the request to complete. Note that if ``retry`` is
specified, the timeout applies to each individual attempt.
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
that is provided to the method.

Returns:
A :class:`~google.cloud.bigquery_datatransfer_v1.types.StartManualTransferRunsResponse` instance.

Raises:
google.api_core.exceptions.GoogleAPICallError: If the request
failed for any reason.
google.api_core.exceptions.RetryError: If the request failed due
to a retryable error and retry attempts failed.
ValueError: If the parameters are invalid.
"""
# Wrap the transport method to add retry and timeout logic.
if "start_manual_transfer_runs" not in self._inner_api_calls:
self._inner_api_calls[
"start_manual_transfer_runs"
] = google.api_core.gapic_v1.method.wrap_method(
self.transport.start_manual_transfer_runs,
default_retry=self._method_configs["StartManualTransferRuns"].retry,
default_timeout=self._method_configs["StartManualTransferRuns"].timeout,
client_info=self._client_info,
)

# Sanity check: We have some fields which are mutually exclusive;
# raise ValueError if more than one is sent.
google.api_core.protobuf_helpers.check_oneof(
requested_time_range=requested_time_range,
requested_run_time=requested_run_time,
)

request = datatransfer_pb2.StartManualTransferRunsRequest(
parent=parent,
requested_time_range=requested_time_range,
requested_run_time=requested_run_time,
)
if metadata is None:
metadata = []
metadata = list(metadata)
try:
routing_header = [("parent", parent)]
except AttributeError:
pass
else:
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
routing_header
)
metadata.append(routing_metadata)

return self._inner_api_calls["start_manual_transfer_runs"](
request, retry=retry, timeout=timeout, metadata=metadata
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,71 +18,71 @@
},
"methods": {
"GetDataSource": {
"timeout_millis": 20000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListDataSources": {
"timeout_millis": 20000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"CreateTransferConfig": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"UpdateTransferConfig": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"DeleteTransferConfig": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetTransferConfig": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListTransferConfigs": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ScheduleTransferRuns": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"StartManualTransferRuns": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetTransferRun": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"DeleteTransferRun": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"ListTransferRuns": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListTransferLogs": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"CheckValidCreds": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"StartManualTransferRuns": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@ def schedule_transfer_runs(self):
"""
return self._stubs["data_transfer_service_stub"].ScheduleTransferRuns

@property
def start_manual_transfer_runs(self):
"""Return the gRPC stub for :meth:`DataTransferServiceClient.start_manual_transfer_runs`.

Start manual transfer runs to be executed now with schedule\_time equal
to current time. The transfer runs can be created for a time range where
the run\_time is between start\_time (inclusive) and end\_time
(exclusive), or for a specific run\_time.

Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["data_transfer_service_stub"].StartManualTransferRuns

@property
def get_transfer_run(self):
"""Return the gRPC stub for :meth:`DataTransferServiceClient.get_transfer_run`.
Expand Down Expand Up @@ -295,19 +311,3 @@ def check_valid_creds(self):
deserialized response object.
"""
return self._stubs["data_transfer_service_stub"].CheckValidCreds

@property
def start_manual_transfer_runs(self):
"""Return the gRPC stub for :meth:`DataTransferServiceClient.start_manual_transfer_runs`.

Start manual transfer runs to be executed now with schedule\_time equal
to current time. The transfer runs can be created for a time range where
the run\_time is between start\_time (inclusive) and end\_time
(exclusive), or for a specific run\_time.

Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["data_transfer_service_stub"].StartManualTransferRuns
Loading