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
Add Configuration Option for Entrypoint Array Querying [#193] #229
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7ba8678
Add a dataset config option to specify whether an array entry point f…
pattisdr ff5e02d
Add return_all_elements=True config option to docs.
pattisdr 9084c93
Adjust quickstart docs, now that example includes results from the re…
pattisdr cf37a4b
Switch out connection config - test
pattisdr 2464acf
Fix missed items from rebase.
pattisdr afa432d
Use yaml formatting in docs and use endswith to save minor time.
pattisdr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,76 +55,97 @@ information for Jane across tables in both the postgres and mongo databases. | |
|
||
```json | ||
{ | ||
"mongo_test:flights": [ | ||
"mongo_test:flights": [ | ||
{ | ||
"passenger_information": { | ||
"full_name": "Jane Customer" | ||
} | ||
} | ||
], | ||
"mongo_test:customer_details": [ | ||
{ | ||
"gender": "female", | ||
"children": [ | ||
"Erica Example" | ||
], | ||
"birthday": "1990-02-28T00:00:00" | ||
} | ||
], | ||
"postgres_example:address": [ | ||
{ | ||
"city": "Example Mountain", | ||
"state": "TX", | ||
"house": 1111, | ||
"zip": "54321", | ||
"street": "Example Place" | ||
} | ||
], | ||
"postgres_example:customer": [ | ||
{ | ||
"email": "[email protected]", | ||
"name": "Jane Customer" | ||
} | ||
], | ||
"mongo_test:rewards": [ | ||
{ | ||
"owner": [ | ||
{ | ||
"passenger_information": { | ||
"full_name": "Jane Customer" | ||
} | ||
} | ||
], | ||
"mongo_test:payment_card": [ | ||
{ | ||
"ccn": "987654321", | ||
"name": "Example Card 2", | ||
"code": "123" | ||
} | ||
], | ||
"postgres_example_test_dataset:address": [ | ||
{ | ||
"zip": "54321", | ||
"street": "Example Place", | ||
"state": "TX", | ||
"city": "Example Mountain", | ||
"house": 1111 | ||
} | ||
], | ||
"mongo_test:customer_details": [ | ||
{ | ||
"birthday": "1990-02-28T00:00:00", | ||
"gender": "female", | ||
"children": [ | ||
"Erica Example" | ||
] | ||
} | ||
], | ||
"postgres_example_test_dataset:customer": [ | ||
"phone": "530-486-6983" | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Jane Customer" | ||
"phone": "818-695-1881" | ||
} | ||
], | ||
"postgres_example_test_dataset:payment_card": [ | ||
] | ||
}, | ||
{ | ||
"owner": [ | ||
{ | ||
"ccn": 373719391, | ||
"name": "Example Card 3", | ||
"code": 222 | ||
"phone": "254-344-9868" | ||
} | ||
], | ||
"mongo_test:employee": [ | ||
] | ||
} | ||
], | ||
"mongo_test:employee": [ | ||
{ | ||
"email": "[email protected]", | ||
"name": "Jane Employee" | ||
} | ||
], | ||
"mongo_test:conversations": [ | ||
{ | ||
"thread": [ | ||
{ | ||
"email": "[email protected]", | ||
"name": "Jane Employee" | ||
"ccn": "987654321", | ||
"chat_name": "Jane C" | ||
} | ||
], | ||
"mongo_test:conversations": [ | ||
] | ||
}, | ||
{ | ||
"thread": [ | ||
{ | ||
"thread": [ | ||
{ | ||
"chat_name": "Jane C" | ||
} | ||
] | ||
"ccn": "987654321", | ||
"chat_name": "Jane C" | ||
}, | ||
{ | ||
"thread": [ | ||
{ | ||
"chat_name": "Jane C" | ||
}, | ||
{ | ||
"chat_name": "Jane C" | ||
} | ||
] | ||
"chat_name": "Jane C" | ||
} | ||
] | ||
] | ||
} | ||
], | ||
"mongo_test:payment_card": [ | ||
{ | ||
"ccn": "987654321", | ||
"code": "123", | ||
"name": "Example Card 2" | ||
} | ||
], | ||
"postgres_example:payment_card": [ | ||
{ | ||
"ccn": 373719391, | ||
"code": 222, | ||
"name": "Example Card 3" | ||
} | ||
] | ||
} | ||
|
||
``` | ||
|
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 |
---|---|---|
|
@@ -87,14 +87,16 @@ db.internal_customer_profile.insert([ | |
}, | ||
{ | ||
"customer_identifiers": { | ||
"internal_id": "cust_002" | ||
"internal_id": "cust_002", | ||
"derived_phone": ["757-499-5508"] | ||
}, | ||
"derived_interests": ["programming", "hiking", "skateboarding"] | ||
}, | ||
{ | ||
"customer_identifiers": { | ||
"internal_id": "cust_003", | ||
"derived_emails": ["[email protected]", "[email protected]"] // Identity within an array field | ||
"derived_emails": ["[email protected]", "[email protected]"], // Identity within an array field | ||
"derived_phone": ["530-486-6983", "254-344-9868"] | ||
}, | ||
"derived_interests": ["interior design", "travel", "photography"] | ||
} | ||
|
@@ -246,6 +248,11 @@ db.customer.insert([ | |
} | ||
]); | ||
|
||
db.rewards.insert([ | ||
{"owner": [{"phone": "530-486-6983", "shopper_name": "janec"}, {"phone": "818-695-1881", "shopper_name": "janec"}], "points": 95, "expiration": Date("2023-01-05")}, | ||
{"owner": [{"phone": "254-344-9868", "shopper_name": "janec"}], "points": 50, "expiration": Date("2023-02-05")}, | ||
{"owner": [{"phone": "304-969-7140", "shopper-name": "timc"}], "points": 3, "expiration": Date("2022-02-05")} | ||
]) | ||
|
||
|
||
db.payment_card.insert([ | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,8 @@ class FidesopsMeta(BaseModel): | |
"""Optionally specify the data type. Fidesops will attempt to cast values to this type when querying.""" | ||
length: Optional[int] | ||
"""Optionally specify the allowable field length. Fidesops will not generate values that exceed this size.""" | ||
return_all_elements: Optional[bool] | ||
"""Optionally specify to query for the entire array if the array is an entrypoint into the node. Default is False.""" | ||
|
||
@validator("data_type") | ||
def valid_data_type(cls, v: Optional[str]) -> Optional[str]: | ||
|
@@ -131,6 +133,19 @@ def valid_data_categories( | |
"""Validate that all annotated data categories exist in the taxonomy""" | ||
return _valid_data_categories(v) | ||
|
||
@validator("fidesops_meta") | ||
def valid_meta(cls, meta_values: Optional[FidesopsMeta]) -> Optional[FidesopsMeta]: | ||
"""Validate upfront that the return_all_elements flag can only be specified on array fields""" | ||
if not meta_values: | ||
return meta_values | ||
|
||
is_array: bool = bool(meta_values.data_type and "[]" in meta_values.data_type) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small nit: I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will change! |
||
if not is_array and meta_values.return_all_elements is not None: | ||
raise ValueError( | ||
"The 'return_all_elements' attribute can only be specified on array fields." | ||
) | ||
return meta_values | ||
|
||
@validator("fields") | ||
def validate_object_fields( | ||
cls, | ||
|
@@ -143,7 +158,7 @@ def validate_object_fields( | |
""" | ||
declared_data_type = None | ||
|
||
if values["fidesops_meta"]: | ||
if values.get("fidesops_meta"): | ||
declared_data_type = values["fidesops_meta"].data_type | ||
|
||
if fields and declared_data_type: | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great description 👍 . Are we better off using yaml notation in the example we give, since that's consistent with the example datasets? ie.
return_all_elements: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good point