Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/logging_v2/services/config_service_v2/pagers.py: 33%

217 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:45 +0000

1# -*- coding: utf-8 -*- 

2# Copyright 2023 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) 

26 

27from google.cloud.logging_v2.types import logging_config 

28 

29 

30class ListBucketsPager: 

31 """A pager for iterating through ``list_buckets`` requests. 

32 

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. 

37 

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. 

42 

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 """ 

47 

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. 

57 

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 

72 

73 def __getattr__(self, name: str) -> Any: 

74 return getattr(self._response, name) 

75 

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 

83 

84 def __iter__(self) -> Iterator[logging_config.LogBucket]: 

85 for page in self.pages: 

86 yield from page.buckets 

87 

88 def __repr__(self) -> str: 

89 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

90 

91 

92class ListBucketsAsyncPager: 

93 """A pager for iterating through ``list_buckets`` requests. 

94 

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. 

99 

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. 

104 

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 """ 

109 

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. 

119 

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 

134 

135 def __getattr__(self, name: str) -> Any: 

136 return getattr(self._response, name) 

137 

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 

145 

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 

151 

152 return async_generator() 

153 

154 def __repr__(self) -> str: 

155 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

156 

157 

158class ListViewsPager: 

159 """A pager for iterating through ``list_views`` requests. 

160 

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. 

165 

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. 

170 

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 """ 

175 

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. 

185 

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 

200 

201 def __getattr__(self, name: str) -> Any: 

202 return getattr(self._response, name) 

203 

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 

211 

212 def __iter__(self) -> Iterator[logging_config.LogView]: 

213 for page in self.pages: 

214 yield from page.views 

215 

216 def __repr__(self) -> str: 

217 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

218 

219 

220class ListViewsAsyncPager: 

221 """A pager for iterating through ``list_views`` requests. 

222 

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. 

227 

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. 

232 

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 """ 

237 

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. 

247 

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 

262 

263 def __getattr__(self, name: str) -> Any: 

264 return getattr(self._response, name) 

265 

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 

273 

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 

279 

280 return async_generator() 

281 

282 def __repr__(self) -> str: 

283 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

284 

285 

286class ListSinksPager: 

287 """A pager for iterating through ``list_sinks`` requests. 

288 

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. 

293 

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. 

298 

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 """ 

303 

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. 

313 

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 

328 

329 def __getattr__(self, name: str) -> Any: 

330 return getattr(self._response, name) 

331 

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 

339 

340 def __iter__(self) -> Iterator[logging_config.LogSink]: 

341 for page in self.pages: 

342 yield from page.sinks 

343 

344 def __repr__(self) -> str: 

345 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

346 

347 

348class ListSinksAsyncPager: 

349 """A pager for iterating through ``list_sinks`` requests. 

350 

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. 

355 

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. 

360 

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 """ 

365 

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. 

375 

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 

390 

391 def __getattr__(self, name: str) -> Any: 

392 return getattr(self._response, name) 

393 

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 

401 

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 

407 

408 return async_generator() 

409 

410 def __repr__(self) -> str: 

411 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

412 

413 

414class ListLinksPager: 

415 """A pager for iterating through ``list_links`` requests. 

416 

417 This class thinly wraps an initial 

418 :class:`google.cloud.logging_v2.types.ListLinksResponse` object, and 

419 provides an ``__iter__`` method to iterate through its 

420 ``links`` field. 

421 

422 If there are more pages, the ``__iter__`` method will make additional 

423 ``ListLinks`` requests and continue to iterate 

424 through the ``links`` field on the 

425 corresponding responses. 

426 

427 All the usual :class:`google.cloud.logging_v2.types.ListLinksResponse` 

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 """ 

431 

432 def __init__( 

433 self, 

434 method: Callable[..., logging_config.ListLinksResponse], 

435 request: logging_config.ListLinksRequest, 

436 response: logging_config.ListLinksResponse, 

437 *, 

438 metadata: Sequence[Tuple[str, str]] = () 

439 ): 

440 """Instantiate the pager. 

441 

442 Args: 

443 method (Callable): The method that was originally called, and 

444 which instantiated this pager. 

445 request (google.cloud.logging_v2.types.ListLinksRequest): 

446 The initial request object. 

447 response (google.cloud.logging_v2.types.ListLinksResponse): 

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.ListLinksRequest(request) 

454 self._response = response 

455 self._metadata = metadata 

456 

457 def __getattr__(self, name: str) -> Any: 

458 return getattr(self._response, name) 

459 

460 @property 

461 def pages(self) -> Iterator[logging_config.ListLinksResponse]: 

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 

467 

468 def __iter__(self) -> Iterator[logging_config.Link]: 

469 for page in self.pages: 

470 yield from page.links 

471 

472 def __repr__(self) -> str: 

473 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

474 

475 

476class ListLinksAsyncPager: 

477 """A pager for iterating through ``list_links`` requests. 

478 

479 This class thinly wraps an initial 

480 :class:`google.cloud.logging_v2.types.ListLinksResponse` object, and 

481 provides an ``__aiter__`` method to iterate through its 

482 ``links`` field. 

483 

484 If there are more pages, the ``__aiter__`` method will make additional 

485 ``ListLinks`` requests and continue to iterate 

486 through the ``links`` field on the 

487 corresponding responses. 

488 

489 All the usual :class:`google.cloud.logging_v2.types.ListLinksResponse` 

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 """ 

493 

494 def __init__( 

495 self, 

496 method: Callable[..., Awaitable[logging_config.ListLinksResponse]], 

497 request: logging_config.ListLinksRequest, 

498 response: logging_config.ListLinksResponse, 

499 *, 

500 metadata: Sequence[Tuple[str, str]] = () 

501 ): 

502 """Instantiates the pager. 

503 

504 Args: 

505 method (Callable): The method that was originally called, and 

506 which instantiated this pager. 

507 request (google.cloud.logging_v2.types.ListLinksRequest): 

508 The initial request object. 

509 response (google.cloud.logging_v2.types.ListLinksResponse): 

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.ListLinksRequest(request) 

516 self._response = response 

517 self._metadata = metadata 

518 

519 def __getattr__(self, name: str) -> Any: 

520 return getattr(self._response, name) 

521 

522 @property 

523 async def pages(self) -> AsyncIterator[logging_config.ListLinksResponse]: 

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 

529 

530 def __aiter__(self) -> AsyncIterator[logging_config.Link]: 

531 async def async_generator(): 

532 async for page in self.pages: 

533 for response in page.links: 

534 yield response 

535 

536 return async_generator() 

537 

538 def __repr__(self) -> str: 

539 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

540 

541 

542class ListExclusionsPager: 

543 """A pager for iterating through ``list_exclusions`` requests. 

544 

545 This class thinly wraps an initial 

546 :class:`google.cloud.logging_v2.types.ListExclusionsResponse` object, and 

547 provides an ``__iter__`` method to iterate through its 

548 ``exclusions`` field. 

549 

550 If there are more pages, the ``__iter__`` method will make additional 

551 ``ListExclusions`` requests and continue to iterate 

552 through the ``exclusions`` field on the 

553 corresponding responses. 

554 

555 All the usual :class:`google.cloud.logging_v2.types.ListExclusionsResponse` 

556 attributes are available on the pager. If multiple requests are made, only 

557 the most recent response is retained, and thus used for attribute lookup. 

558 """ 

559 

560 def __init__( 

561 self, 

562 method: Callable[..., logging_config.ListExclusionsResponse], 

563 request: logging_config.ListExclusionsRequest, 

564 response: logging_config.ListExclusionsResponse, 

565 *, 

566 metadata: Sequence[Tuple[str, str]] = () 

567 ): 

568 """Instantiate the pager. 

569 

570 Args: 

571 method (Callable): The method that was originally called, and 

572 which instantiated this pager. 

573 request (google.cloud.logging_v2.types.ListExclusionsRequest): 

574 The initial request object. 

575 response (google.cloud.logging_v2.types.ListExclusionsResponse): 

576 The initial response object. 

577 metadata (Sequence[Tuple[str, str]]): Strings which should be 

578 sent along with the request as metadata. 

579 """ 

580 self._method = method 

581 self._request = logging_config.ListExclusionsRequest(request) 

582 self._response = response 

583 self._metadata = metadata 

584 

585 def __getattr__(self, name: str) -> Any: 

586 return getattr(self._response, name) 

587 

588 @property 

589 def pages(self) -> Iterator[logging_config.ListExclusionsResponse]: 

590 yield self._response 

591 while self._response.next_page_token: 

592 self._request.page_token = self._response.next_page_token 

593 self._response = self._method(self._request, metadata=self._metadata) 

594 yield self._response 

595 

596 def __iter__(self) -> Iterator[logging_config.LogExclusion]: 

597 for page in self.pages: 

598 yield from page.exclusions 

599 

600 def __repr__(self) -> str: 

601 return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 

602 

603 

604class ListExclusionsAsyncPager: 

605 """A pager for iterating through ``list_exclusions`` requests. 

606 

607 This class thinly wraps an initial 

608 :class:`google.cloud.logging_v2.types.ListExclusionsResponse` object, and 

609 provides an ``__aiter__`` method to iterate through its 

610 ``exclusions`` field. 

611 

612 If there are more pages, the ``__aiter__`` method will make additional 

613 ``ListExclusions`` requests and continue to iterate 

614 through the ``exclusions`` field on the 

615 corresponding responses. 

616 

617 All the usual :class:`google.cloud.logging_v2.types.ListExclusionsResponse` 

618 attributes are available on the pager. If multiple requests are made, only 

619 the most recent response is retained, and thus used for attribute lookup. 

620 """ 

621 

622 def __init__( 

623 self, 

624 method: Callable[..., Awaitable[logging_config.ListExclusionsResponse]], 

625 request: logging_config.ListExclusionsRequest, 

626 response: logging_config.ListExclusionsResponse, 

627 *, 

628 metadata: Sequence[Tuple[str, str]] = () 

629 ): 

630 """Instantiates the pager. 

631 

632 Args: 

633 method (Callable): The method that was originally called, and 

634 which instantiated this pager. 

635 request (google.cloud.logging_v2.types.ListExclusionsRequest): 

636 The initial request object. 

637 response (google.cloud.logging_v2.types.ListExclusionsResponse): 

638 The initial response object. 

639 metadata (Sequence[Tuple[str, str]]): Strings which should be 

640 sent along with the request as metadata. 

641 """ 

642 self._method = method 

643 self._request = logging_config.ListExclusionsRequest(request) 

644 self._response = response 

645 self._metadata = metadata 

646 

647 def __getattr__(self, name: str) -> Any: 

648 return getattr(self._response, name) 

649 

650 @property 

651 async def pages(self) -> AsyncIterator[logging_config.ListExclusionsResponse]: 

652 yield self._response 

653 while self._response.next_page_token: 

654 self._request.page_token = self._response.next_page_token 

655 self._response = await self._method(self._request, metadata=self._metadata) 

656 yield self._response 

657 

658 def __aiter__(self) -> AsyncIterator[logging_config.LogExclusion]: 

659 async def async_generator(): 

660 async for page in self.pages: 

661 for response in page.exclusions: 

662 yield response 

663 

664 return async_generator() 

665 

666 def __repr__(self) -> str: 

667 return "{0}<{1!r}>".format(self.__class__.__name__, self._response)