pebbenote-cli 0.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. pebbenote_cli/__init__.py +0 -0
  2. pebbenote_cli/__main__.py +3 -0
  3. pebbenote_cli/api.py +62 -0
  4. pebbenote_cli/auth.py +120 -0
  5. pebbenote_cli/cli.py +282 -0
  6. pebbenote_cli/client/__init__.py +8 -0
  7. pebbenote_cli/client/api/__init__.py +1 -0
  8. pebbenote_cli/client/api/actions/__init__.py +1 -0
  9. pebbenote_cli/client/api/actions/apply_action.py +166 -0
  10. pebbenote_cli/client/api/instructions/__init__.py +1 -0
  11. pebbenote_cli/client/api/instructions/list_instructions.py +127 -0
  12. pebbenote_cli/client/api/instructions/replace_instructions.py +204 -0
  13. pebbenote_cli/client/api/notes/__init__.py +1 -0
  14. pebbenote_cli/client/api/notes/create_note.py +173 -0
  15. pebbenote_cli/client/api/notes/delete_note.py +159 -0
  16. pebbenote_cli/client/api/notes/edit_note_by_id.py +197 -0
  17. pebbenote_cli/client/api/notes/get_note_by_id.py +184 -0
  18. pebbenote_cli/client/api/notes/list_notes.py +132 -0
  19. pebbenote_cli/client/api/notes/set_default_note.py +161 -0
  20. pebbenote_cli/client/api/sharing/__init__.py +1 -0
  21. pebbenote_cli/client/api/sharing/get_note_sharing.py +161 -0
  22. pebbenote_cli/client/api/sharing/get_shared_note.py +172 -0
  23. pebbenote_cli/client/api/sharing/join_shared_note.py +176 -0
  24. pebbenote_cli/client/api/sharing/make_note_private.py +167 -0
  25. pebbenote_cli/client/api/sharing/remove_note_member.py +173 -0
  26. pebbenote_cli/client/api/sharing/revoke_share_link.py +181 -0
  27. pebbenote_cli/client/api/sharing/share_note.py +202 -0
  28. pebbenote_cli/client/client.py +280 -0
  29. pebbenote_cli/client/errors.py +16 -0
  30. pebbenote_cli/client/models/__init__.py +47 -0
  31. pebbenote_cli/client/models/action_accepted_model.py +68 -0
  32. pebbenote_cli/client/models/action_edit_model.py +96 -0
  33. pebbenote_cli/client/models/action_model.py +105 -0
  34. pebbenote_cli/client/models/action_status.py +10 -0
  35. pebbenote_cli/client/models/http_validation_error.py +79 -0
  36. pebbenote_cli/client/models/instructions_conflict_model.py +75 -0
  37. pebbenote_cli/client/models/instructions_edit_model.py +69 -0
  38. pebbenote_cli/client/models/instructions_model.py +69 -0
  39. pebbenote_cli/client/models/note_access.py +10 -0
  40. pebbenote_cli/client/models/note_conflict_model.py +75 -0
  41. pebbenote_cli/client/models/note_member_model.py +86 -0
  42. pebbenote_cli/client/models/note_model.py +113 -0
  43. pebbenote_cli/client/models/note_sharing_model.py +94 -0
  44. pebbenote_cli/client/models/note_update_model.py +83 -0
  45. pebbenote_cli/client/models/note_view_model.py +143 -0
  46. pebbenote_cli/client/models/share_access.py +9 -0
  47. pebbenote_cli/client/models/share_create_model.py +69 -0
  48. pebbenote_cli/client/models/share_link_model.py +120 -0
  49. pebbenote_cli/client/models/shared_note_model.py +89 -0
  50. pebbenote_cli/client/models/validation_error.py +125 -0
  51. pebbenote_cli/client/models/validation_error_context.py +44 -0
  52. pebbenote_cli/client/types.py +54 -0
  53. pebbenote_cli/config.py +46 -0
  54. pebbenote_cli/editor.py +23 -0
  55. pebbenote_cli/errors.py +10 -0
  56. pebbenote_cli/http.py +36 -0
  57. pebbenote_cli/instructions.py +24 -0
  58. pebbenote_cli/merge.py +79 -0
  59. pebbenote_cli-0.6.1.dist-info/METADATA +129 -0
  60. pebbenote_cli-0.6.1.dist-info/RECORD +62 -0
  61. pebbenote_cli-0.6.1.dist-info/WHEEL +4 -0
  62. pebbenote_cli-0.6.1.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,280 @@
1
+ import ssl
2
+ from typing import Any, Self
3
+
4
+ import httpx
5
+ from attrs import define, evolve, field
6
+
7
+
8
+ @define
9
+ class Client:
10
+ """A class for keeping track of data related to the API
11
+
12
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
13
+
14
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
15
+
16
+ ``cookies``: A dictionary of cookies to be sent with every request
17
+
18
+ ``headers``: A dictionary of headers to be sent with every request
19
+
20
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
21
+ httpx.TimeoutException if this is exceeded.
22
+
23
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
24
+ but can be set to False for testing purposes.
25
+
26
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
27
+
28
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
29
+
30
+
31
+ Attributes:
32
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
33
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
34
+ argument to the constructor.
35
+ """
36
+
37
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
38
+ _base_url: str = field(alias="base_url")
39
+ _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
40
+ _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
41
+ _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
42
+ _verify_ssl: str | bool | ssl.SSLContext = field(
43
+ default=True, kw_only=True, alias="verify_ssl"
44
+ )
45
+ _follow_redirects: bool = field(
46
+ default=False, kw_only=True, alias="follow_redirects"
47
+ )
48
+ _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
49
+ _client: httpx.Client | None = field(default=None, init=False)
50
+ _async_client: httpx.AsyncClient | None = field(default=None, init=False)
51
+
52
+ def with_headers(self, headers: dict[str, str]) -> "Client":
53
+ """Get a new client matching this one with additional headers"""
54
+ if self._client is not None:
55
+ self._client.headers.update(headers)
56
+ if self._async_client is not None:
57
+ self._async_client.headers.update(headers)
58
+ return evolve(self, headers={**self._headers, **headers})
59
+
60
+ def with_cookies(self, cookies: dict[str, str]) -> "Client":
61
+ """Get a new client matching this one with additional cookies"""
62
+ if self._client is not None:
63
+ self._client.cookies.update(cookies)
64
+ if self._async_client is not None:
65
+ self._async_client.cookies.update(cookies)
66
+ return evolve(self, cookies={**self._cookies, **cookies})
67
+
68
+ def with_timeout(self, timeout: httpx.Timeout) -> "Client":
69
+ """Get a new client matching this one with a new timeout configuration"""
70
+ if self._client is not None:
71
+ self._client.timeout = timeout
72
+ if self._async_client is not None:
73
+ self._async_client.timeout = timeout
74
+ return evolve(self, timeout=timeout)
75
+
76
+ def set_httpx_client(self, client: httpx.Client) -> Self:
77
+ """Manually set the underlying httpx.Client
78
+
79
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
80
+ """
81
+ self._client = client
82
+ return self
83
+
84
+ def get_httpx_client(self) -> httpx.Client:
85
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
86
+ if self._client is None:
87
+ self._client = httpx.Client(
88
+ base_url=self._base_url,
89
+ cookies=self._cookies,
90
+ headers=self._headers,
91
+ timeout=self._timeout,
92
+ verify=self._verify_ssl,
93
+ follow_redirects=self._follow_redirects,
94
+ **self._httpx_args,
95
+ )
96
+ return self._client
97
+
98
+ def __enter__(self) -> Self:
99
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
100
+ self.get_httpx_client().__enter__()
101
+ return self
102
+
103
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
104
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
105
+ self.get_httpx_client().__exit__(*args, **kwargs)
106
+
107
+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self:
108
+ """Manually set the underlying httpx.AsyncClient
109
+
110
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
111
+ """
112
+ self._async_client = async_client
113
+ return self
114
+
115
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
116
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
117
+ if self._async_client is None:
118
+ self._async_client = httpx.AsyncClient(
119
+ base_url=self._base_url,
120
+ cookies=self._cookies,
121
+ headers=self._headers,
122
+ timeout=self._timeout,
123
+ verify=self._verify_ssl,
124
+ follow_redirects=self._follow_redirects,
125
+ **self._httpx_args,
126
+ )
127
+ return self._async_client
128
+
129
+ async def __aenter__(self) -> Self:
130
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
131
+ await self.get_async_httpx_client().__aenter__()
132
+ return self
133
+
134
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
135
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
136
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
137
+
138
+
139
+ @define
140
+ class AuthenticatedClient:
141
+ """A Client which has been authenticated for use on secured endpoints
142
+
143
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
144
+
145
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
146
+
147
+ ``cookies``: A dictionary of cookies to be sent with every request
148
+
149
+ ``headers``: A dictionary of headers to be sent with every request
150
+
151
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
152
+ httpx.TimeoutException if this is exceeded.
153
+
154
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
155
+ but can be set to False for testing purposes.
156
+
157
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
158
+
159
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
160
+
161
+
162
+ Attributes:
163
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
164
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
165
+ argument to the constructor.
166
+ token: The token to use for authentication
167
+ prefix: The prefix to use for the Authorization header
168
+ auth_header_name: The name of the Authorization header
169
+ """
170
+
171
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
172
+ _base_url: str = field(alias="base_url")
173
+ _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
174
+ _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
175
+ _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
176
+ _verify_ssl: str | bool | ssl.SSLContext = field(
177
+ default=True, kw_only=True, alias="verify_ssl"
178
+ )
179
+ _follow_redirects: bool = field(
180
+ default=False, kw_only=True, alias="follow_redirects"
181
+ )
182
+ _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
183
+ _client: httpx.Client | None = field(default=None, init=False)
184
+ _async_client: httpx.AsyncClient | None = field(default=None, init=False)
185
+
186
+ token: str
187
+ prefix: str = "Bearer"
188
+ auth_header_name: str = "Authorization"
189
+
190
+ def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
191
+ """Get a new client matching this one with additional headers"""
192
+ if self._client is not None:
193
+ self._client.headers.update(headers)
194
+ if self._async_client is not None:
195
+ self._async_client.headers.update(headers)
196
+ return evolve(self, headers={**self._headers, **headers})
197
+
198
+ def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
199
+ """Get a new client matching this one with additional cookies"""
200
+ if self._client is not None:
201
+ self._client.cookies.update(cookies)
202
+ if self._async_client is not None:
203
+ self._async_client.cookies.update(cookies)
204
+ return evolve(self, cookies={**self._cookies, **cookies})
205
+
206
+ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
207
+ """Get a new client matching this one with a new timeout configuration"""
208
+ if self._client is not None:
209
+ self._client.timeout = timeout
210
+ if self._async_client is not None:
211
+ self._async_client.timeout = timeout
212
+ return evolve(self, timeout=timeout)
213
+
214
+ def set_httpx_client(self, client: httpx.Client) -> Self:
215
+ """Manually set the underlying httpx.Client
216
+
217
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
218
+ """
219
+ self._client = client
220
+ return self
221
+
222
+ def get_httpx_client(self) -> httpx.Client:
223
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
224
+ if self._client is None:
225
+ self._headers[self.auth_header_name] = (
226
+ f"{self.prefix} {self.token}" if self.prefix else self.token
227
+ )
228
+ self._client = httpx.Client(
229
+ base_url=self._base_url,
230
+ cookies=self._cookies,
231
+ headers=self._headers,
232
+ timeout=self._timeout,
233
+ verify=self._verify_ssl,
234
+ follow_redirects=self._follow_redirects,
235
+ **self._httpx_args,
236
+ )
237
+ return self._client
238
+
239
+ def __enter__(self) -> Self:
240
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
241
+ self.get_httpx_client().__enter__()
242
+ return self
243
+
244
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
245
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
246
+ self.get_httpx_client().__exit__(*args, **kwargs)
247
+
248
+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self:
249
+ """Manually set the underlying httpx.AsyncClient
250
+
251
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
252
+ """
253
+ self._async_client = async_client
254
+ return self
255
+
256
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
257
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
258
+ if self._async_client is None:
259
+ self._headers[self.auth_header_name] = (
260
+ f"{self.prefix} {self.token}" if self.prefix else self.token
261
+ )
262
+ self._async_client = httpx.AsyncClient(
263
+ base_url=self._base_url,
264
+ cookies=self._cookies,
265
+ headers=self._headers,
266
+ timeout=self._timeout,
267
+ verify=self._verify_ssl,
268
+ follow_redirects=self._follow_redirects,
269
+ **self._httpx_args,
270
+ )
271
+ return self._async_client
272
+
273
+ async def __aenter__(self) -> Self:
274
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
275
+ await self.get_async_httpx_client().__aenter__()
276
+ return self
277
+
278
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
279
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
280
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
@@ -0,0 +1,16 @@
1
+ """Contains shared errors types that can be raised from API functions"""
2
+
3
+
4
+ class UnexpectedStatus(Exception):
5
+ """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
6
+
7
+ def __init__(self, status_code: int, content: bytes):
8
+ self.status_code = status_code
9
+ self.content = content
10
+
11
+ super().__init__(
12
+ f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
13
+ )
14
+
15
+
16
+ __all__ = ["UnexpectedStatus"]
@@ -0,0 +1,47 @@
1
+ """Contains all the data models used in inputs/outputs"""
2
+
3
+ from .action_accepted_model import ActionAcceptedModel
4
+ from .action_edit_model import ActionEditModel
5
+ from .action_model import ActionModel
6
+ from .action_status import ActionStatus
7
+ from .http_validation_error import HTTPValidationError
8
+ from .instructions_conflict_model import InstructionsConflictModel
9
+ from .instructions_edit_model import InstructionsEditModel
10
+ from .instructions_model import InstructionsModel
11
+ from .note_access import NoteAccess
12
+ from .note_conflict_model import NoteConflictModel
13
+ from .note_member_model import NoteMemberModel
14
+ from .note_model import NoteModel
15
+ from .note_sharing_model import NoteSharingModel
16
+ from .note_update_model import NoteUpdateModel
17
+ from .note_view_model import NoteViewModel
18
+ from .share_access import ShareAccess
19
+ from .share_create_model import ShareCreateModel
20
+ from .share_link_model import ShareLinkModel
21
+ from .shared_note_model import SharedNoteModel
22
+ from .validation_error import ValidationError
23
+ from .validation_error_context import ValidationErrorContext
24
+
25
+ __all__ = (
26
+ "ActionAcceptedModel",
27
+ "ActionEditModel",
28
+ "ActionModel",
29
+ "ActionStatus",
30
+ "HTTPValidationError",
31
+ "InstructionsConflictModel",
32
+ "InstructionsEditModel",
33
+ "InstructionsModel",
34
+ "NoteAccess",
35
+ "NoteConflictModel",
36
+ "NoteMemberModel",
37
+ "NoteModel",
38
+ "NoteSharingModel",
39
+ "NoteUpdateModel",
40
+ "NoteViewModel",
41
+ "ShareAccess",
42
+ "ShareCreateModel",
43
+ "SharedNoteModel",
44
+ "ShareLinkModel",
45
+ "ValidationError",
46
+ "ValidationErrorContext",
47
+ )
@@ -0,0 +1,68 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any, TypeVar
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ if TYPE_CHECKING:
10
+ from ..models.action_model import ActionModel
11
+
12
+
13
+ T = TypeVar("T", bound="ActionAcceptedModel")
14
+
15
+
16
+ @_attrs_define
17
+ class ActionAcceptedModel:
18
+ """The action is queued, the note changes once it is applied
19
+
20
+ Attributes:
21
+ action (ActionModel):
22
+ """
23
+
24
+ action: ActionModel
25
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
26
+
27
+ def to_dict(self) -> dict[str, Any]:
28
+ action = self.action.to_dict()
29
+
30
+ field_dict: dict[str, Any] = {}
31
+ field_dict.update(self.additional_properties)
32
+ field_dict.update(
33
+ {
34
+ "action": action,
35
+ }
36
+ )
37
+
38
+ return field_dict
39
+
40
+ @classmethod
41
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
42
+ from ..models.action_model import ActionModel # noqa: PLC0415
43
+
44
+ d = dict(src_dict)
45
+ action = ActionModel.from_dict(d.pop("action"))
46
+
47
+ action_accepted_model = cls(
48
+ action=action,
49
+ )
50
+
51
+ action_accepted_model.additional_properties = d
52
+ return action_accepted_model
53
+
54
+ @property
55
+ def additional_keys(self) -> list[str]:
56
+ return list(self.additional_properties.keys())
57
+
58
+ def __getitem__(self, key: str) -> Any:
59
+ return self.additional_properties[key]
60
+
61
+ def __setitem__(self, key: str, value: Any) -> None:
62
+ self.additional_properties[key] = value
63
+
64
+ def __delitem__(self, key: str) -> None:
65
+ del self.additional_properties[key]
66
+
67
+ def __contains__(self, key: str) -> bool:
68
+ return key in self.additional_properties
@@ -0,0 +1,96 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import (
5
+ Any,
6
+ Literal,
7
+ TypeVar,
8
+ cast,
9
+ )
10
+ from uuid import UUID
11
+
12
+ from attrs import define as _attrs_define
13
+ from attrs import field as _attrs_field
14
+
15
+ T = TypeVar("T", bound="ActionEditModel")
16
+
17
+
18
+ @_attrs_define
19
+ class ActionEditModel:
20
+ """
21
+ Attributes:
22
+ note_id (Literal['default'] | UUID):
23
+ action (str):
24
+ """
25
+
26
+ note_id: Literal["default"] | UUID
27
+ action: str
28
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29
+
30
+ def to_dict(self) -> dict[str, Any]:
31
+ note_id: Literal["default"] | str
32
+ if isinstance(self.note_id, UUID):
33
+ note_id = str(self.note_id)
34
+ else:
35
+ note_id = self.note_id
36
+
37
+ action = self.action
38
+
39
+ field_dict: dict[str, Any] = {}
40
+ field_dict.update(self.additional_properties)
41
+ field_dict.update(
42
+ {
43
+ "note_id": note_id,
44
+ "action": action,
45
+ }
46
+ )
47
+
48
+ return field_dict
49
+
50
+ @classmethod
51
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
52
+ d = dict(src_dict)
53
+
54
+ def _parse_note_id(data: object) -> Literal["default"] | UUID:
55
+ try:
56
+ if not isinstance(data, str):
57
+ raise TypeError()
58
+ note_id_type_0 = UUID(data)
59
+
60
+ return note_id_type_0
61
+ except (TypeError, ValueError, AttributeError, KeyError):
62
+ pass
63
+ note_id_type_1 = cast(Literal["default"], data)
64
+ if note_id_type_1 != "default":
65
+ raise ValueError(
66
+ f"note_id_type_1 must match const 'default', got '{note_id_type_1}'"
67
+ )
68
+ return note_id_type_1
69
+
70
+ note_id = _parse_note_id(d.pop("note_id"))
71
+
72
+ action = d.pop("action")
73
+
74
+ action_edit_model = cls(
75
+ note_id=note_id,
76
+ action=action,
77
+ )
78
+
79
+ action_edit_model.additional_properties = d
80
+ return action_edit_model
81
+
82
+ @property
83
+ def additional_keys(self) -> list[str]:
84
+ return list(self.additional_properties.keys())
85
+
86
+ def __getitem__(self, key: str) -> Any:
87
+ return self.additional_properties[key]
88
+
89
+ def __setitem__(self, key: str, value: Any) -> None:
90
+ self.additional_properties[key] = value
91
+
92
+ def __delitem__(self, key: str) -> None:
93
+ del self.additional_properties[key]
94
+
95
+ def __contains__(self, key: str) -> bool:
96
+ return key in self.additional_properties
@@ -0,0 +1,105 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import Any, TypeVar
6
+ from uuid import UUID
7
+
8
+ from attrs import define as _attrs_define
9
+ from attrs import field as _attrs_field
10
+
11
+ from ..models.action_status import ActionStatus
12
+
13
+ T = TypeVar("T", bound="ActionModel")
14
+
15
+
16
+ @_attrs_define
17
+ class ActionModel:
18
+ """
19
+ Attributes:
20
+ note_action_id (UUID):
21
+ note_id (UUID):
22
+ action (str):
23
+ status (ActionStatus):
24
+ created_at (datetime.datetime):
25
+ updated_at (datetime.datetime):
26
+ """
27
+
28
+ note_action_id: UUID
29
+ note_id: UUID
30
+ action: str
31
+ status: ActionStatus
32
+ created_at: datetime.datetime
33
+ updated_at: datetime.datetime
34
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
35
+
36
+ def to_dict(self) -> dict[str, Any]:
37
+ note_action_id = str(self.note_action_id)
38
+
39
+ note_id = str(self.note_id)
40
+
41
+ action = self.action
42
+
43
+ status = self.status.value
44
+
45
+ created_at = self.created_at.isoformat()
46
+
47
+ updated_at = self.updated_at.isoformat()
48
+
49
+ field_dict: dict[str, Any] = {}
50
+ field_dict.update(self.additional_properties)
51
+ field_dict.update(
52
+ {
53
+ "note_action_id": note_action_id,
54
+ "note_id": note_id,
55
+ "action": action,
56
+ "status": status,
57
+ "created_at": created_at,
58
+ "updated_at": updated_at,
59
+ }
60
+ )
61
+
62
+ return field_dict
63
+
64
+ @classmethod
65
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
66
+ d = dict(src_dict)
67
+ note_action_id = UUID(d.pop("note_action_id"))
68
+
69
+ note_id = UUID(d.pop("note_id"))
70
+
71
+ action = d.pop("action")
72
+
73
+ status = ActionStatus(d.pop("status"))
74
+
75
+ created_at = datetime.datetime.fromisoformat(d.pop("created_at"))
76
+
77
+ updated_at = datetime.datetime.fromisoformat(d.pop("updated_at"))
78
+
79
+ action_model = cls(
80
+ note_action_id=note_action_id,
81
+ note_id=note_id,
82
+ action=action,
83
+ status=status,
84
+ created_at=created_at,
85
+ updated_at=updated_at,
86
+ )
87
+
88
+ action_model.additional_properties = d
89
+ return action_model
90
+
91
+ @property
92
+ def additional_keys(self) -> list[str]:
93
+ return list(self.additional_properties.keys())
94
+
95
+ def __getitem__(self, key: str) -> Any:
96
+ return self.additional_properties[key]
97
+
98
+ def __setitem__(self, key: str, value: Any) -> None:
99
+ self.additional_properties[key] = value
100
+
101
+ def __delitem__(self, key: str) -> None:
102
+ del self.additional_properties[key]
103
+
104
+ def __contains__(self, key: str) -> bool:
105
+ return key in self.additional_properties
@@ -0,0 +1,10 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class ActionStatus(StrEnum):
5
+ DONE = "done"
6
+ FAILED = "failed"
7
+ PENDING = "pending"
8
+
9
+ def __str__(self) -> str:
10
+ return str(self.value)