Skip to content

Commit

Permalink
Fix client_info bug, update docstrings and timeouts. (#6416)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpebot authored and tseaver committed Nov 6, 2018
1 parent 1632b6f commit 83db4cd
Show file tree
Hide file tree
Showing 14 changed files with 400 additions and 395 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
class AlertPolicyServiceClient(object):
"""
The AlertPolicyService API is used to manage (list, create, delete,
edit) alert policies in Stackdriver Monitoring. An alerting policy is
a description of the conditions under which some aspect of your
system is considered to be \"unhealthy\" and the ways to notify
people or services about this state. In addition to using this API, alert
policies can also be managed through
`Stackdriver Monitoring <https://cloud.google.com/monitoring/docs/>`_,
which can be reached by clicking the \"Monitoring\" tab in
`Cloud Console <https://console.cloud.google.com/>`_.
edit) alert policies in Stackdriver Monitoring. An alerting policy is a
description of the conditions under which some aspect of your system is
considered to be "unhealthy" and the ways to notify people or services
about this state. In addition to using this API, alert policies can also
be managed through `Stackdriver
Monitoring <https://cloud.google.com/monitoring/docs/>`__, which can be
reached by clicking the "Monitoring" tab in `Cloud
Console <https://console.cloud.google.com/>`__.
"""

SERVICE_ADDRESS = 'monitoring.googleapis.com:443'
Expand Down Expand Up @@ -178,9 +178,10 @@ def __init__(self,
)

if client_info is None:
client_info = (
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
gapic_version=_GAPIC_LIBRARY_VERSION, )
else:
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
self._client_info = client_info

# Parse out the default settings for retry and timeout for each RPC
Expand Down Expand Up @@ -224,32 +225,30 @@ def list_alert_policies(self,
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_alert_policies(name, options=CallOptions(page_token=INITIAL_PAGE)):
>>> for page in client.list_alert_policies(name).pages:
... for element in page:
... # process element
... pass
Args:
name (str): The project whose alert policies are to be listed. The format is
projects/[PROJECT_ID]
projects/[PROJECT_ID]
Note that this field names the parent container in which the alerting
policies to be listed are stored. To retrieve a single alerting policy
by name, use the
``GetAlertPolicy``
operation, instead.
filter_ (str): If provided, this field specifies the criteria that must be met by
alert policies to be included in the response.
For more details, see [sorting and
filtering](/monitoring/api/v3/sorting-and-filtering).
by name, use the ``GetAlertPolicy`` operation, instead.
filter_ (str): If provided, this field specifies the criteria that must be met by alert
policies to be included in the response.
For more details, see `sorting and
filtering <https://cloud.google.com/monitoring/api/v3/sorting-and-filtering>`__.
order_by (str): A comma-separated list of fields by which to sort the result. Supports
the same set of field references as the ``filter`` field. Entries can be
prefixed with a minus sign to sort by the field in descending order.
For more details, see [sorting and
filtering](/monitoring/api/v3/sorting-and-filtering).
For more details, see `sorting and
filtering <https://cloud.google.com/monitoring/api/v3/sorting-and-filtering>`__.
page_size (int): The maximum number of resources contained in the
underlying API response. If page streaming is performed per-
resource, this parameter does not affect the return value. If page
Expand Down Expand Up @@ -332,7 +331,7 @@ def get_alert_policy(self,
Args:
name (str): The alerting policy to retrieve. The format is
projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will not
be retried.
Expand Down Expand Up @@ -386,7 +385,7 @@ def create_alert_policy(self,
>>>
>>> name = client.project_path('[PROJECT]')
>>>
>>> # TODO: Initialize ``alert_policy``:
>>> # TODO: Initialize `alert_policy`:
>>> alert_policy = {}
>>>
>>> response = client.create_alert_policy(name, alert_policy)
Expand All @@ -400,9 +399,10 @@ def create_alert_policy(self,
policy that is returned will have a name that contains a normalized
representation of this name as a prefix but adds a suffix of the form
``/alertPolicies/[POLICY_ID]``, identifying the policy in the container.
alert_policy (Union[dict, ~google.cloud.monitoring_v3.types.AlertPolicy]): The requested alerting policy. You should omit the ``name`` field in this
policy. The name will be returned in the new policy, including
a new [ALERT_POLICY_ID] value.
alert_policy (Union[dict, ~google.cloud.monitoring_v3.types.AlertPolicy]): The requested alerting policy. You should omit the ``name`` field in
this policy. The name will be returned in the new policy, including a
new [ALERT\_POLICY\_ID] value.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.monitoring_v3.types.AlertPolicy`
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -466,7 +466,7 @@ def delete_alert_policy(self,
Args:
name (str): The alerting policy to delete. The format is:
projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
For more information, see ``AlertPolicy``.
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -511,49 +511,51 @@ def update_alert_policy(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None):
"""
Updates an alerting policy. You can either replace the entire policy with
a new one or replace only certain fields in the current alerting policy by
specifying the fields to be updated via ``updateMask``. Returns the
updated alerting policy.
Updates an alerting policy. You can either replace the entire policy
with a new one or replace only certain fields in the current alerting
policy by specifying the fields to be updated via ``updateMask``.
Returns the updated alerting policy.
Example:
>>> from google.cloud import monitoring_v3
>>>
>>> client = monitoring_v3.AlertPolicyServiceClient()
>>>
>>> # TODO: Initialize ``alert_policy``:
>>> # TODO: Initialize `alert_policy`:
>>> alert_policy = {}
>>>
>>> response = client.update_alert_policy(alert_policy)
Args:
alert_policy (Union[dict, ~google.cloud.monitoring_v3.types.AlertPolicy]): Required. The updated alerting policy or the updated values for the
fields listed in ``update_mask``.
If ``update_mask`` is not empty, any fields in this policy that are
not in ``update_mask`` are ignored.
fields listed in ``update_mask``. If ``update_mask`` is not empty, any
fields in this policy that are not in ``update_mask`` are ignored.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.monitoring_v3.types.AlertPolicy`
update_mask (Union[dict, ~google.cloud.monitoring_v3.types.FieldMask]): Optional. A list of alerting policy field names. If this field is not
empty, each listed field in the existing alerting policy is set to the
value of the corresponding field in the supplied policy (``alert_policy``),
or to the field's default value if the field is not in the supplied
alerting policy. Fields not listed retain their previous value.
value of the corresponding field in the supplied policy
(``alert_policy``), or to the field's default value if the field is not
in the supplied alerting policy. Fields not listed retain their previous
value.
Examples of valid field masks include ``display_name``, ``documentation``,
``documentation.content``, ``documentation.mime_type``, ``user_labels``,
``user_label.nameofkey``, ``enabled``, ``conditions``, ``combiner``, etc.
Examples of valid field masks include ``display_name``,
``documentation``, ``documentation.content``,
``documentation.mime_type``, ``user_labels``, ``user_label.nameofkey``,
``enabled``, ``conditions``, ``combiner``, etc.
If this field is empty, then the supplied alerting policy replaces the
existing policy. It is the same as deleting the existing policy and
adding the supplied policy, except for the following:
+ The new policy will have the same ``[ALERT_POLICY_ID]`` as the former
policy. This gives you continuity with the former policy in your
notifications and incidents.
+ Conditions in the new policy will keep their former ``[CONDITION_ID]`` if
the supplied condition includes the `name` field with that
`[CONDITION_ID]`. If the supplied condition omits the `name` field,
then a new `[CONDITION_ID]` is created.
- The new policy will have the same ``[ALERT_POLICY_ID]`` as the former
policy. This gives you continuity with the former policy in your
notifications and incidents.
- Conditions in the new policy will keep their former
``[CONDITION_ID]`` if the supplied condition includes the ``name``
field with that ``[CONDITION_ID]``. If the supplied condition omits
the ``name`` field, then a new ``[CONDITION_ID]`` is created.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.monitoring_v3.types.FieldMask`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@
},
"methods": {
"ListAlertPolicies": {
"timeout_millis": 60000,
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"GetAlertPolicy": {
"timeout_millis": 60000,
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"CreateAlertPolicy": {
"timeout_millis": 60000,
"timeout_millis": 30000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"DeleteAlertPolicy": {
"timeout_millis": 60000,
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"UpdateAlertPolicy": {
"timeout_millis": 60000,
"timeout_millis": 30000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
}
Expand Down
Loading

0 comments on commit 83db4cd

Please sign in to comment.