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

Commit

Permalink
Human Readable Names for Connection Types [#1096] (#1297)
Browse files Browse the repository at this point in the history
* Expose a human readable name in the connection type endpoints.

Add a human_readable_name to the saas connector registry and a separate human readable mapping for ConnectionTypes.

* Update changelog and connection type endpoint docs.

* mypy

* Update ConnectorTemplate test.

* Mypy

* Update tests/ops/models/test_connectionconfig.py

Co-authored-by: Paul Sanders <paul@ethyca.com>

Co-authored-by: Paul Sanders <paul@ethyca.com>
  • Loading branch information
pattisdr and Paul Sanders committed Sep 13, 2022
1 parent 1ea917b commit 67e9a2e
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 41 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ The types of changes are:
* Added erasure endpoints for Shopify connector [#1289](https://github.com/ethyca/fidesops/pull/1289)
* Adds ability to send email notification upon privacy request completion [#1282](https://github.com/ethyca/fidesops/pull/1282)

* Added human readable label to ConnectionType endpoint [#1297](https://github.com/ethyca/fidesops/pull/1297)

### Docs

* Fix analytics opt out environment variable name [#1170](https://github.com/ethyca/fidesops/pull/1170)
Expand Down
17 changes: 16 additions & 1 deletion data/saas/saas_connector_registry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,83 @@
config = "data/saas/config/adobe_campaign_config.yml"
dataset = "data/saas/dataset/adobe_campaign_dataset.yml"
icon = "data/saas/icon/adobe.svg"
human_readable = "Adobe Campaign"

[auth0]
config = "data/saas/config/auth0_config.yml"
dataset = "data/saas/dataset/auth0_dataset.yml"
icon = "data/saas/icon/default.svg"
human_readable = "Auth0"

[datadog]
config = "data/saas/config/datadog_config.yml"
dataset = "data/saas/dataset/datadog_dataset.yml"
icon = "data/saas/icon/default.svg"
human_readable = "Datadog"

[hubspot]
config = "data/saas/config/hubspot_config.yml"
dataset = "data/saas/dataset/hubspot_dataset.yml"
icon = "data/saas/icon/hubspot.svg"
human_readable = "HubSpot"


[logi_id]
config = "data/saas/config/logi_id_config.yml"
dataset = "data/saas/dataset/logi_id_dataset.yml"
icon = "data/saas/icon/default.svg"
human_readable = "Logi ID"

[mailchimp]
config = "data/saas/config/mailchimp_config.yml"
dataset = "data/saas/dataset/mailchimp_dataset.yml"
icon = "data/saas/icon/mailchimp.svg"
human_readable = "Mailchimp"

[outreach]
config = "data/saas/config/outreach_config.yml"
dataset = "data/saas/dataset/outreach_dataset.yml"
icon = "data/saas/icon/outreach.svg"
human_readable = "Outreach"

[salesforce]
config = "data/saas/config/salesforce_config.yml"
dataset = "data/saas/dataset/salesforce_dataset.yml"
icon = "data/saas/icon/salesforce.svg"
human_readable = "Salesforce"

[segment]
config = "data/saas/config/segment_config.yml"
dataset = "data/saas/dataset/segment_dataset.yml"
icon = "data/saas/icon/segment.svg"
human_readable = "Segment"

[sendgrid]
config = "data/saas/config/sendgrid_config.yml"
dataset = "data/saas/dataset/sendgrid_dataset.yml"
icon = "data/saas/icon/default.svg"
human_readable = "SendGrid"

[sentry]
config = "data/saas/config/sentry_config.yml"
dataset = "data/saas/dataset/sentry_dataset.yml"
icon = "data/saas/icon/sentry.svg"
human_readable = "Sentry"

[shopify]
config = "data/saas/config/shopify_config.yml"
dataset = "data/saas/dataset/shopify_dataset.yml"
icon = "data/saas/icon/default.svg"
human_readable = "Shopify"

[stripe]
config = "data/saas/config/stripe_config.yml"
dataset = "data/saas/dataset/stripe_dataset.yml"
icon = "data/saas/icon/stripe.svg"
human_readable = "Stripe"

[zendesk]
config = "data/saas/config/zendesk_config.yml"
dataset = "data/saas/dataset/zendesk_dataset.yml"
icon = "data/saas/icon/zendesk.svg"
icon = "data/saas/icon/zendesk.svg"
human_readable = "Zendesk"
80 changes: 56 additions & 24 deletions docs/fidesops/docs/guides/connection_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,130 @@
## Available Connection Types

To view a list of all available connection types, visit `GET /api/v1/connection_type`.
This endpoint can be filtered with a `search` query param and is subject to change. We include
database options and third party API services with which fidesops can communicate.
This endpoint can be filtered with a `search` query param or a `system_type` query param
and is subject to change. We include database options and third party API services with
which fidesops can communicate.

```json title="<code>GET /api/v1/connection_type</code>"
{
"items": [
{
"identifier": "bigquery",
"type": "database"
"type": "database",
"human_readable": "BigQuery"
},
{
"identifier": "mariadb",
"type": "database"
"type": "database",
"human_readable": "MariaDB"
},
{
"identifier": "mongodb",
"type": "database"
"type": "database",
"human_readable": "MongoDB"
},
{
"identifier": "mssql",
"type": "database"
"type": "database",
"human_readable": "Microsoft SQL Server"
},
{
"identifier": "mysql",
"type": "database"
"type": "database",
"human_readable": "MySQL"
},
{
"identifier": "postgres",
"type": "database"
"type": "database",
"human_readable": "PostgreSQL"
},
{
"identifier": "redshift",
"type": "database"
"type": "database",
"human_readable": "Amazon Redshift"
},
{
"identifier": "snowflake",
"type": "database"
"type": "database",
"human_readable": "Snowflake"
},
{
"identifier": "adobe_campaign",
"type": "saas"
"type": "saas",
"human_readable": "Adobe Campaign"
},
{
"identifier": "auth0",
"type": "saas"
"type": "saas",
"human_readable": "Auth0"
},
{
"identifier": "datadog",
"type": "saas"
"type": "saas",
"human_readable": "Datadog"
},
{
"identifier": "hubspot",
"type": "saas"
"type": "saas",
"human_readable": "HubSpot"
},
{
"identifier": "logi_id",
"type": "saas"
"type": "saas",
"human_readable": "Logi ID"
},
{
"identifier": "mailchimp",
"type": "saas"
"type": "saas",
"human_readable": "Mailchimp"
},
{
"identifier": "outreach",
"type": "saas"
"type": "saas",
"human_readable": "Outreach"
},
{
"identifier": "salesforce",
"type": "saas"
"type": "saas",
"human_readable": "Salesforce"
},
{
"identifier": "segment",
"type": "saas"
"type": "saas",
"human_readable": "Segment"
},
{
"identifier": "sendgrid",
"type": "saas"
"type": "saas",
"human_readable": "SendGrid"
},
{
"identifier": "sentry",
"type": "saas"
"type": "saas",
"human_readable": "Sentry"
},
{
"identifier": "shopify",
"type": "saas",
"human_readable": "Shopify"
},
{
"identifier": "stripe",
"type": "saas"
"type": "saas",
"human_readable": "Stripe"
},
{
"identifier": "zendesk",
"type": "saas"
"type": "saas",
"human_readable": "Zendesk"
},
{
"identifier": "manual_webhook",
"type": "manual",
"human_readable": "Manual Webhook"
}
],
"total": 21,
"total": 23,
"page": 1,
"size": 50
}
Expand Down
39 changes: 31 additions & 8 deletions src/fidesops/ops/api/v1/endpoints/connection_type_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
SystemType,
)
from fidesops.ops.schemas.saas.saas_config import SaaSConfig, SaaSType
from fidesops.ops.service.connectors.saas.connector_registry_service import (
ConnectorRegistry,
load_registry,
registry_file,
)
from fidesops.ops.util.oauth_util import verify_oauth_client
from fidesops.ops.util.saas_util import load_config

Expand Down Expand Up @@ -57,7 +62,11 @@ def is_match(elem: str) -> bool:
)
connection_system_types.extend(
[
ConnectionSystemTypeMap(identifier=item, type=SystemType.database)
ConnectionSystemTypeMap(
identifier=item,
type=SystemType.database,
human_readable=ConnectionType(item).human_readable,
)
for item in database_types
]
)
Expand All @@ -69,12 +78,22 @@ def is_match(elem: str) -> bool:
if saas_type != SaaSType.custom and is_match(saas_type.value)
]
)
connection_system_types.extend(
[
ConnectionSystemTypeMap(identifier=item, type=SystemType.saas)
for item in saas_types
]
)
registry: ConnectorRegistry = load_registry(registry_file)

for item in saas_types:
human_readable_name: str = item
if registry.get_connector_template(item) is not None:
human_readable_name = registry.get_connector_template( # type: ignore[union-attr]
item
).human_readable

connection_system_types.append(
ConnectionSystemTypeMap(
identifier=item,
type=SystemType.saas,
human_readable=human_readable_name,
)
)

if system_type == SystemType.manual or system_type is None:
manual_types: List[str] = sorted(
Expand All @@ -87,7 +106,11 @@ def is_match(elem: str) -> bool:
)
connection_system_types.extend(
[
ConnectionSystemTypeMap(identifier=item, type=SystemType.manual)
ConnectionSystemTypeMap(
identifier=item,
type=SystemType.manual,
human_readable=ConnectionType(item).human_readable,
)
for item in manual_types
]
)
Expand Down
29 changes: 28 additions & 1 deletion src/fidesops/ops/models/connectionconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import enum
from datetime import datetime
from typing import Any, Optional, Type
from typing import Any, Dict, Optional, Type

from fideslib.db.base import Base
from fideslib.db.base_class import get_key_from_data
Expand Down Expand Up @@ -48,6 +48,33 @@ class ConnectionType(enum.Enum):
email = "email"
manual_webhook = "manual_webhook" # Run before the traversal

@property
def human_readable(self) -> str:
"""Human-readable mapping for ConnectionTypes
Add to this mapping if you add a new ConnectionType
"""
readable_mapping: Dict[str, str] = {
ConnectionType.postgres.value: "PostgreSQL",
ConnectionType.mongodb.value: "MongoDB",
ConnectionType.mysql.value: "MySQL",
ConnectionType.https.value: "Policy Webhook",
ConnectionType.saas.value: "SaaS",
ConnectionType.redshift.value: "Amazon Redshift",
ConnectionType.snowflake.value: "Snowflake",
ConnectionType.mssql.value: "Microsoft SQL Server",
ConnectionType.mariadb.value: "MariaDB",
ConnectionType.bigquery.value: "BigQuery",
ConnectionType.manual.value: "Manual Connector",
ConnectionType.email.value: "Email Connector",
ConnectionType.manual_webhook.value: "Manual Webhook",
}
try:
return readable_mapping[self.value]
except KeyError:
raise NotImplementedError(
"Add new ConnectionType to human_readable mapping"
)


class AccessLevel(enum.Enum):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ConnectionSystemTypeMap(BaseModel):

identifier: Union[ConnectionType, SaaSType]
type: SystemType
human_readable: str

class Config:
"""Use enum values and set orm mode"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ConnectorTemplate(BaseModel):
config: str
dataset: str
icon: str
human_readable: str

@validator("config")
def validate_config(cls, config: str) -> str:
Expand Down
Loading

0 comments on commit 67e9a2e

Please sign in to comment.