|
11 | 11 | from ..core.request_options import RequestOptions |
12 | 12 | from ..core.serialization import convert_and_respect_annotation_metadata |
13 | 13 | from ..core.unchecked_base_model import construct_type |
| 14 | +from ..errors.bad_request_error import BadRequestError |
| 15 | +from ..errors.forbidden_error import ForbiddenError |
14 | 16 | from ..types.annotation import Annotation |
15 | 17 | from ..types.last_action_enum import LastActionEnum |
16 | 18 | from ..types.selected_items_request import SelectedItemsRequest |
17 | 19 | from .types.create_bulk_annotations_response_item import CreateBulkAnnotationsResponseItem |
| 20 | +from .types.delete_bulk_annotations_response import DeleteBulkAnnotationsResponse |
18 | 21 |
|
19 | 22 | # this is used as the default value for optional parameters |
20 | 23 | OMIT = typing.cast(typing.Any, ...) |
@@ -167,6 +170,64 @@ def create_bulk( |
167 | 170 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
168 | 171 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
169 | 172 |
|
| 173 | + def delete_bulk( |
| 174 | + self, *, request_options: typing.Optional[RequestOptions] = None |
| 175 | + ) -> HttpResponse[DeleteBulkAnnotationsResponse]: |
| 176 | + """ |
| 177 | + Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response. |
| 178 | +
|
| 179 | + Parameters |
| 180 | + ---------- |
| 181 | + request_options : typing.Optional[RequestOptions] |
| 182 | + Request-specific configuration. |
| 183 | +
|
| 184 | + Returns |
| 185 | + ------- |
| 186 | + HttpResponse[DeleteBulkAnnotationsResponse] |
| 187 | + Annotations deleted successfully |
| 188 | + """ |
| 189 | + _response = self._client_wrapper.httpx_client.request( |
| 190 | + "api/annotations/bulk/", |
| 191 | + method="DELETE", |
| 192 | + request_options=request_options, |
| 193 | + ) |
| 194 | + try: |
| 195 | + if 200 <= _response.status_code < 300: |
| 196 | + _data = typing.cast( |
| 197 | + DeleteBulkAnnotationsResponse, |
| 198 | + construct_type( |
| 199 | + type_=DeleteBulkAnnotationsResponse, # type: ignore |
| 200 | + object_=_response.json(), |
| 201 | + ), |
| 202 | + ) |
| 203 | + return HttpResponse(response=_response, data=_data) |
| 204 | + if _response.status_code == 400: |
| 205 | + raise BadRequestError( |
| 206 | + headers=dict(_response.headers), |
| 207 | + body=typing.cast( |
| 208 | + typing.Any, |
| 209 | + construct_type( |
| 210 | + type_=typing.Any, # type: ignore |
| 211 | + object_=_response.json(), |
| 212 | + ), |
| 213 | + ), |
| 214 | + ) |
| 215 | + if _response.status_code == 403: |
| 216 | + raise ForbiddenError( |
| 217 | + headers=dict(_response.headers), |
| 218 | + body=typing.cast( |
| 219 | + typing.Any, |
| 220 | + construct_type( |
| 221 | + type_=typing.Any, # type: ignore |
| 222 | + object_=_response.json(), |
| 223 | + ), |
| 224 | + ), |
| 225 | + ) |
| 226 | + _response_json = _response.json() |
| 227 | + except JSONDecodeError: |
| 228 | + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 229 | + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 230 | + |
170 | 231 | def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Annotation]: |
171 | 232 | """ |
172 | 233 | Retrieve a specific annotation for a task using the annotation result ID. |
@@ -614,6 +675,64 @@ async def create_bulk( |
614 | 675 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
615 | 676 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
616 | 677 |
|
| 678 | + async def delete_bulk( |
| 679 | + self, *, request_options: typing.Optional[RequestOptions] = None |
| 680 | + ) -> AsyncHttpResponse[DeleteBulkAnnotationsResponse]: |
| 681 | + """ |
| 682 | + Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response. |
| 683 | +
|
| 684 | + Parameters |
| 685 | + ---------- |
| 686 | + request_options : typing.Optional[RequestOptions] |
| 687 | + Request-specific configuration. |
| 688 | +
|
| 689 | + Returns |
| 690 | + ------- |
| 691 | + AsyncHttpResponse[DeleteBulkAnnotationsResponse] |
| 692 | + Annotations deleted successfully |
| 693 | + """ |
| 694 | + _response = await self._client_wrapper.httpx_client.request( |
| 695 | + "api/annotations/bulk/", |
| 696 | + method="DELETE", |
| 697 | + request_options=request_options, |
| 698 | + ) |
| 699 | + try: |
| 700 | + if 200 <= _response.status_code < 300: |
| 701 | + _data = typing.cast( |
| 702 | + DeleteBulkAnnotationsResponse, |
| 703 | + construct_type( |
| 704 | + type_=DeleteBulkAnnotationsResponse, # type: ignore |
| 705 | + object_=_response.json(), |
| 706 | + ), |
| 707 | + ) |
| 708 | + return AsyncHttpResponse(response=_response, data=_data) |
| 709 | + if _response.status_code == 400: |
| 710 | + raise BadRequestError( |
| 711 | + headers=dict(_response.headers), |
| 712 | + body=typing.cast( |
| 713 | + typing.Any, |
| 714 | + construct_type( |
| 715 | + type_=typing.Any, # type: ignore |
| 716 | + object_=_response.json(), |
| 717 | + ), |
| 718 | + ), |
| 719 | + ) |
| 720 | + if _response.status_code == 403: |
| 721 | + raise ForbiddenError( |
| 722 | + headers=dict(_response.headers), |
| 723 | + body=typing.cast( |
| 724 | + typing.Any, |
| 725 | + construct_type( |
| 726 | + type_=typing.Any, # type: ignore |
| 727 | + object_=_response.json(), |
| 728 | + ), |
| 729 | + ), |
| 730 | + ) |
| 731 | + _response_json = _response.json() |
| 732 | + except JSONDecodeError: |
| 733 | + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 734 | + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 735 | + |
617 | 736 | async def get( |
618 | 737 | self, id: int, *, request_options: typing.Optional[RequestOptions] = None |
619 | 738 | ) -> AsyncHttpResponse[Annotation]: |
|
0 commit comments