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
File without changes
@@ -0,0 +1,3 @@
1
+ from pebbenote_cli.cli import main
2
+
3
+ main()
pebbenote_cli/api.py ADDED
@@ -0,0 +1,62 @@
1
+ import json
2
+
3
+ import httpx
4
+
5
+ from pebbenote_cli.auth import access_token
6
+ from pebbenote_cli.client import AuthenticatedClient
7
+ from pebbenote_cli.config import Config
8
+ from pebbenote_cli.errors import CliError, ConflictError
9
+ from pebbenote_cli.http import UNAVAILABLE_STATUSES, USER_AGENT
10
+
11
+
12
+ def _client(config: Config, token: str) -> AuthenticatedClient:
13
+ return AuthenticatedClient(
14
+ base_url=config.backend_url,
15
+ token=token,
16
+ headers={"User-Agent": USER_AGENT},
17
+ )
18
+
19
+
20
+ def _detail(content: bytes):
21
+ try:
22
+ payload = json.loads(content or b"null")
23
+ except ValueError:
24
+ return None
25
+ return payload.get("detail") if isinstance(payload, dict) else payload
26
+
27
+
28
+ def call(config: Config, endpoint, *, interactive=True, **kwargs):
29
+ """
30
+ Call a generated endpoint module, retrying once with a fresh token on 401.
31
+
32
+ A 409 raises ConflictError with the current state of what was edited.
33
+ `interactive=False` raises CliError instead of starting a login.
34
+ """
35
+ name = endpoint.__name__.rsplit(".", 1)[-1]
36
+ try:
37
+ response = endpoint.sync_detailed(
38
+ client=_client(config, access_token(config, interactive=interactive)),
39
+ **kwargs,
40
+ )
41
+ if response.status_code == 401:
42
+ response = endpoint.sync_detailed(
43
+ client=_client(
44
+ config,
45
+ access_token(config, force_refresh=True, interactive=interactive),
46
+ ),
47
+ **kwargs,
48
+ )
49
+ except httpx.TransportError as e:
50
+ raise CliError(f"Cannot reach {config.backend_url}: {e}") from e
51
+ if response.status_code in UNAVAILABLE_STATUSES:
52
+ raise CliError(
53
+ f"Cannot reach {config.backend_url} (HTTP {response.status_code}): "
54
+ "the backend seems to be down"
55
+ )
56
+ if response.status_code >= 400:
57
+ message = f"{name} failed ({response.status_code}): {_detail(response.content)}"
58
+ current = getattr(response.parsed, "current", None)
59
+ if response.status_code == 409 and current is not None:
60
+ raise ConflictError(message, current)
61
+ raise CliError(message)
62
+ return response.parsed
pebbenote_cli/auth.py ADDED
@@ -0,0 +1,120 @@
1
+ import json
2
+ import os
3
+ import sys
4
+ import time
5
+
6
+ from pebbenote_cli.config import TOKEN_FILE, Config
7
+ from pebbenote_cli.errors import CliError
8
+ from pebbenote_cli.http import UNAVAILABLE_STATUSES, request
9
+
10
+ CLIENT_ID = "pebbenote-watch"
11
+ EXPIRY_MARGIN = 30
12
+ # Offline tokens outlive the 30 minute Keycloak SSO session idle timeout
13
+ SCOPE = "openid offline_access"
14
+
15
+
16
+ def load_tokens():
17
+ try:
18
+ return json.loads(TOKEN_FILE.read_text())
19
+ except (OSError, ValueError):
20
+ return None
21
+
22
+
23
+ def save_tokens(token_response):
24
+ tokens = {
25
+ "access_token": token_response["access_token"],
26
+ "refresh_token": token_response.get("refresh_token"),
27
+ "expires_at": time.time() + token_response.get("expires_in", 0),
28
+ }
29
+ TOKEN_FILE.parent.mkdir(parents=True, exist_ok=True)
30
+ fd = os.open(TOKEN_FILE, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
31
+ with os.fdopen(fd, "w") as f:
32
+ json.dump(tokens, f)
33
+ return tokens
34
+
35
+
36
+ def check_available(config: Config, status):
37
+ if status in UNAVAILABLE_STATUSES:
38
+ raise CliError(
39
+ f"Cannot reach {config.issuer} (HTTP {status}): "
40
+ "Keycloak and the backend seem to be down"
41
+ )
42
+
43
+
44
+ def login(config: Config):
45
+ status, device = request(
46
+ "POST",
47
+ f"{config.issuer}/protocol/openid-connect/auth/device",
48
+ form={"client_id": CLIENT_ID, "scope": SCOPE},
49
+ )
50
+ check_available(config, status)
51
+ if status != 200:
52
+ raise CliError(f"Device authorization failed: {device}")
53
+ print(f"Sign in at: {device.get('verification_uri_complete')}", file=sys.stderr)
54
+ print(f"Code: {device['user_code']}", file=sys.stderr)
55
+
56
+ interval = device.get("interval", 5)
57
+ deadline = time.time() + device["expires_in"]
58
+ while time.time() < deadline:
59
+ time.sleep(interval)
60
+ status, token = request(
61
+ "POST",
62
+ f"{config.issuer}/protocol/openid-connect/token",
63
+ form={
64
+ "grant_type": "urn:ietf:params:oauth:grant-type:device_code",
65
+ "client_id": CLIENT_ID,
66
+ "device_code": device["device_code"],
67
+ },
68
+ )
69
+ if status == 200:
70
+ return save_tokens(token)
71
+ check_available(config, status)
72
+ error = (token or {}).get("error")
73
+ if error == "authorization_pending":
74
+ continue
75
+ if error == "slow_down":
76
+ interval += 5
77
+ continue
78
+ raise CliError(f"Login failed: {error}")
79
+ raise CliError("Login timed out")
80
+
81
+
82
+ def require_login(config: Config, interactive):
83
+ """Starts a new login, or fails when there is no one to sign in."""
84
+ if not interactive:
85
+ raise CliError("Not logged in; run `pebbenote login`")
86
+ return login(config)
87
+
88
+
89
+ def refresh(config: Config, tokens, interactive=True):
90
+ status, token = request(
91
+ "POST",
92
+ f"{config.issuer}/protocol/openid-connect/token",
93
+ form={
94
+ "grant_type": "refresh_token",
95
+ "client_id": CLIENT_ID,
96
+ "refresh_token": tokens["refresh_token"],
97
+ },
98
+ )
99
+ if status == 200:
100
+ return save_tokens(token)
101
+ # Don't start a new login when the server is down, only when the refresh
102
+ # token was rejected
103
+ check_available(config, status)
104
+ return require_login(config, interactive)
105
+
106
+
107
+ def access_token(config: Config, force_refresh=False, interactive=True):
108
+ """
109
+ Returns a valid access token, refreshing it when needed. Without a usable
110
+ token it logs in, unless `interactive` is false: then it raises CliError.
111
+ """
112
+ tokens = load_tokens()
113
+ if not tokens:
114
+ tokens = require_login(config, interactive)
115
+ elif force_refresh or tokens["expires_at"] - EXPIRY_MARGIN <= time.time():
116
+ if tokens.get("refresh_token"):
117
+ tokens = refresh(config, tokens, interactive)
118
+ else:
119
+ tokens = require_login(config, interactive)
120
+ return tokens["access_token"]
pebbenote_cli/cli.py ADDED
@@ -0,0 +1,282 @@
1
+ # PYTHON_ARGCOMPLETE_OK
2
+ """Edit a Pebbenote note in $EDITOR and sync it with the backend on quit."""
3
+
4
+ import argparse
5
+ import sys
6
+ from importlib.metadata import PackageNotFoundError, version
7
+
8
+ import argcomplete
9
+
10
+ from pebbenote_cli import api, auth
11
+ from pebbenote_cli.client.api.actions import apply_action
12
+ from pebbenote_cli.client.api.instructions import (
13
+ list_instructions,
14
+ replace_instructions,
15
+ )
16
+ from pebbenote_cli.client.api.notes import (
17
+ delete_note,
18
+ edit_note_by_id,
19
+ get_note_by_id,
20
+ list_notes,
21
+ )
22
+ from pebbenote_cli.client.api.sharing import share_note
23
+ from pebbenote_cli.client.models import (
24
+ ActionEditModel,
25
+ InstructionsEditModel,
26
+ NoteAccess,
27
+ NoteUpdateModel,
28
+ ShareAccess,
29
+ ShareCreateModel,
30
+ )
31
+ from pebbenote_cli.config import UNRESOLVED_FILE, load_config
32
+ from pebbenote_cli.editor import edit_text
33
+ from pebbenote_cli.errors import CliError, ConflictError
34
+ from pebbenote_cli.instructions import format_instructions, parse_instructions
35
+ from pebbenote_cli.merge import has_markers, merge3
36
+
37
+
38
+ def push_merging(base, edited, version, push, text_of):
39
+ """
40
+ Syncs `edited`, an edit of the text `base` that had `version` on the
41
+ server, with push(text, base_version).
42
+
43
+ When the server has a newer version, its text (text_of the conflict's
44
+ current state) is merged with the edit like git would: changes in
45
+ different places are combined and pushed again, changes to the same place
46
+ are opened in the editor between conflict markers.
47
+ """
48
+ while True:
49
+ try:
50
+ return push(edited, version)
51
+ except ConflictError as conflict:
52
+ theirs = text_of(conflict.current)
53
+ edited, has_conflicts = merge3(base, edited, theirs)
54
+ base, version = theirs, conflict.current.version
55
+
56
+ if not has_conflicts:
57
+ print("Merged with changes made on the server.", file=sys.stderr)
58
+ continue
59
+ print(
60
+ "Changed on the server in the same places; resolve the conflicts.",
61
+ file=sys.stderr,
62
+ )
63
+ edited = edit_text(edited)
64
+ if has_markers(edited):
65
+ UNRESOLVED_FILE.parent.mkdir(parents=True, exist_ok=True)
66
+ UNRESOLVED_FILE.write_text(edited)
67
+ raise CliError(
68
+ f"Conflict markers left; not syncing. Your text is in {UNRESOLVED_FILE}"
69
+ )
70
+
71
+
72
+ def cmd_edit(config, args):
73
+ note = api.call(config, get_note_by_id, note_id=args.note_id)
74
+ if not sys.stdout.isatty():
75
+ sys.stdout.write(note.content)
76
+ return
77
+ edited = edit_text(note.content)
78
+ if edited == note.content:
79
+ print("No changes; nothing to sync.", file=sys.stderr)
80
+ return
81
+
82
+ def push(text, base_version):
83
+ # The note that was read: "default" may point at another one by now
84
+ api.call(
85
+ config,
86
+ edit_note_by_id,
87
+ note_id=note.note_id,
88
+ body=NoteUpdateModel(content=text, base_version=base_version),
89
+ )
90
+
91
+ push_merging(note.content, edited, note.version, push, lambda note: note.content)
92
+ print("Note synced.", file=sys.stderr)
93
+
94
+
95
+ def cmd_delete(config, args):
96
+ note = api.call(config, get_note_by_id, note_id=args.note_id)
97
+ if not args.yes:
98
+ if not sys.stdin.isatty():
99
+ raise CliError("Not deleting without a terminal to confirm; pass --yes")
100
+ answer = input(f'Delete note "{note.title}"? [y/N] ')
101
+ if answer.strip().lower() not in ("y", "yes"):
102
+ print("Not deleted.", file=sys.stderr)
103
+ return
104
+ # The note that was read: "default" may point at another one by now
105
+ api.call(config, delete_note, note_id=note.note_id)
106
+ print("Note deleted.", file=sys.stderr)
107
+
108
+
109
+ def cmd_list(config, _args):
110
+ for note in api.call(config, list_notes):
111
+ marker = "*" if note.is_default else " "
112
+ shared = " (shared with you)" if note.access == NoteAccess.WRITE else ""
113
+ print(f"{marker} {note.note_id} {note.title}{shared}")
114
+
115
+
116
+ def cmd_share(config, args):
117
+ access = ShareAccess.WRITE if args.write else ShareAccess.READ
118
+ link = api.call(
119
+ config,
120
+ share_note,
121
+ note_id=args.note_id,
122
+ body=ShareCreateModel(access=access),
123
+ )
124
+ if args.write:
125
+ message = "Anyone with this link can sign in and edit the note"
126
+ else:
127
+ message = "Anyone with this link can view the note"
128
+ print(f"{message}, until you make it private.", file=sys.stderr)
129
+ # Only the link, to pipe it to the clipboard
130
+ print(f"{config.backend_url}{link.path}")
131
+
132
+
133
+ def cmd_instructions(config, args):
134
+ current = api.call(config, list_instructions)
135
+ text = format_instructions(current.instructions)
136
+ if not sys.stdout.isatty():
137
+ sys.stdout.write(text)
138
+ return
139
+ edited = edit_text(text)
140
+ # The order of the instructions does not matter
141
+ if sorted(parse_instructions(edited)) == sorted(current.instructions):
142
+ print("No changes; nothing to sync.", file=sys.stderr)
143
+ return
144
+ apply = not args.no_apply
145
+
146
+ def push(text, base_version):
147
+ return api.call(
148
+ config,
149
+ replace_instructions,
150
+ body=InstructionsEditModel(
151
+ instructions=parse_instructions(text), base_version=base_version
152
+ ),
153
+ apply=apply,
154
+ )
155
+
156
+ synced = push_merging(
157
+ text,
158
+ edited,
159
+ current.version,
160
+ push,
161
+ lambda current: format_instructions(current.instructions),
162
+ ).instructions
163
+ message = f"Instructions synced ({len(synced)})"
164
+ if apply and synced:
165
+ message += "; notes will be updated in the background"
166
+ print(f"{message}.", file=sys.stderr)
167
+
168
+
169
+ def cmd_action(config, args):
170
+ api.call(
171
+ config,
172
+ apply_action,
173
+ body=ActionEditModel(note_id=args.note, action=" ".join(args.text)),
174
+ )
175
+ print(
176
+ "Action queued; the note will be updated in the background.",
177
+ file=sys.stderr,
178
+ )
179
+
180
+
181
+ def complete_note_ids(**_kwargs):
182
+ """Completes note ids, with each note's title as description."""
183
+ ids = {"default": "the default note"}
184
+ try:
185
+ # Completion runs on every Tab: never start a login from it
186
+ notes = api.call(load_config(), list_notes, interactive=False)
187
+ except Exception:
188
+ # Logged out, offline or a broken config: complete what we know
189
+ return ids
190
+ for note in notes:
191
+ ids[str(note.note_id)] = note.title
192
+ return ids
193
+
194
+
195
+ def cmd_completion(_config, args):
196
+ sys.stdout.write(argcomplete.shellcode(["pebbenote"], shell=args.shell))
197
+
198
+
199
+ def cmd_login(config, _args):
200
+ auth.login(config)
201
+ print("Logged in.", file=sys.stderr)
202
+
203
+
204
+ def installed_version():
205
+ try:
206
+ return version("pebbenote-cli")
207
+ except PackageNotFoundError: # a checkout set up with --no-root
208
+ return "unknown"
209
+
210
+
211
+ def main():
212
+ parser = argparse.ArgumentParser(prog="pebbenote", description=__doc__)
213
+ parser.add_argument("--version", action="version", version=installed_version())
214
+ sub = parser.add_subparsers(dest="command")
215
+ # `pebbenote <note_id>` edits that note, so complete ids next to commands
216
+ sub.completer = complete_note_ids
217
+
218
+ edit = sub.add_parser("edit", help="edit a note (default command)")
219
+ edit.add_argument(
220
+ "note_id", nargs="?", default="default"
221
+ ).completer = complete_note_ids
222
+ edit.set_defaults(func=cmd_edit)
223
+
224
+ sub.add_parser("list", help="list notes").set_defaults(func=cmd_list)
225
+ delete = sub.add_parser("delete", help="delete a note")
226
+ delete.add_argument(
227
+ "note_id", nargs="?", default="default"
228
+ ).completer = complete_note_ids
229
+ delete.add_argument(
230
+ "-y", "--yes", action="store_true", help="do not ask for confirmation"
231
+ )
232
+ delete.set_defaults(func=cmd_delete)
233
+ share = sub.add_parser(
234
+ "share", help="get the link anyone can view a note with, or edit it"
235
+ )
236
+ share.add_argument(
237
+ "note_id", nargs="?", default="default"
238
+ ).completer = complete_note_ids
239
+ share.add_argument(
240
+ "--write",
241
+ action="store_true",
242
+ help="a link to edit the note, after signing in, instead of viewing it",
243
+ )
244
+ share.set_defaults(func=cmd_share)
245
+ instructions = sub.add_parser(
246
+ "instructions", help="edit the standing instructions, one per list item"
247
+ )
248
+ instructions.add_argument(
249
+ "--no-apply",
250
+ action="store_true",
251
+ help="only save the instructions, do not apply them to existing notes",
252
+ )
253
+ instructions.set_defaults(func=cmd_instructions)
254
+ action = sub.add_parser("action", help="ask the assistant to change a note")
255
+ action.add_argument("text", nargs="+", help="what to do, e.g. add oat milk")
256
+ action.add_argument(
257
+ "--note", default="default", help="note id (default note)"
258
+ ).completer = complete_note_ids
259
+ action.set_defaults(func=cmd_action)
260
+ sub.add_parser("login", help="force a new login").set_defaults(func=cmd_login)
261
+ completion = sub.add_parser("completion", help="print the shell completion script")
262
+ completion.add_argument("shell", choices=["bash", "zsh", "fish"])
263
+ completion.set_defaults(func=cmd_completion)
264
+
265
+ # Answers the shell's completion request and exits, when there is one
266
+ argcomplete.autocomplete(parser)
267
+
268
+ argv = sys.argv[1:]
269
+ # `edit` is the default command: `pebbenote` and `pebbenote <note_id>`
270
+ if not argv or (argv[0] not in sub.choices and not argv[0].startswith("-")):
271
+ argv = ["edit", *argv]
272
+ args = parser.parse_args(argv)
273
+ try:
274
+ args.func(load_config(), args)
275
+ except CliError as e:
276
+ sys.exit(f"error: {e}")
277
+ except KeyboardInterrupt:
278
+ sys.exit(130)
279
+
280
+
281
+ if __name__ == "__main__":
282
+ main()
@@ -0,0 +1,8 @@
1
+ """A client library for accessing PebbeNote"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,166 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.action_accepted_model import ActionAcceptedModel
9
+ from ...models.action_edit_model import ActionEditModel
10
+ from ...models.http_validation_error import HTTPValidationError
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: ActionEditModel,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": "/api/action/",
23
+ }
24
+
25
+ _kwargs["json"] = body.to_dict()
26
+
27
+ headers["Content-Type"] = "application/json"
28
+
29
+ _kwargs["headers"] = headers
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: AuthenticatedClient | Client, response: httpx.Response
35
+ ) -> ActionAcceptedModel | HTTPValidationError | None:
36
+ if response.status_code == 202:
37
+ response_202 = ActionAcceptedModel.from_dict(response.json())
38
+
39
+ return response_202
40
+
41
+ if response.status_code == 422:
42
+ response_422 = HTTPValidationError.from_dict(response.json())
43
+
44
+ return response_422
45
+
46
+ if client.raise_on_unexpected_status:
47
+ raise errors.UnexpectedStatus(response.status_code, response.content)
48
+ else:
49
+ return None
50
+
51
+
52
+ def _build_response(
53
+ *, client: AuthenticatedClient | Client, response: httpx.Response
54
+ ) -> Response[ActionAcceptedModel | HTTPValidationError]:
55
+ return Response(
56
+ status_code=HTTPStatus(response.status_code),
57
+ content=response.content,
58
+ headers=response.headers,
59
+ parsed=_parse_response(client=client, response=response),
60
+ )
61
+
62
+
63
+ def sync_detailed(
64
+ *,
65
+ client: AuthenticatedClient,
66
+ body: ActionEditModel,
67
+ ) -> Response[ActionAcceptedModel | HTTPValidationError]:
68
+ """Apply Action
69
+
70
+ Args:
71
+ body (ActionEditModel):
72
+
73
+ Raises:
74
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
75
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
76
+
77
+ Returns:
78
+ Response[ActionAcceptedModel | HTTPValidationError]
79
+ """
80
+
81
+ kwargs = _get_kwargs(
82
+ body=body,
83
+ )
84
+
85
+ response = client.get_httpx_client().request(
86
+ **kwargs,
87
+ )
88
+
89
+ return _build_response(client=client, response=response)
90
+
91
+
92
+ def sync(
93
+ *,
94
+ client: AuthenticatedClient,
95
+ body: ActionEditModel,
96
+ ) -> ActionAcceptedModel | HTTPValidationError | None:
97
+ """Apply Action
98
+
99
+ Args:
100
+ body (ActionEditModel):
101
+
102
+ Raises:
103
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
104
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
105
+
106
+ Returns:
107
+ ActionAcceptedModel | HTTPValidationError
108
+ """
109
+
110
+ return sync_detailed(
111
+ client=client,
112
+ body=body,
113
+ ).parsed
114
+
115
+
116
+ async def asyncio_detailed(
117
+ *,
118
+ client: AuthenticatedClient,
119
+ body: ActionEditModel,
120
+ ) -> Response[ActionAcceptedModel | HTTPValidationError]:
121
+ """Apply Action
122
+
123
+ Args:
124
+ body (ActionEditModel):
125
+
126
+ Raises:
127
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
128
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
129
+
130
+ Returns:
131
+ Response[ActionAcceptedModel | HTTPValidationError]
132
+ """
133
+
134
+ kwargs = _get_kwargs(
135
+ body=body,
136
+ )
137
+
138
+ response = await client.get_async_httpx_client().request(**kwargs)
139
+
140
+ return _build_response(client=client, response=response)
141
+
142
+
143
+ async def asyncio(
144
+ *,
145
+ client: AuthenticatedClient,
146
+ body: ActionEditModel,
147
+ ) -> ActionAcceptedModel | HTTPValidationError | None:
148
+ """Apply Action
149
+
150
+ Args:
151
+ body (ActionEditModel):
152
+
153
+ Raises:
154
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
156
+
157
+ Returns:
158
+ ActionAcceptedModel | HTTPValidationError
159
+ """
160
+
161
+ return (
162
+ await asyncio_detailed(
163
+ client=client,
164
+ body=body,
165
+ )
166
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""