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.
Files changed (185) hide show
  1. hiloop-0.1.0/PKG-INFO +139 -0
  2. hiloop-0.1.0/README.md +124 -0
  3. hiloop-0.1.0/hiloop/__init__.py +8 -0
  4. hiloop-0.1.0/hiloop/api/__init__.py +1 -0
  5. hiloop-0.1.0/hiloop/api/annotation_schema_service/__init__.py +1 -0
  6. hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_archive_annotation_schema.py +176 -0
  7. hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_get_annotation_schema.py +176 -0
  8. hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_list_annotation_schemas.py +160 -0
  9. hiloop-0.1.0/hiloop/api/annotation_schema_service/annotation_schema_service_register_annotation_schema.py +168 -0
  10. hiloop-0.1.0/hiloop/api/annotation_service/__init__.py +1 -0
  11. hiloop-0.1.0/hiloop/api/annotation_service/annotation_service_annotate.py +160 -0
  12. hiloop-0.1.0/hiloop/api/annotation_service/annotation_service_annotate_range.py +164 -0
  13. hiloop-0.1.0/hiloop/api/identity_service/__init__.py +1 -0
  14. hiloop-0.1.0/hiloop/api/identity_service/identity_service_who_am_i.py +128 -0
  15. hiloop-0.1.0/hiloop/api/project_service/__init__.py +1 -0
  16. hiloop-0.1.0/hiloop/api/project_service/project_service_create_project.py +158 -0
  17. hiloop-0.1.0/hiloop/api/project_service/project_service_get_project.py +151 -0
  18. hiloop-0.1.0/hiloop/api/project_service/project_service_list_projects.py +173 -0
  19. hiloop-0.1.0/hiloop/api/project_service/project_service_update_project.py +174 -0
  20. hiloop-0.1.0/hiloop/api/run_service/__init__.py +1 -0
  21. hiloop-0.1.0/hiloop/api/run_service/run_service_get_run.py +151 -0
  22. hiloop-0.1.0/hiloop/api/run_service/run_service_list_fork_nodes.py +153 -0
  23. hiloop-0.1.0/hiloop/api/run_service/run_service_list_runs.py +235 -0
  24. hiloop-0.1.0/hiloop/api/runtime_service/__init__.py +1 -0
  25. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_create_sandbox.py +169 -0
  26. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_create_snapshot.py +185 -0
  27. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_delete_sandbox.py +149 -0
  28. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_delete_snapshot.py +149 -0
  29. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_execute_sandbox.py +185 -0
  30. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_file_from_artifact.py +187 -0
  31. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_file_to_artifact.py +185 -0
  32. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_fork_sandbox.py +183 -0
  33. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_artifact.py +147 -0
  34. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_execution.py +149 -0
  35. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_fork.py +147 -0
  36. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_operation.py +149 -0
  37. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_sandbox.py +147 -0
  38. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_get_snapshot.py +147 -0
  39. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_kill_execution.py +174 -0
  40. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_list_runtime_capabilities.py +124 -0
  41. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_list_sandboxes.py +199 -0
  42. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_list_snapshots.py +154 -0
  43. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_restore_snapshot.py +187 -0
  44. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_send_execution_input.py +180 -0
  45. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_start_execution.py +182 -0
  46. hiloop-0.1.0/hiloop/api/runtime_service/runtime_service_stream_execution.py +151 -0
  47. hiloop-0.1.0/hiloop/api/telemetry_query_service/__init__.py +1 -0
  48. hiloop-0.1.0/hiloop/api/telemetry_query_service/telemetry_query_service_branch_diff.py +156 -0
  49. hiloop-0.1.0/hiloop/api/telemetry_query_service/telemetry_query_service_query.py +156 -0
  50. hiloop-0.1.0/hiloop/api/telemetry_query_service/telemetry_query_service_rollup.py +160 -0
  51. hiloop-0.1.0/hiloop/api/telemetry_view_service/__init__.py +1 -0
  52. hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_delete_data_view.py +153 -0
  53. hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_delete_saved_view.py +155 -0
  54. hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_list_data_views.py +126 -0
  55. hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_list_saved_views.py +126 -0
  56. hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_put_data_view.py +180 -0
  57. hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_put_saved_view.py +176 -0
  58. hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_run_data_view.py +151 -0
  59. hiloop-0.1.0/hiloop/api/telemetry_view_service/telemetry_view_service_run_saved_view.py +151 -0
  60. hiloop-0.1.0/hiloop/api/usage_service/__init__.py +1 -0
  61. hiloop-0.1.0/hiloop/api/usage_service/usage_service_get_usage_series.py +207 -0
  62. hiloop-0.1.0/hiloop/api/usage_service/usage_service_get_usage_snapshot.py +164 -0
  63. hiloop-0.1.0/hiloop/client.py +268 -0
  64. hiloop-0.1.0/hiloop/errors.py +16 -0
  65. hiloop-0.1.0/hiloop/models/__init__.py +239 -0
  66. hiloop-0.1.0/hiloop/models/annotate_range_request.py +120 -0
  67. hiloop-0.1.0/hiloop/models/annotate_request.py +111 -0
  68. hiloop-0.1.0/hiloop/models/annotate_response.py +61 -0
  69. hiloop-0.1.0/hiloop/models/annotation_schema.py +127 -0
  70. hiloop-0.1.0/hiloop/models/archive_annotation_schema_request.py +70 -0
  71. hiloop-0.1.0/hiloop/models/archive_annotation_schema_response.py +75 -0
  72. hiloop-0.1.0/hiloop/models/artifact.py +115 -0
  73. hiloop-0.1.0/hiloop/models/attribute_value.py +89 -0
  74. hiloop-0.1.0/hiloop/models/branch_diff_request.py +78 -0
  75. hiloop-0.1.0/hiloop/models/branch_diff_response.py +80 -0
  76. hiloop-0.1.0/hiloop/models/branch_diff_spec.py +94 -0
  77. hiloop-0.1.0/hiloop/models/build_artifact_image.py +61 -0
  78. hiloop-0.1.0/hiloop/models/calculation.py +81 -0
  79. hiloop-0.1.0/hiloop/models/calculation_op.py +16 -0
  80. hiloop-0.1.0/hiloop/models/capability.py +79 -0
  81. hiloop-0.1.0/hiloop/models/capability_requirement.py +79 -0
  82. hiloop-0.1.0/hiloop/models/capture_spec.py +81 -0
  83. hiloop-0.1.0/hiloop/models/capture_spec_policy.py +10 -0
  84. hiloop-0.1.0/hiloop/models/command_spec.py +112 -0
  85. hiloop-0.1.0/hiloop/models/command_spec_env.py +47 -0
  86. hiloop-0.1.0/hiloop/models/create_project_request.py +70 -0
  87. hiloop-0.1.0/hiloop/models/create_project_response.py +74 -0
  88. hiloop-0.1.0/hiloop/models/create_sandbox_request.py +214 -0
  89. hiloop-0.1.0/hiloop/models/create_sandbox_request_labels.py +47 -0
  90. hiloop-0.1.0/hiloop/models/create_sandbox_response.py +92 -0
  91. hiloop-0.1.0/hiloop/models/create_snapshot_request.py +118 -0
  92. hiloop-0.1.0/hiloop/models/create_snapshot_response.py +74 -0
  93. hiloop-0.1.0/hiloop/models/data_view.py +118 -0
  94. hiloop-0.1.0/hiloop/models/data_view_spec.py +54 -0
  95. hiloop-0.1.0/hiloop/models/delete_data_view_response.py +47 -0
  96. hiloop-0.1.0/hiloop/models/delete_sandbox_response.py +74 -0
  97. hiloop-0.1.0/hiloop/models/delete_saved_view_response.py +47 -0
  98. hiloop-0.1.0/hiloop/models/delete_snapshot_response.py +92 -0
  99. hiloop-0.1.0/hiloop/models/egress_policy.py +95 -0
  100. hiloop-0.1.0/hiloop/models/egress_policy_mode.py +10 -0
  101. hiloop-0.1.0/hiloop/models/exec_exit.py +71 -0
  102. hiloop-0.1.0/hiloop/models/exec_output_event.py +93 -0
  103. hiloop-0.1.0/hiloop/models/execute_sandbox_request.py +92 -0
  104. hiloop-0.1.0/hiloop/models/execute_sandbox_response.py +92 -0
  105. hiloop-0.1.0/hiloop/models/execution.py +115 -0
  106. hiloop-0.1.0/hiloop/models/file_from_artifact_request.py +79 -0
  107. hiloop-0.1.0/hiloop/models/file_from_artifact_response.py +74 -0
  108. hiloop-0.1.0/hiloop/models/file_to_artifact_request.py +79 -0
  109. hiloop-0.1.0/hiloop/models/file_to_artifact_response.py +74 -0
  110. hiloop-0.1.0/hiloop/models/filter_.py +101 -0
  111. hiloop-0.1.0/hiloop/models/filter_op.py +16 -0
  112. hiloop-0.1.0/hiloop/models/fork.py +142 -0
  113. hiloop-0.1.0/hiloop/models/fork_node.py +107 -0
  114. hiloop-0.1.0/hiloop/models/fork_sandbox_request.py +259 -0
  115. hiloop-0.1.0/hiloop/models/fork_sandbox_request_labels.py +47 -0
  116. hiloop-0.1.0/hiloop/models/fork_sandbox_response.py +92 -0
  117. hiloop-0.1.0/hiloop/models/get_annotation_schema_response.py +75 -0
  118. hiloop-0.1.0/hiloop/models/get_artifact_response.py +83 -0
  119. hiloop-0.1.0/hiloop/models/get_execution_response.py +74 -0
  120. hiloop-0.1.0/hiloop/models/get_fork_response.py +74 -0
  121. hiloop-0.1.0/hiloop/models/get_operation_response.py +74 -0
  122. hiloop-0.1.0/hiloop/models/get_project_response.py +74 -0
  123. hiloop-0.1.0/hiloop/models/get_run_response.py +76 -0
  124. hiloop-0.1.0/hiloop/models/get_sandbox_response.py +74 -0
  125. hiloop-0.1.0/hiloop/models/get_snapshot_response.py +74 -0
  126. hiloop-0.1.0/hiloop/models/get_usage_series_response.py +79 -0
  127. hiloop-0.1.0/hiloop/models/get_usage_snapshot_response.py +74 -0
  128. hiloop-0.1.0/hiloop/models/identity.py +100 -0
  129. hiloop-0.1.0/hiloop/models/kill_execution_request.py +79 -0
  130. hiloop-0.1.0/hiloop/models/kill_execution_request_signal.py +12 -0
  131. hiloop-0.1.0/hiloop/models/kill_execution_response.py +47 -0
  132. hiloop-0.1.0/hiloop/models/list_annotation_schemas_response.py +81 -0
  133. hiloop-0.1.0/hiloop/models/list_data_views_response.py +79 -0
  134. hiloop-0.1.0/hiloop/models/list_fork_nodes_response.py +79 -0
  135. hiloop-0.1.0/hiloop/models/list_projects_response.py +89 -0
  136. hiloop-0.1.0/hiloop/models/list_runs_response.py +89 -0
  137. hiloop-0.1.0/hiloop/models/list_runtime_capabilities_response.py +79 -0
  138. hiloop-0.1.0/hiloop/models/list_sandboxes_response.py +89 -0
  139. hiloop-0.1.0/hiloop/models/list_saved_views_response.py +79 -0
  140. hiloop-0.1.0/hiloop/models/list_snapshots_response.py +79 -0
  141. hiloop-0.1.0/hiloop/models/oci_image.py +70 -0
  142. hiloop-0.1.0/hiloop/models/operation.py +124 -0
  143. hiloop-0.1.0/hiloop/models/order.py +72 -0
  144. hiloop-0.1.0/hiloop/models/project.py +110 -0
  145. hiloop-0.1.0/hiloop/models/provider_native_image.py +62 -0
  146. hiloop-0.1.0/hiloop/models/put_data_view_request.py +96 -0
  147. hiloop-0.1.0/hiloop/models/put_data_view_request_spec.py +50 -0
  148. hiloop-0.1.0/hiloop/models/put_saved_view_request.py +71 -0
  149. hiloop-0.1.0/hiloop/models/query_request.py +76 -0
  150. hiloop-0.1.0/hiloop/models/query_response.py +79 -0
  151. hiloop-0.1.0/hiloop/models/query_spec.py +190 -0
  152. hiloop-0.1.0/hiloop/models/register_annotation_schema_request.py +80 -0
  153. hiloop-0.1.0/hiloop/models/register_annotation_schema_response.py +75 -0
  154. hiloop-0.1.0/hiloop/models/reserved_resources.py +91 -0
  155. hiloop-0.1.0/hiloop/models/resource_spec.py +96 -0
  156. hiloop-0.1.0/hiloop/models/resource_spec_architecture.py +10 -0
  157. hiloop-0.1.0/hiloop/models/restore_snapshot_request.py +241 -0
  158. hiloop-0.1.0/hiloop/models/restore_snapshot_request_labels.py +47 -0
  159. hiloop-0.1.0/hiloop/models/restore_snapshot_response.py +92 -0
  160. hiloop-0.1.0/hiloop/models/rollup_request.py +79 -0
  161. hiloop-0.1.0/hiloop/models/rollup_response.py +82 -0
  162. hiloop-0.1.0/hiloop/models/rollup_spec.py +98 -0
  163. hiloop-0.1.0/hiloop/models/row.py +76 -0
  164. hiloop-0.1.0/hiloop/models/row_columns.py +60 -0
  165. hiloop-0.1.0/hiloop/models/run.py +145 -0
  166. hiloop-0.1.0/hiloop/models/sandbox.py +135 -0
  167. hiloop-0.1.0/hiloop/models/sandbox_image.py +111 -0
  168. hiloop-0.1.0/hiloop/models/sandbox_state_count.py +71 -0
  169. hiloop-0.1.0/hiloop/models/saved_view.py +71 -0
  170. hiloop-0.1.0/hiloop/models/secret_binding.py +82 -0
  171. hiloop-0.1.0/hiloop/models/send_execution_input_request.py +88 -0
  172. hiloop-0.1.0/hiloop/models/send_execution_input_request_signal.py +12 -0
  173. hiloop-0.1.0/hiloop/models/send_execution_input_response.py +47 -0
  174. hiloop-0.1.0/hiloop/models/snapshot.py +133 -0
  175. hiloop-0.1.0/hiloop/models/start_execution_request.py +102 -0
  176. hiloop-0.1.0/hiloop/models/start_execution_response.py +74 -0
  177. hiloop-0.1.0/hiloop/models/time_range.py +71 -0
  178. hiloop-0.1.0/hiloop/models/update_project_request.py +70 -0
  179. hiloop-0.1.0/hiloop/models/update_project_response.py +74 -0
  180. hiloop-0.1.0/hiloop/models/usage_series_point.py +90 -0
  181. hiloop-0.1.0/hiloop/models/usage_snapshot.py +157 -0
  182. hiloop-0.1.0/hiloop/models/who_am_i_response.py +76 -0
  183. hiloop-0.1.0/hiloop/py.typed +1 -0
  184. hiloop-0.1.0/hiloop/types.py +54 -0
  185. 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,8 @@
1
+ """A client library for accessing"""
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,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
@@ -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