Coverage for src/hush_hush/_generated/models/create_token_request.py: 54%

37 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 Any, TypeVar 

7 

8from attrs import define as _attrs_define 

9from attrs import field as _attrs_field 

10 

11T = TypeVar("T", bound="CreateTokenRequest") 

12 

13 

14@_attrs_define 

15class CreateTokenRequest: 

16 """ 

17 Attributes: 

18 description (str): 

19 ttl_seconds (int): How long a token stays valid for, starting now. The default is 90 

20 days (7776000), and the cap is 365 days (31536000): a longer 

21 lifetime is a 422 that names the limit. A zero or negative value is 

22 a 400. The cap applies when a token is minted or rotated; a token 

23 issued before it existed keeps working until it expires. 

24 

25 The field stays `required` so generated clients keep a plain 

26 integer rather than an optional one, which would change their types 

27 for a limit they don't need. A request that leaves it out anyway is 

28 given the default rather than rejected. 

29 """ 

30 

31 description: str 

32 ttl_seconds: int 

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

34 

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

36 description = self.description 

37 

38 ttl_seconds = self.ttl_seconds 

39 

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

41 field_dict.update(self.additional_properties) 

42 field_dict.update( 

43 { 

44 "description": description, 

45 "ttl_seconds": ttl_seconds, 

46 } 

47 ) 

48 

49 return field_dict 

50 

51 @classmethod 

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

53 d = dict(src_dict) 

54 description = d.pop("description") 

55 

56 ttl_seconds = d.pop("ttl_seconds") 

57 

58 create_token_request = cls( 

59 description=description, 

60 ttl_seconds=ttl_seconds, 

61 ) 

62 

63 create_token_request.additional_properties = d 

64 return create_token_request 

65 

66 @property 

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

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

69 

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

71 return self.additional_properties[key] 

72 

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

74 self.additional_properties[key] = value 

75 

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

77 del self.additional_properties[key] 

78 

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

80 return key in self.additional_properties