-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into allow-no-content-response
- Loading branch information
Showing
12 changed files
with
460 additions
and
26 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,37 @@ | ||
saas_config: | ||
fides_key: <instance_fides_key> | ||
name: Marigold Engage by Sailthru | ||
type: marigold_engage | ||
description: A sample schema representing the Marigold Engage via Sailthru connector for Fides | ||
version: 0.1.0 | ||
|
||
connector_params: | ||
- name: domain | ||
default_value: api.sailthru.com | ||
- name: api_key | ||
label: API key | ||
sensitive: True | ||
- name: secret | ||
label: Marigold secret | ||
sensitive: True | ||
|
||
client_config: | ||
protocol: https | ||
host: <domain> | ||
|
||
test_request: | ||
request_override: marigold_engage_test | ||
|
||
endpoints: | ||
- name: user | ||
requests: | ||
read: | ||
request_override: marigold_engage_user_read | ||
param_values: | ||
- name: email | ||
identity: email | ||
delete: | ||
request_override: marigold_engage_user_delete | ||
param_values: | ||
- name: email | ||
identity: email |
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,47 @@ | ||
dataset: | ||
- fides_key: <instance_fides_key> | ||
name: Marigold Engage Dataset | ||
description: A sample dataset representing the Marigold Engage integration for Fides | ||
collections: | ||
- name: user | ||
fields: | ||
- name: activity | ||
fidesops_meta: | ||
data_type: object | ||
fields: | ||
- name: create_time | ||
data_categories: [system.operations] | ||
fidesops_meta: | ||
data_type: string | ||
- name: engagement | ||
data_categories: [system.operations] | ||
fidesops_meta: | ||
data_type: string | ||
- name: keys | ||
fidesops_meta: | ||
data_type: object | ||
fields: | ||
- name: sid | ||
data_categories: [system.operations] | ||
fidesops_meta: | ||
data_type: string | ||
- name: cookie | ||
data_categories: [user.device.cookie_id] | ||
fidesops_meta: | ||
data_type: string | ||
- name: email | ||
data_categories: [user.contact.email] | ||
fidesops_meta: | ||
primary_key: True | ||
data_type: string | ||
- name: lists | ||
- name: optout_email | ||
data_categories: [system.operations] | ||
fidesops_meta: | ||
data_type: string | ||
- name: smart_lists | ||
- name: vars | ||
- name: purchases | ||
- name: device | ||
- name: purchase_incomplete | ||
- name: lifetime |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
123 changes: 123 additions & 0 deletions
123
...es/api/service/saas_request/override_implementations/marigold_engage_request_overrides.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,123 @@ | ||
import hashlib | ||
import json | ||
from typing import Any, Dict, List | ||
|
||
from fides.api.graph.traversal import TraversalNode | ||
from fides.api.models.policy import Policy | ||
from fides.api.models.privacy_request import PrivacyRequest | ||
from fides.api.schemas.saas.shared_schemas import HTTPMethod, SaaSRequestParams | ||
from fides.api.service.connectors.saas.authenticated_client import AuthenticatedClient | ||
from fides.api.service.saas_request.saas_request_override_factory import ( | ||
SaaSRequestType, | ||
register, | ||
) | ||
from fides.api.util.collection_util import Row | ||
|
||
|
||
@register("marigold_engage_test", [SaaSRequestType.TEST]) | ||
def marigold_engage_test(client: AuthenticatedClient, secrets: Dict[str, Any]) -> None: | ||
""" | ||
Calls Marigold Engage's `GET /list` endpoint with a signed payload. | ||
""" | ||
|
||
client.send( | ||
SaaSRequestParams( | ||
method=HTTPMethod.GET, | ||
path="/list", | ||
query_params=signed_payload(secrets, {}), | ||
) | ||
) | ||
|
||
|
||
@register("marigold_engage_user_read", [SaaSRequestType.READ]) | ||
def marigold_engage_user_read( | ||
client: AuthenticatedClient, | ||
node: TraversalNode, | ||
policy: Policy, | ||
privacy_request: PrivacyRequest, | ||
input_data: Dict[str, List[Any]], | ||
secrets: Dict[str, Any], | ||
) -> List[Row]: | ||
""" | ||
Calls Marigold Engage's `GET /user` endpoint with a signed payload. | ||
""" | ||
|
||
output = [] | ||
emails = input_data.get("email", []) | ||
for email in emails: | ||
payload = { | ||
"id": email, | ||
"key": "email", | ||
"fields": { | ||
"activity": 1, | ||
"engagement": 1, | ||
"keys": 1, | ||
"lists": 1, | ||
"optout_email": 1, | ||
"smart_lists": 1, | ||
"vars": 1, | ||
"purchases": 1, | ||
"device": 1, | ||
"purchase_incomplete": 1, | ||
"lifetime": 1, | ||
}, | ||
} | ||
response = client.send( | ||
SaaSRequestParams( | ||
method=HTTPMethod.GET, | ||
path="/user", | ||
query_params=signed_payload(secrets, payload), | ||
) | ||
) | ||
user = response.json() | ||
output.append(user) | ||
|
||
return output | ||
|
||
|
||
@register("marigold_engage_user_delete", [SaaSRequestType.DELETE]) | ||
def marigold_engage_user_delete( | ||
client: AuthenticatedClient, | ||
param_values_per_row: List[Dict[str, Any]], | ||
policy: Policy, | ||
privacy_request: PrivacyRequest, | ||
secrets: Dict[str, Any], | ||
) -> int: | ||
""" | ||
Calls Marigold Engage's `DELETE /user` endpoint with a signed payload. | ||
""" | ||
|
||
rows_deleted = 0 | ||
for row_param_values in param_values_per_row: | ||
email = row_param_values["email"] | ||
client.send( | ||
SaaSRequestParams( | ||
method=HTTPMethod.DELETE, | ||
path="/user", | ||
query_params=signed_payload(secrets, {"id": email}), | ||
) | ||
) | ||
rows_deleted += 1 | ||
return rows_deleted | ||
|
||
|
||
def signed_payload(secrets: Dict[str, Any], payload: Dict[str, Any]) -> Dict[str, Any]: | ||
""" | ||
Creates a signed payload dictionary with an MD5 hash of the secret, API key, format, and payload. | ||
""" | ||
|
||
# the signature is the md5 hash of the concatenated string | ||
# of secret, API key, format, and stringified payload | ||
stringified_payload = json.dumps(payload) | ||
parameter_values = ( | ||
f'{secrets["secret"]}{secrets["api_key"]}json{stringified_payload}' | ||
) | ||
hash_value = hashlib.md5(parameter_values.encode()) | ||
sig = hash_value.hexdigest() | ||
|
||
return { | ||
"api_key": secrets["api_key"], | ||
"sig": sig, | ||
"format": "json", | ||
"json": stringified_payload, | ||
} |
Oops, something went wrong.