hiloop 0.1.0__tar.gz
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.
- hiloop-0.1.0/PKG-INFO +139 -0
- hiloop-0.1.0/README.md +124 -0
- hiloop-0.1.0/hiloop/__init__.py +8 -0
- hiloop-0.1.0/hiloop/api/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/annotation_schema_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_archive_annotation_schema.py +176 -0
- hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_get_annotation_schema.py +176 -0
- hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_list_annotation_schemas.py +160 -0
- hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_register_annotation_schema.py +168 -0
- hiloop-0.1.0/hiloop/api/annotation_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/annotation_service/annotation_service_annotate.py +160 -0
- hiloop-0.1.0/hiloop/api/annotation_service/annotation_service_annotate_range.py +164 -0
- hiloop-0.1.0/hiloop/api/identity_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/identity_service/identity_service_who_am_i.py +128 -0
- hiloop-0.1.0/hiloop/api/project_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/project_service/project_service_create_project.py +158 -0
- hiloop-0.1.0/hiloop/api/project_service/project_service_get_project.py +151 -0
- hiloop-0.1.0/hiloop/api/project_service/project_service_list_projects.py +173 -0
- hiloop-0.1.0/hiloop/api/project_service/project_service_update_project.py +174 -0
- hiloop-0.1.0/hiloop/api/run_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/run_service/run_service_get_run.py +151 -0
- hiloop-0.1.0/hiloop/api/run_service/run_service_list_fork_nodes.py +153 -0
- hiloop-0.1.0/hiloop/api/run_service/run_service_list_runs.py +235 -0
- hiloop-0.1.0/hiloop/api/runtime_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_create_sandbox.py +169 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_create_snapshot.py +185 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_delete_sandbox.py +149 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_delete_snapshot.py +149 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_execute_sandbox.py +185 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_file_from_artifact.py +187 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_file_to_artifact.py +185 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_fork_sandbox.py +183 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_artifact.py +147 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_execution.py +149 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_fork.py +147 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_operation.py +149 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_sandbox.py +147 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_snapshot.py +147 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_kill_execution.py +174 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_list_runtime_capabilities.py +124 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_list_sandboxes.py +199 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_list_snapshots.py +154 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_restore_snapshot.py +187 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_send_execution_input.py +180 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_start_execution.py +182 -0
- hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_stream_execution.py +151 -0
- hiloop-0.1.0/hiloop/api/telemetry_query_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/telemetry_query_service/telemetry_query_service_branch_diff.py +156 -0
- hiloop-0.1.0/hiloop/api/telemetry_query_service/telemetry_query_service_query.py +156 -0
- hiloop-0.1.0/hiloop/api/telemetry_query_service/telemetry_query_service_rollup.py +160 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_delete_data_view.py +153 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_delete_saved_view.py +155 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_list_data_views.py +126 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_list_saved_views.py +126 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_put_data_view.py +180 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_put_saved_view.py +176 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_run_data_view.py +151 -0
- hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_run_saved_view.py +151 -0
- hiloop-0.1.0/hiloop/api/usage_service/__init__.py +1 -0
- hiloop-0.1.0/hiloop/api/usage_service/usage_service_get_usage_series.py +207 -0
- hiloop-0.1.0/hiloop/api/usage_service/usage_service_get_usage_snapshot.py +164 -0
- hiloop-0.1.0/hiloop/client.py +268 -0
- hiloop-0.1.0/hiloop/errors.py +16 -0
- hiloop-0.1.0/hiloop/models/__init__.py +239 -0
- hiloop-0.1.0/hiloop/models/annotate_range_request.py +120 -0
- hiloop-0.1.0/hiloop/models/annotate_request.py +111 -0
- hiloop-0.1.0/hiloop/models/annotate_response.py +61 -0
- hiloop-0.1.0/hiloop/models/annotation_schema.py +127 -0
- hiloop-0.1.0/hiloop/models/archive_annotation_schema_request.py +70 -0
- hiloop-0.1.0/hiloop/models/archive_annotation_schema_response.py +75 -0
- hiloop-0.1.0/hiloop/models/artifact.py +115 -0
- hiloop-0.1.0/hiloop/models/attribute_value.py +89 -0
- hiloop-0.1.0/hiloop/models/branch_diff_request.py +78 -0
- hiloop-0.1.0/hiloop/models/branch_diff_response.py +80 -0
- hiloop-0.1.0/hiloop/models/branch_diff_spec.py +94 -0
- hiloop-0.1.0/hiloop/models/build_artifact_image.py +61 -0
- hiloop-0.1.0/hiloop/models/calculation.py +81 -0
- hiloop-0.1.0/hiloop/models/calculation_op.py +16 -0
- hiloop-0.1.0/hiloop/models/capability.py +79 -0
- hiloop-0.1.0/hiloop/models/capability_requirement.py +79 -0
- hiloop-0.1.0/hiloop/models/capture_spec.py +81 -0
- hiloop-0.1.0/hiloop/models/capture_spec_policy.py +10 -0
- hiloop-0.1.0/hiloop/models/command_spec.py +112 -0
- hiloop-0.1.0/hiloop/models/command_spec_env.py +47 -0
- hiloop-0.1.0/hiloop/models/create_project_request.py +70 -0
- hiloop-0.1.0/hiloop/models/create_project_response.py +74 -0
- hiloop-0.1.0/hiloop/models/create_sandbox_request.py +214 -0
- hiloop-0.1.0/hiloop/models/create_sandbox_request_labels.py +47 -0
- hiloop-0.1.0/hiloop/models/create_sandbox_response.py +92 -0
- hiloop-0.1.0/hiloop/models/create_snapshot_request.py +118 -0
- hiloop-0.1.0/hiloop/models/create_snapshot_response.py +74 -0
- hiloop-0.1.0/hiloop/models/data_view.py +118 -0
- hiloop-0.1.0/hiloop/models/data_view_spec.py +54 -0
- hiloop-0.1.0/hiloop/models/delete_data_view_response.py +47 -0
- hiloop-0.1.0/hiloop/models/delete_sandbox_response.py +74 -0
- hiloop-0.1.0/hiloop/models/delete_saved_view_response.py +47 -0
- hiloop-0.1.0/hiloop/models/delete_snapshot_response.py +92 -0
- hiloop-0.1.0/hiloop/models/egress_policy.py +95 -0
- hiloop-0.1.0/hiloop/models/egress_policy_mode.py +10 -0
- hiloop-0.1.0/hiloop/models/exec_exit.py +71 -0
- hiloop-0.1.0/hiloop/models/exec_output_event.py +93 -0
- hiloop-0.1.0/hiloop/models/execute_sandbox_request.py +92 -0
- hiloop-0.1.0/hiloop/models/execute_sandbox_response.py +92 -0
- hiloop-0.1.0/hiloop/models/execution.py +115 -0
- hiloop-0.1.0/hiloop/models/file_from_artifact_request.py +79 -0
- hiloop-0.1.0/hiloop/models/file_from_artifact_response.py +74 -0
- hiloop-0.1.0/hiloop/models/file_to_artifact_request.py +79 -0
- hiloop-0.1.0/hiloop/models/file_to_artifact_response.py +74 -0
- hiloop-0.1.0/hiloop/models/filter_.py +101 -0
- hiloop-0.1.0/hiloop/models/filter_op.py +16 -0
- hiloop-0.1.0/hiloop/models/fork.py +142 -0
- hiloop-0.1.0/hiloop/models/fork_node.py +107 -0
- hiloop-0.1.0/hiloop/models/fork_sandbox_request.py +259 -0
- hiloop-0.1.0/hiloop/models/fork_sandbox_request_labels.py +47 -0
- hiloop-0.1.0/hiloop/models/fork_sandbox_response.py +92 -0
- hiloop-0.1.0/hiloop/models/get_annotation_schema_response.py +75 -0
- hiloop-0.1.0/hiloop/models/get_artifact_response.py +83 -0
- hiloop-0.1.0/hiloop/models/get_execution_response.py +74 -0
- hiloop-0.1.0/hiloop/models/get_fork_response.py +74 -0
- hiloop-0.1.0/hiloop/models/get_operation_response.py +74 -0
- hiloop-0.1.0/hiloop/models/get_project_response.py +74 -0
- hiloop-0.1.0/hiloop/models/get_run_response.py +76 -0
- hiloop-0.1.0/hiloop/models/get_sandbox_response.py +74 -0
- hiloop-0.1.0/hiloop/models/get_snapshot_response.py +74 -0
- hiloop-0.1.0/hiloop/models/get_usage_series_response.py +79 -0
- hiloop-0.1.0/hiloop/models/get_usage_snapshot_response.py +74 -0
- hiloop-0.1.0/hiloop/models/identity.py +100 -0
- hiloop-0.1.0/hiloop/models/kill_execution_request.py +79 -0
- hiloop-0.1.0/hiloop/models/kill_execution_request_signal.py +12 -0
- hiloop-0.1.0/hiloop/models/kill_execution_response.py +47 -0
- hiloop-0.1.0/hiloop/models/list_annotation_schemas_response.py +81 -0
- hiloop-0.1.0/hiloop/models/list_data_views_response.py +79 -0
- hiloop-0.1.0/hiloop/models/list_fork_nodes_response.py +79 -0
- hiloop-0.1.0/hiloop/models/list_projects_response.py +89 -0
- hiloop-0.1.0/hiloop/models/list_runs_response.py +89 -0
- hiloop-0.1.0/hiloop/models/list_runtime_capabilities_response.py +79 -0
- hiloop-0.1.0/hiloop/models/list_sandboxes_response.py +89 -0
- hiloop-0.1.0/hiloop/models/list_saved_views_response.py +79 -0
- hiloop-0.1.0/hiloop/models/list_snapshots_response.py +79 -0
- hiloop-0.1.0/hiloop/models/oci_image.py +70 -0
- hiloop-0.1.0/hiloop/models/operation.py +124 -0
- hiloop-0.1.0/hiloop/models/order.py +72 -0
- hiloop-0.1.0/hiloop/models/project.py +110 -0
- hiloop-0.1.0/hiloop/models/provider_native_image.py +62 -0
- hiloop-0.1.0/hiloop/models/put_data_view_request.py +96 -0
- hiloop-0.1.0/hiloop/models/put_data_view_request_spec.py +50 -0
- hiloop-0.1.0/hiloop/models/put_saved_view_request.py +71 -0
- hiloop-0.1.0/hiloop/models/query_request.py +76 -0
- hiloop-0.1.0/hiloop/models/query_response.py +79 -0
- hiloop-0.1.0/hiloop/models/query_spec.py +190 -0
- hiloop-0.1.0/hiloop/models/register_annotation_schema_request.py +80 -0
- hiloop-0.1.0/hiloop/models/register_annotation_schema_response.py +75 -0
- hiloop-0.1.0/hiloop/models/reserved_resources.py +91 -0
- hiloop-0.1.0/hiloop/models/resource_spec.py +96 -0
- hiloop-0.1.0/hiloop/models/resource_spec_architecture.py +10 -0
- hiloop-0.1.0/hiloop/models/restore_snapshot_request.py +241 -0
- hiloop-0.1.0/hiloop/models/restore_snapshot_request_labels.py +47 -0
- hiloop-0.1.0/hiloop/models/restore_snapshot_response.py +92 -0
- hiloop-0.1.0/hiloop/models/rollup_request.py +79 -0
- hiloop-0.1.0/hiloop/models/rollup_response.py +82 -0
- hiloop-0.1.0/hiloop/models/rollup_spec.py +98 -0
- hiloop-0.1.0/hiloop/models/row.py +76 -0
- hiloop-0.1.0/hiloop/models/row_columns.py +60 -0
- hiloop-0.1.0/hiloop/models/run.py +145 -0
- hiloop-0.1.0/hiloop/models/sandbox.py +135 -0
- hiloop-0.1.0/hiloop/models/sandbox_image.py +111 -0
- hiloop-0.1.0/hiloop/models/sandbox_state_count.py +71 -0
- hiloop-0.1.0/hiloop/models/saved_view.py +71 -0
- hiloop-0.1.0/hiloop/models/secret_binding.py +82 -0
- hiloop-0.1.0/hiloop/models/send_execution_input_request.py +88 -0
- hiloop-0.1.0/hiloop/models/send_execution_input_request_signal.py +12 -0
- hiloop-0.1.0/hiloop/models/send_execution_input_response.py +47 -0
- hiloop-0.1.0/hiloop/models/snapshot.py +133 -0
- hiloop-0.1.0/hiloop/models/start_execution_request.py +102 -0
- hiloop-0.1.0/hiloop/models/start_execution_response.py +74 -0
- hiloop-0.1.0/hiloop/models/time_range.py +71 -0
- hiloop-0.1.0/hiloop/models/update_project_request.py +70 -0
- hiloop-0.1.0/hiloop/models/update_project_response.py +74 -0
- hiloop-0.1.0/hiloop/models/usage_series_point.py +90 -0
- hiloop-0.1.0/hiloop/models/usage_snapshot.py +157 -0
- hiloop-0.1.0/hiloop/models/who_am_i_response.py +76 -0
- hiloop-0.1.0/hiloop/py.typed +1 -0
- hiloop-0.1.0/hiloop/types.py +54 -0
- hiloop-0.1.0/pyproject.toml +25 -0
hiloop-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hiloop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A client library for accessing
|
|
5
|
+
Requires-Python: >=3.11,<4.0
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Requires-Dist: attrs (>=22.2.0)
|
|
12
|
+
Requires-Dist: httpx (>=0.23.1,<0.29.0)
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# hiloop-sdk
|
|
16
|
+
A client library for accessing
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
First, create a client:
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from hiloop import Client
|
|
23
|
+
|
|
24
|
+
client = Client(base_url="https://api.example.com")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from hiloop import AuthenticatedClient
|
|
31
|
+
|
|
32
|
+
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Now call your endpoint and use your models:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from hiloop.models import MyDataModel
|
|
39
|
+
from hiloop.api.my_tag import get_my_data_model
|
|
40
|
+
from hiloop.types import Response
|
|
41
|
+
|
|
42
|
+
with client as client:
|
|
43
|
+
my_data: MyDataModel = get_my_data_model.sync(client=client)
|
|
44
|
+
# or if you need more info (e.g. status_code)
|
|
45
|
+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or do the same thing with an async version:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from hiloop.models import MyDataModel
|
|
52
|
+
from hiloop.api.my_tag import get_my_data_model
|
|
53
|
+
from hiloop.types import Response
|
|
54
|
+
|
|
55
|
+
async with client as client:
|
|
56
|
+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
|
|
57
|
+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
client = AuthenticatedClient(
|
|
64
|
+
base_url="https://internal_api.example.com",
|
|
65
|
+
token="SuperSecretToken",
|
|
66
|
+
verify_ssl="/path/to/certificate_bundle.pem",
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
You can also disable certificate validation altogether, but beware that **this is a security risk**.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
client = AuthenticatedClient(
|
|
74
|
+
base_url="https://internal_api.example.com",
|
|
75
|
+
token="SuperSecretToken",
|
|
76
|
+
verify_ssl=False
|
|
77
|
+
)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Things to know:
|
|
81
|
+
1. Every path/method combo becomes a Python module with four functions:
|
|
82
|
+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
|
|
83
|
+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
|
|
84
|
+
1. `asyncio`: Like `sync` but async instead of blocking
|
|
85
|
+
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
|
|
86
|
+
|
|
87
|
+
1. All path/query params, and bodies become method arguments.
|
|
88
|
+
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
|
|
89
|
+
1. Any endpoint which did not have a tag will be in `hiloop.api.default`
|
|
90
|
+
|
|
91
|
+
## Advanced customizations
|
|
92
|
+
|
|
93
|
+
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from hiloop import Client
|
|
97
|
+
|
|
98
|
+
def log_request(request):
|
|
99
|
+
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
|
|
100
|
+
|
|
101
|
+
def log_response(response):
|
|
102
|
+
request = response.request
|
|
103
|
+
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
|
|
104
|
+
|
|
105
|
+
client = Client(
|
|
106
|
+
base_url="https://api.example.com",
|
|
107
|
+
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
import httpx
|
|
117
|
+
from hiloop import Client
|
|
118
|
+
|
|
119
|
+
client = Client(
|
|
120
|
+
base_url="https://api.example.com",
|
|
121
|
+
)
|
|
122
|
+
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
|
|
123
|
+
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Building / publishing this package
|
|
127
|
+
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
|
|
128
|
+
1. Update the metadata in pyproject.toml (e.g. authors, version)
|
|
129
|
+
1. If you're using a private repository, configure it with Poetry
|
|
130
|
+
1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
|
|
131
|
+
1. `poetry config http-basic.<your-repository-name> <username> <password>`
|
|
132
|
+
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
|
|
133
|
+
|
|
134
|
+
If you want to install this client into another project without publishing it (e.g. for development) then:
|
|
135
|
+
1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
|
|
136
|
+
1. If that project is not using Poetry:
|
|
137
|
+
1. Build a wheel with `poetry build -f wheel`
|
|
138
|
+
1. Install that wheel from the other project `pip install <path-to-wheel>`
|
|
139
|
+
|
hiloop-0.1.0/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# hiloop-sdk
|
|
2
|
+
A client library for accessing
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
First, create a client:
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from hiloop import Client
|
|
9
|
+
|
|
10
|
+
client = Client(base_url="https://api.example.com")
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from hiloop import AuthenticatedClient
|
|
17
|
+
|
|
18
|
+
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now call your endpoint and use your models:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from hiloop.models import MyDataModel
|
|
25
|
+
from hiloop.api.my_tag import get_my_data_model
|
|
26
|
+
from hiloop.types import Response
|
|
27
|
+
|
|
28
|
+
with client as client:
|
|
29
|
+
my_data: MyDataModel = get_my_data_model.sync(client=client)
|
|
30
|
+
# or if you need more info (e.g. status_code)
|
|
31
|
+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or do the same thing with an async version:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from hiloop.models import MyDataModel
|
|
38
|
+
from hiloop.api.my_tag import get_my_data_model
|
|
39
|
+
from hiloop.types import Response
|
|
40
|
+
|
|
41
|
+
async with client as client:
|
|
42
|
+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
|
|
43
|
+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
client = AuthenticatedClient(
|
|
50
|
+
base_url="https://internal_api.example.com",
|
|
51
|
+
token="SuperSecretToken",
|
|
52
|
+
verify_ssl="/path/to/certificate_bundle.pem",
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
You can also disable certificate validation altogether, but beware that **this is a security risk**.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
client = AuthenticatedClient(
|
|
60
|
+
base_url="https://internal_api.example.com",
|
|
61
|
+
token="SuperSecretToken",
|
|
62
|
+
verify_ssl=False
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Things to know:
|
|
67
|
+
1. Every path/method combo becomes a Python module with four functions:
|
|
68
|
+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
|
|
69
|
+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
|
|
70
|
+
1. `asyncio`: Like `sync` but async instead of blocking
|
|
71
|
+
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
|
|
72
|
+
|
|
73
|
+
1. All path/query params, and bodies become method arguments.
|
|
74
|
+
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
|
|
75
|
+
1. Any endpoint which did not have a tag will be in `hiloop.api.default`
|
|
76
|
+
|
|
77
|
+
## Advanced customizations
|
|
78
|
+
|
|
79
|
+
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from hiloop import Client
|
|
83
|
+
|
|
84
|
+
def log_request(request):
|
|
85
|
+
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
|
|
86
|
+
|
|
87
|
+
def log_response(response):
|
|
88
|
+
request = response.request
|
|
89
|
+
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
|
|
90
|
+
|
|
91
|
+
client = Client(
|
|
92
|
+
base_url="https://api.example.com",
|
|
93
|
+
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import httpx
|
|
103
|
+
from hiloop import Client
|
|
104
|
+
|
|
105
|
+
client = Client(
|
|
106
|
+
base_url="https://api.example.com",
|
|
107
|
+
)
|
|
108
|
+
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
|
|
109
|
+
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Building / publishing this package
|
|
113
|
+
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
|
|
114
|
+
1. Update the metadata in pyproject.toml (e.g. authors, version)
|
|
115
|
+
1. If you're using a private repository, configure it with Poetry
|
|
116
|
+
1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
|
|
117
|
+
1. `poetry config http-basic.<your-repository-name> <username> <password>`
|
|
118
|
+
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
|
|
119
|
+
|
|
120
|
+
If you want to install this client into another project without publishing it (e.g. for development) then:
|
|
121
|
+
1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
|
|
122
|
+
1. If that project is not using Poetry:
|
|
123
|
+
1. Build a wheel with `poetry build -f wheel`
|
|
124
|
+
1. Install that wheel from the other project `pip install <path-to-wheel>`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains methods for accessing the API"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
from urllib.parse import quote
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.archive_annotation_schema_request import ArchiveAnnotationSchemaRequest
|
|
10
|
+
from ...models.archive_annotation_schema_response import ArchiveAnnotationSchemaResponse
|
|
11
|
+
from ...types import Response
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_kwargs(
|
|
15
|
+
name: str,
|
|
16
|
+
*,
|
|
17
|
+
body: ArchiveAnnotationSchemaRequest,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
headers: dict[str, Any] = {}
|
|
20
|
+
|
|
21
|
+
_kwargs: dict[str, Any] = {
|
|
22
|
+
"method": "post",
|
|
23
|
+
"url": "/v1/annotation-schemas/{name}:archive".format(
|
|
24
|
+
name=quote(str(name), safe=""),
|
|
25
|
+
),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_kwargs["json"] = body.to_dict()
|
|
29
|
+
|
|
30
|
+
headers["Content-Type"] = "application/json"
|
|
31
|
+
|
|
32
|
+
_kwargs["headers"] = headers
|
|
33
|
+
return _kwargs
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _parse_response(
|
|
37
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
38
|
+
) -> ArchiveAnnotationSchemaResponse | None:
|
|
39
|
+
if response.status_code == 200:
|
|
40
|
+
response_200 = ArchiveAnnotationSchemaResponse.from_dict(response.json())
|
|
41
|
+
|
|
42
|
+
return response_200
|
|
43
|
+
|
|
44
|
+
if client.raise_on_unexpected_status:
|
|
45
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
46
|
+
else:
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _build_response(
|
|
51
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
52
|
+
) -> Response[ArchiveAnnotationSchemaResponse]:
|
|
53
|
+
return Response(
|
|
54
|
+
status_code=HTTPStatus(response.status_code),
|
|
55
|
+
content=response.content,
|
|
56
|
+
headers=response.headers,
|
|
57
|
+
parsed=_parse_response(client=client, response=response),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def sync_detailed(
|
|
62
|
+
name: str,
|
|
63
|
+
*,
|
|
64
|
+
client: AuthenticatedClient | Client,
|
|
65
|
+
body: ArchiveAnnotationSchemaRequest,
|
|
66
|
+
) -> Response[ArchiveAnnotationSchemaResponse]:
|
|
67
|
+
"""Archive a schema config version (stamp archived_at; never hard-delete) in the caller's tenant.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
name (str):
|
|
71
|
+
body (ArchiveAnnotationSchemaRequest):
|
|
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[ArchiveAnnotationSchemaResponse]
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
kwargs = _get_kwargs(
|
|
82
|
+
name=name,
|
|
83
|
+
body=body,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
response = client.get_httpx_client().request(
|
|
87
|
+
**kwargs,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return _build_response(client=client, response=response)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def sync(
|
|
94
|
+
name: str,
|
|
95
|
+
*,
|
|
96
|
+
client: AuthenticatedClient | Client,
|
|
97
|
+
body: ArchiveAnnotationSchemaRequest,
|
|
98
|
+
) -> ArchiveAnnotationSchemaResponse | None:
|
|
99
|
+
"""Archive a schema config version (stamp archived_at; never hard-delete) in the caller's tenant.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
name (str):
|
|
103
|
+
body (ArchiveAnnotationSchemaRequest):
|
|
104
|
+
|
|
105
|
+
Raises:
|
|
106
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
107
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
ArchiveAnnotationSchemaResponse
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
return sync_detailed(
|
|
114
|
+
name=name,
|
|
115
|
+
client=client,
|
|
116
|
+
body=body,
|
|
117
|
+
).parsed
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
async def asyncio_detailed(
|
|
121
|
+
name: str,
|
|
122
|
+
*,
|
|
123
|
+
client: AuthenticatedClient | Client,
|
|
124
|
+
body: ArchiveAnnotationSchemaRequest,
|
|
125
|
+
) -> Response[ArchiveAnnotationSchemaResponse]:
|
|
126
|
+
"""Archive a schema config version (stamp archived_at; never hard-delete) in the caller's tenant.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
name (str):
|
|
130
|
+
body (ArchiveAnnotationSchemaRequest):
|
|
131
|
+
|
|
132
|
+
Raises:
|
|
133
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
134
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
Response[ArchiveAnnotationSchemaResponse]
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
kwargs = _get_kwargs(
|
|
141
|
+
name=name,
|
|
142
|
+
body=body,
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
146
|
+
|
|
147
|
+
return _build_response(client=client, response=response)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
async def asyncio(
|
|
151
|
+
name: str,
|
|
152
|
+
*,
|
|
153
|
+
client: AuthenticatedClient | Client,
|
|
154
|
+
body: ArchiveAnnotationSchemaRequest,
|
|
155
|
+
) -> ArchiveAnnotationSchemaResponse | None:
|
|
156
|
+
"""Archive a schema config version (stamp archived_at; never hard-delete) in the caller's tenant.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
name (str):
|
|
160
|
+
body (ArchiveAnnotationSchemaRequest):
|
|
161
|
+
|
|
162
|
+
Raises:
|
|
163
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
164
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
ArchiveAnnotationSchemaResponse
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
await asyncio_detailed(
|
|
172
|
+
name=name,
|
|
173
|
+
client=client,
|
|
174
|
+
body=body,
|
|
175
|
+
)
|
|
176
|
+
).parsed
|
hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_get_annotation_schema.py
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
from urllib.parse import quote
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.get_annotation_schema_response import GetAnnotationSchemaResponse
|
|
10
|
+
from ...types import UNSET, Response, Unset
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_kwargs(
|
|
14
|
+
name: str,
|
|
15
|
+
*,
|
|
16
|
+
version: str | Unset = UNSET,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
|
|
19
|
+
params: dict[str, Any] = {}
|
|
20
|
+
|
|
21
|
+
params["version"] = version
|
|
22
|
+
|
|
23
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
24
|
+
|
|
25
|
+
_kwargs: dict[str, Any] = {
|
|
26
|
+
"method": "get",
|
|
27
|
+
"url": "/v1/annotation-schemas/{name}".format(
|
|
28
|
+
name=quote(str(name), safe=""),
|
|
29
|
+
),
|
|
30
|
+
"params": params,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return _kwargs
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _parse_response(
|
|
37
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
38
|
+
) -> GetAnnotationSchemaResponse | None:
|
|
39
|
+
if response.status_code == 200:
|
|
40
|
+
response_200 = GetAnnotationSchemaResponse.from_dict(response.json())
|
|
41
|
+
|
|
42
|
+
return response_200
|
|
43
|
+
|
|
44
|
+
if client.raise_on_unexpected_status:
|
|
45
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
46
|
+
else:
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _build_response(
|
|
51
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
52
|
+
) -> Response[GetAnnotationSchemaResponse]:
|
|
53
|
+
return Response(
|
|
54
|
+
status_code=HTTPStatus(response.status_code),
|
|
55
|
+
content=response.content,
|
|
56
|
+
headers=response.headers,
|
|
57
|
+
parsed=_parse_response(client=client, response=response),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def sync_detailed(
|
|
62
|
+
name: str,
|
|
63
|
+
*,
|
|
64
|
+
client: AuthenticatedClient | Client,
|
|
65
|
+
version: str | Unset = UNSET,
|
|
66
|
+
) -> Response[GetAnnotationSchemaResponse]:
|
|
67
|
+
"""Get a schema config by name (latest live version, or a specific version) in the caller's tenant.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
name (str):
|
|
71
|
+
version (str | Unset):
|
|
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[GetAnnotationSchemaResponse]
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
kwargs = _get_kwargs(
|
|
82
|
+
name=name,
|
|
83
|
+
version=version,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
response = client.get_httpx_client().request(
|
|
87
|
+
**kwargs,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return _build_response(client=client, response=response)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def sync(
|
|
94
|
+
name: str,
|
|
95
|
+
*,
|
|
96
|
+
client: AuthenticatedClient | Client,
|
|
97
|
+
version: str | Unset = UNSET,
|
|
98
|
+
) -> GetAnnotationSchemaResponse | None:
|
|
99
|
+
"""Get a schema config by name (latest live version, or a specific version) in the caller's tenant.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
name (str):
|
|
103
|
+
version (str | Unset):
|
|
104
|
+
|
|
105
|
+
Raises:
|
|
106
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
107
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
GetAnnotationSchemaResponse
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
return sync_detailed(
|
|
114
|
+
name=name,
|
|
115
|
+
client=client,
|
|
116
|
+
version=version,
|
|
117
|
+
).parsed
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
async def asyncio_detailed(
|
|
121
|
+
name: str,
|
|
122
|
+
*,
|
|
123
|
+
client: AuthenticatedClient | Client,
|
|
124
|
+
version: str | Unset = UNSET,
|
|
125
|
+
) -> Response[GetAnnotationSchemaResponse]:
|
|
126
|
+
"""Get a schema config by name (latest live version, or a specific version) in the caller's tenant.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
name (str):
|
|
130
|
+
version (str | Unset):
|
|
131
|
+
|
|
132
|
+
Raises:
|
|
133
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
134
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
Response[GetAnnotationSchemaResponse]
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
kwargs = _get_kwargs(
|
|
141
|
+
name=name,
|
|
142
|
+
version=version,
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
146
|
+
|
|
147
|
+
return _build_response(client=client, response=response)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
async def asyncio(
|
|
151
|
+
name: str,
|
|
152
|
+
*,
|
|
153
|
+
client: AuthenticatedClient | Client,
|
|
154
|
+
version: str | Unset = UNSET,
|
|
155
|
+
) -> GetAnnotationSchemaResponse | None:
|
|
156
|
+
"""Get a schema config by name (latest live version, or a specific version) in the caller's tenant.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
name (str):
|
|
160
|
+
version (str | Unset):
|
|
161
|
+
|
|
162
|
+
Raises:
|
|
163
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
164
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
GetAnnotationSchemaResponse
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
await asyncio_detailed(
|
|
172
|
+
name=name,
|
|
173
|
+
client=client,
|
|
174
|
+
version=version,
|
|
175
|
+
)
|
|
176
|
+
).parsed
|