Coverage for src/hush_hush/_generated/models/create_consumer_token_request.py: 52%

40 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="CreateConsumerTokenRequest") 

12 

13 

14@_attrs_define 

15class CreateConsumerTokenRequest: 

16 """ 

17 Attributes: 

18 consumer (str): The consumer this token is scoped to - it authorizes 

19 `getObject` only for an object whose `used_by` list includes 

20 this name. Free text, matching how a consumer name is stored 

21 elsewhere (`used_by`, `/consumers`); the consumer doesn't have 

22 to already exist. 

23 description (str): 

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

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

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

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

28 issued before it existed keeps working until it expires. 

29 

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

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

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

33 given the default rather than rejected. 

34 """ 

35 

36 consumer: str 

37 description: str 

38 ttl_seconds: int 

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

40 

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

42 consumer = self.consumer 

43 

44 description = self.description 

45 

46 ttl_seconds = self.ttl_seconds 

47 

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

49 field_dict.update(self.additional_properties) 

50 field_dict.update( 

51 { 

52 "consumer": consumer, 

53 "description": description, 

54 "ttl_seconds": ttl_seconds, 

55 } 

56 ) 

57 

58 return field_dict 

59 

60 @classmethod 

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

62 d = dict(src_dict) 

63 consumer = d.pop("consumer") 

64 

65 description = d.pop("description") 

66 

67 ttl_seconds = d.pop("ttl_seconds") 

68 

69 create_consumer_token_request = cls( 

70 consumer=consumer, 

71 description=description, 

72 ttl_seconds=ttl_seconds, 

73 ) 

74 

75 create_consumer_token_request.additional_properties = d 

76 return create_consumer_token_request 

77 

78 @property 

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

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

81 

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

83 return self.additional_properties[key] 

84 

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

86 self.additional_properties[key] = value 

87 

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

89 del self.additional_properties[key] 

90 

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

92 return key in self.additional_properties