diff --git a/.mock/definition/blueprints.yml b/.mock/definition/blueprints.yml index 99ddd0d56..3fca5ba5f 100644 --- a/.mock/definition/blueprints.yml +++ b/.mock/definition/blueprints.yml @@ -49,7 +49,7 @@ service: title: title updated_at: '2024-01-15T09:30:00Z' audiences: - - public + - internal delete: path: /api/blueprints/{id}/ method: DELETE @@ -64,7 +64,7 @@ service: - path-parameters: id: id audiences: - - public + - internal api_blueprints_create_project_retrieve: path: /api/blueprints/{share_id}/create-project method: GET diff --git a/.mock/openapi/openapi.yaml b/.mock/openapi/openapi.yaml index 26d1f5dcb..ef4d9b7cb 100644 --- a/.mock/openapi/openapi.yaml +++ b/.mock/openapi/openapi.yaml @@ -876,7 +876,7 @@ paths: tags: - Blueprints x-fern-audiences: - - public + - internal x-fern-sdk-group-name: blueprints x-fern-sdk-method-name: create /api/blueprints/{id}/: @@ -898,7 +898,7 @@ paths: tags: - Blueprints x-fern-audiences: - - public + - internal x-fern-sdk-group-name: blueprints x-fern-sdk-method-name: delete /api/blueprints/{share_id}/create-project: diff --git a/pyproject.toml b/pyproject.toml index 06b82fdcf..faa6b2026 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "label-studio-sdk" [tool.poetry] name = "label-studio-sdk" -version = "2.0.9.dev" +version = "2.0.9" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 53cf6dd37..b03f8de19 100644 --- a/reference.md +++ b/reference.md @@ -1680,179 +1680,6 @@ client.billing.info() - - - - -## Blueprints -
client.blueprints.create(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Create a new blueprint -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from label_studio_sdk import LabelStudio - -client = LabelStudio( - api_key="YOUR_API_KEY", -) -client.blueprints.create( - project=1, -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**project:** `int` - -
-
- -
-
- -**created_by:** `typing.Optional[int]` - -
-
- -
-
- -**description:** `typing.Optional[str]` — Project description - -
-
- -
-
- -**label_config:** `typing.Optional[str]` — Labeling configuration in XML format - -
-
- -
-
- -**title:** `typing.Optional[str]` — Blueprint name. Must be between 3 and 50 characters long. - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- - -
-
-
- -
client.blueprints.delete(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Delete a blueprint by ID -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from label_studio_sdk import LabelStudio - -client = LabelStudio( - api_key="YOUR_API_KEY", -) -client.blueprints.delete( - id="id", -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**id:** `str` - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- -
diff --git a/src/label_studio_sdk/__init__.py b/src/label_studio_sdk/__init__.py index 4fe4748d8..d2fc5ef39 100644 --- a/src/label_studio_sdk/__init__.py +++ b/src/label_studio_sdk/__init__.py @@ -35,7 +35,6 @@ BillingFlags, BillingInfoResponse, BlankEnum, - Blueprint, BlueprintList, BudgetResetPeriodEnum, ChildFilter, @@ -240,7 +239,6 @@ annotation_reviews, annotations, billing, - blueprints, comments, export_storage, files, @@ -394,7 +392,6 @@ "BillingFlags", "BillingInfoResponse", "BlankEnum", - "Blueprint", "BlueprintList", "BudgetResetPeriodEnum", "ChildFilter", @@ -649,7 +646,6 @@ "annotation_reviews", "annotations", "billing", - "blueprints", "comments", "export_storage", "files", diff --git a/src/label_studio_sdk/base_client.py b/src/label_studio_sdk/base_client.py index 97c219e18..a3ae28d4b 100644 --- a/src/label_studio_sdk/base_client.py +++ b/src/label_studio_sdk/base_client.py @@ -11,7 +11,6 @@ from .annotation_reviews.client import AnnotationReviewsClient from .annotations.client import AnnotationsClient from .billing.client import BillingClient -from .blueprints.client import BlueprintsClient from .comments.client import CommentsClient from .users.client import UsersClient from .actions.client import ActionsClient @@ -40,7 +39,6 @@ from .annotation_reviews.client import AsyncAnnotationReviewsClient from .annotations.client import AsyncAnnotationsClient from .billing.client import AsyncBillingClient -from .blueprints.client import AsyncBlueprintsClient from .comments.client import AsyncCommentsClient from .users.client import AsyncUsersClient from .actions.client import AsyncActionsClient @@ -132,7 +130,6 @@ def __init__( self.annotation_reviews = AnnotationReviewsClient(client_wrapper=self._client_wrapper) self.annotations = AnnotationsClient(client_wrapper=self._client_wrapper) self.billing = BillingClient(client_wrapper=self._client_wrapper) - self.blueprints = BlueprintsClient(client_wrapper=self._client_wrapper) self.comments = CommentsClient(client_wrapper=self._client_wrapper) self.users = UsersClient(client_wrapper=self._client_wrapper) self.actions = ActionsClient(client_wrapper=self._client_wrapper) @@ -224,7 +221,6 @@ def __init__( self.annotation_reviews = AsyncAnnotationReviewsClient(client_wrapper=self._client_wrapper) self.annotations = AsyncAnnotationsClient(client_wrapper=self._client_wrapper) self.billing = AsyncBillingClient(client_wrapper=self._client_wrapper) - self.blueprints = AsyncBlueprintsClient(client_wrapper=self._client_wrapper) self.comments = AsyncCommentsClient(client_wrapper=self._client_wrapper) self.users = AsyncUsersClient(client_wrapper=self._client_wrapper) self.actions = AsyncActionsClient(client_wrapper=self._client_wrapper) diff --git a/src/label_studio_sdk/blueprints/__init__.py b/src/label_studio_sdk/blueprints/__init__.py deleted file mode 100644 index f3ea2659b..000000000 --- a/src/label_studio_sdk/blueprints/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - diff --git a/src/label_studio_sdk/blueprints/client.py b/src/label_studio_sdk/blueprints/client.py deleted file mode 100644 index 20f1d8b17..000000000 --- a/src/label_studio_sdk/blueprints/client.py +++ /dev/null @@ -1,272 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing -from ..core.client_wrapper import SyncClientWrapper -from ..core.request_options import RequestOptions -from ..types.blueprint import Blueprint -from ..core.unchecked_base_model import construct_type -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.jsonable_encoder import jsonable_encoder -from ..core.client_wrapper import AsyncClientWrapper - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) - - -class BlueprintsClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - - def create( - self, - *, - project: int, - created_by: typing.Optional[int] = OMIT, - description: typing.Optional[str] = OMIT, - label_config: typing.Optional[str] = OMIT, - title: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> Blueprint: - """ - Create a new blueprint - - Parameters - ---------- - project : int - - created_by : typing.Optional[int] - - description : typing.Optional[str] - Project description - - label_config : typing.Optional[str] - Labeling configuration in XML format - - title : typing.Optional[str] - Blueprint name. Must be between 3 and 50 characters long. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - Blueprint - - - Examples - -------- - from label_studio_sdk import LabelStudio - - client = LabelStudio( - api_key="YOUR_API_KEY", - ) - client.blueprints.create( - project=1, - ) - """ - _response = self._client_wrapper.httpx_client.request( - "api/blueprints/", - method="POST", - json={ - "created_by": created_by, - "description": description, - "label_config": label_config, - "project": project, - "title": title, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - Blueprint, - construct_type( - type_=Blueprint, # type: ignore - object_=_response.json(), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: - """ - Delete a blueprint by ID - - Parameters - ---------- - id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - from label_studio_sdk import LabelStudio - - client = LabelStudio( - api_key="YOUR_API_KEY", - ) - client.blueprints.delete( - id="id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"api/blueprints/{jsonable_encoder(id)}/", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - -class AsyncBlueprintsClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def create( - self, - *, - project: int, - created_by: typing.Optional[int] = OMIT, - description: typing.Optional[str] = OMIT, - label_config: typing.Optional[str] = OMIT, - title: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> Blueprint: - """ - Create a new blueprint - - Parameters - ---------- - project : int - - created_by : typing.Optional[int] - - description : typing.Optional[str] - Project description - - label_config : typing.Optional[str] - Labeling configuration in XML format - - title : typing.Optional[str] - Blueprint name. Must be between 3 and 50 characters long. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - Blueprint - - - Examples - -------- - import asyncio - - from label_studio_sdk import AsyncLabelStudio - - client = AsyncLabelStudio( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.blueprints.create( - project=1, - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "api/blueprints/", - method="POST", - json={ - "created_by": created_by, - "description": description, - "label_config": label_config, - "project": project, - "title": title, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - Blueprint, - construct_type( - type_=Blueprint, # type: ignore - object_=_response.json(), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: - """ - Delete a blueprint by ID - - Parameters - ---------- - id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - import asyncio - - from label_studio_sdk import AsyncLabelStudio - - client = AsyncLabelStudio( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.blueprints.delete( - id="id", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"api/blueprints/{jsonable_encoder(id)}/", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/label_studio_sdk/types/__init__.py b/src/label_studio_sdk/types/__init__.py index f539e9f73..3ed6a7578 100644 --- a/src/label_studio_sdk/types/__init__.py +++ b/src/label_studio_sdk/types/__init__.py @@ -36,7 +36,6 @@ from .billing_flags import BillingFlags from .billing_info_response import BillingInfoResponse from .blank_enum import BlankEnum -from .blueprint import Blueprint from .blueprint_list import BlueprintList from .budget_reset_period_enum import BudgetResetPeriodEnum from .child_filter import ChildFilter @@ -261,7 +260,6 @@ "BillingFlags", "BillingInfoResponse", "BlankEnum", - "Blueprint", "BlueprintList", "BudgetResetPeriodEnum", "ChildFilter", diff --git a/src/label_studio_sdk/types/blueprint.py b/src/label_studio_sdk/types/blueprint.py deleted file mode 100644 index 1ab2a859d..000000000 --- a/src/label_studio_sdk/types/blueprint.py +++ /dev/null @@ -1,41 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ..core.unchecked_base_model import UncheckedBaseModel -import datetime as dt -import typing -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 - - -class Blueprint(UncheckedBaseModel): - created_at: dt.datetime - created_by: typing.Optional[int] = None - description: typing.Optional[str] = pydantic.Field(default=None) - """ - Project description - """ - - id: int - label_config: typing.Optional[str] = pydantic.Field(default=None) - """ - Labeling configuration in XML format - """ - - project: int - share_id: str - short_url: str - title: typing.Optional[str] = pydantic.Field(default=None) - """ - Blueprint name. Must be between 3 and 50 characters long. - """ - - updated_at: dt.datetime - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/tests/test_blueprints.py b/tests/test_blueprints.py deleted file mode 100644 index 761d4b5d8..000000000 --- a/tests/test_blueprints.py +++ /dev/null @@ -1,51 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from label_studio_sdk import LabelStudio -from label_studio_sdk import AsyncLabelStudio -import typing -from .utilities import validate_response - - -async def test_create(client: LabelStudio, async_client: AsyncLabelStudio) -> None: - expected_response: typing.Any = { - "created_at": "2024-01-15T09:30:00Z", - "created_by": 1, - "description": "description", - "id": 1, - "label_config": "label_config", - "project": 1, - "share_id": "share_id", - "short_url": "short_url", - "title": "title", - "updated_at": "2024-01-15T09:30:00Z", - } - expected_types: typing.Any = { - "created_at": "datetime", - "created_by": "integer", - "description": None, - "id": "integer", - "label_config": None, - "project": "integer", - "share_id": None, - "short_url": None, - "title": None, - "updated_at": "datetime", - } - response = client.blueprints.create(project=1) - validate_response(response, expected_response, expected_types) - - async_response = await async_client.blueprints.create(project=1) - validate_response(async_response, expected_response, expected_types) - - -async def test_delete(client: LabelStudio, async_client: AsyncLabelStudio) -> None: - # Type ignore to avoid mypy complaining about the function not being meant to return a value - assert ( - client.blueprints.delete(id="id") # type: ignore[func-returns-value] - is None - ) - - assert ( - await async_client.blueprints.delete(id="id") # type: ignore[func-returns-value] - is None - )