This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
706 Adds SaaS connection type to SaaS yaml config (#748)
* Adds Saas type to saas yaml config * To allow data migration that queries on a connectiontype enum to work, update previous schema migrations that used "alter type" to update connection type to rename the enum type, create a new enum with the new types, and then delete the old enum type. Co-authored-by: Dawn Pattison <[email protected]>
- Loading branch information
1 parent
c5c3084
commit 511835b
Showing
24 changed files
with
234 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 40 additions & 12 deletions
52
docs/fidesops/docs/postman/Fidesops.postman_collection.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/fidesops/migrations/versions/fc90277bbcde_populate_saas_type_to_saas_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"""Populate saas type to saas config | ||
Revision ID: fc90277bbcde | ||
Revises: ed1b00ff963d | ||
Create Date: 2022-07-05 19:20:59.384767 | ||
""" | ||
import enum | ||
from typing import List | ||
|
||
from alembic import op | ||
from sqlalchemy import text | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "fc90277bbcde" | ||
down_revision = "c7cc36820d4b" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
class SaaSType(enum.Enum): | ||
""" | ||
Enum to store saas connection type in Fidesops | ||
""" | ||
|
||
mailchimp = "mailchimp" | ||
hubspot = "hubspot" | ||
outreach = "outreach" | ||
segment = "segment" | ||
sentry = "sentry" | ||
stripe = "stripe" | ||
zendesk = "zendesk" | ||
custom = "custom" | ||
|
||
|
||
query = text( | ||
"""select connectionconfig.id, connectionconfig.saas_config from connectionconfig WHERE connectionconfig.connection_type = :connection_type""" | ||
) | ||
update_query = text( | ||
"""update connectionconfig set saas_config = jsonb_set(saas_config, '{type}', :saas_type) where id = :id""" | ||
) | ||
|
||
|
||
def upgrade(): | ||
connection = op.get_bind() | ||
saas_options: List[str] = [saas_type.value for saas_type in SaaSType] | ||
for id, saas_config in connection.execute(query, {"connection_type": "saas"}): | ||
if not saas_config: | ||
continue | ||
fides_key: str = saas_config.get("fides_key", "") | ||
saas_name: str = saas_config.get("name", "") | ||
|
||
try: | ||
saas_type: str = next( | ||
( | ||
opt | ||
for opt in saas_options | ||
if any( | ||
[ | ||
fides_key.lower().startswith(opt), | ||
saas_name.lower().startswith(opt), | ||
] | ||
) | ||
), | ||
"custom", | ||
) | ||
connection.execute(update_query, {"saas_type": f'"{saas_type}"', "id": id}) | ||
except Exception: | ||
# default to using "custom" if something went wrong | ||
connection.execute(update_query, {"saas_type": f'"custom"', "id": id}) | ||
|
||
|
||
def downgrade(): | ||
connection = op.get_bind() | ||
for id, saas_config in connection.execute(query, {"connection_type": "saas"}): | ||
connection.execute(update_query, {"saas_type": f'"custom"', "id": id}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.