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

Fix parameter_sensitivities checking the values instead of the keys #357

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 5 additions & 4 deletions nipyapi/nifi/models/parameter_group_configuration_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ def parameter_sensitivities(self, parameter_sensitivities):
:param parameter_sensitivities: The parameter_sensitivities of this ParameterGroupConfigurationEntity.
:type: dict(str, str)
"""
allowed_values = ["SENSITIVE", "NON_SENSITIVE"]
if not set(parameter_sensitivities.keys()).issubset(set(allowed_values)):
# Added None, since that's what NiFi returns when the value is not yet set
allowed_values = ["SENSITIVE", "NON_SENSITIVE", None]
if not set(parameter_sensitivities.values()).issubset(set(allowed_values)):
raise ValueError(
"Invalid keys in `parameter_sensitivities` [{0}], must be a subset of [{1}]"
.format(", ".join(map(str, set(parameter_sensitivities.keys())-set(allowed_values))),
"Invalid values in `parameter_sensitivities` [{0}], must be a subset of [{1}]"
.format(", ".join(map(str, set(parameter_sensitivities.values())-set(allowed_values))),
", ".join(map(str, allowed_values)))
)

Expand Down
6 changes: 3 additions & 3 deletions resources/client_gen/swagger_templates/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class {{classname}}(object):
)
{{/isListContainer}}
{{#isMapContainer}}
if not set({{{name}}}.keys()).issubset(set(allowed_values)):
if not set({{{name}}}.values()).issubset(set(allowed_values)):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this have an or None to satisfy the response from NiFi without breaking the codebase?

raise ValueError(
"Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]"
.format(", ".join(map(str, set({{{name}}}.keys())-set(allowed_values))),
"Invalid values in `{{{name}}}` [{0}], must be a subset of [{1}]"
.format(", ".join(map(str, set({{{name}}}.values())-set(allowed_values))),
", ".join(map(str, allowed_values)))
)
{{/isMapContainer}}
Expand Down