Coverage for src/hush_hush/_generated/models/actor.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="Actor") 

12 

13 

14@_attrs_define 

15class Actor: 

16 """Who performed an audited write. `type` is `session` (the admin 

17 account, `id` is its actor id), `token` (a write token, `id` is its 

18 token id) or `consumer_token` (a consumer token, `id` is its id) - 

19 the same values `GET /audit-log` reports. 

20 

21 Attributes: 

22 type_ (str): 

23 id (str): 

24 """ 

25 

26 type_: str 

27 id: str 

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

29 

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

31 type_ = self.type_ 

32 

33 id = self.id 

34 

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

36 field_dict.update(self.additional_properties) 

37 field_dict.update( 

38 { 

39 "type": type_, 

40 "id": id, 

41 } 

42 ) 

43 

44 return field_dict 

45 

46 @classmethod 

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

48 d = dict(src_dict) 

49 type_ = d.pop("type") 

50 

51 id = d.pop("id") 

52 

53 actor = cls( 

54 type_=type_, 

55 id=id, 

56 ) 

57 

58 actor.additional_properties = d 

59 return actor 

60 

61 @property 

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

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

64 

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

66 return self.additional_properties[key] 

67 

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

69 self.additional_properties[key] = value 

70 

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

72 del self.additional_properties[key] 

73 

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

75 return key in self.additional_properties