Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org-wide and filtered access to cloud integrations #831

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion encord/orm/cloud_integration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Optional
from uuid import UUID

from encord.orm.base_dto import BaseDTO
Expand All @@ -16,3 +16,9 @@ class CloudIntegrationV2(BaseDTO):

class GetCloudIntegrationsResponse(BaseDTO):
result: List[CloudIntegrationV2]


class GetCloudIntegrationsParams(BaseDTO):
filter_integration_uuids: Optional[List[UUID]] = None
filter_integration_titles: Optional[List[str]] = None
include_org_access: bool = False
30 changes: 27 additions & 3 deletions encord/user_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
)
from encord.ontology import Ontology
from encord.orm.client_metadata_schema import ClientMetadataSchemaTypes
from encord.orm.cloud_integration import CloudIntegration, GetCloudIntegrationsResponse
from encord.orm.cloud_integration import CloudIntegration, GetCloudIntegrationsParams, GetCloudIntegrationsResponse
from encord.orm.dataset import (
DEFAULT_DATASET_ACCESS_SETTINGS,
CreateDatasetPayload,
Expand Down Expand Up @@ -865,15 +865,39 @@ def __upload_cvat_images(

return dataset_hash, image_title_to_image

def get_cloud_integrations(self) -> List[CloudIntegration]:
def get_cloud_integrations(
self,
filter_integration_uuids: Optional[Union[List[UUID], List[str], List[Union[UUID, str]]]] = None,
filter_integration_titles: Optional[List[str]] = None,
include_org_access: bool = False,
) -> List[CloudIntegration]:
"""
List either all (if called with no arguments) or matching cloud integrations the user has access to.
Args:
filter_integration_uuids: optional list of integration UUIDs to include.
filter_integration_titles: optional list of integration titles to include (exact match).
include_org_access: if set to true and the calling user is the organization admin, the
method will return all cloud integrations in the organization.
If `filter_integration_uuids` and `filter_integration_titles` are both provided, the method will return
the integrations that match both of the filters.
"""

if filter_integration_uuids is not None:
filter_integration_uuids = [UUID(x) if isinstance(x, str) else x for x in filter_integration_uuids]
return [
CloudIntegration(
id=str(x.integration_uuid),
title=x.title,
)
for x in self._api_client.get(
"cloud-integrations",
params=None,
params=GetCloudIntegrationsParams(
filter_integration_uuids=filter_integration_uuids,
filter_integration_titles=filter_integration_titles,
include_org_access=include_org_access,
),
result_type=GetCloudIntegrationsResponse,
).result
]
Expand Down
Loading