UncountablePythonSDK 0.0.23__py3-none-any.whl → 0.0.25__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.

Potentially problematic release.


This version of UncountablePythonSDK might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: UncountablePythonSDK
3
- Version: 0.0.23
3
+ Version: 0.0.25
4
4
  Summary: Uncountable SDK
5
5
  Project-URL: Homepage, https://github.com/uncountableinc/uncountable-python-sdk
6
6
  Project-URL: Repository, https://github.com/uncountableinc/uncountable-python-sdk.git
@@ -15,7 +15,7 @@ docs/static/favicons/manifest.json,sha256=6q_3nZkcg_x0xut4eE-xpdeMY1TydwiZIcbXlL
15
15
  docs/static/favicons/mstile-150x150.png,sha256=eAK4QdEofhdLtfmjuPTpnX3MJqYnvGXsHYUjlcQekyY,1035
16
16
  docs/static/favicons/safari-pinned-tab.svg,sha256=S84fRnz0ZxLnQrKtmmFZytiRyu1xLtMR_RVy5jmwU7k,1926
17
17
  examples/async_batch.py,sha256=wpf_3P547375vTIO4pKv5vw6WCkUnzqvw_S3idfhjvM,1122
18
- examples/create_entity.py,sha256=54AmZt83EpypxGcYZSIMmWlGz2oAgHFOsKuLSZOcHsI,625
18
+ examples/create_entity.py,sha256=2ciY0Cy4McGmfyElFF19OyUrbAa7jOEG8PQfR7Hq6NI,636
19
19
  examples/upload_files.py,sha256=ZsMChgOioraVHv207YREpivAOf4dq3IxGIBoROoDX_4,482
20
20
  examples/recipe-import/importer.py,sha256=baD71xuNibxDTe3bGHsMEIZEf9Xtb-IumBNpCEV0RZU,1134
21
21
  pkgs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -44,7 +44,7 @@ pkgs/type_spec/emit_python.py,sha256=aGPnp86DZN0N7c5eiBHVAT_smDf1uCLmRldDhxmWx9g
44
44
  pkgs/type_spec/emit_typescript.py,sha256=4hpCJwiDf-v8LJaNFVfFtf8zvtG73YNPFwwa_5NuffI,17729
45
45
  pkgs/type_spec/emit_typescript_util.py,sha256=93FzJnpYse4PKFzgdw4DGV4zFTi5tF4WR-CIi7cW498,873
46
46
  pkgs/type_spec/load_types.py,sha256=xEHwdB_miR3vNs161Oy1luafE0VC-yk9-utAyCJmbEo,3629
47
- pkgs/type_spec/open_api_util.py,sha256=TFbK2bkYT6S4qPQGO3_G2mfVgtNB26d31kwaHQ9y99E,6730
47
+ pkgs/type_spec/open_api_util.py,sha256=IGh-_snGPST_P_8FdYtO8MTEa9PUxRW6Rzg9X9EgQik,7114
48
48
  pkgs/type_spec/test.py,sha256=4ueujBq-pEgnX3Z69HyPmD-bullFXmpixcpVzfOkhP4,489
49
49
  pkgs/type_spec/util.py,sha256=6m6MPfY-SwjyZf2FWQKclswWB5o7gcdd-3tdpViPYOQ,4844
50
50
  pkgs/type_spec/actions_registry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -85,6 +85,7 @@ type_spec/external/api/project/get_projects.yaml,sha256=pQXGGPHenmFWYUuzEmZ-ORf0
85
85
  type_spec/external/api/project/get_projects_data.yaml,sha256=8xQoyL8HlAropfZPYYcQ-W4fO4yuqueAWTKxRzTXAa0,1981
86
86
  type_spec/external/api/recipe_links/create_recipe_link.yaml,sha256=7b2p7Ei4LnQXqccHsOVAfYyNK4WXm0n1IqxPG-qQDh0,941
87
87
  type_spec/external/api/recipe_metadata/get_recipe_metadata_data.yaml,sha256=mJs82Ci8XSp2ng0W9MKqoeYwIjjgaVYmC5MWFmWFkR8,1759
88
+ type_spec/external/api/recipes/archive_recipes.yaml,sha256=Oe-NIFwERiG1DwgzsWj3ouKVdnRDTelrgqE5b9Bt_vQ,515
88
89
  type_spec/external/api/recipes/associate_recipe_as_input.yaml,sha256=7t0jto37RyLjl63-GK3mLC2uFiX1gd8vPwTwnobxkeI,654
89
90
  type_spec/external/api/recipes/associate_recipe_as_lot.yaml,sha256=8wzeJg5njt4qG2kavA6Jpo9PkWE6rIbuA4IPNdhcwEg,605
90
91
  type_spec/external/api/recipes/create_recipe.yaml,sha256=mGLyKJI3pN_7nU4rcSqCO3WjuKhO_odZ2pewVgYcMUU,1322
@@ -104,11 +105,11 @@ type_spec/external/api/recipes/set_recipe_tags.yaml,sha256=IrdkbryxZjNy8n4aMNLRT
104
105
  type_spec/external/api/triggers/run_trigger.yaml,sha256=c8xDV3bQRjcRRDG4Y7kdQmMMu1fj3ae5eUi-Sdbsi54,405
105
106
  uncountable/__init__.py,sha256=281cC2hs8pbrD0jVKMol-tbWSh7Zcsc8oRT42dKteyE,102
106
107
  uncountable/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
- uncountable/core/__init__.py,sha256=7xUnbSWJzS31sWg0jCe5nIksn5s0PVdwUrUmDttHfCY,258
108
+ uncountable/core/__init__.py,sha256=J0CeeztqyJe7klvHM-8fwSivN1sud6xZThOdaThnQrU,314
108
109
  uncountable/core/async_batch.py,sha256=0cRmCr6Z9sNxZyfY9Dl8wlCA4anISVZuHGgBegHhUbc,749
109
- uncountable/core/client.py,sha256=7bLuACxMJZsckSfL2j-p-XThYdvDAUAwm5nND9s-v1o,6946
110
+ uncountable/core/client.py,sha256=cP6yEHv5KGE2NJn0BAQh470mirBfITMLsfEs-zj-6Ys,9024
110
111
  uncountable/core/file_upload.py,sha256=zTpAFSd7_-TmEVWxOn1rDznyWE6_AdZyuDQC3LP34iI,2667
111
- uncountable/core/types.py,sha256=gQtCw1-WSRak_ypFlGI1Ea9iZBP9zDeFq6XQtiXBlZA,459
112
+ uncountable/core/types.py,sha256=RaNVuUPpcMBCfk-stS4Jh-9WBFzKK6_cVgRfPv7Dz6g,280
112
113
  uncountable/integration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
113
114
  uncountable/integration/construct_client.py,sha256=r6M5pnIO0fKcjf5d_AREPtWZ6AkWgcjkdu_jHQEYlT8,1084
114
115
  uncountable/integration/cron.py,sha256=TIPqMPMSMtMJTu4aXwLf6QY-OLrpmyITLDp48UIr4Ok,919
@@ -120,13 +121,13 @@ uncountable/integration/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
120
121
  uncountable/integration/db/connect.py,sha256=iI9e8a2hfbFP-dvH0MGLsrG-RpM0dHKCL-oCLkah9hs,181
121
122
  uncountable/integration/executors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
122
123
  uncountable/integration/executors/script_executor.py,sha256=6oMPAFe0PUdqt76e8jMi4vXszGVsVHLULob7Qbl3o38,816
123
- uncountable/types/__init__.py,sha256=fTNNsvFFkjp4acdBA8eS00OZVnDo_Zn7aRwPs8SFnrs,6024
124
- uncountable/types/async_batch.py,sha256=FtIoDCeyt9rF5hknQs6Sw-vjiYBMJbe1re0-4bk_6VY,1578
124
+ uncountable/types/__init__.py,sha256=6XYh9ACSJRnbbTGfpQ69bLFfwyBiCG1ZlHqSAOugTG8,6111
125
+ uncountable/types/async_batch.py,sha256=aWiul1fK3-cXaCESUUJ_92FF-NuuwxSjn9n3jC9vY5o,1618
125
126
  uncountable/types/async_batch_processor.py,sha256=YksvTyJaZ3rqpZx4UXofUf7XU1Br4aNBNPZXB3LLtkA,5940
126
127
  uncountable/types/base.py,sha256=w3BRf8SAvYPlKrcJtJcQ_WhCU3A9zy0VuRTRWRFKVUA,2709
127
128
  uncountable/types/calculations.py,sha256=16J-KKMp-I8ZQUkYNmKCHfAn6DGb99cFinALcDIdGHY,562
128
129
  uncountable/types/chemical_structure.py,sha256=zQKl53DGtQQONIUHFXuwjWLQaG7FPZY7x6SBSOzkGV0,758
129
- uncountable/types/client_base.py,sha256=nsV7NWN5UoqjCfFSw9XLXT_rbpfZeWRrOLxqeZ20Sjw,47114
130
+ uncountable/types/client_base.py,sha256=EIsd-OoOglTX2tVgbWDosPlq7hAkB_Nlacr_e8epjb4,47949
130
131
  uncountable/types/curves.py,sha256=qYyRntMmFNonEwTrGhquMLbgMqjyP1moQflNTP0FMec,1308
131
132
  uncountable/types/entity.py,sha256=NjMZrqBwQ7sZe_oUuJqy9IEG7dWZmFMkQQXJ0_odcnA,11637
132
133
  uncountable/types/experiment_groups.py,sha256=ZBEk06F4n98Jz3oEA09WaDmw5rqPs7iVAm_Ysr4gc_o,599
@@ -190,6 +191,7 @@ uncountable/types/api/recipe_links/create_recipe_link.py,sha256=1Ok6XMGFKBIPV-uR
190
191
  uncountable/types/api/recipe_metadata/__init__.py,sha256=gCgbynxG3jA8FQHzercKtrHKHkiIKr8APdZYUniAor8,55
191
192
  uncountable/types/api/recipe_metadata/get_recipe_metadata_data.py,sha256=el6Pn5XqExX66ZEEHM8CHPxnyXSMZPdfdvLBz86sAVY,1267
192
193
  uncountable/types/api/recipes/__init__.py,sha256=gCgbynxG3jA8FQHzercKtrHKHkiIKr8APdZYUniAor8,55
194
+ uncountable/types/api/recipes/archive_recipes.py,sha256=XFCqBa90bG4Tpxu6fhUqzl7PWlY35bbzOmJf5EOviRM,852
193
195
  uncountable/types/api/recipes/associate_recipe_as_input.py,sha256=88a2lirEgrodyyE6og0oYtkGAWih2uJCZRmy45kTBow,976
194
196
  uncountable/types/api/recipes/associate_recipe_as_lot.py,sha256=bTYjbnY3B7GKz4MV4UGn7vPjaqMkAfUTio8872d4iws,955
195
197
  uncountable/types/api/recipes/create_recipe.py,sha256=Ni00efkcPkQ3WTIgDHzkfu1qoc52ReV9VT0wwwPOT4g,1364
@@ -208,7 +210,7 @@ uncountable/types/api/recipes/set_recipe_outputs.py,sha256=QYq39TNchQ80ET1C77OE9
208
210
  uncountable/types/api/recipes/set_recipe_tags.py,sha256=U710hgq9-t6QZGRB-ZGHskpt4iXwYEjIRb67eh3P518,2453
209
211
  uncountable/types/api/triggers/__init__.py,sha256=gCgbynxG3jA8FQHzercKtrHKHkiIKr8APdZYUniAor8,55
210
212
  uncountable/types/api/triggers/run_trigger.py,sha256=9m9M8-nlGB_sAU2Qm2lWugp4h4Osqj6QpjNfU8osd1U,901
211
- UncountablePythonSDK-0.0.23.dist-info/METADATA,sha256=W6CHPkwSSSiPK9zlnXFS8WjX7sCL8o2-76dd4m2CJkY,1613
212
- UncountablePythonSDK-0.0.23.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
213
- UncountablePythonSDK-0.0.23.dist-info/top_level.txt,sha256=HaMiBnH1wA7SG9-RVHIJPBH3l8X5gee2jUf-77Nz-Dk,41
214
- UncountablePythonSDK-0.0.23.dist-info/RECORD,,
213
+ UncountablePythonSDK-0.0.25.dist-info/METADATA,sha256=LU2djI-Urro-UFLucKkSiaI6kq9ueCClAJhRDI2snAM,1613
214
+ UncountablePythonSDK-0.0.25.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
215
+ UncountablePythonSDK-0.0.25.dist-info/top_level.txt,sha256=HaMiBnH1wA7SG9-RVHIJPBH3l8X5gee2jUf-77Nz-Dk,41
216
+ UncountablePythonSDK-0.0.25.dist-info/RECORD,,
examples/create_entity.py CHANGED
@@ -1,4 +1,5 @@
1
- from uncountable.core import AuthDetailsApiKey, Client
1
+ from uncountable.core import Client
2
+ from uncountable.core.client import AuthDetailsOAuth
2
3
  from uncountable.types import (
3
4
  entity_t,
4
5
  field_values_t,
@@ -7,9 +8,8 @@ from uncountable.types import (
7
8
 
8
9
  client = Client(
9
10
  base_url="https://app.uncountable.com",
10
- auth_details=AuthDetailsApiKey(
11
- api_id="X",
12
- api_secret_key="X",
11
+ auth_details=AuthDetailsOAuth(
12
+ refresh_token="x"
13
13
  ),
14
14
  )
15
15
  entities = client.create_entity(
@@ -174,6 +174,18 @@ class OpenAPIObjectType(OpenAPIType):
174
174
 
175
175
  return {"description": desc}
176
176
 
177
+ def _emit_property(
178
+ self, property_name: str, property_type: OpenAPIType
179
+ ) -> dict[str, object]:
180
+ property_info = {
181
+ **property_type.asdict(),
182
+ }
183
+ property_description = self._emit_property_desc(property_name)
184
+ if "$ref" in property_info and "description" in property_description:
185
+ return {"allOf": [property_info, property_description]}
186
+
187
+ return property_info | property_description
188
+
177
189
  def asdict(self) -> dict[str, object]:
178
190
  return self.add_addl_info({
179
191
  "type": "object",
@@ -183,10 +195,7 @@ class OpenAPIObjectType(OpenAPIType):
183
195
  if not property_type.nullable
184
196
  ],
185
197
  "properties": {
186
- property_name: {
187
- **property_type.asdict(),
188
- }
189
- | self._emit_property_desc(property_name)
198
+ property_name: self._emit_property(property_name, property_type)
190
199
  for property_name, property_type in self.properties.items()
191
200
  },
192
201
  })
@@ -0,0 +1,20 @@
1
+ $endpoint:
2
+ is_sdk: true
3
+ method: post
4
+ path: ${external}/recipes/archive
5
+ function: main.site.app.external.recipes.archive_recipes.archive_recipes
6
+ desc: Archive the provided recipes and their children
7
+
8
+ Arguments:
9
+ type: Object
10
+ properties:
11
+ recipes:
12
+ type: List<identifier.IdentifierKey>
13
+ desc: Identifier for the recipe
14
+ reason?:
15
+ type: String
16
+ desc: This reason will be written to the audit log archive entry
17
+
18
+
19
+ Data:
20
+ type: Object
@@ -1,5 +1,6 @@
1
- from .client import AuthDetailsApiKey, Client
1
+ from .client import Client
2
+ from .types import AuthDetailsApiKey, AuthDetailsOAuth
2
3
  from .file_upload import MediaFileUpload, UploadedFile
3
4
  from .async_batch import AsyncBatchProcessor
4
5
 
5
- __all__: list[str] = ["AuthDetailsApiKey", "AsyncBatchProcessor", "Client", "MediaFileUpload", "UploadedFile"]
6
+ __all__: list[str] = ["AuthDetailsApiKey", "AuthDetailsOAuth", "AsyncBatchProcessor", "Client", "MediaFileUpload", "UploadedFile"]
@@ -1,4 +1,5 @@
1
1
  import base64
2
+ from datetime import datetime, timedelta
2
3
  import json
3
4
  import typing
4
5
  from dataclasses import dataclass
@@ -14,7 +15,7 @@ from pkgs.serialization_util.serialization_helpers import JsonValue
14
15
  from uncountable.types.client_base import APIRequest, ClientMethods
15
16
 
16
17
  from .file_upload import FileUpload, FileUploader, UploadedFile
17
- from .types import AuthDetails, AuthDetailsApiKey
18
+ from .types import AuthDetails, AuthDetailsApiKey, AuthDetailsOAuth
18
19
 
19
20
  DT = typing.TypeVar("DT")
20
21
 
@@ -48,11 +49,13 @@ class HTTPPostRequest(HTTPRequestBase):
48
49
  HTTPRequest = HTTPPostRequest | HTTPGetRequest
49
50
 
50
51
 
51
-
52
52
  @dataclass(kw_only=True)
53
- class ClientConfig():
53
+ class ClientConfig:
54
54
  allow_insecure_tls: bool = False
55
-
55
+
56
+
57
+ OAUTH_REFRESH_WINDOW_SECONDS = 60 * 5
58
+
56
59
 
57
60
  class APIResponseError(BaseException):
58
61
  status_code: int
@@ -107,19 +110,60 @@ class SDKError(BaseException):
107
110
  return f"internal SDK error, please contact Uncountable support: {self.message}"
108
111
 
109
112
 
113
+ @dataclass(kw_only=True)
114
+ class OAuthBearerTokenCache:
115
+ token: str
116
+ expires_at: datetime
117
+
118
+
119
+ @dataclass(kw_only=True)
120
+ class GetOauthBearerTokenData:
121
+ access_token: str
122
+ expires_in: int
123
+ token_type: str
124
+ scope: str
125
+
126
+
127
+ oauth_bearer_token_data_parser = CachedParser(GetOauthBearerTokenData)
128
+
129
+
110
130
  class Client(ClientMethods):
111
131
  _parser_map: dict[type, CachedParser] = {}
112
132
  _auth_details: AuthDetails
113
133
  _base_url: str
114
134
  _file_uploader: FileUploader
115
135
  _cfg: ClientConfig
136
+ _oauth_bearer_token_cache: OAuthBearerTokenCache | None = None
116
137
 
117
- def __init__(self, *, base_url: str, auth_details: AuthDetails, config: ClientConfig | None = None):
138
+ def __init__(
139
+ self,
140
+ *,
141
+ base_url: str,
142
+ auth_details: AuthDetails,
143
+ config: ClientConfig | None = None,
144
+ ):
118
145
  self._auth_details = auth_details
119
146
  self._base_url = base_url
120
147
  self._file_uploader = FileUploader(self._base_url, self._auth_details)
121
148
  self._cfg = config or ClientConfig()
122
149
 
150
+ def _get_response_json(self, response: requests.Response) -> dict[str, JsonValue]:
151
+ if response.status_code < 200 or response.status_code > 299:
152
+ extra_details: dict[str, JsonValue] | None = None
153
+ try:
154
+ data = response.json()
155
+ if "error" in data:
156
+ extra_details = data["error"]
157
+ except JSONDecodeError:
158
+ pass
159
+ raise APIResponseError.construct_error(
160
+ status_code=response.status_code, extra_details=extra_details
161
+ )
162
+ try:
163
+ return response.json()
164
+ except JSONDecodeError:
165
+ raise SDKError("unable to process response")
166
+
123
167
  def do_request(self, *, api_request: APIRequest, return_type: type[DT]) -> DT:
124
168
  http_request = self._build_http_request(api_request=api_request)
125
169
  match http_request:
@@ -128,7 +172,7 @@ class Client(ClientMethods):
128
172
  http_request.url,
129
173
  headers=http_request.headers,
130
174
  params=http_request.query_params,
131
- verify=not self._cfg.allow_insecure_tls
175
+ verify=not self._cfg.allow_insecure_tls,
132
176
  )
133
177
  case HTTPPostRequest():
134
178
  response = requests.post(
@@ -136,26 +180,16 @@ class Client(ClientMethods):
136
180
  headers=http_request.headers,
137
181
  data=http_request.body,
138
182
  params=http_request.query_params,
139
- verify=not self._cfg.allow_insecure_tls
183
+ verify=not self._cfg.allow_insecure_tls,
140
184
  )
141
185
  case _:
142
186
  typing.assert_never(http_request)
143
- if response.status_code < 200 or response.status_code > 299:
144
- extra_details: dict[str, JsonValue] | None = None
145
- try:
146
- data = response.json()
147
- if "error" in data:
148
- extra_details = data["error"]
149
- except JSONDecodeError:
150
- pass
151
- raise APIResponseError.construct_error(
152
- status_code=response.status_code, extra_details=extra_details
153
- )
187
+ response_data = self._get_response_json(response)
154
188
  cached_parser = self._get_cached_parser(return_type)
155
189
  try:
156
- data = response.json()["data"]
190
+ data = response_data["data"]
157
191
  return cached_parser.parse_api(data)
158
- except ValueError | JSONDecodeError:
192
+ except ValueError | JSONDecodeError | KeyError:
159
193
  raise SDKError("unable to process response")
160
194
 
161
195
  def _get_cached_parser(self, data_type: type[DT]) -> CachedParser[DT]:
@@ -163,6 +197,32 @@ class Client(ClientMethods):
163
197
  self._parser_map[data_type] = CachedParser(data_type)
164
198
  return self._parser_map[data_type]
165
199
 
200
+ def _get_oauth_bearer_token(self, *, oauth_details: AuthDetailsOAuth) -> str:
201
+ if (
202
+ self._oauth_bearer_token_cache is None
203
+ or (
204
+ self._oauth_bearer_token_cache.expires_at - datetime.now()
205
+ ).total_seconds()
206
+ < OAUTH_REFRESH_WINDOW_SECONDS
207
+ ):
208
+ refresh_url = urljoin(self._base_url, "/token/get_bearer_token")
209
+ response = requests.post(
210
+ refresh_url,
211
+ data={
212
+ "client_secret": oauth_details.refresh_token,
213
+ "scope": oauth_details.scope,
214
+ "grant_type": "client_credentials",
215
+ },
216
+ )
217
+ data = self._get_response_json(response)
218
+ token_data = oauth_bearer_token_data_parser.parse_storage(data)
219
+ self._oauth_bearer_token_cache = OAuthBearerTokenCache(
220
+ token=token_data.access_token,
221
+ expires_at=datetime.now() + timedelta(seconds=token_data.expires_in),
222
+ )
223
+
224
+ return self._oauth_bearer_token_cache.token
225
+
166
226
  def _build_auth_headers(self) -> dict[str, str]:
167
227
  match self._auth_details:
168
228
  case AuthDetailsApiKey():
@@ -170,6 +230,9 @@ class Client(ClientMethods):
170
230
  f"{self._auth_details.api_id}:{self._auth_details.api_secret_key}".encode()
171
231
  ).decode("utf-8")
172
232
  return {"Authorization": f"Basic {encoded}"}
233
+ case AuthDetailsOAuth():
234
+ token = self._get_oauth_bearer_token(oauth_details=self._auth_details)
235
+ return {"Authorization": f"Bearer {token}"}
173
236
  typing.assert_never(self._auth_details)
174
237
 
175
238
  def _build_http_request(self, *, api_request: APIRequest) -> HTTPRequest:
uncountable/core/types.py CHANGED
@@ -1,16 +1,4 @@
1
- import base64
2
- import json
3
- import typing
4
1
  from dataclasses import dataclass
5
- from enum import StrEnum
6
- from urllib.parse import urljoin
7
-
8
- import aiohttp
9
- import requests
10
-
11
- from pkgs.argument_parser import CachedParser
12
- from pkgs.serialization_util import serialize_for_api
13
- from uncountable.types.client_base import APIRequest, ClientMethods
14
2
 
15
3
 
16
4
  @dataclass(kw_only=True)
@@ -19,4 +7,10 @@ class AuthDetailsApiKey:
19
7
  api_secret_key: str
20
8
 
21
9
 
22
- AuthDetails = AuthDetailsApiKey
10
+ @dataclass(kw_only=True)
11
+ class AuthDetailsOAuth:
12
+ refresh_token: str
13
+ scope: str = "unc.rnd"
14
+
15
+
16
+ AuthDetails = AuthDetailsApiKey | AuthDetailsOAuth
@@ -3,6 +3,7 @@
3
3
  # ruff: noqa: E402
4
4
  # fmt: off
5
5
  # isort: skip_file
6
+ from .api.recipes import archive_recipes as archive_recipes_t
6
7
  from .api.recipes import associate_recipe_as_input as associate_recipe_as_input_t
7
8
  from .api.recipes import associate_recipe_as_lot as associate_recipe_as_lot_t
8
9
  from . import async_batch as async_batch_t
@@ -77,6 +78,7 @@ from . import workflows as workflows_t
77
78
 
78
79
 
79
80
  __all__: list[str] = [
81
+ "archive_recipes_t",
80
82
  "associate_recipe_as_input_t",
81
83
  "associate_recipe_as_lot_t",
82
84
  "async_batch_t",
@@ -0,0 +1,35 @@
1
+ # DO NOT MODIFY -- This file is generated by type_spec
2
+ # flake8: noqa: F821
3
+ # ruff: noqa: E402
4
+ # fmt: off
5
+ # isort: skip_file
6
+ from __future__ import annotations
7
+ import typing # noqa: F401
8
+ import datetime # noqa: F401
9
+ from decimal import Decimal # noqa: F401
10
+ from dataclasses import dataclass
11
+ from ... import identifier as identifier_t
12
+
13
+ __all__: list[str] = [
14
+ "Arguments",
15
+ "Data",
16
+ "ENDPOINT_METHOD",
17
+ "ENDPOINT_PATH",
18
+ ]
19
+
20
+ ENDPOINT_METHOD = "POST"
21
+ ENDPOINT_PATH = "api/external/recipes/archive"
22
+
23
+
24
+ # DO NOT MODIFY -- This file is generated by type_spec
25
+ @dataclass(kw_only=True)
26
+ class Arguments:
27
+ recipes: list[identifier_t.IdentifierKey]
28
+ reason: typing.Optional[str] = None
29
+
30
+
31
+ # DO NOT MODIFY -- This file is generated by type_spec
32
+ @dataclass(kw_only=True)
33
+ class Data:
34
+ pass
35
+ # DO NOT MODIFY -- This file is generated by type_spec
@@ -26,6 +26,7 @@ class AsyncBatchRequestPath(StrEnum):
26
26
  SET_RECIPE_METADATA = "recipes/set_recipe_metadata"
27
27
  SET_RECIPE_TAGS = "recipes/set_recipe_tags"
28
28
  EDIT_RECIPE_INPUTS = "recipes/edit_recipe_inputs"
29
+ ARCHIVE_RECIPES = "recipes/archive"
29
30
 
30
31
 
31
32
  # DO NOT MODIFY -- This file is generated by type_spec
@@ -9,6 +9,7 @@ import typing # noqa: F401
9
9
  import datetime # noqa: F401
10
10
  from decimal import Decimal # noqa: F401
11
11
  from pkgs.serialization import OpaqueKey
12
+ import uncountable.types.api.recipes.archive_recipes as archive_recipes_t
12
13
  import uncountable.types.api.recipes.associate_recipe_as_input as associate_recipe_as_input_t
13
14
  import uncountable.types.api.recipes.associate_recipe_as_lot as associate_recipe_as_lot_t
14
15
  from uncountable.types import async_batch as async_batch_t
@@ -83,6 +84,28 @@ class ClientMethods(ABC):
83
84
  def do_request(self, *, api_request: APIRequest, return_type: type[DT]) -> DT:
84
85
  ...
85
86
 
87
+ def archive_recipes(
88
+ self,
89
+ *,
90
+ recipes: list[identifier_t.IdentifierKey],
91
+ reason: typing.Optional[str] = None,
92
+ ) -> archive_recipes_t.Data:
93
+ """Archive the provided recipes and their children
94
+
95
+ :param recipes: Identifier for the recipe
96
+ :param reason: This reason will be written to the audit log archive entry
97
+ """
98
+ args = archive_recipes_t.Arguments(
99
+ recipes=recipes,
100
+ reason=reason,
101
+ )
102
+ api_request = APIRequest(
103
+ method=archive_recipes_t.ENDPOINT_METHOD,
104
+ endpoint=archive_recipes_t.ENDPOINT_PATH,
105
+ args=args,
106
+ )
107
+ return self.do_request(api_request=api_request, return_type=archive_recipes_t.Data)
108
+
86
109
  def associate_recipe_as_input(
87
110
  self,
88
111
  *,