diff --git a/encord/api_v2/__init__.py b/encord/api_v2/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/encord/api_v2/endpoints.py b/encord/api_v2/endpoints.py new file mode 100644 index 000000000..fd9a0324e --- /dev/null +++ b/encord/api_v2/endpoints.py @@ -0,0 +1,1824 @@ +import datetime +from typing import ( + Any, + Dict, + List, + Union, +) +from uuid import UUID + +from requests import Request + +from encord.api_v2.models import ( + ApiAnnotationTaskState, + ApiClientMetadataSchema, + ApiClientMetadataSchemaOrmRead, + ApiCordDataType, + ApiFoldersSortBy, + ApiJobStatusInfo, + ApiJournalActionTarget, + ApiJournalActionType, + ApiJournalRecord, + ApiLabelReviewTaskStatus, + ApiLabelValidationState, + ApiOrganisationUserInfo, + ApiPaginatedResponseDataset, + ApiPaginatedResponseDatasetGroup, + ApiPaginatedResponseFolderGroup, + ApiPaginatedResponseGroup, + ApiPaginatedResponseIndexCollection, + ApiPaginatedResponseIndexFilterPreset, + ApiPaginatedResponseJournalRecord, + ApiPaginatedResponseLabelReview, + ApiPaginatedResponseOntologyGroup, + ApiPaginatedResponseProjectGroup, + ApiPaginatedResponseProjectPerformanceCollaboratorData, + ApiPaginatedResponseProjectUser, + ApiPaginatedResponseStorageFolder, + ApiPaginatedResponseStorageItem, + ApiPaginatedResponseStorageItemUnion, + ApiPaginatedResponseTask, + ApiPaginatedResponseUploadUrl, + ApiProject, + ApiRequestAddDatasetGroups, + ApiRequestAddFolderGroups, + ApiRequestAddOntologyGroups, + ApiRequestAddProjectGroup, + ApiRequestCreateDataset, + ApiRequestCreateFolder, + ApiRequestDeleteFolderChildren, + ApiRequestGetItemsBulk, + ApiRequestIndexCollectionBulkItem, + ApiRequestIndexCollectionInsert, + ApiRequestIndexCollectionPreset, + ApiRequestIndexCollectionUpdate, + ApiRequestIndexFilterPresetCreate, + ApiRequestIndexFilterPresetUpdate, + ApiRequestMoveFolders, + ApiRequestMoveItems, + ApiRequestPatchFolder, + ApiRequestPatchFolderBulk, + ApiRequestPatchItem, + ApiRequestPatchItemsBulk, + ApiRequestPriorities, + ApiRequestStartTraining, + ApiRequestStorageItemsMigrate, + ApiRequestStorageItemsRencode, + ApiRequestUploadJob, + ApiRequestUploadSignedUrls, + ApiResponseBearerToken, + ApiResponseCancelFolderUploadJob, + ApiResponseCreateDataset, + ApiResponseDatasetsWithUserRoles, + ApiResponseDeletion, + ApiResponseFolderUploadStatus, + ApiResponseGetCurrentUser, + ApiResponseGetTrainingResultDone, + ApiResponseGetTrainingResultError, + ApiResponseGetTrainingResultPending, + ApiResponseIndexCollectionBulkItem, + ApiResponseLegacyPublic, + ApiResponseStorageFolder, + ApiResponseStorageFolderSummary, + ApiResponseStorageItem, + ApiResponseStorageItemSummary, + ApiReviewTaskState, + ApiStorageFolderConfig, + ApiStorageItemType, + ApiTimersGroupBy, + IndexGetPresetFilterResponsePublicIndexGetPresetFilterIndexPresetsUuidGet, + LegacyPublicRouteData, + LegacyPublicUserRouteData, + OrgCreateMetadataSchemaLegacyMetadataSchema, + WorkflowExecuteStageActionsBodyItem, +) +from encord.http.v2.api_client import ApiClient + + +def api_legacy_public_route( + *, + client: ApiClient, + body: LegacyPublicRouteData, + authorization: str, + resource_id: UUID, + resource_type: Union[None, str], + x_cloud_trace_context: Union[None, str], +) -> ApiResponseLegacyPublic: + return client.request( + Request( + method="post", + url="/public", + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseLegacyPublic, + ) + + +def api_legacy_public_user_route( + *, + client: ApiClient, + body: LegacyPublicUserRouteData, + authorization: str, + x_cloud_trace_context: Union[None, str], +) -> ApiResponseLegacyPublic: + return client.request( + Request( + method="post", + url="/public/user", + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseLegacyPublic, + ) + + +def api_analytics_get_collaborator_time_metrics( + *, + client: ApiClient, + project_hash: UUID, + after: datetime.datetime, + before: Union[None, datetime.datetime], + group_by: Union[None, ApiTimersGroupBy] = ApiTimersGroupBy.DATAUNIT, + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseProjectPerformanceCollaboratorData: + return client.request( + Request( + method="get", + url="/v2/public/analytics/collaborators/timers", + params={ + k: v + for k, v in { + "projectHash": project_hash, + "after": after, + "before": before, + "groupBy": group_by, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseProjectPerformanceCollaboratorData, + ) + + +def api_dataset_create_new( + *, + client: ApiClient, + body: ApiRequestCreateDataset, +) -> ApiResponseCreateDataset: + return client.request( + Request( + method="post", + url="/v2/public/datasets", + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseCreateDataset, + ) + + +def api_dataset_list_all( + *, + client: ApiClient, + title_eq: Union[None, str], + title_like: Union[None, str], + description_eq: Union[None, str], + description_like: Union[None, str], + created_before: Union[None, datetime.datetime], + created_after: Union[None, datetime.datetime], + edited_before: Union[None, datetime.datetime], + edited_after: Union[None, datetime.datetime], +) -> ApiResponseDatasetsWithUserRoles: + return client.request( + Request( + method="get", + url="/v2/public/datasets/list", + params={ + k: v + for k, v in { + "titleEq": title_eq, + "titleLike": title_like, + "descriptionEq": description_eq, + "descriptionLike": description_like, + "createdBefore": created_before, + "createdAfter": created_after, + "editedBefore": edited_before, + "editedAfter": edited_after, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiResponseDatasetsWithUserRoles, + ) + + +def api_dataset_delete_by_id( + dataset_hash: UUID, + *, + client: ApiClient, +) -> None: + return client.request( + Request( + method="delete", + url="/v2/public/datasets/{dataset_hash}".format( + dataset_hash=dataset_hash, + ), + ).prepare(), + result_type=None, + ) + + +def api_dataset_list_groups( + dataset_hash: UUID, + *, + client: ApiClient, +) -> ApiPaginatedResponseDatasetGroup: + return client.request( + Request( + method="get", + url="/v2/public/datasets/{dataset_hash}/groups".format( + dataset_hash=dataset_hash, + ), + ).prepare(), + result_type=ApiPaginatedResponseDatasetGroup, + ) + + +def api_dataset_add_groups( + dataset_hash: UUID, + *, + client: ApiClient, + body: ApiRequestAddDatasetGroups, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/datasets/{dataset_hash}/groups".format( + dataset_hash=dataset_hash, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_dataset_remove_groups( + dataset_hash: UUID, + *, + client: ApiClient, + group_hash_list: List[UUID], +) -> None: + return client.request( + Request( + method="delete", + url="/v2/public/datasets/{dataset_hash}/groups".format( + dataset_hash=dataset_hash, + ), + params={ + k: v + for k, v in { + "groupHashList": group_hash_list, + }.items() + if v is not None + }, + ).prepare(), + result_type=None, + ) + + +def api_index_list_collections( + *, + client: ApiClient, + top_level_folder_uuid: Union[None, UUID], + uuids: Union[List[UUID], None], + search: Union[None, str], + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseIndexCollection: + return client.request( + Request( + method="get", + url="/v2/public/index/collections", + params={ + k: v + for k, v in { + "topLevelFolderUuid": top_level_folder_uuid, + "uuids": uuids, + "search": search, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseIndexCollection, + ) + + +def api_index_create_collection( + *, + client: ApiClient, + body: ApiRequestIndexCollectionInsert, + top_level_folder_uuid: UUID, +) -> UUID: + return client.request( + Request( + method="post", + url="/v2/public/index/collections", + params={ + k: v + for k, v in { + "topLevelFolderUuid": top_level_folder_uuid, + }.items() + if v is not None + }, + json=client.serialise_payload(body), + ).prepare(), + result_type=UUID, + ) + + +def api_index_list_accessible_items( + collection_id: UUID, + *, + client: ApiClient, + sign_urls: Union[None, bool] = False, + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseStorageItem: + return client.request( + Request( + method="get", + url="/v2/public/index/collections/{collection_id}/accessible-items".format( + collection_id=collection_id, + ), + params={ + k: v + for k, v in { + "signUrls": sign_urls, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseStorageItem, + ) + + +def api_index_add_items_to_collection( + collection_id: UUID, + *, + client: ApiClient, + body: ApiRequestIndexCollectionBulkItem, +) -> ApiResponseIndexCollectionBulkItem: + return client.request( + Request( + method="post", + url="/v2/public/index/collections/{collection_id}/add-items".format( + collection_id=collection_id, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseIndexCollectionBulkItem, + ) + + +def api_index_add_preset_items_to_collection( + collection_id: UUID, + *, + client: ApiClient, + body: ApiRequestIndexCollectionPreset, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/index/collections/{collection_id}/add-preset-items".format( + collection_id=collection_id, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_index_list_all_items( + collection_id: UUID, + *, + client: ApiClient, + sign_urls: Union[None, bool] = False, + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseStorageItemUnion: + return client.request( + Request( + method="get", + url="/v2/public/index/collections/{collection_id}/all-items".format( + collection_id=collection_id, + ), + params={ + k: v + for k, v in { + "signUrls": sign_urls, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseStorageItemUnion, + ) + + +def api_index_remove_items_from_collection( + collection_id: UUID, + *, + client: ApiClient, + body: ApiRequestIndexCollectionBulkItem, +) -> ApiResponseIndexCollectionBulkItem: + return client.request( + Request( + method="post", + url="/v2/public/index/collections/{collection_id}/remove-items".format( + collection_id=collection_id, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseIndexCollectionBulkItem, + ) + + +def api_index_remove_preset_items_from_collection( + collection_id: UUID, + *, + client: ApiClient, + body: ApiRequestIndexCollectionPreset, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/index/collections/{collection_id}/remove-preset-items".format( + collection_id=collection_id, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_index_delete_collection( + uuid: UUID, + *, + client: ApiClient, +) -> None: + return client.request( + Request( + method="delete", + url="/v2/public/index/collections/{uuid}".format( + uuid=uuid, + ), + ).prepare(), + result_type=None, + ) + + +def api_index_update_collection( + uuid: UUID, + *, + client: ApiClient, + body: ApiRequestIndexCollectionUpdate, +) -> None: + return client.request( + Request( + method="patch", + url="/v2/public/index/collections/{uuid}".format( + uuid=uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_index_list_presets( + *, + client: ApiClient, + top_level_folder_uuid: Union[None, UUID], + uuids: Union[List[UUID], None], + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseIndexFilterPreset: + return client.request( + Request( + method="get", + url="/v2/public/index/presets", + params={ + k: v + for k, v in { + "topLevelFolderUuid": top_level_folder_uuid, + "uuids": uuids, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseIndexFilterPreset, + ) + + +def api_index_create_preset( + *, + client: ApiClient, + body: ApiRequestIndexFilterPresetCreate, + top_level_folder_uuid: UUID, +) -> UUID: + return client.request( + Request( + method="post", + url="/v2/public/index/presets", + params={ + k: v + for k, v in { + "topLevelFolderUuid": top_level_folder_uuid, + }.items() + if v is not None + }, + json=client.serialise_payload(body), + ).prepare(), + result_type=UUID, + ) + + +def api_index_get_preset_filter( + uuid: UUID, + *, + client: ApiClient, +) -> IndexGetPresetFilterResponsePublicIndexGetPresetFilterIndexPresetsUuidGet: + return client.request( + Request( + method="get", + url="/v2/public/index/presets/{uuid}".format( + uuid=uuid, + ), + ).prepare(), + result_type=IndexGetPresetFilterResponsePublicIndexGetPresetFilterIndexPresetsUuidGet, + ) + + +def api_index_delete_preset( + uuid: UUID, + *, + client: ApiClient, +) -> None: + return client.request( + Request( + method="delete", + url="/v2/public/index/presets/{uuid}".format( + uuid=uuid, + ), + ).prepare(), + result_type=None, + ) + + +def api_index_update_preset( + uuid: UUID, + *, + client: ApiClient, + body: ApiRequestIndexFilterPresetUpdate, +) -> None: + return client.request( + Request( + method="patch", + url="/v2/public/index/presets/{uuid}".format( + uuid=uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_ml_model_start_training( + model_hash: UUID, + *, + client: ApiClient, + body: ApiRequestStartTraining, +) -> UUID: + return client.request( + Request( + method="post", + url="/v2/public/ml-models/{model_hash}/training".format( + model_hash=model_hash, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=UUID, + ) + + +def api_ml_model_get_training_result( + model_hash: UUID, + training_hash: UUID, + *, + client: ApiClient, + timeout_seconds: Union[None, int] = 0, +) -> Union[ + ApiResponseGetTrainingResultDone, + ApiResponseGetTrainingResultError, + ApiResponseGetTrainingResultPending, +]: + return client.request( + Request( + method="get", + url="/v2/public/ml-models/{model_hash}/{training_hash}/training".format( + model_hash=model_hash, + training_hash=training_hash, + ), + params={ + k: v + for k, v in { + "timeoutSeconds": timeout_seconds, + }.items() + if v is not None + }, + ).prepare(), + result_type=Union[ + ApiResponseGetTrainingResultDone, + ApiResponseGetTrainingResultError, + ApiResponseGetTrainingResultPending, + ], + ) + + +def api_ontology_list_groups( + ontology_hash: UUID, + *, + client: ApiClient, +) -> ApiPaginatedResponseOntologyGroup: + return client.request( + Request( + method="get", + url="/v2/public/ontologies/{ontology_hash}/groups".format( + ontology_hash=ontology_hash, + ), + ).prepare(), + result_type=ApiPaginatedResponseOntologyGroup, + ) + + +def api_ontology_add_groups( + ontology_hash: UUID, + *, + client: ApiClient, + body: ApiRequestAddOntologyGroups, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/ontologies/{ontology_hash}/groups".format( + ontology_hash=ontology_hash, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_ontology_remove_groups( + ontology_hash: UUID, + *, + client: ApiClient, + group_hash_list: List[UUID], +) -> None: + return client.request( + Request( + method="delete", + url="/v2/public/ontologies/{ontology_hash}/groups".format( + ontology_hash=ontology_hash, + ), + params={ + k: v + for k, v in { + "groupHashList": group_hash_list, + }.items() + if v is not None + }, + ).prepare(), + result_type=None, + ) + + +def api_org_get_metadata_schema_legacy( + *, + client: ApiClient, +) -> Union[ + ApiClientMetadataSchemaOrmRead, + None, +]: + return client.request( + Request( + method="get", + url="/v2/public/organisation/client-metadata-schema", + ).prepare(), + result_type=Union[ + ApiClientMetadataSchemaOrmRead, + None, + ], + ) + + +def api_org_create_metadata_schema_legacy( + *, + client: ApiClient, + body: OrgCreateMetadataSchemaLegacyMetadataSchema, +) -> UUID: + return client.request( + Request( + method="post", + url="/v2/public/organisation/client-metadata-schema", + json=client.serialise_payload(body), + ).prepare(), + result_type=UUID, + ) + + +def api_org_get_metadata_schema( + *, + client: ApiClient, +) -> Union[ + ApiClientMetadataSchema, + None, +]: + return client.request( + Request( + method="get", + url="/v2/public/organisation/client-metadata-schema-v2", + ).prepare(), + result_type=Union[ + ApiClientMetadataSchema, + None, + ], + ) + + +def api_org_create_metadata_schema( + *, + client: ApiClient, + body: ApiClientMetadataSchema, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/organisation/client-metadata-schema-v2", + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_org_list_journal_records( + *, + client: ApiClient, + include_action_data: Union[None, bool] = False, + created_after: Union[None, datetime.datetime], + include_targets: Union[None, List[ApiJournalActionTarget]], + include_types: Union[None, List[ApiJournalActionType]], + page_size: Union[None, int] = 1000, + page_token: Union[None, str], +) -> ApiPaginatedResponseJournalRecord: + return client.request( + Request( + method="get", + url="/v2/public/organisation/journal-records", + params={ + k: v + for k, v in { + "includeActionData": include_action_data, + "createdAfter": created_after, + "includeTargets": include_targets, + "includeTypes": include_types, + "pageSize": page_size, + "pageToken": page_token, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseJournalRecord, + ) + + +def api_org_get_bulk_journal_records( + *, + client: ApiClient, + body: List[UUID], +) -> ApiPaginatedResponseJournalRecord: + return client.request( + Request( + method="post", + url="/v2/public/organisation/journal-records/get-bulk", + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiPaginatedResponseJournalRecord, + ) + + +def api_org_get_journal_record( + record_uuid: UUID, + *, + client: ApiClient, +) -> ApiJournalRecord: + return client.request( + Request( + method="get", + url="/v2/public/organisation/journal-records/{record_uuid}".format( + record_uuid=record_uuid, + ), + ).prepare(), + result_type=ApiJournalRecord, + ) + + +def api_project_get_details( + project_hash: UUID, + *, + client: ApiClient, +) -> ApiProject: + return client.request( + Request( + method="get", + url="/v2/public/projects/{project_hash}".format( + project_hash=project_hash, + ), + ).prepare(), + result_type=ApiProject, + ) + + +def api_project_list_datasets( + project_hash: UUID, + *, + client: ApiClient, +) -> ApiPaginatedResponseDataset: + return client.request( + Request( + method="get", + url="/v2/public/projects/{project_hash}/datasets".format( + project_hash=project_hash, + ), + ).prepare(), + result_type=ApiPaginatedResponseDataset, + ) + + +def api_project_list_groups( + project_hash: UUID, + *, + client: ApiClient, +) -> ApiPaginatedResponseProjectGroup: + return client.request( + Request( + method="get", + url="/v2/public/projects/{project_hash}/groups".format( + project_hash=project_hash, + ), + ).prepare(), + result_type=ApiPaginatedResponseProjectGroup, + ) + + +def api_project_add_groups( + project_hash: UUID, + *, + client: ApiClient, + body: ApiRequestAddProjectGroup, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/projects/{project_hash}/groups".format( + project_hash=project_hash, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_project_remove_groups( + project_hash: UUID, + *, + client: ApiClient, + group_hash_list: List[UUID], +) -> None: + return client.request( + Request( + method="delete", + url="/v2/public/projects/{project_hash}/groups".format( + project_hash=project_hash, + ), + params={ + k: v + for k, v in { + "groupHashList": group_hash_list, + }.items() + if v is not None + }, + ).prepare(), + result_type=None, + ) + + +def api_project_list_label_branches( + project_hash: UUID, + *, + client: ApiClient, + branch_name_search: Union[None, str], +) -> List[str]: + return client.request( + Request( + method="get", + url="/v2/public/projects/{project_hash}/label-branches".format( + project_hash=project_hash, + ), + params={ + k: v + for k, v in { + "branchNameSearch": branch_name_search, + }.items() + if v is not None + }, + ).prepare(), + result_type=List[str], + ) + + +def api_project_get_label_validation_state( + project_hash: UUID, + label_hash: UUID, + *, + client: ApiClient, + branch_name: Union[None, str] = "main", +) -> ApiLabelValidationState: + return client.request( + Request( + method="get", + url="/v2/public/projects/{project_hash}/labels/{label_hash}/validation-state".format( + project_hash=project_hash, + label_hash=label_hash, + ), + params={ + k: v + for k, v in { + "branchName": branch_name, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiLabelValidationState, + ) + + +def api_project_set_task_priorities( + project_hash: UUID, + *, + client: ApiClient, + body: ApiRequestPriorities, +) -> List[ + Union[ + ApiAnnotationTaskState, + ApiReviewTaskState, + ], +]: + return client.request( + Request( + method="post", + url="/v2/public/projects/{project_hash}/priorities".format( + project_hash=project_hash, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=List[ + Union[ + ApiAnnotationTaskState, + ApiReviewTaskState, + ], + ], + ) + + +def api_project_list_users( + project_hash: UUID, + *, + client: ApiClient, + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseProjectUser: + return client.request( + Request( + method="get", + url="/v2/public/projects/{project_hash}/users".format( + project_hash=project_hash, + ), + params={ + k: v + for k, v in { + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseProjectUser, + ) + + +def api_workflow_execute_stage_actions( + project_hash: UUID, + workflow_stage_uuid: UUID, + *, + client: ApiClient, + body: List["WorkflowExecuteStageActionsBodyItem"], +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/projects/{project_hash}/workflow/stages/{workflow_stage_uuid}/actions".format( + project_hash=project_hash, + workflow_stage_uuid=workflow_stage_uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_workflow_list_stage_tasks( + project_hash: UUID, + workflow_stage_uuid: UUID, + *, + client: ApiClient, + data_title_contains: Union[None, str], + user_emails: Union[None, List[str]], + data_hashes: Union[None, List[UUID]], + dataset_hashes: Union[None, List[UUID]], + data_types: Union[None, List[ApiCordDataType]], + statuses: Union[None, List[str]], + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseTask: + return client.request( + Request( + method="get", + url="/v2/public/projects/{project_hash}/workflow/stages/{workflow_stage_uuid}/tasks".format( + project_hash=project_hash, + workflow_stage_uuid=workflow_stage_uuid, + ), + params={ + k: v + for k, v in { + "dataTitleContains": data_title_contains, + "userEmails": user_emails, + "dataHashes": data_hashes, + "datasetHashes": dataset_hashes, + "dataTypes": data_types, + "statuses": statuses, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseTask, + ) + + +def api_workflow_list_task_reviews( + project_hash: UUID, + workflow_stage_uuid: UUID, + task_uuid: UUID, + *, + client: ApiClient, + statuses: Union[List[ApiLabelReviewTaskStatus], None], +) -> ApiPaginatedResponseLabelReview: + return client.request( + Request( + method="get", + url="/v2/public/projects/{project_hash}/workflow/stages/{workflow_stage_uuid}/tasks/{task_uuid}/reviews".format( + project_hash=project_hash, + workflow_stage_uuid=workflow_stage_uuid, + task_uuid=task_uuid, + ), + params={ + k: v + for k, v in { + "statuses": statuses, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseLabelReview, + ) + + +def api_storage_list_root_folders( + *, + client: ApiClient, + search: Union[None, str], + dataset_synced: Union[None, bool], + include_org_access: Union[None, bool], + include_hidden: Union[None, bool] = True, + order: Union[None, ApiFoldersSortBy] = ApiFoldersSortBy.NAME, + desc: Union[None, bool] = False, + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseStorageFolder: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders", + params={ + k: v + for k, v in { + "search": search, + "datasetSynced": dataset_synced, + "includeOrgAccess": include_org_access, + "includeHidden": include_hidden, + "order": order, + "desc": desc, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseStorageFolder, + ) + + +def api_storage_create_folder( + *, + client: ApiClient, + body: ApiRequestCreateFolder, +) -> ApiResponseStorageFolder: + return client.request( + Request( + method="post", + url="/v2/public/storage/folders", + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseStorageFolder, + ) + + +def api_storage_move_folders( + *, + client: ApiClient, + body: ApiRequestMoveFolders, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/storage/folders/move", + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_storage_update_folders_bulk( + *, + client: ApiClient, + body: ApiRequestPatchFolderBulk, +) -> ApiPaginatedResponseStorageFolder: + return client.request( + Request( + method="patch", + url="/v2/public/storage/folders/patch-bulk", + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiPaginatedResponseStorageFolder, + ) + + +def api_storage_get_folder_info( + folder_uuid: UUID, + *, + client: ApiClient, +) -> ApiResponseStorageFolder: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}".format( + folder_uuid=folder_uuid, + ), + ).prepare(), + result_type=ApiResponseStorageFolder, + ) + + +def api_storage_delete_folder( + folder_uuid: UUID, + *, + client: ApiClient, +) -> None: + return client.request( + Request( + method="delete", + url="/v2/public/storage/folders/{folder_uuid}".format( + folder_uuid=folder_uuid, + ), + ).prepare(), + result_type=None, + ) + + +def api_storage_update_folder( + folder_uuid: UUID, + *, + client: ApiClient, + body: ApiRequestPatchFolder, +) -> ApiResponseStorageFolder: + return client.request( + Request( + method="patch", + url="/v2/public/storage/folders/{folder_uuid}".format( + folder_uuid=folder_uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseStorageFolder, + ) + + +def api_storage_create_upload_job( + folder_uuid: UUID, + *, + client: ApiClient, + body: ApiRequestUploadJob, +) -> UUID: + return client.request( + Request( + method="post", + url="/v2/public/storage/folders/{folder_uuid}/data-upload-jobs".format( + folder_uuid=folder_uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=UUID, + ) + + +def api_storage_get_upload_status( + folder_uuid: UUID, + upload_job_hash: UUID, + *, + client: ApiClient, + timeout_seconds: int, +) -> ApiResponseFolderUploadStatus: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}/data-upload-jobs/{upload_job_hash}".format( + folder_uuid=folder_uuid, + upload_job_hash=upload_job_hash, + ), + params={ + k: v + for k, v in { + "timeoutSeconds": timeout_seconds, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiResponseFolderUploadStatus, + ) + + +def api_storage_cancel_upload_job( + folder_uuid: UUID, + upload_job_hash: UUID, + *, + client: ApiClient, +) -> ApiResponseCancelFolderUploadJob: + return client.request( + Request( + method="post", + url="/v2/public/storage/folders/{folder_uuid}/data-upload-jobs/{upload_job_hash}/cancel".format( + folder_uuid=folder_uuid, + upload_job_hash=upload_job_hash, + ), + ).prepare(), + result_type=ApiResponseCancelFolderUploadJob, + ) + + +def api_storage_get_folder_config( + folder_uuid: UUID, + *, + client: ApiClient, +) -> ApiStorageFolderConfig: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}/folder-config".format( + folder_uuid=folder_uuid, + ), + ).prepare(), + result_type=ApiStorageFolderConfig, + ) + + +def api_storage_list_subfolders( + folder_uuid: UUID, + *, + client: ApiClient, + search: Union[None, str], + is_recursive: Union[None, bool] = False, + dataset_synced: Union[None, bool], + include_hidden: Union[None, bool] = True, + order: Union[None, ApiFoldersSortBy] = ApiFoldersSortBy.NAME, + desc: Union[None, bool] = False, + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseStorageFolder: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}/folders".format( + folder_uuid=folder_uuid, + ), + params={ + k: v + for k, v in { + "search": search, + "isRecursive": is_recursive, + "datasetSynced": dataset_synced, + "includeHidden": include_hidden, + "order": order, + "desc": desc, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseStorageFolder, + ) + + +def api_storage_list_folder_groups( + folder_uuid: UUID, + *, + client: ApiClient, +) -> ApiPaginatedResponseFolderGroup: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}/groups".format( + folder_uuid=folder_uuid, + ), + ).prepare(), + result_type=ApiPaginatedResponseFolderGroup, + ) + + +def api_storage_add_folder_groups( + folder_uuid: UUID, + *, + client: ApiClient, + body: ApiRequestAddFolderGroups, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/storage/folders/{folder_uuid}/groups".format( + folder_uuid=folder_uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_storage_remove_folder_groups( + folder_uuid: UUID, + *, + client: ApiClient, + group_hash_list: List[UUID], +) -> None: + return client.request( + Request( + method="delete", + url="/v2/public/storage/folders/{folder_uuid}/groups".format( + folder_uuid=folder_uuid, + ), + params={ + k: v + for k, v in { + "groupHashList": group_hash_list, + }.items() + if v is not None + }, + ).prepare(), + result_type=None, + ) + + +def api_storage_list_folder_items( + folder_uuid: UUID, + *, + client: ApiClient, + search: Union[None, str], + is_recursive: Union[None, bool] = False, + is_in_dataset: Union[None, bool], + item_types: Union[List[ApiStorageItemType], None], + order: Union[None, ApiFoldersSortBy] = ApiFoldersSortBy.NAME, + desc: Union[None, bool] = False, + page_token: Union[None, str], + page_size: Union[None, int] = 100, + sign_urls: Union[None, bool] = False, +) -> ApiPaginatedResponseStorageItem: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}/items".format( + folder_uuid=folder_uuid, + ), + params={ + k: v + for k, v in { + "search": search, + "isRecursive": is_recursive, + "isInDataset": is_in_dataset, + "itemTypes": item_types, + "order": order, + "desc": desc, + "pageToken": page_token, + "pageSize": page_size, + "signUrls": sign_urls, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseStorageItem, + ) + + +def api_storage_delete_folder_items( + folder_uuid: UUID, + *, + client: ApiClient, + body: ApiRequestDeleteFolderChildren, +) -> ApiResponseDeletion: + return client.request( + Request( + method="post", + url="/v2/public/storage/folders/{folder_uuid}/items/delete".format( + folder_uuid=folder_uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseDeletion, + ) + + +def api_storage_move_folder_items( + folder_uuid: UUID, + *, + client: ApiClient, + body: ApiRequestMoveItems, +) -> None: + return client.request( + Request( + method="post", + url="/v2/public/storage/folders/{folder_uuid}/items/move".format( + folder_uuid=folder_uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=None, + ) + + +def api_storage_update_folder_item( + folder_uuid: UUID, + item_uuid: UUID, + *, + client: ApiClient, + body: ApiRequestPatchItem, +) -> ApiResponseStorageItem: + return client.request( + Request( + method="patch", + url="/v2/public/storage/folders/{folder_uuid}/items/{item_uuid}".format( + folder_uuid=folder_uuid, + item_uuid=item_uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiResponseStorageItem, + ) + + +def api_storage_list_item_children( + folder_uuid: UUID, + item_uuid: UUID, + *, + client: ApiClient, + frames: Union[List[int], None], + sign_urls: Union[None, bool] = False, +) -> ApiPaginatedResponseStorageItem: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}/items/{item_uuid}/child-items".format( + folder_uuid=folder_uuid, + item_uuid=item_uuid, + ), + params={ + k: v + for k, v in { + "frames": frames, + "signUrls": sign_urls, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseStorageItem, + ) + + +def api_storage_get_item_summary( + folder_uuid: UUID, + item_uuid: UUID, + *, + client: ApiClient, +) -> ApiResponseStorageItemSummary: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}/items/{item_uuid}/summary".format( + folder_uuid=folder_uuid, + item_uuid=item_uuid, + ), + ).prepare(), + result_type=ApiResponseStorageItemSummary, + ) + + +def api_storage_get_folder_summary( + folder_uuid: UUID, + *, + client: ApiClient, +) -> ApiResponseStorageFolderSummary: + return client.request( + Request( + method="get", + url="/v2/public/storage/folders/{folder_uuid}/summary".format( + folder_uuid=folder_uuid, + ), + ).prepare(), + result_type=ApiResponseStorageFolderSummary, + ) + + +def api_storage_create_upload_urls( + folder_uuid: UUID, + *, + client: ApiClient, + body: ApiRequestUploadSignedUrls, +) -> ApiPaginatedResponseUploadUrl: + return client.request( + Request( + method="post", + url="/v2/public/storage/folders/{folder_uuid}/upload-signed-urls".format( + folder_uuid=folder_uuid, + ), + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiPaginatedResponseUploadUrl, + ) + + +def api_storage_get_items_bulk( + *, + client: ApiClient, + body: ApiRequestGetItemsBulk, +) -> ApiPaginatedResponseStorageItem: + return client.request( + Request( + method="post", + url="/v2/public/storage/items/get-bulk", + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiPaginatedResponseStorageItem, + ) + + +def api_storage_migrate_items( + *, + client: ApiClient, + body: ApiRequestStorageItemsMigrate, +) -> List[UUID]: + return client.request( + Request( + method="post", + url="/v2/public/storage/items/migrate-storage", + json=client.serialise_payload(body), + ).prepare(), + result_type=List[UUID], + ) + + +def api_storage_update_items_bulk( + *, + client: ApiClient, + body: ApiRequestPatchItemsBulk, +) -> ApiPaginatedResponseStorageItem: + return client.request( + Request( + method="patch", + url="/v2/public/storage/items/patch-bulk", + json=client.serialise_payload(body), + ).prepare(), + result_type=ApiPaginatedResponseStorageItem, + ) + + +def api_storage_start_item_reencoding( + *, + client: ApiClient, + body: ApiRequestStorageItemsRencode, +) -> UUID: + return client.request( + Request( + method="post", + url="/v2/public/storage/items/reencode", + json=client.serialise_payload(body), + ).prepare(), + result_type=UUID, + ) + + +def api_storage_get_reencoding_status( + process_hash: UUID, + *, + client: ApiClient, +) -> ApiJobStatusInfo: + return client.request( + Request( + method="get", + url="/v2/public/storage/items/reencode/{process_hash}".format( + process_hash=process_hash, + ), + ).prepare(), + result_type=ApiJobStatusInfo, + ) + + +def api_storage_get_item_info( + item_uuid: UUID, + *, + client: ApiClient, + sign_url: Union[None, bool] = False, +) -> ApiResponseStorageItem: + return client.request( + Request( + method="get", + url="/v2/public/storage/items/{item_uuid}".format( + item_uuid=item_uuid, + ), + params={ + k: v + for k, v in { + "signUrl": sign_url, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiResponseStorageItem, + ) + + +def api_storage_search_folders( + *, + client: ApiClient, + search: Union[None, str], + dataset_synced: Union[None, bool], + include_org_access: Union[None, bool], + order: Union[None, ApiFoldersSortBy] = ApiFoldersSortBy.NAME, + desc: Union[None, bool] = False, + page_token: Union[None, str], + page_size: Union[None, int] = 100, +) -> ApiPaginatedResponseStorageFolder: + return client.request( + Request( + method="get", + url="/v2/public/storage/search/folders", + params={ + k: v + for k, v in { + "search": search, + "datasetSynced": dataset_synced, + "includeOrgAccess": include_org_access, + "order": order, + "desc": desc, + "pageToken": page_token, + "pageSize": page_size, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseStorageFolder, + ) + + +def api_storage_search_items( + *, + client: ApiClient, + search: Union[None, str], + is_in_dataset: Union[None, bool], + item_types: Union[List[ApiStorageItemType], None], + include_org_access: Union[None, bool], + order: Union[None, ApiFoldersSortBy] = ApiFoldersSortBy.NAME, + desc: Union[None, bool] = False, + page_token: Union[None, str], + page_size: Union[None, int] = 100, + sign_urls: Union[None, bool] = False, +) -> ApiPaginatedResponseStorageItem: + return client.request( + Request( + method="get", + url="/v2/public/storage/search/items", + params={ + k: v + for k, v in { + "search": search, + "isInDataset": is_in_dataset, + "itemTypes": item_types, + "includeOrgAccess": include_org_access, + "order": order, + "desc": desc, + "pageToken": page_token, + "pageSize": page_size, + "signUrls": sign_urls, + }.items() + if v is not None + }, + ).prepare(), + result_type=ApiPaginatedResponseStorageItem, + ) + + +def api_user_get_bearer_token( + *, + client: ApiClient, +) -> ApiResponseBearerToken: + return client.request( + Request( + method="get", + url="/v2/public/user/bearer-token", + ).prepare(), + result_type=ApiResponseBearerToken, + ) + + +def api_user_get_current_user( + *, + client: ApiClient, +) -> ApiResponseGetCurrentUser: + return client.request( + Request( + method="get", + url="/v2/public/user/current", + ).prepare(), + result_type=ApiResponseGetCurrentUser, + ) + + +def api_user_list_org_groups( + *, + client: ApiClient, +) -> ApiPaginatedResponseGroup: + return client.request( + Request( + method="get", + url="/v2/public/user/current-organisation/groups", + ).prepare(), + result_type=ApiPaginatedResponseGroup, + ) + + +def api_user_get_org_role( + *, + client: ApiClient, +) -> ApiOrganisationUserInfo: + return client.request( + Request( + method="get", + url="/v2/public/user/current-organisation/info", + ).prepare(), + result_type=ApiOrganisationUserInfo, + ) diff --git a/encord/api_v2/models.py b/encord/api_v2/models.py new file mode 100644 index 000000000..2d7cf0118 --- /dev/null +++ b/encord/api_v2/models.py @@ -0,0 +1,1332 @@ +import datetime +from enum import Enum, IntEnum +from typing import ( + Any, + Dict, + List, + Literal, + Union, +) +from uuid import UUID + +from encord.orm.base_dto import BaseDTO + + +class ApiAnnotationTaskAction(str, Enum): + ASSIGNED = "ASSIGNED" + COMPLETED = "COMPLETED" + CREATED = "CREATED" + DELETED = "DELETED" + INACTIVATED = "INACTIVATED" + RELEASED = "RELEASED" + REOPENED = "REOPENED" + RESOLVED = "RESOLVED" + SKIPPED = "SKIPPED" + + +class ApiClientMetadataSchemaTypeVariantHint(str, Enum): + BOOLEAN = "boolean" + DATETIME = "datetime" + NUMBER = "number" + TEXT = "text" + UUID = "uuid" + VARCHAR = "varchar" + + +class ApiCordDataType(IntEnum): + VALUE_0 = 0 + VALUE_1 = 1 + VALUE_2 = 2 + VALUE_3 = 3 + VALUE_4 = 4 + VALUE_5 = 5 + VALUE_6 = 6 + VALUE_7 = 7 + VALUE_8 = 8 + + +class ApiDatasetUserRole(str, Enum): + ADMIN = "admin" + USER = "user" + + +class ApiFoldersSortBy(str, Enum): + CREATEDAT = "createdAt" + NAME = "name" + + +class ApiJobStatus(str, Enum): + DONE = "done" + ERROR = "error" + SUBMITTED = "submitted" + + +class ApiJournalActionTarget(str, Enum): + DATASET = "dataset" + FOLDER = "folder" + GROUP = "group" + ONTOLOGY = "ontology" + ORGANISATION = "organisation" + PROJECT = "project" + + +class ApiJournalActionType(str, Enum): + ADDITEMS = "addItems" + CHANGEPERMISSIONS = "changePermissions" + CREATE = "create" + DELETE = "delete" + FOLDERCONFIG = "folderConfig" + MOVE = "move" + REMOVEITEMS = "removeItems" + UNSYNCFOLDER = "unsyncFolder" + UPDATE = "update" + UPDATEITEMS = "updateItems" + + +class ApiLabelReviewTaskStatus(str, Enum): + APPROVED = "APPROVED" + NEW = "NEW" + REJECTED = "REJECTED" + REOPENED = "REOPENED" + RESOLVED = "RESOLVED" + + +class ApiLongPollingStatus(str, Enum): + CANCELLED = "CANCELLED" + DONE = "DONE" + ERROR = "ERROR" + PENDING = "PENDING" + + +class ApiNumberFormat(str, Enum): + F32 = "F32" + F64 = "F64" + + +class ApiOntologyUserRole(IntEnum): + VALUE_0 = 0 + VALUE_1 = 1 + + +class ApiOrganisationUserRole(IntEnum): + VALUE_0 = 0 + VALUE_1 = 1 + + +class ApiProjectType(str, Enum): + MANUAL_QA = "manual_qa" + WORKFLOW = "workflow" + + +class ApiProjectUserRole(IntEnum): + VALUE_0 = 0 + VALUE_1 = 1 + VALUE_2 = 2 + VALUE_3 = 3 + VALUE_4 = 4 + + +class ApiReviewApprovalStatus(str, Enum): + APPROVED = "APPROVED" + DELETED = "DELETED" + PENDING = "PENDING" + REJECTED = "REJECTED" + + +class ApiReviewTaskAction(str, Enum): + APPROVE = "APPROVE" + CREATE = "CREATE" + DELETE = "DELETE" + INACTIVATE = "INACTIVATE" + REJECT = "REJECT" + REOPEN = "REOPEN" + RESOLVE = "RESOLVE" + + +class ApiStorageItemType(str, Enum): + AUDIO = "audio" + DICOMFILE = "dicomFile" + DICOMSERIES = "dicomSeries" + IMAGE = "image" + IMAGEGROUP = "imageGroup" + IMAGESEQUENCE = "imageSequence" + NIFTI = "nifti" + PDF = "pdf" + PLAINTEXT = "plainText" + VIDEO = "video" + + +class ApiStorageLocation(IntEnum): + VALUE_0 = 0 + VALUE_1 = 1 + VALUE_2 = 2 + VALUE_3 = 3 + VALUE_4 = 4 + VALUE_5 = 5 + + +class ApiStorageLocationName(str, Enum): + AZURE = "azure" + DIRECTACCESS = "directAccess" + ENCORD = "encord" + GCP = "gcp" + OPENTELEKOM = "openTelekom" + S3 = "s3" + S3COMPATIBLE = "s3Compatible" + + +class ApiStorageUserRole(str, Enum): + ADMIN = "admin" + USER = "user" + + +class ApiTimersGroupBy(str, Enum): + DATAUNIT = "dataUnit" + PROJECT = "project" + + +class ApiTms1DisplayStatus(str, Enum): + ASSIGNED = "ASSIGNED" + COMPLETED = "COMPLETED" + DELETED = "DELETED" + IN_REVIEW = "IN_REVIEW" + QUEUED = "QUEUED" + RETURNED = "RETURNED" + + +class ApiTms1TaskStatus(str, Enum): + APPROVED = "APPROVED" + ASSIGNED = "ASSIGNED" + COMPLETED = "COMPLETED" + CREATED = "CREATED" + DELETED = "DELETED" + IN_REVIEW = "IN_REVIEW" + PENDING = "PENDING" + QUEUED = "QUEUED" + REJECTED = "REJECTED" + RETURNED = "RETURNED" + + +class ApiUploadItemType(str, Enum): + AUDIO = "audio" + DICOMFILE = "dicomFile" + IMAGE = "image" + NIFTI = "nifti" + VIDEO = "video" + + +class ApiWorkflowNodeType(str, Enum): + AGENT = "AGENT" + ANNOTATION = "ANNOTATION" + CONSENSUS_ANNOTATION = "CONSENSUS_ANNOTATION" + CONSENSUS_REVIEW = "CONSENSUS_REVIEW" + DONE = "DONE" + PERCENTAGE_ROUTER = "PERCENTAGE_ROUTER" + REVIEW = "REVIEW" + START = "START" + USER_ROUTER = "USER_ROUTER" + + +class ApiAgentNodeNodeType(str, Enum): + AGENT = "AGENT" + + +class ApiAnnotationNodeNodeType(str, Enum): + ANNOTATION = "ANNOTATION" + + +class ApiAnnotationTaskStateType(str, Enum): + ANNOTATION = "ANNOTATION" + + +class ApiClientMetadataSchemaTypeBooleanTy(str, Enum): + BOOLEAN = "boolean" + + +class ApiClientMetadataSchemaTypeDateTimeTy(str, Enum): + DATETIME = "datetime" + + +class ApiClientMetadataSchemaTypeEmbeddingTy(str, Enum): + EMBEDDING = "embedding" + + +class ApiClientMetadataSchemaTypeEnumTy(str, Enum): + ENUM = "enum" + + +class ApiClientMetadataSchemaTypeNumberTy(str, Enum): + NUMBER = "number" + + +class ApiClientMetadataSchemaTypeTextTy(str, Enum): + TEXT = "text" + + +class ApiClientMetadataSchemaTypeTombstoneTy(str, Enum): + TOMBSTONE = "tombstone" + + +class ApiClientMetadataSchemaTypeUUIDTy(str, Enum): + UUID = "uuid" + + +class ApiClientMetadataSchemaTypeUserTy(str, Enum): + USER = "user" + + +class ApiClientMetadataSchemaTypeVarCharTy(str, Enum): + VARCHAR = "varchar" + + +class ApiClientMetadataSchemaTypeVariantTy(str, Enum): + VARIANT = "variant" + + +class ApiConsensusAnnotationNodeNodeType(str, Enum): + CONSENSUS_ANNOTATION = "CONSENSUS_ANNOTATION" + + +class ApiRequestDataUploadAudioExternalFileType(str, Enum): + AUDIO = "AUDIO" + + +class ApiRequestDataUploadDicomSeriesExternalFileType(str, Enum): + DICOM = "DICOM" + + +class ApiRequestDataUploadImageExternalFileType(str, Enum): + IMAGE = "IMAGE" + + +class ApiRequestDataUploadImageGroupExternalFileType(str, Enum): + IMG_GROUP = "IMG_GROUP" + + +class ApiRequestDataUploadImageGroupFromItemsExternalFileType(str, Enum): + IMG_GROUP_FROM_ITEMS = "IMG_GROUP_FROM_ITEMS" + + +class ApiRequestDataUploadNiftiExternalFileType(str, Enum): + NIFTI = "NIFTI" + + +class ApiRequestDataUploadPDFExternalFileType(str, Enum): + PDF = "PDF" + + +class ApiRequestDataUploadTextExternalFileType(str, Enum): + PLAIN_TEXT = "PLAIN_TEXT" + + +class ApiRequestDataUploadVideoExternalFileType(str, Enum): + VIDEO = "VIDEO" + + +class ApiRequestLabelReviewApproveAction(str, Enum): + APPROVE = "APPROVE" + + +class ApiRequestLabelReviewRejectAction(str, Enum): + REJECT = "REJECT" + + +class ApiRequestLabelReviewReopenAction(str, Enum): + REOPEN = "REOPEN" + + +class ApiRequestLabelReviewResolveAction(str, Enum): + RESOLVE = "RESOLVE" + + +class ApiResponseGetTrainingResultDoneStatus(str, Enum): + DONE = "DONE" + + +class ApiResponseGetTrainingResultErrorStatus(str, Enum): + ERROR = "ERROR" + + +class ApiResponseGetTrainingResultPendingStatus(str, Enum): + PENDING = "PENDING" + + +class ApiReviewNodeNodeType(str, Enum): + REVIEW = "REVIEW" + + +class ApiReviewTaskStateType(str, Enum): + REVIEW = "REVIEW" + + +class ApiAgentNode(BaseDTO): + pathways_to_nodes_mapping: "ApiAgentNodePathwaysToNodesMapping" + title: str + uuid: UUID + node_type: ApiAgentNodeNodeType = ApiAgentNodeNodeType.AGENT + + +class ApiAnnotationNode(BaseDTO): + title: str + to_node: UUID + uuid: UUID + node_type: ApiAnnotationNodeNodeType = ApiAnnotationNodeNodeType.ANNOTATION + + +class ApiAnnotationState(BaseDTO): + action: ApiAnnotationTaskAction + created_at: datetime.datetime + priority: float + task_uuid: UUID + legacy_user_id: Union[None, int] + task_metadata: Union["ApiAnnotationStateTaskMetadataType0", None] + user_email: Union[None, str] + user_hash: Union[None, str] + + +class ApiAnnotationTaskState(BaseDTO): + graph_node: Union["ApiAgentNode", "ApiAnnotationNode", "ApiConsensusAnnotationNode"] + outstanding_review_count: int + resolvable_reviews: List["ApiReviewTaskState"] + state: "ApiAnnotationState" + task_created: datetime.datetime + data_unit: Union["ApiTaskDataUnit", None] + label_branch_name: Union[None, str] + legacy_state_info: Union["ApiLegacyStateInfo", None] + subtasks: Union[List["ApiAnnotationTaskState"], None] + type: Union[None, ApiAnnotationTaskStateType] = ApiAnnotationTaskStateType.ANNOTATION + + +class ApiAutoSubfolderNamePlaceholder(BaseDTO): + auto: Union[None, bool] = True + suffix: Union[None, str] + + +ApiClientMetadataSchema = Dict + + +class ApiClientMetadataSchemaOrmRead(BaseDTO): + created_at: datetime.datetime + metadata_schema: "ApiClientMetadataSchemaOrmReadMetadataSchema" + organisation_id: int + updated_at: datetime.datetime + uuid: UUID + + +class ApiClientMetadataSchemaTypeBoolean(BaseDTO): + ty: Union[None, ApiClientMetadataSchemaTypeBooleanTy] = ApiClientMetadataSchemaTypeBooleanTy.BOOLEAN + + +class ApiClientMetadataSchemaTypeDateTime(BaseDTO): + timezone: Union[None, str] = "UTC" + ty: Union[None, ApiClientMetadataSchemaTypeDateTimeTy] = ApiClientMetadataSchemaTypeDateTimeTy.DATETIME + + +class ApiClientMetadataSchemaTypeEmbedding(BaseDTO): + size: int + ty: Union[None, ApiClientMetadataSchemaTypeEmbeddingTy] = ApiClientMetadataSchemaTypeEmbeddingTy.EMBEDDING + + +class ApiClientMetadataSchemaTypeEnum(BaseDTO): + ty: Union[None, ApiClientMetadataSchemaTypeEnumTy] = ApiClientMetadataSchemaTypeEnumTy.ENUM + values: Union[None, List[str]] + + +class ApiClientMetadataSchemaTypeNumber(BaseDTO): + format_: Union[None, ApiNumberFormat] = ApiNumberFormat.F64 + ty: Union[None, ApiClientMetadataSchemaTypeNumberTy] = ApiClientMetadataSchemaTypeNumberTy.NUMBER + + +class ApiClientMetadataSchemaTypeText(BaseDTO): + ty: Union[None, ApiClientMetadataSchemaTypeTextTy] = ApiClientMetadataSchemaTypeTextTy.TEXT + + +class ApiClientMetadataSchemaTypeTombstone(BaseDTO): + deleted_ty: Union[ + "ApiClientMetadataSchemaTypeBoolean", + "ApiClientMetadataSchemaTypeDateTime", + "ApiClientMetadataSchemaTypeEmbedding", + "ApiClientMetadataSchemaTypeEnum", + "ApiClientMetadataSchemaTypeNumber", + "ApiClientMetadataSchemaTypeText", + "ApiClientMetadataSchemaTypeUUID", + "ApiClientMetadataSchemaTypeUser", + "ApiClientMetadataSchemaTypeVarChar", + "ApiClientMetadataSchemaTypeVariant", + None, + ] + ty: Union[None, ApiClientMetadataSchemaTypeTombstoneTy] = ApiClientMetadataSchemaTypeTombstoneTy.TOMBSTONE + + +class ApiClientMetadataSchemaTypeUUID(BaseDTO): + ty: Union[None, ApiClientMetadataSchemaTypeUUIDTy] = ApiClientMetadataSchemaTypeUUIDTy.UUID + + +class ApiClientMetadataSchemaTypeUser(BaseDTO): + ty: Union[None, ApiClientMetadataSchemaTypeUserTy] = ApiClientMetadataSchemaTypeUserTy.USER + + +class ApiClientMetadataSchemaTypeVarChar(BaseDTO): + max_length: Union[None, int] = 8192 + ty: Union[None, ApiClientMetadataSchemaTypeVarCharTy] = ApiClientMetadataSchemaTypeVarCharTy.VARCHAR + + +class ApiClientMetadataSchemaTypeVariant(BaseDTO): + hint: Union[None, ApiClientMetadataSchemaTypeVariantHint] = ApiClientMetadataSchemaTypeVariantHint.TEXT + ty: Union[None, ApiClientMetadataSchemaTypeVariantTy] = ApiClientMetadataSchemaTypeVariantTy.VARIANT + + +class ApiConsensusAnnotationNode(BaseDTO): + title: str + to_node: UUID + uuid: UUID + node_type: ApiConsensusAnnotationNodeNodeType = ApiConsensusAnnotationNodeNodeType.CONSENSUS_ANNOTATION + + +class ApiCustomerProvidedAudioMetadata(BaseDTO): + bit_depth: int + codec: str + duration: float + file_size: int + mime_type: str + num_channels: int + sample_rate: int + + +class ApiCustomerProvidedImageMetadata(BaseDTO): + file_size: int + height: int + mime_type: str + width: int + + +class ApiCustomerProvidedVideoMetadata(BaseDTO): + duration: float + file_size: int + fps: float + height: int + mime_type: str + width: int + + +class ApiDataUnitError(BaseDTO): + action_description: str + error: str + object_urls: List[str] + subtask_uuid: UUID + + +class ApiDataset(BaseDTO): + backing_folder_uuid: Union[None, UUID] + dataset_hash: UUID + dataset_type: str + description: str + title: str + + +class ApiHTTPValidationError(BaseDTO): + detail: Union[None, List["ApiValidationError"]] + + +class ApiIndexFolderConfig(BaseDTO): + embedding_config: "ApiIndexFolderConfigEmbeddingConfig" + base_metrics_enabled: Union[None, bool] = False + + +class ApiJobStatusInfo(BaseDTO): + status: ApiJobStatus + result: Union["ApiJobStatusInfoResultType1", List[Any], None] + + +class ApiJournalRecord(BaseDTO): + action_data: Union["ApiJournalRecordActionDataType0", None] + action_type: ApiJournalActionType + created_at: datetime.datetime + target_type: ApiJournalActionTarget + target_uuid: UUID + user_email: str + uuid: UUID + referenced_entity_uuid: Union[None, UUID] + + +class ApiLabelReview(BaseDTO): + label_id: str + label_type: str + review_uuid: UUID + status: ApiLabelReviewTaskStatus + task_uuid: UUID + + +class ApiLabelValidationState(BaseDTO): + branch_name: str + errors: List[str] + is_valid: bool + label_hash: UUID + version: int + + +class ApiLegacyStateInfo(BaseDTO): + displayed_status: ApiTms1DisplayStatus + status: ApiTms1TaskStatus + + +class ApiOrganisationUserInfo(BaseDTO): + user_role: ApiOrganisationUserRole + + +class ApiPaginatedResponseDataset(BaseDTO): + results: List["ApiDataset"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseDatasetGroup(BaseDTO): + results: List["ApiResponseDatasetGroup"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseFolderGroup(BaseDTO): + results: List["ApiResponseFolderGroup"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseGroup(BaseDTO): + results: List["ApiResponseGroup"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseIndexCollection(BaseDTO): + results: List["ApiResponseIndexCollection"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseIndexFilterPreset(BaseDTO): + results: List["ApiResponseIndexFilterPreset"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseJournalRecord(BaseDTO): + results: List["ApiJournalRecord"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseLabelReview(BaseDTO): + results: List["ApiLabelReview"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseOntologyGroup(BaseDTO): + results: List["ApiResponseOntologyGroup"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseProjectGroup(BaseDTO): + results: List["ApiResponseProjectGroup"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseProjectPerformanceCollaboratorData(BaseDTO): + results: List["ApiResponseProjectPerformanceCollaborator"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseProjectUser(BaseDTO): + results: List["ApiProjectUser"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseStorageFolder(BaseDTO): + results: List["ApiResponseStorageFolder"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseStorageItem(BaseDTO): + results: List["ApiResponseStorageItem"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseStorageItemUnion(BaseDTO): + results: List[Union["ApiResponseStorageItem", "ApiResponseStorageItemInaccessible"]] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseTask(BaseDTO): + results: List["ApiTask"] + next_page_token: Union[None, str] + + +class ApiPaginatedResponseUploadUrl(BaseDTO): + results: List["ApiResponseUploadUrl"] + + +class ApiPathElement(BaseDTO): + name: str + uuid: UUID + parent_uuid: Union[None, UUID] + synced_dataset_hash: Union[None, UUID] + + +class ApiPerEmbeddingConfig(BaseDTO): + advanced_metrics_enabled: Union[None, bool] = False + embedding_reduction_enabled: Union[None, bool] = False + + +class ApiProject(BaseDTO): + created_at: datetime.datetime + description: str + last_edited_at: datetime.datetime + ontology_hash: UUID + project_hash: UUID + project_type: ApiProjectType + title: str + workflow: Union["ApiWorkflow", None] + + +class ApiProjectUser(BaseDTO): + user_email: str + user_role: ApiProjectUserRole + + +class ApiRequestAddDatasetGroups(BaseDTO): + group_hash_list: List[UUID] + user_role: ApiDatasetUserRole + + +class ApiRequestAddFolderGroups(BaseDTO): + group_hash_list: List[UUID] + user_role: ApiStorageUserRole + + +class ApiRequestAddOntologyGroups(BaseDTO): + group_hash_list: List[UUID] + user_role: ApiOntologyUserRole + + +class ApiRequestAddProjectGroup(BaseDTO): + group_hash_list: List[UUID] + user_role: ApiProjectUserRole + + +class ApiRequestCreateDataset(BaseDTO): + create_backing_folder: bool + legacy_call: bool + title: str + description: Union[None, str] + + +class ApiRequestCreateFolder(BaseDTO): + name: str + client_metadata: Union[None, str] = "{}" + description: Union[None, str] + parent: Union[None, UUID] + + +class ApiRequestDataUploadAudio(BaseDTO): + object_url: str + audio_metadata: Union["ApiCustomerProvidedAudioMetadata", None] + client_metadata: Union[None, "ApiRequestDataUploadAudioClientMetadata"] + external_file_type: Union[None, ApiRequestDataUploadAudioExternalFileType] = ( + ApiRequestDataUploadAudioExternalFileType.AUDIO + ) + placeholder_item_uuid: Union[None, UUID] + title: Union[None, str] + + +class ApiRequestDataUploadDicomSeries(BaseDTO): + dicom_files: List["ApiRequestDataUploadDicomSeriesFile"] + client_metadata: Union[None, "ApiRequestDataUploadDicomSeriesClientMetadata"] + external_file_type: Union[None, ApiRequestDataUploadDicomSeriesExternalFileType] = ( + ApiRequestDataUploadDicomSeriesExternalFileType.DICOM + ) + title: Union[None, str] + + +class ApiRequestDataUploadDicomSeriesFile(BaseDTO): + url: str + placeholder_item_uuid: Union[None, UUID] + title: Union[None, str] + + +class ApiRequestDataUploadImage(BaseDTO): + object_url: str + client_metadata: Union[None, "ApiRequestDataUploadImageClientMetadata"] + external_file_type: Union[None, ApiRequestDataUploadImageExternalFileType] = ( + ApiRequestDataUploadImageExternalFileType.IMAGE + ) + image_metadata: Union["ApiCustomerProvidedImageMetadata", None] + placeholder_item_uuid: Union[None, UUID] + title: Union[None, str] + + +class ApiRequestDataUploadImageGroup(BaseDTO): + images: List["ApiRequestDataUploadImageGroupImage"] + client_metadata: Union[None, "ApiRequestDataUploadImageGroupClientMetadata"] + cluster_by_resolution: Union[None, bool] = False + create_video: Union[None, bool] = False + external_file_type: Union[None, ApiRequestDataUploadImageGroupExternalFileType] = ( + ApiRequestDataUploadImageGroupExternalFileType.IMG_GROUP + ) + title: Union[None, str] + + +class ApiRequestDataUploadImageGroupFromItems(BaseDTO): + create_video: bool + image_items: List[UUID] + client_metadata: Union[None, "ApiRequestDataUploadImageGroupFromItemsClientMetadata"] + cluster_by_resolution: Union[None, bool] = False + external_file_type: Union[None, ApiRequestDataUploadImageGroupFromItemsExternalFileType] = ( + ApiRequestDataUploadImageGroupFromItemsExternalFileType.IMG_GROUP_FROM_ITEMS + ) + title: Union[None, str] + video_url_prefix: Union[None, str] + + +class ApiRequestDataUploadImageGroupImage(BaseDTO): + url: str + image_metadata: Union["ApiCustomerProvidedImageMetadata", None] + placeholder_item_uuid: Union[None, UUID] + title: Union[None, str] + + +class ApiRequestDataUploadItems(BaseDTO): + audio: Union[None, List["ApiRequestDataUploadAudio"]] + dicom_series: Union[None, List["ApiRequestDataUploadDicomSeries"]] + image_groups: Union[None, List["ApiRequestDataUploadImageGroup"]] + image_groups_from_items: Union[None, List["ApiRequestDataUploadImageGroupFromItems"]] + images: Union[None, List["ApiRequestDataUploadImage"]] + nifti: Union[None, List["ApiRequestDataUploadNifti"]] + pdf: Union[None, List["ApiRequestDataUploadPDF"]] + skip_duplicate_urls: Union[None, bool] = False + text: Union[None, List["ApiRequestDataUploadText"]] + upsert_metadata: Union[None, bool] = False + videos: Union[None, List["ApiRequestDataUploadVideo"]] + + +class ApiRequestDataUploadNifti(BaseDTO): + object_url: str + client_metadata: Union[None, "ApiRequestDataUploadNiftiClientMetadata"] + external_file_type: Union[None, ApiRequestDataUploadNiftiExternalFileType] = ( + ApiRequestDataUploadNiftiExternalFileType.NIFTI + ) + placeholder_item_uuid: Union[None, UUID] + title: Union[None, str] + + +class ApiRequestDataUploadPDF(BaseDTO): + object_url: str + client_metadata: Union[None, "ApiRequestDataUploadPDFClientMetadata"] + external_file_type: Union[None, ApiRequestDataUploadPDFExternalFileType] = ( + ApiRequestDataUploadPDFExternalFileType.PDF + ) + placeholder_item_uuid: Union[None, UUID] + title: Union[None, str] + + +class ApiRequestDataUploadText(BaseDTO): + object_url: str + client_metadata: Union[None, "ApiRequestDataUploadTextClientMetadata"] + external_file_type: Union[None, ApiRequestDataUploadTextExternalFileType] = ( + ApiRequestDataUploadTextExternalFileType.PLAIN_TEXT + ) + placeholder_item_uuid: Union[None, UUID] + title: Union[None, str] + + +class ApiRequestDataUploadVideo(BaseDTO): + object_url: str + client_metadata: Union[None, "ApiRequestDataUploadVideoClientMetadata"] + external_file_type: Union[None, ApiRequestDataUploadVideoExternalFileType] = ( + ApiRequestDataUploadVideoExternalFileType.VIDEO + ) + placeholder_item_uuid: Union[None, UUID] + title: Union[None, str] + video_metadata: Union["ApiCustomerProvidedVideoMetadata", None] + + +class ApiRequestDeleteFolderChildren(BaseDTO): + child_uuids: List[UUID] + remove_unused_frames: Union[None, bool] = False + + +class ApiRequestGetItemsBulk(BaseDTO): + item_uuids: List[UUID] + child_frame_numbers: Union[List[int], None] + require_all: Union[None, bool] = False + sign_urls: Union[None, bool] = False + + +class ApiRequestIndexCollectionBulkItem(BaseDTO): + item_uuids: Union[None, List[UUID]] + + +class ApiRequestIndexCollectionInsert(BaseDTO): + description: str + name: str + + +class ApiRequestIndexCollectionPreset(BaseDTO): + preset_uuid: UUID + + +class ApiRequestIndexCollectionUpdate(BaseDTO): + description: Union[None, str] + name: Union[None, str] + + +class ApiRequestIndexFilterPresetCreate(BaseDTO): + description: str + filter_preset_json: "ApiRequestIndexFilterPresetCreateFilterPresetJson" + name: str + + +class ApiRequestIndexFilterPresetUpdate(BaseDTO): + description: Union[None, str] + filter_preset: Union["ApiRequestIndexFilterPresetUpdateFilterPresetType0", None] + name: Union[None, str] + + +class ApiRequestLabelReviewApprove(BaseDTO): + review_uuid: UUID + action: Union[None, ApiRequestLabelReviewApproveAction] = ApiRequestLabelReviewApproveAction.APPROVE + + +class ApiRequestLabelReviewReject(BaseDTO): + review_uuid: UUID + action: Union[None, ApiRequestLabelReviewRejectAction] = ApiRequestLabelReviewRejectAction.REJECT + + +class ApiRequestLabelReviewReopen(BaseDTO): + review_uuid: UUID + action: Union[None, ApiRequestLabelReviewReopenAction] = ApiRequestLabelReviewReopenAction.REOPEN + + +class ApiRequestLabelReviewResolve(BaseDTO): + review_uuid: UUID + action: Union[None, ApiRequestLabelReviewResolveAction] = ApiRequestLabelReviewResolveAction.RESOLVE + + +class ApiRequestMoveFolders(BaseDTO): + folder_uuids: List[UUID] + new_parent_uuid: Union[None, UUID] + + +class ApiRequestMoveItems(BaseDTO): + item_uuids: List[UUID] + allow_synced_dataset_move: Union[None, bool] = False + new_parent_uuid: Union[None, UUID] + + +class ApiRequestPatchFolder(BaseDTO): + client_metadata: Union["ApiRequestPatchFolderClientMetadataType0", None] + description: Union[None, str] + name: Union[None, str] + + +class ApiRequestPatchFolderBulk(BaseDTO): + folder_patches: Union[None, "ApiRequestPatchFolderBulkFolderPatches"] + + +class ApiRequestPatchItem(BaseDTO): + client_metadata: Union["ApiRequestPatchItemClientMetadataType0", None] + description: Union[None, str] + name: Union[None, str] + + +class ApiRequestPatchItemsBulk(BaseDTO): + item_patches: Union[None, "ApiRequestPatchItemsBulkItemPatches"] + + +class ApiRequestPriorities(BaseDTO): + priorities: List[List[Union[UUID, float]]] + + +class ApiRequestStartTraining(BaseDTO): + batch_size: int + device: str + epochs: int + label_rows: List[UUID] + model: str + training_weights_link: Union[None, str] + + +class ApiRequestStorageItemsMigrate(BaseDTO): + from_integration_hash: Union[None, UUID] + items_map: Union[None, "ApiRequestStorageItemsMigrateItemsMap"] + skip_missing: Union[None, bool] = False + to_integration_hash: Union[None, UUID] + urls_map: Union[None, "ApiRequestStorageItemsMigrateUrlsMap"] + validate_access: Union[None, bool] = False + + +class ApiRequestStorageItemsRencode(BaseDTO): + force_full_reencoding: bool + process_title: str + storage_items: List[UUID] + + +class ApiRequestUploadJob(BaseDTO): + data_items: Union["ApiRequestDataUploadItems", None] + external_files: Union["ApiRequestUploadJobExternalFilesType0", None] + file_name: Union[None, str] + ignore_errors: Union[None, bool] = False + integration_hash: Union[None, UUID] + + +class ApiRequestUploadSignedUrls(BaseDTO): + item_type: ApiUploadItemType + count: Union[None, int] = 1 + frames_subfolder_name: Union["ApiAutoSubfolderNamePlaceholder", None, str] + + +class ApiResponseBearerToken(BaseDTO): + token: str + + +class ApiResponseCancelFolderUploadJob(BaseDTO): + units_cancelled_count: int + + +class ApiResponseCreateDataset(BaseDTO): + backing_folder_uuid: Union[None, UUID] + dataset_hash: UUID + + +class ApiResponseDatasetGroup(BaseDTO): + created_at: datetime.datetime + description: str + group_hash: UUID + is_same_organisation: bool + name: str + user_role: ApiDatasetUserRole + + +class ApiResponseDatasetShort(BaseDTO): + data_hashes: List[UUID] + data_units_created_at: datetime.datetime + dataset_hash: UUID + title: str + backing_folder_uuid: Union[None, UUID] + + +class ApiResponseDatasetsWithUserRoles(BaseDTO): + result: List["ApiResponseDatasetsWithUserRolesItem"] + + +class ApiResponseDatasetsWithUserRolesItem(BaseDTO): + backing_folder_uuid: Union[None, UUID] + created_at: datetime.datetime + dataset_hash: UUID + description: str + last_edited_at: datetime.datetime + storage_location: ApiStorageLocation + title: str + user_email: str + user_hash: str + user_role: ApiDatasetUserRole + + +class ApiResponseDeletion(BaseDTO): + removed_folders_count: int + removed_items_count: int + + +class ApiResponseFolderGroup(BaseDTO): + created_at: datetime.datetime + description: str + group_hash: UUID + is_same_organisation: bool + name: str + user_role: ApiStorageUserRole + + +class ApiResponseFolderUploadStatus(BaseDTO): + errors: List[str] + file_name: Union[None, str] + items_with_names: List["ApiStorageItemWithName"] + status: ApiLongPollingStatus + unit_errors: List["ApiDataUnitError"] + units_cancelled_count: int + units_done_count: int + units_error_count: int + units_pending_count: int + + +class ApiResponseGetCurrentUser(BaseDTO): + user_email: str + user_hash: str + + +class ApiResponseGetTrainingResultDone(BaseDTO): + result: "ApiResponseGetTrainingResultDoneData" + status: Union[None, ApiResponseGetTrainingResultDoneStatus] = ApiResponseGetTrainingResultDoneStatus.DONE + + +class ApiResponseGetTrainingResultDoneData(BaseDTO): + batch_size: int + created_at: datetime.datetime + duration: int + epochs: int + final_loss: float + framework: str + model: str + model_hash: UUID + title: str + training_hash: UUID + type: str + weights_link: str + + +class ApiResponseGetTrainingResultError(BaseDTO): + status: Union[None, ApiResponseGetTrainingResultErrorStatus] = ApiResponseGetTrainingResultErrorStatus.ERROR + + +class ApiResponseGetTrainingResultPending(BaseDTO): + status: Union[None, ApiResponseGetTrainingResultPendingStatus] = ApiResponseGetTrainingResultPendingStatus.PENDING + + +class ApiResponseGroup(BaseDTO): + created_at: datetime.datetime + description: str + group_hash: UUID + name: str + + +class ApiResponseIndexCollection(BaseDTO): + created_at: datetime.datetime + description: str + last_edited_at: datetime.datetime + name: str + top_level_folder_uuid: UUID + uuid: UUID + + +class ApiResponseIndexCollectionBulkItem(BaseDTO): + failed_items: List[UUID] + + +class ApiResponseIndexFilterPreset(BaseDTO): + created_at: datetime.datetime + description: str + last_updated_at: datetime.datetime + name: str + uuid: UUID + + +class ApiResponseItemShort(BaseDTO): + item_type: ApiStorageItemType + name: str + parent_name: str + parent_uuid: UUID + uuid: UUID + + +ApiResponseLegacyPublic = Dict + + +class ApiResponseOntologyGroup(BaseDTO): + created_at: datetime.datetime + description: str + group_hash: UUID + is_same_organisation: bool + name: str + user_role: ApiOntologyUserRole + + +class ApiResponseProjectGroup(BaseDTO): + created_at: datetime.datetime + description: str + group_hash: UUID + is_same_organisation: bool + name: str + user_role: ApiProjectUserRole + + +class ApiResponseProjectPerformanceCollaborator(BaseDTO): + time_seconds: float + user_email: str + user_role: int + data_title: Union[None, str] + + +class ApiResponseStorageFolder(BaseDTO): + created_at: datetime.datetime + description: str + last_edited_at: datetime.datetime + name: str + owner: str + user_role: ApiStorageUserRole + uuid: UUID + client_metadata: Union[None, str] = "{}" + parent: Union[None, UUID] + path_to_root: Union[List["ApiPathElement"], None] + synced_dataset_hash: Union[None, UUID] + + +class ApiResponseStorageFolderSummary(BaseDTO): + audios: int + dicom_files: int + dicom_series: int + files: int + folders: int + image_groups: int + image_sequences: int + images: int + niftis: int + pdfs: int + plain_texts: int + tombstones: int + total_size: float + upload_jobs: int + videos: int + + +class ApiResponseStorageItem(BaseDTO): + backed_data_units_count: int + created_at: datetime.datetime + description: str + item_type: ApiStorageItemType + last_edited_at: datetime.datetime + name: str + owner: str + parent: UUID + storage_location: ApiStorageLocationName + uuid: UUID + audio_bit_depth: Union[None, int] + audio_codec: Union[None, str] + audio_num_channels: Union[None, int] + audio_sample_rate: Union[None, int] + child_frame_number: Union[None, int] + client_metadata: Union[None, str] = "{}" + dicom_instance_uid: Union[None, str] + dicom_series_uid: Union[None, str] + dicom_study_uid: Union[None, str] + duration: Union[None, float] + file_size: Union[None, int] + fps: Union[None, float] + frame_count: Union[None, int] + height: Union[None, int] + integration_hash: Union[None, UUID] + is_placeholder: Union[None, bool] = False + is_tombstone: Union[None, bool] = False + mime_type: Union[None, str] + signed_url: Union[None, str] + url: Union[None, str] + width: Union[None, int] + + +class ApiResponseStorageItemInaccessible(BaseDTO): + uuid: UUID + + +class ApiResponseStorageItemSummary(BaseDTO): + accessible_datasets: List["ApiResponseDatasetShort"] + accessible_group_items: List["ApiResponseItemShort"] + frame_in_groups: int + used_in_datasets: int + + +class ApiResponseUploadUrl(BaseDTO): + item_uuid: UUID + object_key: str + signed_url: str + + +class ApiReviewNode(BaseDTO): + on_approve_to_node: UUID + on_reject_to_node: UUID + title: str + uuid: UUID + node_type: ApiReviewNodeNodeType = ApiReviewNodeNodeType.REVIEW + + +class ApiReviewState(BaseDTO): + action: ApiReviewTaskAction + created_at: datetime.datetime + legacy_approval: ApiReviewApprovalStatus + task_uuid: UUID + legacy_user_email: Union[None, str] + legacy_user_id: Union[None, int] + task_metadata: Union["ApiReviewStateTaskMetadataType0", None] + + +class ApiReviewTaskState(BaseDTO): + composite_review_task_uuid: UUID + granularity: str + granularity_hash: str + graph_node: "ApiReviewNode" + state: "ApiReviewState" + task_created: datetime.datetime + data_unit: Union["ApiTaskDataUnit", None] + legacy_state_info: Union["ApiLegacyStateInfo", None] + type: Union[None, ApiReviewTaskStateType] = ApiReviewTaskStateType.REVIEW + + +class ApiStorageFolderConfig(BaseDTO): + index_folder_config: "ApiIndexFolderConfig" + + +class ApiStorageItemWithName(BaseDTO): + item_uuid: UUID + name: str + + +class ApiTask(BaseDTO): + created_at: datetime.datetime + updated_at: datetime.datetime + uuid: UUID + + +class ApiTaskDataUnit(BaseDTO): + data_cord_type: ApiCordDataType + data_hash: str + data_title: str + dataset_hash: str + dataset_title: str + project_hash: str + + +class ApiValidationError(BaseDTO): + loc: List[Union[int, str]] + msg: str + type: str + + +class ApiWorkflow(BaseDTO): + stages: List["ApiWorkflowStage"] + + +class ApiWorkflowStage(BaseDTO): + stage_type: ApiWorkflowNodeType + title: str + uuid: UUID + + +ApiAgentNodePathwaysToNodesMapping = Dict +ApiAnnotationStateTaskMetadataType0 = Dict +ApiClientMetadataSchemaOrmReadMetadataSchema = Dict +ApiIndexFolderConfigEmbeddingConfig = Dict +ApiJobStatusInfoResultType1 = Dict +ApiJournalRecordActionDataType0 = Dict +ApiRequestDataUploadAudioClientMetadata = Dict +ApiRequestDataUploadDicomSeriesClientMetadata = Dict +ApiRequestDataUploadImageClientMetadata = Dict +ApiRequestDataUploadImageGroupClientMetadata = Dict +ApiRequestDataUploadImageGroupFromItemsClientMetadata = Dict +ApiRequestDataUploadNiftiClientMetadata = Dict +ApiRequestDataUploadPDFClientMetadata = Dict +ApiRequestDataUploadTextClientMetadata = Dict +ApiRequestDataUploadVideoClientMetadata = Dict +ApiRequestIndexFilterPresetCreateFilterPresetJson = Dict +ApiRequestIndexFilterPresetUpdateFilterPresetType0 = Dict +ApiRequestPatchFolderClientMetadataType0 = Dict +ApiRequestPatchFolderBulkFolderPatches = Dict +ApiRequestPatchItemClientMetadataType0 = Dict +ApiRequestPatchItemsBulkItemPatches = Dict +ApiRequestStorageItemsMigrateItemsMap = Dict +ApiRequestStorageItemsMigrateUrlsMap = Dict +ApiRequestUploadJobExternalFilesType0 = Dict +ApiReviewStateTaskMetadataType0 = Dict +LegacyPublicRouteData = Dict +LegacyPublicUserRouteData = Dict +IndexGetPresetFilterResponsePublicIndexGetPresetFilterIndexPresetsUuidGet = Dict +OrgCreateMetadataSchemaLegacyMetadataSchema = Dict +WorkflowExecuteStageActionsBodyItem = Dict diff --git a/encord/http/v2/api_client.py b/encord/http/v2/api_client.py index a4c605ffb..4c9a15199 100644 --- a/encord/http/v2/api_client.py +++ b/encord/http/v2/api_client.py @@ -120,8 +120,12 @@ def patch( ) -> T: return self._request_with_payload("PATCH", path, params, payload, result_type) - def _serialise_payload(self, payload: Union[BaseDTO, Sequence[BaseDTO], None]) -> Union[List[Dict], Dict, None]: - if isinstance(payload, list): + def serialise_payload( + self, payload: Union[BaseDTO, Sequence[BaseDTO], List, Dict, None] + ) -> Union[List[Dict], Dict, None]: + if isinstance(payload, dict): + return payload + elif isinstance(payload, list): return [p.to_dict() for p in payload] elif isinstance(payload, BaseDTO): return payload.to_dict() @@ -145,7 +149,7 @@ def _request_with_payload( result_type: Optional[Type[T]], ) -> T: params_dict = params.to_dict() if params is not None else None - payload_serialised = self._serialise_payload(payload) + payload_serialised = self.serialise_payload(payload) req = requests.Request( method=method, @@ -170,7 +174,7 @@ def _request_without_payload( return self._request(req, result_type=result_type, allow_none=allow_none) # type: ignore - def _request(self, req: PreparedRequest, result_type: Optional[Type[T]], allow_none: bool = False): + def request(self, req: PreparedRequest, result_type: Optional[Type], allow_none: bool = False): req = self._config.define_headers_v2(req) timeouts = (self._config.connect_timeout, self._config.read_timeout)