|
34 | 34 | from lib.app.serializers import SettingsSerializer |
35 | 35 | from lib.app.serializers import TeamSerializer |
36 | 36 | from lib.core import LIMITED_FUNCTIONS |
| 37 | +from lib.core.entities.integrations import IntegrationEntity |
37 | 38 | from lib.core.entities.project_entities import AnnotationClassEntity |
38 | 39 | from lib.core.enums import ImageQuality |
39 | 40 | from lib.core.exceptions import AppException |
@@ -2923,3 +2924,49 @@ def upload_priority_scores(project: NotEmptyStr, scores: List[PriorityScore]): |
2923 | 2924 | if response.errors: |
2924 | 2925 | raise AppException(response.errors) |
2925 | 2926 | return response.data |
| 2927 | + |
| 2928 | + |
| 2929 | +@Trackable |
| 2930 | +@validate_arguments |
| 2931 | +def get_integrations(): |
| 2932 | + """Get all integrations per team |
| 2933 | +
|
| 2934 | + :return: metadata objects of all integrations of the team. |
| 2935 | + :rtype: list of dicts |
| 2936 | + """ |
| 2937 | + response = Controller.get_default().get_integrations() |
| 2938 | + if response.errors: |
| 2939 | + raise AppException(response.errors) |
| 2940 | + integrations = response.data |
| 2941 | + return BaseSerializers.serialize_iterable(integrations, ("name", "type", "root")) |
| 2942 | + |
| 2943 | + |
| 2944 | +@Trackable |
| 2945 | +@validate_arguments |
| 2946 | +def attach_items_from_integrated_storage( |
| 2947 | + project: NotEmptyStr, |
| 2948 | + integration: Union[NotEmptyStr, IntegrationEntity], |
| 2949 | + folder_path: Optional[NotEmptyStr] = None |
| 2950 | +): |
| 2951 | + """Link images from integrated external storage to SuperAnnotate. |
| 2952 | +
|
| 2953 | + :param project: project name or folder path where items should be attached (e.g., “project1/folder1”). |
| 2954 | + :type project: str |
| 2955 | +
|
| 2956 | + :param project: project name or folder path where items should be attached (e.g., “project1/folder1”). |
| 2957 | + :type project: str |
| 2958 | +
|
| 2959 | + :param integration: existing integration name or metadata dict to pull items from. |
| 2960 | + Mandatory keys in integration metadata’s dict is “name”. |
| 2961 | + :type integration: str |
| 2962 | +
|
| 2963 | + :param folder_path: Points to an exact folder/directory within given storage. |
| 2964 | + If None, items are fetched from the root directory. |
| 2965 | + :type folder_path: str |
| 2966 | + """ |
| 2967 | + project_name, folder_name = extract_project_folder(project) |
| 2968 | + if isinstance(integration, str): |
| 2969 | + integration = IntegrationEntity(name=integration) |
| 2970 | + response = Controller.get_default().attach_integrations(project_name, folder_name, integration, folder_path) |
| 2971 | + if response.errors: |
| 2972 | + raise AppException(response.errors) |
0 commit comments