orca-cli-sdk 0.1.0__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.
- orca_cli_sdk-0.1.0.dist-info/METADATA +226 -0
- orca_cli_sdk-0.1.0.dist-info/RECORD +16 -0
- orca_cli_sdk-0.1.0.dist-info/WHEEL +4 -0
- orca_cli_sdk-0.1.0.dist-info/licenses/LICENSE +21 -0
- orca_sdk/__init__.py +41 -0
- orca_sdk/_async_client.py +171 -0
- orca_sdk/_client.py +195 -0
- orca_sdk/_core.py +314 -0
- orca_sdk/_exceptions.py +105 -0
- orca_sdk/_generated.py +11094 -0
- orca_sdk/_resource.py +85 -0
- orca_sdk/_version.py +4 -0
- orca_sdk/data/agent-context.json +7811 -0
- orca_sdk/data/flag-types.json +2146 -0
- orca_sdk/py.typed +0 -0
- orca_sdk/schema.py +33 -0
orca_sdk/_resource.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Base classes shared by the generated command wrappers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
from typing import TYPE_CHECKING, Any
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from ._async_client import AsyncOrca
|
|
10
|
+
from ._client import Orca
|
|
11
|
+
|
|
12
|
+
#: A value accepted for a flag or positional argument.
|
|
13
|
+
Scalar = str | int | float
|
|
14
|
+
|
|
15
|
+
FlagValue = Scalar | bool | Sequence[Scalar] | None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_args(
|
|
19
|
+
command: str,
|
|
20
|
+
positionals: Sequence[Any],
|
|
21
|
+
flags: Sequence[tuple[str, FlagValue]],
|
|
22
|
+
) -> list[str]:
|
|
23
|
+
"""Turn a command path, positionals and ``(flag, value)`` pairs into argv.
|
|
24
|
+
|
|
25
|
+
``None`` and ``False`` values are omitted, ``True`` emits a bare flag, and a
|
|
26
|
+
list/tuple value emits the flag once per item (for repeatable flags).
|
|
27
|
+
A list positional (variadic) is expanded in place.
|
|
28
|
+
"""
|
|
29
|
+
argv = command.split()
|
|
30
|
+
for value in positionals:
|
|
31
|
+
if value is None:
|
|
32
|
+
continue
|
|
33
|
+
if isinstance(value, (list, tuple)):
|
|
34
|
+
argv.extend(_to_str(v) for v in value)
|
|
35
|
+
else:
|
|
36
|
+
argv.append(_to_str(value))
|
|
37
|
+
for name, value in flags:
|
|
38
|
+
if value is None or value is False:
|
|
39
|
+
continue
|
|
40
|
+
if value is True:
|
|
41
|
+
argv.append(f"--{name}")
|
|
42
|
+
elif isinstance(value, (list, tuple)):
|
|
43
|
+
for item in value:
|
|
44
|
+
argv += _flag(name, item)
|
|
45
|
+
else:
|
|
46
|
+
argv += _flag(name, value)
|
|
47
|
+
return argv
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _flag(name: str, value: Any) -> list[str]:
|
|
51
|
+
text = _to_str(value)
|
|
52
|
+
# Values that look like flags must be attached so the CLI parser keeps them.
|
|
53
|
+
if text.startswith("-"):
|
|
54
|
+
return [f"--{name}={text}"]
|
|
55
|
+
return [f"--{name}", text]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _to_str(value: Any) -> str:
|
|
59
|
+
if isinstance(value, bool):
|
|
60
|
+
return "true" if value else "false"
|
|
61
|
+
return str(value)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class _Resource:
|
|
65
|
+
def __init__(self, client: Orca) -> None:
|
|
66
|
+
self._client = client
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class _AsyncResource:
|
|
70
|
+
def __init__(self, client: AsyncOrca) -> None:
|
|
71
|
+
self._client = client
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class _SyncRoot:
|
|
75
|
+
_client: Orca
|
|
76
|
+
|
|
77
|
+
def __init__(self) -> None:
|
|
78
|
+
self._client = self # type: ignore[assignment]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class _AsyncRoot:
|
|
82
|
+
_client: AsyncOrca
|
|
83
|
+
|
|
84
|
+
def __init__(self) -> None:
|
|
85
|
+
self._client = self # type: ignore[assignment]
|
orca_sdk/_version.py
ADDED