Coverage for src/hush_hush/_generated/models/update_consumer_request.py: 50%

42 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 

11from ..types import UNSET, Unset 

12 

13T = TypeVar("T", bound="UpdateConsumerRequest") 

14 

15 

16@_attrs_define 

17class UpdateConsumerRequest: 

18 """At least one of `name` or `public_key` is required (enforced by 

19 `minProperties` above); a field left out leaves that aspect of the 

20 consumer unchanged. There is no way to clear a registered public 

21 key through this request, only to set or replace one. 

22 

23 Attributes: 

24 name (str | Unset): The consumer's new name. If it already matches another 

25 recorded consumer, the two merge - every object recording 

26 either ends up recording just the new name, no duplicates. A 

27 registered public key survives the merge: the target name's 

28 own key wins if it already had one, otherwise the renamed 

29 consumer's key carries over. 

30 public_key (str | Unset): Registers or replaces the consumer's age public key, safe to 

31 store server-side since it's public. A consumer's private key 

32 SHALL NOT be sent here or anywhere else in this API - this 

33 field only ever accepts a public key. Registering a key 

34 doesn't require the consumer to already be recorded anywhere; 

35 a name never referenced by any object's `used_by` list yet is 

36 accepted the same as an existing one. 

37 """ 

38 

39 name: str | Unset = UNSET 

40 public_key: str | Unset = UNSET 

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

42 

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

44 name = self.name 

45 

46 public_key = self.public_key 

47 

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

49 field_dict.update(self.additional_properties) 

50 field_dict.update({}) 

51 if name is not UNSET: 

52 field_dict["name"] = name 

53 if public_key is not UNSET: 

54 field_dict["public_key"] = public_key 

55 

56 return field_dict 

57 

58 @classmethod 

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

60 d = dict(src_dict) 

61 name = d.pop("name", UNSET) 

62 

63 public_key = d.pop("public_key", UNSET) 

64 

65 update_consumer_request = cls( 

66 name=name, 

67 public_key=public_key, 

68 ) 

69 

70 update_consumer_request.additional_properties = d 

71 return update_consumer_request 

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