Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/logging_v2/services/config_service_v2/pagers.py: 33%
174 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:30 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:30 +0000
1# -*- coding: utf-8 -*-
2# Copyright 2022 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16from typing import (
17 Any,
18 AsyncIterator,
19 Awaitable,
20 Callable,
21 Sequence,
22 Tuple,
23 Optional,
24 Iterator,
25)
27from google.cloud.logging_v2.types import logging_config
30class ListBucketsPager:
31 """A pager for iterating through ``list_buckets`` requests.
33 This class thinly wraps an initial
34 :class:`google.cloud.logging_v2.types.ListBucketsResponse` object, and
35 provides an ``__iter__`` method to iterate through its
36 ``buckets`` field.
38 If there are more pages, the ``__iter__`` method will make additional
39 ``ListBuckets`` requests and continue to iterate
40 through the ``buckets`` field on the
41 corresponding responses.
43 All the usual :class:`google.cloud.logging_v2.types.ListBucketsResponse`
44 attributes are available on the pager. If multiple requests are made, only
45 the most recent response is retained, and thus used for attribute lookup.
46 """
48 def __init__(
49 self,
50 method: Callable[..., logging_config.ListBucketsResponse],
51 request: logging_config.ListBucketsRequest,
52 response: logging_config.ListBucketsResponse,
53 *,
54 metadata: Sequence[Tuple[str, str]] = ()
55 ):
56 """Instantiate the pager.
58 Args:
59 method (Callable): The method that was originally called, and
60 which instantiated this pager.
61 request (google.cloud.logging_v2.types.ListBucketsRequest):
62 The initial request object.
63 response (google.cloud.logging_v2.types.ListBucketsResponse):
64 The initial response object.
65 metadata (Sequence[Tuple[str, str]]): Strings which should be
66 sent along with the request as metadata.
67 """
68 self._method = method
69 self._request = logging_config.ListBucketsRequest(request)
70 self._response = response
71 self._metadata = metadata
73 def __getattr__(self, name: str) -> Any:
74 return getattr(self._response, name)
76 @property
77 def pages(self) -> Iterator[logging_config.ListBucketsResponse]:
78 yield self._response
79 while self._response.next_page_token:
80 self._request.page_token = self._response.next_page_token
81 self._response = self._method(self._request, metadata=self._metadata)
82 yield self._response
84 def __iter__(self) -> Iterator[logging_config.LogBucket]:
85 for page in self.pages:
86 yield from page.buckets
88 def __repr__(self) -> str:
89 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
92class ListBucketsAsyncPager:
93 """A pager for iterating through ``list_buckets`` requests.
95 This class thinly wraps an initial
96 :class:`google.cloud.logging_v2.types.ListBucketsResponse` object, and
97 provides an ``__aiter__`` method to iterate through its
98 ``buckets`` field.
100 If there are more pages, the ``__aiter__`` method will make additional
101 ``ListBuckets`` requests and continue to iterate
102 through the ``buckets`` field on the
103 corresponding responses.
105 All the usual :class:`google.cloud.logging_v2.types.ListBucketsResponse`
106 attributes are available on the pager. If multiple requests are made, only
107 the most recent response is retained, and thus used for attribute lookup.
108 """
110 def __init__(
111 self,
112 method: Callable[..., Awaitable[logging_config.ListBucketsResponse]],
113 request: logging_config.ListBucketsRequest,
114 response: logging_config.ListBucketsResponse,
115 *,
116 metadata: Sequence[Tuple[str, str]] = ()
117 ):
118 """Instantiates the pager.
120 Args:
121 method (Callable): The method that was originally called, and
122 which instantiated this pager.
123 request (google.cloud.logging_v2.types.ListBucketsRequest):
124 The initial request object.
125 response (google.cloud.logging_v2.types.ListBucketsResponse):
126 The initial response object.
127 metadata (Sequence[Tuple[str, str]]): Strings which should be
128 sent along with the request as metadata.
129 """
130 self._method = method
131 self._request = logging_config.ListBucketsRequest(request)
132 self._response = response
133 self._metadata = metadata
135 def __getattr__(self, name: str) -> Any:
136 return getattr(self._response, name)
138 @property
139 async def pages(self) -> AsyncIterator[logging_config.ListBucketsResponse]:
140 yield self._response
141 while self._response.next_page_token:
142 self._request.page_token = self._response.next_page_token
143 self._response = await self._method(self._request, metadata=self._metadata)
144 yield self._response
146 def __aiter__(self) -> AsyncIterator[logging_config.LogBucket]:
147 async def async_generator():
148 async for page in self.pages:
149 for response in page.buckets:
150 yield response
152 return async_generator()
154 def __repr__(self) -> str:
155 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
158class ListViewsPager:
159 """A pager for iterating through ``list_views`` requests.
161 This class thinly wraps an initial
162 :class:`google.cloud.logging_v2.types.ListViewsResponse` object, and
163 provides an ``__iter__`` method to iterate through its
164 ``views`` field.
166 If there are more pages, the ``__iter__`` method will make additional
167 ``ListViews`` requests and continue to iterate
168 through the ``views`` field on the
169 corresponding responses.
171 All the usual :class:`google.cloud.logging_v2.types.ListViewsResponse`
172 attributes are available on the pager. If multiple requests are made, only
173 the most recent response is retained, and thus used for attribute lookup.
174 """
176 def __init__(
177 self,
178 method: Callable[..., logging_config.ListViewsResponse],
179 request: logging_config.ListViewsRequest,
180 response: logging_config.ListViewsResponse,
181 *,
182 metadata: Sequence[Tuple[str, str]] = ()
183 ):
184 """Instantiate the pager.
186 Args:
187 method (Callable): The method that was originally called, and
188 which instantiated this pager.
189 request (google.cloud.logging_v2.types.ListViewsRequest):
190 The initial request object.
191 response (google.cloud.logging_v2.types.ListViewsResponse):
192 The initial response object.
193 metadata (Sequence[Tuple[str, str]]): Strings which should be
194 sent along with the request as metadata.
195 """
196 self._method = method
197 self._request = logging_config.ListViewsRequest(request)
198 self._response = response
199 self._metadata = metadata
201 def __getattr__(self, name: str) -> Any:
202 return getattr(self._response, name)
204 @property
205 def pages(self) -> Iterator[logging_config.ListViewsResponse]:
206 yield self._response
207 while self._response.next_page_token:
208 self._request.page_token = self._response.next_page_token
209 self._response = self._method(self._request, metadata=self._metadata)
210 yield self._response
212 def __iter__(self) -> Iterator[logging_config.LogView]:
213 for page in self.pages:
214 yield from page.views
216 def __repr__(self) -> str:
217 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
220class ListViewsAsyncPager:
221 """A pager for iterating through ``list_views`` requests.
223 This class thinly wraps an initial
224 :class:`google.cloud.logging_v2.types.ListViewsResponse` object, and
225 provides an ``__aiter__`` method to iterate through its
226 ``views`` field.
228 If there are more pages, the ``__aiter__`` method will make additional
229 ``ListViews`` requests and continue to iterate
230 through the ``views`` field on the
231 corresponding responses.
233 All the usual :class:`google.cloud.logging_v2.types.ListViewsResponse`
234 attributes are available on the pager. If multiple requests are made, only
235 the most recent response is retained, and thus used for attribute lookup.
236 """
238 def __init__(
239 self,
240 method: Callable[..., Awaitable[logging_config.ListViewsResponse]],
241 request: logging_config.ListViewsRequest,
242 response: logging_config.ListViewsResponse,
243 *,
244 metadata: Sequence[Tuple[str, str]] = ()
245 ):
246 """Instantiates the pager.
248 Args:
249 method (Callable): The method that was originally called, and
250 which instantiated this pager.
251 request (google.cloud.logging_v2.types.ListViewsRequest):
252 The initial request object.
253 response (google.cloud.logging_v2.types.ListViewsResponse):
254 The initial response object.
255 metadata (Sequence[Tuple[str, str]]): Strings which should be
256 sent along with the request as metadata.
257 """
258 self._method = method
259 self._request = logging_config.ListViewsRequest(request)
260 self._response = response
261 self._metadata = metadata
263 def __getattr__(self, name: str) -> Any:
264 return getattr(self._response, name)
266 @property
267 async def pages(self) -> AsyncIterator[logging_config.ListViewsResponse]:
268 yield self._response
269 while self._response.next_page_token:
270 self._request.page_token = self._response.next_page_token
271 self._response = await self._method(self._request, metadata=self._metadata)
272 yield self._response
274 def __aiter__(self) -> AsyncIterator[logging_config.LogView]:
275 async def async_generator():
276 async for page in self.pages:
277 for response in page.views:
278 yield response
280 return async_generator()
282 def __repr__(self) -> str:
283 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
286class ListSinksPager:
287 """A pager for iterating through ``list_sinks`` requests.
289 This class thinly wraps an initial
290 :class:`google.cloud.logging_v2.types.ListSinksResponse` object, and
291 provides an ``__iter__`` method to iterate through its
292 ``sinks`` field.
294 If there are more pages, the ``__iter__`` method will make additional
295 ``ListSinks`` requests and continue to iterate
296 through the ``sinks`` field on the
297 corresponding responses.
299 All the usual :class:`google.cloud.logging_v2.types.ListSinksResponse`
300 attributes are available on the pager. If multiple requests are made, only
301 the most recent response is retained, and thus used for attribute lookup.
302 """
304 def __init__(
305 self,
306 method: Callable[..., logging_config.ListSinksResponse],
307 request: logging_config.ListSinksRequest,
308 response: logging_config.ListSinksResponse,
309 *,
310 metadata: Sequence[Tuple[str, str]] = ()
311 ):
312 """Instantiate the pager.
314 Args:
315 method (Callable): The method that was originally called, and
316 which instantiated this pager.
317 request (google.cloud.logging_v2.types.ListSinksRequest):
318 The initial request object.
319 response (google.cloud.logging_v2.types.ListSinksResponse):
320 The initial response object.
321 metadata (Sequence[Tuple[str, str]]): Strings which should be
322 sent along with the request as metadata.
323 """
324 self._method = method
325 self._request = logging_config.ListSinksRequest(request)
326 self._response = response
327 self._metadata = metadata
329 def __getattr__(self, name: str) -> Any:
330 return getattr(self._response, name)
332 @property
333 def pages(self) -> Iterator[logging_config.ListSinksResponse]:
334 yield self._response
335 while self._response.next_page_token:
336 self._request.page_token = self._response.next_page_token
337 self._response = self._method(self._request, metadata=self._metadata)
338 yield self._response
340 def __iter__(self) -> Iterator[logging_config.LogSink]:
341 for page in self.pages:
342 yield from page.sinks
344 def __repr__(self) -> str:
345 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
348class ListSinksAsyncPager:
349 """A pager for iterating through ``list_sinks`` requests.
351 This class thinly wraps an initial
352 :class:`google.cloud.logging_v2.types.ListSinksResponse` object, and
353 provides an ``__aiter__`` method to iterate through its
354 ``sinks`` field.
356 If there are more pages, the ``__aiter__`` method will make additional
357 ``ListSinks`` requests and continue to iterate
358 through the ``sinks`` field on the
359 corresponding responses.
361 All the usual :class:`google.cloud.logging_v2.types.ListSinksResponse`
362 attributes are available on the pager. If multiple requests are made, only
363 the most recent response is retained, and thus used for attribute lookup.
364 """
366 def __init__(
367 self,
368 method: Callable[..., Awaitable[logging_config.ListSinksResponse]],
369 request: logging_config.ListSinksRequest,
370 response: logging_config.ListSinksResponse,
371 *,
372 metadata: Sequence[Tuple[str, str]] = ()
373 ):
374 """Instantiates the pager.
376 Args:
377 method (Callable): The method that was originally called, and
378 which instantiated this pager.
379 request (google.cloud.logging_v2.types.ListSinksRequest):
380 The initial request object.
381 response (google.cloud.logging_v2.types.ListSinksResponse):
382 The initial response object.
383 metadata (Sequence[Tuple[str, str]]): Strings which should be
384 sent along with the request as metadata.
385 """
386 self._method = method
387 self._request = logging_config.ListSinksRequest(request)
388 self._response = response
389 self._metadata = metadata
391 def __getattr__(self, name: str) -> Any:
392 return getattr(self._response, name)
394 @property
395 async def pages(self) -> AsyncIterator[logging_config.ListSinksResponse]:
396 yield self._response
397 while self._response.next_page_token:
398 self._request.page_token = self._response.next_page_token
399 self._response = await self._method(self._request, metadata=self._metadata)
400 yield self._response
402 def __aiter__(self) -> AsyncIterator[logging_config.LogSink]:
403 async def async_generator():
404 async for page in self.pages:
405 for response in page.sinks:
406 yield response
408 return async_generator()
410 def __repr__(self) -> str:
411 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
414class ListExclusionsPager:
415 """A pager for iterating through ``list_exclusions`` requests.
417 This class thinly wraps an initial
418 :class:`google.cloud.logging_v2.types.ListExclusionsResponse` object, and
419 provides an ``__iter__`` method to iterate through its
420 ``exclusions`` field.
422 If there are more pages, the ``__iter__`` method will make additional
423 ``ListExclusions`` requests and continue to iterate
424 through the ``exclusions`` field on the
425 corresponding responses.
427 All the usual :class:`google.cloud.logging_v2.types.ListExclusionsResponse`
428 attributes are available on the pager. If multiple requests are made, only
429 the most recent response is retained, and thus used for attribute lookup.
430 """
432 def __init__(
433 self,
434 method: Callable[..., logging_config.ListExclusionsResponse],
435 request: logging_config.ListExclusionsRequest,
436 response: logging_config.ListExclusionsResponse,
437 *,
438 metadata: Sequence[Tuple[str, str]] = ()
439 ):
440 """Instantiate the pager.
442 Args:
443 method (Callable): The method that was originally called, and
444 which instantiated this pager.
445 request (google.cloud.logging_v2.types.ListExclusionsRequest):
446 The initial request object.
447 response (google.cloud.logging_v2.types.ListExclusionsResponse):
448 The initial response object.
449 metadata (Sequence[Tuple[str, str]]): Strings which should be
450 sent along with the request as metadata.
451 """
452 self._method = method
453 self._request = logging_config.ListExclusionsRequest(request)
454 self._response = response
455 self._metadata = metadata
457 def __getattr__(self, name: str) -> Any:
458 return getattr(self._response, name)
460 @property
461 def pages(self) -> Iterator[logging_config.ListExclusionsResponse]:
462 yield self._response
463 while self._response.next_page_token:
464 self._request.page_token = self._response.next_page_token
465 self._response = self._method(self._request, metadata=self._metadata)
466 yield self._response
468 def __iter__(self) -> Iterator[logging_config.LogExclusion]:
469 for page in self.pages:
470 yield from page.exclusions
472 def __repr__(self) -> str:
473 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
476class ListExclusionsAsyncPager:
477 """A pager for iterating through ``list_exclusions`` requests.
479 This class thinly wraps an initial
480 :class:`google.cloud.logging_v2.types.ListExclusionsResponse` object, and
481 provides an ``__aiter__`` method to iterate through its
482 ``exclusions`` field.
484 If there are more pages, the ``__aiter__`` method will make additional
485 ``ListExclusions`` requests and continue to iterate
486 through the ``exclusions`` field on the
487 corresponding responses.
489 All the usual :class:`google.cloud.logging_v2.types.ListExclusionsResponse`
490 attributes are available on the pager. If multiple requests are made, only
491 the most recent response is retained, and thus used for attribute lookup.
492 """
494 def __init__(
495 self,
496 method: Callable[..., Awaitable[logging_config.ListExclusionsResponse]],
497 request: logging_config.ListExclusionsRequest,
498 response: logging_config.ListExclusionsResponse,
499 *,
500 metadata: Sequence[Tuple[str, str]] = ()
501 ):
502 """Instantiates the pager.
504 Args:
505 method (Callable): The method that was originally called, and
506 which instantiated this pager.
507 request (google.cloud.logging_v2.types.ListExclusionsRequest):
508 The initial request object.
509 response (google.cloud.logging_v2.types.ListExclusionsResponse):
510 The initial response object.
511 metadata (Sequence[Tuple[str, str]]): Strings which should be
512 sent along with the request as metadata.
513 """
514 self._method = method
515 self._request = logging_config.ListExclusionsRequest(request)
516 self._response = response
517 self._metadata = metadata
519 def __getattr__(self, name: str) -> Any:
520 return getattr(self._response, name)
522 @property
523 async def pages(self) -> AsyncIterator[logging_config.ListExclusionsResponse]:
524 yield self._response
525 while self._response.next_page_token:
526 self._request.page_token = self._response.next_page_token
527 self._response = await self._method(self._request, metadata=self._metadata)
528 yield self._response
530 def __aiter__(self) -> AsyncIterator[logging_config.LogExclusion]:
531 async def async_generator():
532 async for page in self.pages:
533 for response in page.exclusions:
534 yield response
536 return async_generator()
538 def __repr__(self) -> str:
539 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)