Skip to content

[CDTOOL-1187] Add support for the 'mode' parameter when enabling DDoS Protection #796

Open
rcaril wants to merge 3 commits intomainfrom
rcaril/CDTOOL-1187-add-support-for-mode-parameter-for-enabling-ddos
Open

[CDTOOL-1187] Add support for the 'mode' parameter when enabling DDoS Protection #796
rcaril wants to merge 3 commits intomainfrom
rcaril/CDTOOL-1187-add-support-for-mode-parameter-for-enabling-ddos

Conversation

@rcaril
Copy link
Copy Markdown
Contributor

@rcaril rcaril commented Mar 27, 2026

Change summary

This PR adds support for passing the mode parameter when calling the Enable DDOS Protection endpoint. This was previously missing and only available through Update.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

@rcaril rcaril marked this pull request as ready for review March 27, 2026 19:13
@rcaril rcaril requested a review from a team as a code owner March 27, 2026 19:13
@rcaril rcaril requested a review from philippschulte March 27, 2026 19:13
Copy link
Copy Markdown
Member

@philippschulte philippschulte left a comment

Choose a reason for hiding this comment

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

This looks functionally correct, and the added fixtures/tests for explicit mode are good.

My only concern is backward compatibility: changing Enable(...) to require an EnableInput argument is a breaking API change for existing consumers!

// Enable enables the DDoS Protection product on the service.
func Enable(ctx context.Context, c *fastly.Client, serviceID string) (EnableOutput, error) {
return productcore.Put[EnableOutput](ctx, &productcore.PutInput[products.NullInput]{
func Enable(ctx context.Context, c *fastly.Client, serviceID string, i EnableInput) (EnableOutput, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a breaking change for all existing callers, even if they do not care about mode!

In Go there is no function overloading, so current code will stop compiling after upgrading.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, good point. I instead created a new function in 969cd5d which allows a custom input. Enable now still acts the same by relying on the API default for the 'Mode' param - making this a non-breaking change. I have added comments so users are aware of this.

Let me know if this pattern is acceptable.

Reverted the breaking change to the 'Enable' func by maintaining the same "default" mode behavior and creating a new 'EnableWithInput' func which can be used to specify a 'mode'.
@rcaril rcaril requested a review from philippschulte March 27, 2026 19:58
@kpfleming
Copy link
Copy Markdown
Contributor

Given the very low number of users of go-fastly, I think a breaking change would be fine, and preferable to having a separate function. For the future, we should probably standardize on all 'action' functions accepting an input structure even if it is empty, so we can add fields to that structure in the future without a breaking change.

Copy link
Copy Markdown
Member

@philippschulte philippschulte left a comment

Choose a reason for hiding this comment

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

Looks good to me now. Preserving Enable(...) and adding EnableWithInput(...) avoids the breaking API change while still exposing mode. The added tests for explicit mode and verification are great. Thank you!

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.

3 participants