Skip to content

pass layer & id to https_rule update call #213

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

Merged
merged 9 commits into from
May 29, 2025

Conversation

phkrl
Copy link
Contributor

@phkrl phkrl commented Apr 4, 2025

Currently, https rule update does not pass rule id & rule layer to api call, thus resulting in errors, since these fields are mandatory. This patch fixes issue, explicitly adding uid and layer fields to the structure passed to api.

@phkrl phkrl changed the title pass layer & id to update call pass layer & id to https_rule update call Apr 5, 2025
@chkp-royl
Copy link
Contributor

Hi @phkrl ,

Thanks for your PR.
I understand the issue and I have few comments:

  1. API payload should get name or uid fields and currently both of them can be set.
  2. There is no 'new-layer' field in 'set-https-rule' API request. Only 'layer' field should be used.

Thanks,
Roy

@phkrl
Copy link
Contributor Author

phkrl commented Apr 7, 2025

Hi @chkp-royl,

1. API payload should get name or uid fields and currently both of them can be set.

This statement contradicts the issue we encountered: we explicitly set name field for each rule but still got error claiming that uid is required. It was only after this patch when we could update our existing https rules.

2. There is no 'new-layer' field in 'set-https-rule' API request. Only 'layer' field should be used.

Fixed in latest commit.

@chkp-royl
Copy link
Contributor

This might happen if both rules had the same name so we can identify them only by uid.

  1. Need to set layer anyway regardless if was changed, you can do it with d.Get("layer") after you handle with the uid.
  2. If name was changed, just add "new-name" to the request because we don't want to have both name and uid.

@phkrl
Copy link
Contributor Author

phkrl commented Apr 7, 2025

This might happen if both rules had the same name so we can identify them only by uid.

We have unique rule names. They are keys of map in our module.

1. Need to set layer anyway regardless if was changed, you can do it with d.Get("layer") after you handle with the uid.

I believe, this block should set layer both if it was changed and if it wasn't. Is my assumption wrong?

2. If name was changed, just add "new-name" to the request because we don't want to have both name and uid.

Do you mean, i should pass only "new-name" field, without setting "name" at all, since "uid" is passed unconditionally?

@chkp-royl
Copy link
Contributor

chkp-royl commented Apr 7, 2025

I believe, this block should set layer both if it was changed and if it wasn't. Is my assumption wrong?

The check of HasChange is irrelevant now. We can set layer anyway just like you did with the uid.

Do you mean, i should pass only "new-name" field, without setting "name" at all, since "uid" is passed unconditionally?

yes

@phkrl
Copy link
Contributor Author

phkrl commented Apr 7, 2025

Fixed both

@phkrl
Copy link
Contributor Author

phkrl commented Apr 7, 2025

Added one more commit to fix destroy issue. Otherwise the error states that ignore-errors is unrecognized parameter.

@chkp-royl
Copy link
Contributor

Fixed both

Looks better now.
For 'new-name' field you can use d.Get("name") instead because we don't use old value.
Move 'layer' to be right after set uid.

Added one more commit to fix destroy issue. Otherwise the error states that ignore-errors is unrecognized parameter.

Alright.

@phkrl
Copy link
Contributor Author

phkrl commented Apr 8, 2025

Looks better now. For 'new-name' field you can use d.Get("name") instead because we don't use old value. Move 'layer' to be right after set uid.

Applied both.

@chkp-royl
Copy link
Contributor

Thanks for the effort. Merged.

@chkp-royl chkp-royl merged commit d26fcf8 into CheckPointSW:master May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants