Coverage for src/hush_hush/_generated/models/credential.py: 44%
57 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-16 16:01 +0000
« 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.
3from __future__ import annotations
5import datetime
6from collections.abc import Mapping
7from typing import Any, TypeVar
9from attrs import define as _attrs_define
10from attrs import field as _attrs_field
12from ..types import UNSET, Unset
14T = TypeVar("T", bound="Credential")
17@_attrs_define
18class Credential:
19 """
20 Attributes:
21 id (str):
22 nickname (str):
23 created_at (datetime.datetime):
24 last_used_at (datetime.datetime | Unset): Absent if this credential has never been used to log in.
25 wrapped_identity (str | Unset): This credential's own copy of the user's escrowed writer
26 identity private key, wrapped with a key derived from this
27 credential's WebAuthn PRF extension output and
28 base64-encoded. Absent for a credential that doesn't support
29 PRF. Safe to return to the authenticated owner: it's already
30 wrapped, and only unwrappable with that same credential's own
31 PRF secret or the break-glass recovery phrase.
32 """
34 id: str
35 nickname: str
36 created_at: datetime.datetime
37 last_used_at: datetime.datetime | Unset = UNSET
38 wrapped_identity: str | Unset = UNSET
39 additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
41 def to_dict(self) -> dict[str, Any]:
42 id = self.id
44 nickname = self.nickname
46 created_at = self.created_at.isoformat()
48 last_used_at: str | Unset = UNSET
49 if not isinstance(self.last_used_at, Unset):
50 last_used_at = self.last_used_at.isoformat()
52 wrapped_identity = self.wrapped_identity
54 field_dict: dict[str, Any] = {}
55 field_dict.update(self.additional_properties)
56 field_dict.update(
57 {
58 "id": id,
59 "nickname": nickname,
60 "created_at": created_at,
61 }
62 )
63 if last_used_at is not UNSET:
64 field_dict["last_used_at"] = last_used_at
65 if wrapped_identity is not UNSET:
66 field_dict["wrapped_identity"] = wrapped_identity
68 return field_dict
70 @classmethod
71 def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
72 d = dict(src_dict)
73 id = d.pop("id")
75 nickname = d.pop("nickname")
77 created_at = datetime.datetime.fromisoformat(d.pop("created_at"))
79 _last_used_at = d.pop("last_used_at", UNSET)
80 last_used_at: datetime.datetime | Unset
81 if isinstance(_last_used_at, Unset):
82 last_used_at = UNSET
83 else:
84 last_used_at = datetime.datetime.fromisoformat(_last_used_at)
86 wrapped_identity = d.pop("wrapped_identity", UNSET)
88 credential = cls(
89 id=id,
90 nickname=nickname,
91 created_at=created_at,
92 last_used_at=last_used_at,
93 wrapped_identity=wrapped_identity,
94 )
96 credential.additional_properties = d
97 return credential
99 @property
100 def additional_keys(self) -> list[str]:
101 return list(self.additional_properties.keys())
103 def __getitem__(self, key: str) -> Any:
104 return self.additional_properties[key]
106 def __setitem__(self, key: str, value: Any) -> None:
107 self.additional_properties[key] = value
109 def __delitem__(self, key: str) -> None:
110 del self.additional_properties[key]
112 def __contains__(self, key: str) -> bool:
113 return key in self.additional_properties