Skip to content

Commit

Permalink
Merge pull request #13 from ethyca/add-custom-request-field-in-fidesmeta
Browse files Browse the repository at this point in the history
PROD-2486 Add custom_request_field to FidesMeta
  • Loading branch information
erosselli authored Aug 27, 2024
2 parents 627685b + 3440fc2 commit a1a2ac8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
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

0 comments on commit a1a2ac8

Please sign in to comment.