Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Add ConnectionConfig Filters #675

Merged
merged 9 commits into from
Jun 17, 2022

Conversation

pattisdr
Copy link
Contributor

@pattisdr pattisdr commented Jun 16, 2022

Purpose

Add ConnectionConfig filters to support the frontend datastore management landing page.

Changes

  • Filters added for disabled: api/v1/connection/?disabled=true or api/v1/connection/?disabled=false
  • Filters added for multiple connectiontypes: `?api/v1/connection/?connection_type=postgres&connection_type=redshift
    • If there are multiple connection_type query params, the backend looks for any that match.
  • Filters for test_status: ?test_status=passed, ?test_status=failed, and ?test_status=untested
  • Filters for system_type: ?system_type=saas and ?system_type=database

Checklist

  • Update CHANGELOG.md file
    • Merge in main so the most recent CHANGELOG.md file is being appended to
    • Add description within the Unreleased section in an appropriate category. Add a new category from the list at the top of the file if the needed one isn't already there.
    • Add a link to this PR at the end of the description with the PR number as the text. example: #1
  • Applicable documentation updated (guides, quickstart, postman collections, tutorial, fidesdemo, database diagram.
  • If docs updated (select one):
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Good unit test/integration test coverage
  • This PR contains a DB migration. If checked, the reviewer should confirm with the author that the down_revision correctly references the previous migration before merging
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Fixes #670

…ection_config_filtering

# Conflicts:
#	CHANGELOG.md
…uery so FastAPI interprets as a query param and not a request body per FastAPI docs.
Comment on lines +111 to +117

if connection_type:
query = query.filter(ConnectionConfig.connection_type.in_(connection_type))

if disabled is not None:
query = query.filter(ConnectionConfig.disabled == disabled)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just connection_type and disabled were detailed in the ticket - is there anything else I should add while I'm here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are 2 more filters that are needed for the frontend.

One is Testing Status. This would be filtering based on the last_test_succeeded field. I think it needs to be able to filter based on true, false, and null. null would be for connections that have never been tested.

The second is System Type. In the mockups it looks it's for filtering for all SAAS connections or all Database connections. I'm not sure if this is possible with the current data model. I think it would conflict with the connection_type filter you added because it would be a second filter based on the same field. Does that seem correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @TheAndrewJackson - I can add both testing status and system type. it's fine if it's a second filter on the same field, just important to note that if the user selects "saas" and then filters for "postgres" then they'll get no results.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: Testing status, let's make sure we're being careful about the "null" status. Usually a None would mean, "don't filter", and in this case, you're wanting it to mean "we never tested it". Maybe we do string filters here, "passed", "failed", "untested", and None, or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I added filtering on ?test_status=passed, ?test_status=failed, and?test_status=untested, and then there's
?system_type=saas and ?system_type=database.

If someone filters on conflicting fields, they'll get no results: ?system_type=saas&connection_type=postgres.

@@ -86,9 +86,15 @@ def get_connections(
db: Session = Depends(deps.get_db),
params: Params = Depends(),
search: Optional[str] = None,
disabled: Optional[bool] = None,
connection_type: Optional[List[str]] = Query(default=None), # type:ignore
Copy link
Contributor Author

@pattisdr pattisdr Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to search for multiple connection_types do: ?connection_type=postgres&connection_type=mongo.

I would have preferred this syntax: ?connection_type=postgres,mongo for an OR query, but I am using the syntax in the docs https://fastapi.tiangolo.com/it/tutorial/query-params-str-validations/#query-parameter-list-multiple-values which works well with the autogenerated API docs. I just think we need to make sure our meaning is clear in our own docs.

Screen Shot 2022-06-16 at 6 33 51 PM

@pattisdr pattisdr marked this pull request as ready for review June 16, 2022 23:36
@pattisdr
Copy link
Contributor Author

@ethyca/docs-authors some items added that describe filtering options on connection configs.

elif system_type == SystemType.database:
query = query.filter(
ConnectionConfig.connection_type.notin_(
[ConnectionType.saas, ConnectionType.manual]
Copy link
Contributor Author

@pattisdr pattisdr Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointing out that there's really 3 system types right now, saas, database, and manual. I've only added system_type filtering for the first two, but I can change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pattisdr Does that backend support manual connection types right now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it does but there's not an easy way to interact with them yet, it is a connection type that requires a user to go manually perform some action and upload data back to fidesops.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Maybe we should add it in in the backend just to get ahead of the future update? The frontend can always leave the filtering option out if it isn't supposed to handle it yet.

@pattisdr pattisdr changed the title Add ConnectionConfig Search: Disabled and ConnectionType Add ConnectionConfig Filters Jun 17, 2022
failed = "failed"
untested = "untested"

def str_to_bool(self) -> Optional[bool]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this! Good idea

elif system_type == SystemType.database:
query = query.filter(
ConnectionConfig.connection_type.notin_(
[ConnectionType.saas, ConnectionType.manual]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pattisdr Does that backend support manual connection types right now?

@TheAndrewJackson TheAndrewJackson merged commit 9b3bab3 into main Jun 17, 2022
@TheAndrewJackson TheAndrewJackson deleted the fidesops_670_add_connection_config_filtering branch June 17, 2022 19:27
sanders41 pushed a commit that referenced this pull request Sep 22, 2022
* Add connectionconfig filtering on connection_type (can search multiple) and whether the connection is disabled.

* Update changelog.

* Ignore mypy error - we intentionally want the default value to be a Query so FastAPI interprets as a query param and not a request body per FastAPI docs.

* Remove unused union.

* Add connection config filtering on system_type and test_status.

* No elif after return.

* Add manual system type for connectionconfig filtering.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Datastore Management] Adding filtering capabilities to landing page BACK END
2 participants