Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/resourcemanager_v3/services/tag_bindings/pagers.py: 34%
88 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-06 06:03 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-06 06:03 +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 Iterator,
22 Optional,
23 Sequence,
24 Tuple,
25)
27from google.cloud.resourcemanager_v3.types import tag_bindings
30class ListTagBindingsPager:
31 """A pager for iterating through ``list_tag_bindings`` requests.
33 This class thinly wraps an initial
34 :class:`google.cloud.resourcemanager_v3.types.ListTagBindingsResponse` object, and
35 provides an ``__iter__`` method to iterate through its
36 ``tag_bindings`` field.
38 If there are more pages, the ``__iter__`` method will make additional
39 ``ListTagBindings`` requests and continue to iterate
40 through the ``tag_bindings`` field on the
41 corresponding responses.
43 All the usual :class:`google.cloud.resourcemanager_v3.types.ListTagBindingsResponse`
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[..., tag_bindings.ListTagBindingsResponse],
51 request: tag_bindings.ListTagBindingsRequest,
52 response: tag_bindings.ListTagBindingsResponse,
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.resourcemanager_v3.types.ListTagBindingsRequest):
62 The initial request object.
63 response (google.cloud.resourcemanager_v3.types.ListTagBindingsResponse):
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 = tag_bindings.ListTagBindingsRequest(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[tag_bindings.ListTagBindingsResponse]:
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[tag_bindings.TagBinding]:
85 for page in self.pages:
86 yield from page.tag_bindings
88 def __repr__(self) -> str:
89 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
92class ListTagBindingsAsyncPager:
93 """A pager for iterating through ``list_tag_bindings`` requests.
95 This class thinly wraps an initial
96 :class:`google.cloud.resourcemanager_v3.types.ListTagBindingsResponse` object, and
97 provides an ``__aiter__`` method to iterate through its
98 ``tag_bindings`` field.
100 If there are more pages, the ``__aiter__`` method will make additional
101 ``ListTagBindings`` requests and continue to iterate
102 through the ``tag_bindings`` field on the
103 corresponding responses.
105 All the usual :class:`google.cloud.resourcemanager_v3.types.ListTagBindingsResponse`
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[tag_bindings.ListTagBindingsResponse]],
113 request: tag_bindings.ListTagBindingsRequest,
114 response: tag_bindings.ListTagBindingsResponse,
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.resourcemanager_v3.types.ListTagBindingsRequest):
124 The initial request object.
125 response (google.cloud.resourcemanager_v3.types.ListTagBindingsResponse):
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 = tag_bindings.ListTagBindingsRequest(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[tag_bindings.ListTagBindingsResponse]:
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[tag_bindings.TagBinding]:
147 async def async_generator():
148 async for page in self.pages:
149 for response in page.tag_bindings:
150 yield response
152 return async_generator()
154 def __repr__(self) -> str:
155 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
158class ListEffectiveTagsPager:
159 """A pager for iterating through ``list_effective_tags`` requests.
161 This class thinly wraps an initial
162 :class:`google.cloud.resourcemanager_v3.types.ListEffectiveTagsResponse` object, and
163 provides an ``__iter__`` method to iterate through its
164 ``effective_tags`` field.
166 If there are more pages, the ``__iter__`` method will make additional
167 ``ListEffectiveTags`` requests and continue to iterate
168 through the ``effective_tags`` field on the
169 corresponding responses.
171 All the usual :class:`google.cloud.resourcemanager_v3.types.ListEffectiveTagsResponse`
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[..., tag_bindings.ListEffectiveTagsResponse],
179 request: tag_bindings.ListEffectiveTagsRequest,
180 response: tag_bindings.ListEffectiveTagsResponse,
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.resourcemanager_v3.types.ListEffectiveTagsRequest):
190 The initial request object.
191 response (google.cloud.resourcemanager_v3.types.ListEffectiveTagsResponse):
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 = tag_bindings.ListEffectiveTagsRequest(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[tag_bindings.ListEffectiveTagsResponse]:
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[tag_bindings.EffectiveTag]:
213 for page in self.pages:
214 yield from page.effective_tags
216 def __repr__(self) -> str:
217 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
220class ListEffectiveTagsAsyncPager:
221 """A pager for iterating through ``list_effective_tags`` requests.
223 This class thinly wraps an initial
224 :class:`google.cloud.resourcemanager_v3.types.ListEffectiveTagsResponse` object, and
225 provides an ``__aiter__`` method to iterate through its
226 ``effective_tags`` field.
228 If there are more pages, the ``__aiter__`` method will make additional
229 ``ListEffectiveTags`` requests and continue to iterate
230 through the ``effective_tags`` field on the
231 corresponding responses.
233 All the usual :class:`google.cloud.resourcemanager_v3.types.ListEffectiveTagsResponse`
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[tag_bindings.ListEffectiveTagsResponse]],
241 request: tag_bindings.ListEffectiveTagsRequest,
242 response: tag_bindings.ListEffectiveTagsResponse,
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.resourcemanager_v3.types.ListEffectiveTagsRequest):
252 The initial request object.
253 response (google.cloud.resourcemanager_v3.types.ListEffectiveTagsResponse):
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 = tag_bindings.ListEffectiveTagsRequest(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[tag_bindings.ListEffectiveTagsResponse]:
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[tag_bindings.EffectiveTag]:
275 async def async_generator():
276 async for page in self.pages:
277 for response in page.effective_tags:
278 yield response
280 return async_generator()
282 def __repr__(self) -> str:
283 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)