|
8 | 8 | from json.decoder import JSONDecodeError
|
9 | 9 | from ..core.api_error import ApiError
|
10 | 10 | from ..core.jsonable_encoder import jsonable_encoder
|
11 |
| -from ..errors.not_found_error import NotFoundError |
12 | 11 | from ..core.client_wrapper import AsyncClientWrapper
|
13 | 12 |
|
14 | 13 | # this is used as the default value for optional parameters
|
@@ -135,58 +134,6 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] =
|
135 | 134 | raise ApiError(status_code=_response.status_code, body=_response.text)
|
136 | 135 | raise ApiError(status_code=_response.status_code, body=_response_json)
|
137 | 136 |
|
138 |
| - def create_project_from_blueprint( |
139 |
| - self, share_id: str, *, request_options: typing.Optional[RequestOptions] = None |
140 |
| - ) -> None: |
141 |
| - """ |
142 |
| - Create a new project from an existing blueprint. On success, user is redirected to the new project with a 302. |
143 |
| -
|
144 |
| - Parameters |
145 |
| - ---------- |
146 |
| - share_id : str |
147 |
| - Blueprint share ID |
148 |
| -
|
149 |
| - request_options : typing.Optional[RequestOptions] |
150 |
| - Request-specific configuration. |
151 |
| -
|
152 |
| - Returns |
153 |
| - ------- |
154 |
| - None |
155 |
| -
|
156 |
| - Examples |
157 |
| - -------- |
158 |
| - from label_studio_sdk import LabelStudio |
159 |
| -
|
160 |
| - client = LabelStudio( |
161 |
| - api_key="YOUR_API_KEY", |
162 |
| - ) |
163 |
| - client.blueprints.create_project_from_blueprint( |
164 |
| - share_id="share_id", |
165 |
| - ) |
166 |
| - """ |
167 |
| - _response = self._client_wrapper.httpx_client.request( |
168 |
| - f"api/blueprints/{jsonable_encoder(share_id)}/create-project", |
169 |
| - method="GET", |
170 |
| - request_options=request_options, |
171 |
| - ) |
172 |
| - try: |
173 |
| - if 200 <= _response.status_code < 300: |
174 |
| - return |
175 |
| - if _response.status_code == 404: |
176 |
| - raise NotFoundError( |
177 |
| - typing.cast( |
178 |
| - typing.Optional[typing.Any], |
179 |
| - construct_type( |
180 |
| - type_=typing.Optional[typing.Any], # type: ignore |
181 |
| - object_=_response.json(), |
182 |
| - ), |
183 |
| - ) |
184 |
| - ) |
185 |
| - _response_json = _response.json() |
186 |
| - except JSONDecodeError: |
187 |
| - raise ApiError(status_code=_response.status_code, body=_response.text) |
188 |
| - raise ApiError(status_code=_response.status_code, body=_response_json) |
189 |
| - |
190 | 137 |
|
191 | 138 | class AsyncBlueprintsClient:
|
192 | 139 | def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
@@ -323,63 +270,3 @@ async def main() -> None:
|
323 | 270 | except JSONDecodeError:
|
324 | 271 | raise ApiError(status_code=_response.status_code, body=_response.text)
|
325 | 272 | raise ApiError(status_code=_response.status_code, body=_response_json)
|
326 |
| - |
327 |
| - async def create_project_from_blueprint( |
328 |
| - self, share_id: str, *, request_options: typing.Optional[RequestOptions] = None |
329 |
| - ) -> None: |
330 |
| - """ |
331 |
| - Create a new project from an existing blueprint. On success, user is redirected to the new project with a 302. |
332 |
| -
|
333 |
| - Parameters |
334 |
| - ---------- |
335 |
| - share_id : str |
336 |
| - Blueprint share ID |
337 |
| -
|
338 |
| - request_options : typing.Optional[RequestOptions] |
339 |
| - Request-specific configuration. |
340 |
| -
|
341 |
| - Returns |
342 |
| - ------- |
343 |
| - None |
344 |
| -
|
345 |
| - Examples |
346 |
| - -------- |
347 |
| - import asyncio |
348 |
| -
|
349 |
| - from label_studio_sdk import AsyncLabelStudio |
350 |
| -
|
351 |
| - client = AsyncLabelStudio( |
352 |
| - api_key="YOUR_API_KEY", |
353 |
| - ) |
354 |
| -
|
355 |
| -
|
356 |
| - async def main() -> None: |
357 |
| - await client.blueprints.create_project_from_blueprint( |
358 |
| - share_id="share_id", |
359 |
| - ) |
360 |
| -
|
361 |
| -
|
362 |
| - asyncio.run(main()) |
363 |
| - """ |
364 |
| - _response = await self._client_wrapper.httpx_client.request( |
365 |
| - f"api/blueprints/{jsonable_encoder(share_id)}/create-project", |
366 |
| - method="GET", |
367 |
| - request_options=request_options, |
368 |
| - ) |
369 |
| - try: |
370 |
| - if 200 <= _response.status_code < 300: |
371 |
| - return |
372 |
| - if _response.status_code == 404: |
373 |
| - raise NotFoundError( |
374 |
| - typing.cast( |
375 |
| - typing.Optional[typing.Any], |
376 |
| - construct_type( |
377 |
| - type_=typing.Optional[typing.Any], # type: ignore |
378 |
| - object_=_response.json(), |
379 |
| - ), |
380 |
| - ) |
381 |
| - ) |
382 |
| - _response_json = _response.json() |
383 |
| - except JSONDecodeError: |
384 |
| - raise ApiError(status_code=_response.status_code, body=_response.text) |
385 |
| - raise ApiError(status_code=_response.status_code, body=_response_json) |
0 commit comments