diff --git a/src/fides/api/api/v1/endpoints/dataset_endpoints.py b/src/fides/api/api/v1/endpoints/dataset_endpoints.py index 8471f827bad..00a07865be9 100644 --- a/src/fides/api/api/v1/endpoints/dataset_endpoints.py +++ b/src/fides/api/api/v1/endpoints/dataset_endpoints.py @@ -584,6 +584,7 @@ def delete_dataset( f"/filter{DATASETS}", dependencies=[Security(verify_oauth_client, scopes=[DATASET_READ])], response_model=List[Dataset], + deprecated=True, ) def get_ctl_datasets( db: Session = Depends(deps.get_db), diff --git a/src/fides/api/api/v1/endpoints/generic_overrides.py b/src/fides/api/api/v1/endpoints/generic_overrides.py index bc8b09a03e5..52e9b959822 100644 --- a/src/fides/api/api/v1/endpoints/generic_overrides.py +++ b/src/fides/api/api/v1/endpoints/generic_overrides.py @@ -8,7 +8,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.sql.expression import select -from fides.api.db.crud import list_resource +from fides.api.db.crud import list_resource_query from fides.api.db.ctl_session import get_async_db from fides.api.models.connectionconfig import ConnectionConfig from fides.api.models.datasetconfig import DatasetConfig @@ -45,15 +45,14 @@ async def list_dataset_paginated( ) -> Union[Page[Dataset], List[Dataset]]: """ Get a list of all of the Datasets. - If any pagination parameters (size or page) are provided, then the response will be paginated - & provided filters (search, data_categories, exclude_saas_datasets, only_unlinked_datasets) will be applied. + If any pagination parameters (size or page) are provided, then the response will be paginated. Otherwise all Datasets will be returned (this may be a slow operation if there are many datasets, so using the pagination parameters is recommended). + Provided filters (search, data_categories, exclude_saas_datasets, only_unlinked_datasets) will be applied, + returning only the datasets that match ALL of the filters. """ - if not page and not size: - return await list_resource(CtlDataset, db) - query = select(CtlDataset) + # Add filters for search and data categories filter_params = FilterParams(search=search, data_categories=data_categories) filtered_query = apply_filters_to_query( @@ -79,6 +78,9 @@ async def list_dataset_paginated( not_(CtlDataset.fides_key.in_(saas_subquery)) ) + if not page and not size: + return await list_resource_query(db, filtered_query, CtlDataset) + pagination_params = Params(page=page or 1, size=size or 50) return await async_paginate(db, filtered_query, pagination_params) diff --git a/tests/ops/api/v1/endpoints/test_dataset_endpoints.py b/tests/ops/api/v1/endpoints/test_dataset_endpoints.py index fd51399c073..18a2eefb4e0 100644 --- a/tests/ops/api/v1/endpoints/test_dataset_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_dataset_endpoints.py @@ -2015,6 +2015,42 @@ def test_list_dataset_no_pagination( assert sorted_items[0]["fides_key"] == ctl_dataset.fides_key assert sorted_items[1]["fides_key"] == secondary_sendgrid_instance[1].fides_key + def test_list_dataset_no_pagination_exclude_saas( + self, + api_client: TestClient, + generate_auth_header, + ctl_dataset, + secondary_sendgrid_instance, + ): + auth_header = generate_auth_header(scopes=[DATASET_READ]) + response = api_client.get( + f"{V1_URL_PREFIX}/dataset?exclude_saas_datasets=True", + headers=auth_header, + ) + + assert response.status_code == 200 + response_json = response.json() + assert len(response_json) == 1 + assert response_json[0]["fides_key"] == ctl_dataset.fides_key + + def test_list_dataset_no_pagination_only_unlinked_datasets( + self, + api_client: TestClient, + generate_auth_header, + unlinked_dataset, + linked_dataset, + ): + auth_header = generate_auth_header(scopes=[DATASET_READ]) + response = api_client.get( + f"{V1_URL_PREFIX}/dataset?only_unlinked_datasets=True", + headers=auth_header, + ) + + assert response.status_code == 200 + response_json = response.json() + assert len(response_json) == 1 + assert response_json[0]["fides_key"] == unlinked_dataset.fides_key + def test_list_dataset_with_pagination( self, api_client: TestClient,