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

Add GET_SHARE_OBJECT permissions to get data filters API #1717

Merged
merged 2 commits into from
Nov 25, 2024
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
10 changes: 4 additions & 6 deletions backend/dataall/modules/shares_base/api/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,10 @@ def list_shares_in_my_outbox(context: Context, source, filter: dict = None):
def list_shared_with_environment_data_items(context: Context, source, environmentUri: str = None, filter: dict = None):
if not filter:
filter = {}
with context.engine.scoped_session() as session:
return ShareItemService.paginated_shared_with_environment_datasets(
session=session,
uri=environmentUri,
data=filter,
)
return ShareItemService.paginated_shared_with_environment_datasets(
uri=environmentUri,
data=filter,
)


def update_share_request_purpose(context: Context, source, shareUri: str = None, requestPurpose: str = None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,11 @@ def list_shareable_objects(share, filter, is_revokable=False):

@staticmethod
@ResourcePolicyService.has_resource_permission(LIST_ENVIRONMENT_SHARED_WITH_OBJECTS)
def paginated_shared_with_environment_datasets(session, uri, data) -> dict:
share_item_shared_states = ShareStatusRepository.get_share_item_shared_states()
return ShareObjectRepository.paginate_shared_datasets(session, uri, data, share_item_shared_states)
def paginated_shared_with_environment_datasets(uri, data) -> dict:
context = get_context()
with context.db_engine.scoped_session() as session:
share_item_shared_states = ShareStatusRepository.get_share_item_shared_states()
return ShareObjectRepository.paginate_shared_datasets(session, uri, data, share_item_shared_states)

@staticmethod
@TenantPolicyService.has_tenant_permission(MANAGE_SHARES)
Expand Down Expand Up @@ -256,6 +258,9 @@ def update_filters_table_share_item(uri: str, data: dict):
raise ObjectNotFound('ShareObjectItem', uri)

@staticmethod
@ResourcePolicyService.has_resource_permission(
GET_SHARE_OBJECT, parent_resource=_get_share_uri_from_item_filter_uri
)
def get_share_item_data_filters(uri: str):
with get_context().db_engine.scoped_session() as session:
return ShareObjectItemRepository.get_share_item_filter_by_uri(session, uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def check_view_logs_permissions(shareUri):
return True

@staticmethod
def get_share_logs_name_query(shareUri):
def _get_share_logs_name_query(shareUri):
log.info(f'Get share Logs stream name for share {shareUri}')

query = f"""fields @logStream
Expand All @@ -56,7 +56,7 @@ def get_share_logs_name_query(shareUri):
return query

@staticmethod
def get_share_logs_query(log_stream_name):
def _get_share_logs_query(log_stream_name):
query = f"""fields @timestamp, @message, @logStream, @log as @logGroup
| sort @timestamp asc
| filter @logStream like "{log_stream_name}"
Expand All @@ -65,14 +65,13 @@ def get_share_logs_query(log_stream_name):

@staticmethod
def get_share_logs(shareUri):
context = get_context()
ShareLogsService.check_view_logs_permissions(shareUri)
envname = os.getenv('envname', 'local')
log_query_period_days = config.get_property('core.log_query_period_days', 1)
log.info(f'log_query_period_days: {log_query_period_days}')
log_group_name = f"/{Parameter().get_parameter(env=envname, path='resourcePrefix')}/{envname}/ecs/share-manager"

query_for_name = ShareLogsService.get_share_logs_name_query(shareUri=shareUri)
query_for_name = ShareLogsService._get_share_logs_name_query(shareUri=shareUri)
name_query_result = CloudWatch.run_query(
query=query_for_name,
log_group_name=log_group_name,
Expand All @@ -83,7 +82,7 @@ def get_share_logs(shareUri):

name = name_query_result[0]['logStream']

query = ShareLogsService.get_share_logs_query(log_stream_name=name)
query = ShareLogsService._get_share_logs_query(log_stream_name=name)
results = CloudWatch.run_query(
query=query,
log_group_name=log_group_name,
Expand Down
Loading