From e1713969bc84e21f03dccb320ccfcfc84999dd03 Mon Sep 17 00:00:00 2001 From: Eliana Rosselli Date: Wed, 21 Aug 2024 11:28:32 -0300 Subject: [PATCH 1/2] Add custom_request_field to FidesMeta --- src/fideslang/models.py | 4 ++++ tests/fideslang/test_validation.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/fideslang/models.py b/src/fideslang/models.py index 92626a8..f254d3f 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -402,6 +402,10 @@ class FidesMeta(BaseModel): default=None, description="Optionally specify if a field is read-only, meaning it can't be updated or deleted.", ) + custom_request_field: Optional[str] = Field( + default=None, + description="Optionally specify that a field may be used as a custom request field in DSRs. The value is the name of the field in the DSR.", + ) @field_validator("data_type") @classmethod diff --git a/tests/fideslang/test_validation.py b/tests/fideslang/test_validation.py index 698d983..0de6c7f 100644 --- a/tests/fideslang/test_validation.py +++ b/tests/fideslang/test_validation.py @@ -625,6 +625,26 @@ def test_specify_fides_meta_directly(self): read_only=None, ) + def test_specify_fides_meta_with_custom_request_field(self): + """fidesops_meta copied to fides_meta""" + field = DatasetField( + name="test_field", + fides_meta={"custom_request_field": "site_id", "primary_key": False}, + fields=[], + ) + + assert not hasattr(field, "fidesops_meta") + assert field.fides_meta == FidesMeta( + references=None, + identity=None, + primary_key=False, + data_type=None, + length=None, + return_all_elements=None, + read_only=None, + custom_request_field="site_id" + ) + def test_specify_both_fidesops_meta_and_fides_meta(self): """fidesops_meta copied to fides_meta - fides_meta field takes priority""" field = DatasetField( From 3440fc2e342b8d1e72f6094f6c29027a708a957b Mon Sep 17 00:00:00 2001 From: Eliana Rosselli Date: Tue, 27 Aug 2024 15:35:52 -0300 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20a81fb..3379b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ The types of changes are: - `Security` in case of vulnerabilities. ## [Unreleased](https://github.com/ethyca/fideslang/compare/3.0.2...main) - +- Add custom_request_field to FidesMeta [#13](https://github.com/ethyca/fideslang/pull/13) ## [3.0.2](https://github.com/ethyca/fideslang/compare/3.0.1...3.0.2)