-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Adds Saas type to saas yaml config * alter postman collection * updates changelog * lint fixes * Add endpoint to surface all available connectors including database options and saas options. * Exclude custom and manual types from list of available connectors. - Add docs and postman collection. * Update changelog. * Remove committed ANALYTICS_ID. * Import ClientDetail from fideslib instead of fidesops. * Fix import order. Co-authored-by: eastandwestwind <[email protected]>
- Loading branch information
1 parent
8767f73
commit f82e789
Showing
8 changed files
with
182 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Connection Types | ||
|
||
|
||
## Available Connection Types | ||
|
||
To view a list of all available connection types, visit `/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. | ||
|
||
```json title="<code>GET /api/v1/connection_type</code>" | ||
{ | ||
"items": [ | ||
"bigquery", | ||
"hubspot", | ||
"mailchimp", | ||
"mariadb", | ||
"mongodb", | ||
"mssql", | ||
"mysql", | ||
"outreach", | ||
"postgres", | ||
"redshift", | ||
"segment", | ||
"sentry", | ||
"snowflake", | ||
"stripe", | ||
"zendesk" | ||
], | ||
"total": 15, | ||
"page": 1, | ||
"size": 50 | ||
} | ||
``` |
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
48 changes: 48 additions & 0 deletions
48
src/fidesops/api/v1/endpoints/connection_type_endpoints.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,48 @@ | ||
import logging | ||
from typing import List, Optional | ||
|
||
from fastapi import APIRouter, Depends | ||
from fastapi.params import Security | ||
from fastapi_pagination import Page, Params, paginate | ||
from fastapi_pagination.bases import AbstractPage | ||
|
||
from fidesops.api.v1.scope_registry import CONNECTION_TYPE_READ | ||
from fidesops.api.v1.urn_registry import CONNECTION_TYPES, V1_URL_PREFIX | ||
from fidesops.models.connectionconfig import ConnectionType | ||
from fidesops.schemas.saas.saas_config import SaaSType | ||
from fidesops.util.oauth_util import verify_oauth_client | ||
|
||
router = APIRouter(tags=["Connection Types"], prefix=V1_URL_PREFIX) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@router.get( | ||
CONNECTION_TYPES, | ||
dependencies=[Security(verify_oauth_client, scopes=[CONNECTION_TYPE_READ])], | ||
response_model=Page[str], | ||
) | ||
def get_all_connection_types( | ||
*, params: Params = Depends(), search: Optional[str] = None | ||
) -> AbstractPage[str]: | ||
"""Returns a list of connection options in Fidesops - includes only database and saas options here.""" | ||
|
||
def is_match(elem: str) -> bool: | ||
"""If a search query param was included, is it a substring of an available connector type?""" | ||
return search in elem if search else True | ||
|
||
database_types: List[str] = [ | ||
conn_type.value | ||
for conn_type in ConnectionType | ||
if conn_type | ||
not in [ConnectionType.saas, ConnectionType.https, ConnectionType.manual] | ||
and is_match(conn_type.value) | ||
] | ||
saas_types: List[str] = [ | ||
saas_type.value | ||
for saas_type in SaaSType | ||
if saas_type != SaaSType.custom and is_match(saas_type.value) | ||
] | ||
connection_types: List[str] = sorted(database_types + saas_types) | ||
|
||
return paginate(connection_types, params) |
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
59 changes: 59 additions & 0 deletions
59
tests/api/v1/endpoints/test_connection_template_endpoints.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,59 @@ | ||
import pytest | ||
from fastapi_pagination import Params | ||
from fideslib.models.client import ClientDetail | ||
from starlette.testclient import TestClient | ||
|
||
from fidesops.api.v1.scope_registry import CONNECTION_READ, CONNECTION_TYPE_READ | ||
from fidesops.api.v1.urn_registry import CONNECTION_TYPES, V1_URL_PREFIX | ||
|
||
|
||
class TestGetConnections: | ||
@pytest.fixture(scope="function") | ||
def url(self, oauth_client: ClientDetail, policy) -> str: | ||
return V1_URL_PREFIX + CONNECTION_TYPES | ||
|
||
def test_get_connection_types_not_authenticated(self, api_client, url): | ||
resp = api_client.get(url, headers={}) | ||
assert resp.status_code == 401 | ||
|
||
def test_get_connection_types_forbidden( | ||
self, api_client, url, generate_auth_header | ||
): | ||
auth_header = generate_auth_header(scopes=[CONNECTION_READ]) | ||
resp = api_client.get(url, headers=auth_header) | ||
assert resp.status_code == 403 | ||
|
||
def test_get_connection_types( | ||
self, api_client: TestClient, generate_auth_header, url | ||
) -> None: | ||
auth_header = generate_auth_header(scopes=[CONNECTION_TYPE_READ]) | ||
resp = api_client.get(url, headers=auth_header) | ||
data = resp.json() | ||
assert resp.status_code == 200 | ||
assert "items" in data | ||
assert "total" in data | ||
assert "page" in data | ||
assert data["size"] == Params().size | ||
|
||
assert "postgres" in data["items"] | ||
assert "stripe" in data["items"] | ||
|
||
assert "saas" not in data["items"] | ||
assert "https" not in data["items"] | ||
assert "custom" not in data["items"] | ||
assert "manual" not in data["items"] | ||
|
||
def test_search_connection_types(self, api_client, generate_auth_header, url): | ||
auth_header = generate_auth_header(scopes=[CONNECTION_TYPE_READ]) | ||
|
||
resp = api_client.get(url + "?search=str", headers=auth_header) | ||
assert resp.status_code == 200 | ||
data = resp.json() | ||
assert data["total"] == 1 | ||
assert data["items"][0] == "stripe" | ||
|
||
resp = api_client.get(url + "?search=re", headers=auth_header) | ||
assert resp.status_code == 200 | ||
data = resp.json() | ||
assert data["total"] == 3 | ||
assert data["items"] == ["outreach", "postgres", "redshift"] |