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

Commit

Permalink
fix: correct protobuf type for diagnose_cluster, update retry configs (
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation committed Jul 16, 2020
1 parent b539920 commit 822315e
Show file tree
Hide file tree
Showing 43 changed files with 2,027 additions and 1,572 deletions.
84 changes: 42 additions & 42 deletions google/cloud/dataproc_v1/gapic/autoscaling_policy_service_client.py
Expand Up @@ -218,31 +218,41 @@ def __init__(
self._inner_api_calls = {}

# Service calls
def update_autoscaling_policy(
def create_autoscaling_policy(
self,
parent,
policy,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Updates (replaces) autoscaling policy.
Disabled check for update_mask, because all updates will be full
replacements.
Creates new autoscaling policy.
Example:
>>> from google.cloud import dataproc_v1
>>>
>>> client = dataproc_v1.AutoscalingPolicyServiceClient()
>>>
>>> parent = client.region_path('[PROJECT]', '[REGION]')
>>>
>>> # TODO: Initialize `policy`:
>>> policy = {}
>>>
>>> response = client.update_autoscaling_policy(policy)
>>> response = client.create_autoscaling_policy(parent, policy)
Args:
policy (Union[dict, ~google.cloud.dataproc_v1.types.AutoscalingPolicy]): Required. The updated autoscaling policy.
parent (str): Required. The "resource name" of the region or location, as
described in https://cloud.google.com/apis/design/resource_names.
- For ``projects.regions.autoscalingPolicies.create``, the resource
name of the region has the following format:
``projects/{project_id}/regions/{region}``
- For ``projects.locations.autoscalingPolicies.create``, the resource
name of the location has the following format:
``projects/{project_id}/locations/{location}``
policy (Union[dict, ~google.cloud.dataproc_v1.types.AutoscalingPolicy]): Required. The autoscaling policy to create.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.dataproc_v1.types.AutoscalingPolicy`
Expand All @@ -266,24 +276,24 @@ def update_autoscaling_policy(
ValueError: If the parameters are invalid.
"""
# Wrap the transport method to add retry and timeout logic.
if "update_autoscaling_policy" not in self._inner_api_calls:
if "create_autoscaling_policy" not in self._inner_api_calls:
self._inner_api_calls[
"update_autoscaling_policy"
"create_autoscaling_policy"
] = google.api_core.gapic_v1.method.wrap_method(
self.transport.update_autoscaling_policy,
default_retry=self._method_configs["UpdateAutoscalingPolicy"].retry,
default_timeout=self._method_configs["UpdateAutoscalingPolicy"].timeout,
self.transport.create_autoscaling_policy,
default_retry=self._method_configs["CreateAutoscalingPolicy"].retry,
default_timeout=self._method_configs["CreateAutoscalingPolicy"].timeout,
client_info=self._client_info,
)

request = autoscaling_policies_pb2.UpdateAutoscalingPolicyRequest(
policy=policy,
request = autoscaling_policies_pb2.CreateAutoscalingPolicyRequest(
parent=parent, policy=policy,
)
if metadata is None:
metadata = []
metadata = list(metadata)
try:
routing_header = [("policy.name", policy.name)]
routing_header = [("parent", parent)]
except AttributeError:
pass
else:
Expand All @@ -292,45 +302,35 @@ def update_autoscaling_policy(
)
metadata.append(routing_metadata)

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

def create_autoscaling_policy(
def update_autoscaling_policy(
self,
parent,
policy,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Creates new autoscaling policy.
Updates (replaces) autoscaling policy.
Disabled check for update_mask, because all updates will be full
replacements.
Example:
>>> from google.cloud import dataproc_v1
>>>
>>> client = dataproc_v1.AutoscalingPolicyServiceClient()
>>>
>>> parent = client.region_path('[PROJECT]', '[REGION]')
>>>
>>> # TODO: Initialize `policy`:
>>> policy = {}
>>>
>>> response = client.create_autoscaling_policy(parent, policy)
>>> response = client.update_autoscaling_policy(policy)
Args:
parent (str): Required. The "resource name" of the region or location, as
described in https://cloud.google.com/apis/design/resource_names.
- For ``projects.regions.autoscalingPolicies.create``, the resource
name of the region has the following format:
``projects/{project_id}/regions/{region}``
- For ``projects.locations.autoscalingPolicies.create``, the resource
name of the location has the following format:
``projects/{project_id}/locations/{location}``
policy (Union[dict, ~google.cloud.dataproc_v1.types.AutoscalingPolicy]): Required. The autoscaling policy to create.
policy (Union[dict, ~google.cloud.dataproc_v1.types.AutoscalingPolicy]): Required. The updated autoscaling policy.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.dataproc_v1.types.AutoscalingPolicy`
Expand All @@ -354,24 +354,24 @@ def create_autoscaling_policy(
ValueError: If the parameters are invalid.
"""
# Wrap the transport method to add retry and timeout logic.
if "create_autoscaling_policy" not in self._inner_api_calls:
if "update_autoscaling_policy" not in self._inner_api_calls:
self._inner_api_calls[
"create_autoscaling_policy"
"update_autoscaling_policy"
] = google.api_core.gapic_v1.method.wrap_method(
self.transport.create_autoscaling_policy,
default_retry=self._method_configs["CreateAutoscalingPolicy"].retry,
default_timeout=self._method_configs["CreateAutoscalingPolicy"].timeout,
self.transport.update_autoscaling_policy,
default_retry=self._method_configs["UpdateAutoscalingPolicy"].retry,
default_timeout=self._method_configs["UpdateAutoscalingPolicy"].timeout,
client_info=self._client_info,
)

request = autoscaling_policies_pb2.CreateAutoscalingPolicyRequest(
parent=parent, policy=policy,
request = autoscaling_policies_pb2.UpdateAutoscalingPolicyRequest(
policy=policy,
)
if metadata is None:
metadata = []
metadata = list(metadata)
try:
routing_header = [("parent", parent)]
routing_header = [("policy.name", policy.name)]
except AttributeError:
pass
else:
Expand All @@ -380,7 +380,7 @@ def create_autoscaling_policy(
)
metadata.append(routing_metadata)

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

Expand Down
Expand Up @@ -2,45 +2,136 @@
"interfaces": {
"google.cloud.dataproc.v1.AutoscalingPolicyService": {
"retry_codes": {
"idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
"non_idempotent": [],
"retry_policy_4_codes": [
"DEADLINE_EXCEEDED",
"INTERNAL",
"UNAVAILABLE",
],
"retry_policy_1_codes": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
"retry_policy_6_codes": [
"INTERNAL",
"DEADLINE_EXCEEDED",
"UNAVAILABLE",
],
"no_retry_codes": [],
"retry_policy_3_codes": ["UNAVAILABLE"],
"retry_policy_2_codes": [
"DEADLINE_EXCEEDED",
"INTERNAL",
"UNAVAILABLE",
],
"no_retry_1_codes": [],
"retry_policy_5_codes": ["UNAVAILABLE"],
"retry_policy_7_codes": ["UNAVAILABLE"],
},
"retry_params": {
"default": {
"retry_policy_1_params": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 20000,
"initial_rpc_timeout_millis": 600000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 20000,
"max_rpc_timeout_millis": 600000,
"total_timeout_millis": 600000,
}
},
"retry_policy_3_params": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 600000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 600000,
"total_timeout_millis": 600000,
},
"retry_policy_2_params": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 900000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 900000,
"total_timeout_millis": 900000,
},
"retry_policy_6_params": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 300000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 300000,
"total_timeout_millis": 300000,
},
"retry_policy_7_params": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 900000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 900000,
"total_timeout_millis": 900000,
},
"retry_policy_5_params": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 300000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 300000,
"total_timeout_millis": 300000,
},
"retry_policy_4_params": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 600000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 600000,
"total_timeout_millis": 600000,
},
"no_retry_params": {
"initial_retry_delay_millis": 0,
"retry_delay_multiplier": 0.0,
"max_retry_delay_millis": 0,
"initial_rpc_timeout_millis": 0,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 0,
"total_timeout_millis": 0,
},
"no_retry_1_params": {
"initial_retry_delay_millis": 0,
"retry_delay_multiplier": 0.0,
"max_retry_delay_millis": 0,
"initial_rpc_timeout_millis": 600000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 600000,
"total_timeout_millis": 600000,
},
},
"methods": {
"UpdateAutoscalingPolicy": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"CreateAutoscalingPolicy": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
"timeout_millis": 600000,
"retry_codes_name": "no_retry_1_codes",
"retry_params_name": "no_retry_1_params",
},
"UpdateAutoscalingPolicy": {
"timeout_millis": 600000,
"retry_codes_name": "retry_policy_1_codes",
"retry_params_name": "retry_policy_1_params",
},
"GetAutoscalingPolicy": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
"timeout_millis": 600000,
"retry_codes_name": "retry_policy_1_codes",
"retry_params_name": "retry_policy_1_params",
},
"ListAutoscalingPolicies": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
"timeout_millis": 600000,
"retry_codes_name": "retry_policy_1_codes",
"retry_params_name": "retry_policy_1_params",
},
"DeleteAutoscalingPolicy": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
"timeout_millis": 600000,
"retry_codes_name": "no_retry_1_codes",
"retry_params_name": "no_retry_1_params",
},
},
}
Expand Down

0 comments on commit 822315e

Please sign in to comment.