-
Notifications
You must be signed in to change notification settings - Fork 9
/
connection_record.py
63 lines (54 loc) · 2.07 KB
/
connection_record.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from typing import Literal, Optional
from aries_cloudcontroller import ConnRecord
from pydantic import BaseModel
State = Literal[
"active",
"response",
"request",
"start",
"completed",
"init",
"error",
"invitation",
"abandoned",
]
Role = Literal["invitee", "requester", "inviter", "responder"]
Protocol = Literal["connections/1.0", "didexchange/1.0"]
class Connection(BaseModel):
# accept: Optional[str] = None
# inbound_connection_id: Optional[str] = None
# request_id: Optional[str] = None
# rfc23_state: Optional[str] = None
alias: Optional[str] = None
connection_id: Optional[str] = None
connection_protocol: Optional[Protocol] = None
created_at: Optional[str] = None
error_msg: Optional[str] = None
invitation_key: Optional[str] = None
invitation_mode: Optional[Literal["once", "multi", "static"]] = None
invitation_msg_id: Optional[str] = None
my_did: Optional[str] = None
state: Optional[str] = None # not State Literal because we use rfc23_state
their_did: Optional[str] = None
their_label: Optional[str] = None
their_public_did: Optional[str] = None
their_role: Optional[Role] = None
updated_at: Optional[str] = None
def conn_record_to_connection(connection_record: ConnRecord):
return Connection(
alias=connection_record.alias,
connection_id=connection_record.connection_id,
connection_protocol=connection_record.connection_protocol,
created_at=connection_record.created_at,
error_msg=connection_record.error_msg,
invitation_key=connection_record.invitation_key,
invitation_mode=connection_record.invitation_mode,
invitation_msg_id=connection_record.invitation_msg_id,
my_did=connection_record.my_did,
state=connection_record.rfc23_state,
their_did=connection_record.their_did,
their_label=connection_record.their_label,
their_public_did=connection_record.their_public_did,
their_role=connection_record.their_role,
updated_at=connection_record.updated_at,
)