Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROD-2486 Add custom_request_field to FidesMeta #13

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions src/fideslang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions tests/fideslang/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading