Coverage for src/hush_hush/_generated/models/consumers_page.py: 44%

45 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-10-16 16:01 +0000

1# Code generated by openapi-python-client from hush-hush/api/openapi.yaml; DO NOT EDIT. 

2 

3from __future__ import annotations 

4 

5from collections.abc import Mapping 

6from typing import TYPE_CHECKING, Any, TypeVar 

7 

8from attrs import define as _attrs_define 

9from attrs import field as _attrs_field 

10 

11if TYPE_CHECKING: 

12 from ..models.consumer_entry import ConsumerEntry 

13 

14 

15T = TypeVar("T", bound="ConsumersPage") 

16 

17 

18@_attrs_define 

19class ConsumersPage: 

20 """ 

21 Attributes: 

22 consumers (list[ConsumerEntry]): 

23 total (int): The total number of consumers matching the request's filter, 

24 across every page - not just this page's own count - so a 

25 caller can render page-number navigation. 

26 """ 

27 

28 consumers: list[ConsumerEntry] 

29 total: int 

30 additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) 

31 

32 def to_dict(self) -> dict[str, Any]: 

33 consumers = [] 

34 for consumers_item_data in self.consumers: 

35 consumers_item = consumers_item_data.to_dict() 

36 consumers.append(consumers_item) 

37 

38 total = self.total 

39 

40 field_dict: dict[str, Any] = {} 

41 field_dict.update(self.additional_properties) 

42 field_dict.update( 

43 { 

44 "consumers": consumers, 

45 "total": total, 

46 } 

47 ) 

48 

49 return field_dict 

50 

51 @classmethod 

52 def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: 

53 from ..models.consumer_entry import ConsumerEntry # noqa: PLC0415 

54 

55 d = dict(src_dict) 

56 consumers = [] 

57 _consumers = d.pop("consumers") 

58 for consumers_item_data in _consumers: 

59 consumers_item = ConsumerEntry.from_dict(consumers_item_data) 

60 

61 consumers.append(consumers_item) 

62 

63 total = d.pop("total") 

64 

65 consumers_page = cls( 

66 consumers=consumers, 

67 total=total, 

68 ) 

69 

70 consumers_page.additional_properties = d 

71 return consumers_page 

72 

73 @property 

74 def additional_keys(self) -> list[str]: 

75 return list(self.additional_properties.keys()) 

76 

77 def __getitem__(self, key: str) -> Any: 

78 return self.additional_properties[key] 

79 

80 def __setitem__(self, key: str, value: Any) -> None: 

81 self.additional_properties[key] = value 

82 

83 def __delitem__(self, key: str) -> None: 

84 del self.additional_properties[key] 

85 

86 def __contains__(self, key: str) -> bool: 

87 return key in self.additional_properties