Skip to content

Commit 271f3ef

Browse files
authored
Fix client_info bug, update docstrings via synth. (googleapis#6442)
Remove now-spurious replacements from synth. Fix newly-generated raw HTML junk in docstrings. Closes googleapis#6411.
1 parent 1787742 commit 271f3ef

File tree

6 files changed

+91
-83
lines changed

6 files changed

+91
-83
lines changed

error_reporting/google/cloud/errorreporting_v1beta1/gapic/enums.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ class TimedCountAlignment(enum.IntEnum):
2424
2525
Attributes:
2626
ERROR_COUNT_ALIGNMENT_UNSPECIFIED (int): No alignment specified.
27-
ALIGNMENT_EQUAL_ROUNDED (int): The time periods shall be consecutive, have width equal to the
28-
requested duration, and be aligned at the ``alignment_time`` provided in
29-
the request.
30-
The ``alignment_time`` does not have to be inside the query period but
31-
even if it is outside, only time periods are returned which overlap
32-
with the query period.
33-
A rounded alignment will typically result in a
34-
different size of the first or the last time period.
27+
ALIGNMENT_EQUAL_ROUNDED (int): The time periods shall be consecutive, have width equal to the requested
28+
duration, and be aligned at the ``alignment_time`` provided in the
29+
request. The ``alignment_time`` does not have to be inside the query
30+
period but even if it is outside, only time periods are returned which
31+
overlap with the query period. A rounded alignment will typically result
32+
in a different size of the first or the last time period.
3533
ALIGNMENT_EQUAL_AT_END (int): The time periods shall be consecutive, have width equal to the
3634
requested duration, and be aligned at the end of the requested time
3735
period. This can result in a different size of the

error_reporting/google/cloud/errorreporting_v1beta1/gapic/error_group_service_client.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ def __init__(self,
146146
)
147147

148148
if client_info is None:
149-
client_info = (
150-
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
151-
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
149+
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
150+
gapic_version=_GAPIC_LIBRARY_VERSION, )
151+
else:
152+
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
152153
self._client_info = client_info
153154

154155
# Parse out the default settings for retry and timeout for each RPC
@@ -184,13 +185,10 @@ def get_group(self,
184185
185186
Args:
186187
group_name (str): [Required] The group resource name. Written as
187-
<code>projects/<var>projectID</var>/groups/<var>group_name</var></code>.
188-
Call
189-
<a href=\"/error-reporting/reference/rest/v1beta1/projects.groupStats/list\">
190-
<code>groupStats.list</code></a> to return a list of groups belonging to
191-
this project.
188+
projects/projectID/groups/group\_name. Call groupStats.list to return a
189+
list of groups belonging to this project.
192190
193-
Example: <code>projects/my-project-123/groups/my-group</code>
191+
Example: projects/my-project-123/groups/my-group
194192
retry (Optional[google.api_core.retry.Retry]): A retry object used
195193
to retry requests. If ``None`` is specified, requests will not
196194
be retried.
@@ -239,13 +237,14 @@ def update_group(self,
239237
>>>
240238
>>> client = errorreporting_v1beta1.ErrorGroupServiceClient()
241239
>>>
242-
>>> # TODO: Initialize ``group``:
240+
>>> # TODO: Initialize `group`:
243241
>>> group = {}
244242
>>>
245243
>>> response = client.update_group(group)
246244
247245
Args:
248246
group (Union[dict, ~google.cloud.errorreporting_v1beta1.types.ErrorGroup]): [Required] The group which replaces the resource on the server.
247+
249248
If a dict is provided, it must be of the same form as the protobuf
250249
message :class:`~google.cloud.errorreporting_v1beta1.types.ErrorGroup`
251250
retry (Optional[google.api_core.retry.Retry]): A retry object used

error_reporting/google/cloud/errorreporting_v1beta1/gapic/error_stats_service_client.py

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ def __init__(self,
154154
)
155155

156156
if client_info is None:
157-
client_info = (
158-
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
159-
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
157+
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
158+
gapic_version=_GAPIC_LIBRARY_VERSION, )
159+
else:
160+
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
160161
self._client_info = client_info
161162

162163
# Parse out the default settings for retry and timeout for each RPC
@@ -196,7 +197,7 @@ def list_group_stats(self,
196197
>>>
197198
>>> project_name = client.project_path('[PROJECT]')
198199
>>>
199-
>>> # TODO: Initialize ``time_range``:
200+
>>> # TODO: Initialize `time_range`:
200201
>>> time_range = {}
201202
>>>
202203
>>> # Iterate over all results
@@ -208,45 +209,46 @@ def list_group_stats(self,
208209
>>> # Alternatively:
209210
>>>
210211
>>> # Iterate over results one page at a time
211-
>>> for page in client.list_group_stats(project_name, time_range, options=CallOptions(page_token=INITIAL_PAGE)):
212+
>>> for page in client.list_group_stats(project_name, time_range).pages:
212213
... for element in page:
213214
... # process element
214215
... pass
215216
216217
Args:
217-
project_name (str): [Required] The resource name of the Google Cloud Platform project. Written
218-
as <code>projects/</code> plus the
219-
<a href=\"https://support.google.com/cloud/answer/6158840\">Google Cloud
220-
Platform project ID</a>.
221-
222-
Example: <code>projects/my-project-123</code>.
223-
time_range (Union[dict, ~google.cloud.errorreporting_v1beta1.types.QueryTimeRange]): [Optional] List data for the given time range.
224-
If not set a default time range is used. The field time_range_begin
225-
in the response will specify the beginning of this time range.
226-
Only <code>ErrorGroupStats</code> with a non-zero count in the given time
227-
range are returned, unless the request contains an explicit group_id list.
228-
If a group_id list is given, also <code>ErrorGroupStats</code> with zero
229-
occurrences are returned.
218+
project_name (str): [Required] The resource name of the Google Cloud Platform project.
219+
Written as projects/ plus the Google Cloud Platform project ID.
220+
221+
Example: projects/my-project-123.
222+
time_range (Union[dict, ~google.cloud.errorreporting_v1beta1.types.QueryTimeRange]): [Optional] List data for the given time range. If not set a default time
223+
range is used. The field time\_range\_begin in the response will specify
224+
the beginning of this time range. Only ErrorGroupStats with a non-zero
225+
count in the given time range are returned, unless the request contains
226+
an explicit group\_id list. If a group\_id list is given, also
227+
ErrorGroupStats with zero occurrences are returned.
228+
230229
If a dict is provided, it must be of the same form as the protobuf
231230
message :class:`~google.cloud.errorreporting_v1beta1.types.QueryTimeRange`
232-
group_id (list[str]): [Optional] List all <code>ErrorGroupStats</code> with these IDs.
233-
service_filter (Union[dict, ~google.cloud.errorreporting_v1beta1.types.ServiceContextFilter]): [Optional] List only <code>ErrorGroupStats</code> which belong to a service
234-
context that matches the filter.
235-
Data for all service contexts is returned if this field is not specified.
231+
group_id (list[str]): [Optional] List all ErrorGroupStats with these IDs.
232+
service_filter (Union[dict, ~google.cloud.errorreporting_v1beta1.types.ServiceContextFilter]): [Optional] List only ErrorGroupStats which belong to a service context
233+
that matches the filter. Data for all service contexts is returned if
234+
this field is not specified.
235+
236236
If a dict is provided, it must be of the same form as the protobuf
237237
message :class:`~google.cloud.errorreporting_v1beta1.types.ServiceContextFilter`
238238
timed_count_duration (Union[dict, ~google.cloud.errorreporting_v1beta1.types.Duration]): [Optional] The preferred duration for a single returned ``TimedCount``.
239239
If not set, no timed counts are returned.
240+
240241
If a dict is provided, it must be of the same form as the protobuf
241242
message :class:`~google.cloud.errorreporting_v1beta1.types.Duration`
242-
alignment (~google.cloud.errorreporting_v1beta1.types.TimedCountAlignment): [Optional] The alignment of the timed counts to be returned.
243-
Default is ``ALIGNMENT_EQUAL_AT_END``.
243+
alignment (~google.cloud.errorreporting_v1beta1.types.TimedCountAlignment): [Optional] The alignment of the timed counts to be returned. Default is
244+
``ALIGNMENT_EQUAL_AT_END``.
244245
alignment_time (Union[dict, ~google.cloud.errorreporting_v1beta1.types.Timestamp]): [Optional] Time where the timed counts shall be aligned if rounded
245246
alignment is chosen. Default is 00:00 UTC.
247+
246248
If a dict is provided, it must be of the same form as the protobuf
247249
message :class:`~google.cloud.errorreporting_v1beta1.types.Timestamp`
248-
order (~google.cloud.errorreporting_v1beta1.types.ErrorGroupOrder): [Optional] The sort order in which the results are returned.
249-
Default is ``COUNT_DESC``.
250+
order (~google.cloud.errorreporting_v1beta1.types.ErrorGroupOrder): [Optional] The sort order in which the results are returned. Default is
251+
``COUNT_DESC``.
250252
page_size (int): The maximum number of resources contained in the
251253
underlying API response. If page streaming is performed per-
252254
resource, this parameter does not affect the return value. If page
@@ -329,7 +331,7 @@ def list_events(self,
329331
>>>
330332
>>> project_name = client.project_path('[PROJECT]')
331333
>>>
332-
>>> # TODO: Initialize ``group_id``:
334+
>>> # TODO: Initialize `group_id`:
333335
>>> group_id = ''
334336
>>>
335337
>>> # Iterate over all results
@@ -341,26 +343,27 @@ def list_events(self,
341343
>>> # Alternatively:
342344
>>>
343345
>>> # Iterate over results one page at a time
344-
>>> for page in client.list_events(project_name, group_id, options=CallOptions(page_token=INITIAL_PAGE)):
346+
>>> for page in client.list_events(project_name, group_id).pages:
345347
... for element in page:
346348
... # process element
347349
... pass
348350
349351
Args:
350-
project_name (str): [Required] The resource name of the Google Cloud Platform project. Written
351-
as ``projects/`` plus the
352-
[Google Cloud Platform project
353-
ID](https://support.google.com/cloud/answer/6158840).
354-
Example: ``projects/my-project-123``.
352+
project_name (str): [Required] The resource name of the Google Cloud Platform project.
353+
Written as ``projects/`` plus the `Google Cloud Platform project
354+
ID <https://support.google.com/cloud/answer/6158840>`__. Example:
355+
``projects/my-project-123``.
355356
group_id (str): [Required] The group for which events shall be returned.
356357
service_filter (Union[dict, ~google.cloud.errorreporting_v1beta1.types.ServiceContextFilter]): [Optional] List only ErrorGroups which belong to a service context that
357-
matches the filter.
358-
Data for all service contexts is returned if this field is not specified.
358+
matches the filter. Data for all service contexts is returned if this
359+
field is not specified.
360+
359361
If a dict is provided, it must be of the same form as the protobuf
360362
message :class:`~google.cloud.errorreporting_v1beta1.types.ServiceContextFilter`
361-
time_range (Union[dict, ~google.cloud.errorreporting_v1beta1.types.QueryTimeRange]): [Optional] List only data for the given time range.
362-
If not set a default time range is used. The field time_range_begin
363-
in the response will specify the beginning of this time range.
363+
time_range (Union[dict, ~google.cloud.errorreporting_v1beta1.types.QueryTimeRange]): [Optional] List only data for the given time range. If not set a default
364+
time range is used. The field time\_range\_begin in the response will
365+
specify the beginning of this time range.
366+
364367
If a dict is provided, it must be of the same form as the protobuf
365368
message :class:`~google.cloud.errorreporting_v1beta1.types.QueryTimeRange`
366369
page_size (int): The maximum number of resources contained in the
@@ -439,11 +442,10 @@ def delete_events(self,
439442
>>> response = client.delete_events(project_name)
440443
441444
Args:
442-
project_name (str): [Required] The resource name of the Google Cloud Platform project. Written
443-
as ``projects/`` plus the
444-
[Google Cloud Platform project
445-
ID](https://support.google.com/cloud/answer/6158840).
446-
Example: ``projects/my-project-123``.
445+
project_name (str): [Required] The resource name of the Google Cloud Platform project.
446+
Written as ``projects/`` plus the `Google Cloud Platform project
447+
ID <https://support.google.com/cloud/answer/6158840>`__. Example:
448+
``projects/my-project-123``.
447449
retry (Optional[google.api_core.retry.Retry]): A retry object used
448450
to retry requests. If ``None`` is specified, requests will not
449451
be retried.

error_reporting/google/cloud/errorreporting_v1beta1/gapic/report_errors_service_client.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ def __init__(self,
151151
)
152152

153153
if client_info is None:
154-
client_info = (
155-
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
156-
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
154+
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
155+
gapic_version=_GAPIC_LIBRARY_VERSION, )
156+
else:
157+
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
157158
self._client_info = client_info
158159

159160
# Parse out the default settings for retry and timeout for each RPC
@@ -179,31 +180,25 @@ def report_error_event(self,
179180
"""
180181
Report an individual error event.
181182
182-
This endpoint accepts <strong>either</strong> an OAuth token,
183-
<strong>or</strong> an
184-
<a href=\"https://support.google.com/cloud/answer/6158862\">API key</a>
185-
for authentication. To use an API key, append it to the URL as the value of
186-
a ``key`` parameter. For example:
187-
<pre>POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456</pre>
188-
189183
Example:
190184
>>> from google.cloud import errorreporting_v1beta1
191185
>>>
192186
>>> client = errorreporting_v1beta1.ReportErrorsServiceClient()
193187
>>>
194188
>>> project_name = client.project_path('[PROJECT]')
195189
>>>
196-
>>> # TODO: Initialize ``event``:
190+
>>> # TODO: Initialize `event`:
197191
>>> event = {}
198192
>>>
199193
>>> response = client.report_error_event(project_name, event)
200194
201195
Args:
202-
project_name (str): [Required] The resource name of the Google Cloud Platform project. Written
203-
as ``projects/`` plus the
204-
`Google Cloud Platform project ID <https://support.google.com/cloud/answer/6158840>`_.
205-
Example: ``projects/my-project-123``.
196+
project_name (str): [Required] The resource name of the Google Cloud Platform project.
197+
Written as ``projects/`` plus the `Google Cloud Platform project
198+
ID <https://support.google.com/cloud/answer/6158840>`__. Example:
199+
``projects/my-project-123``.
206200
event (Union[dict, ~google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent]): [Required] The error event to be reported.
201+
207202
If a dict is provided, it must be of the same form as the protobuf
208203
message :class:`~google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent`
209204
retry (Optional[google.api_core.retry.Retry]): A retry object used

error_reporting/google/cloud/errorreporting_v1beta1/gapic/transports/report_errors_service_grpc_transport.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ def report_error_event(self):
9898
9999
Report an individual error event.
100100
101-
This endpoint accepts <strong>either</strong> an OAuth token,
102-
<strong>or</strong> an
103-
<a href=\"https://support.google.com/cloud/answer/6158862\">API key</a>
104-
for authentication. To use an API key, append it to the URL as the value of
105-
a ``key`` parameter. For example:
106-
<pre>POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456</pre>
107-
108101
Returns:
109102
Callable: A callable which accepts the appropriate
110103
deserialized request object and returns a

error_reporting/synth.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,24 @@
3838
r"from google.devtools.clouderrorreporting_v1beta1.proto import ",
3939
r"from google.cloud.errorreporting_v1beta1.proto import ",
4040
)
41+
42+
# Fix up docstrings in GAPIC clients
43+
DISCARD_AUTH_BOILERPLATE = r"""
44+
This endpoint accepts either an OAuth token, or an API key for
45+
authentication. To use an API key, append it to the URL as the value of
46+
a ``key`` parameter. For example:
47+
48+
\.\. raw:: html
49+
<pre>POST .*
50+
"""
51+
52+
targets = [
53+
'google/cloud/errorreporting_v1beta1/gapic/*_client.py',
54+
'google/cloud/errorreporting_v1beta1/gapic/transports/*_transport.py',
55+
]
56+
57+
s.replace(
58+
targets,
59+
DISCARD_AUTH_BOILERPLATE,
60+
r"",
61+
)

0 commit comments

Comments
 (0)