-
Notifications
You must be signed in to change notification settings - Fork 618
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
Add Zaraz #1467
Add Zaraz #1467
Conversation
changelog detected ✅ |
cc: @jonnyparris |
zaraz.go
Outdated
"github.com/goccy/go-json" | ||
) | ||
|
||
type ZarazConfig = map[string]interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason why we don't opt for a struct here?
zaraz.go
Outdated
Response | ||
} | ||
|
||
type UpdateZarazConfigParams = map[string]interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a struct to prevent any unknown keys from being pushed into the parameters.
zaraz.go
Outdated
return recordResp, nil | ||
} | ||
|
||
func (api *API) UpdateZarazConfig(ctx context.Context, rc *ResourceContainer, params UpdateZarazConfigParams) (ZarazConfigResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you definitely want UpdateZarazConfigParams
to be typed here otherwise i can put anything in here without type constraints which may lead to API errors.
zaraz.go
Outdated
return response, nil | ||
} | ||
|
||
func (api *API) UpdateZarazWorkflow(ctx context.Context, rc *ResourceContainer, workflowToUpdate string) (ZarazWorkflowResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the third parameter of all methods should be the params
- see https://github.com/cloudflare/cloudflare-go/blob/master/docs/conventions.md#methods for examples.
zaraz.go
Outdated
return response, nil | ||
} | ||
|
||
func (api *API) PublishZarazConfig(ctx context.Context, rc *ResourceContainer, description string) (ZarazPublishResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the third parameter of all methods should be the params - see https://github.com/cloudflare/cloudflare-go/blob/master/docs/conventions.md#methods for examples.
zaraz.go
Outdated
|
||
type ZarazConfigRow struct { | ||
ID int64 `json:"id,omitempty"` | ||
UserId string `json:"usedId,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ID
is usually one of the words we uppercase (UserId
=> UserID
)
zaraz.go
Outdated
return response, nil | ||
} | ||
|
||
func (api *API) GetZarazConfigHistory(ctx context.Context, rc *ResourceContainer, params GetZarazConfigHistoryParams) ([]ZarazConfigRow, *ResultInfo, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally a "fetch all" type of method is prefixed with List
to denote it is capable of returning multiple values - https://github.com/cloudflare/cloudflare-go/blob/master/docs/experimental.md#consistent-crud-method-signatures
Oops! It looks like no changelog entry is attached to this PR. Please include a release note as described in https://github.com/cloudflare/cloudflare-go/blob/master/docs/changelog-process.md. Example:
If you do not require a release note to be included, please add the |
This PR adds support for the Zaraz API
Description
The primary goal is to be able to terraform Zaraz (RM-17254)
The following endpoints need to be covered.
/config
(GET and PUT)/workflow
(GET and PUT)/publish
(POST)/history
(GET)/export
(GET)/default
(GET)Please note that these aren't publicly documented as of today, but the plan is to add that too.
Has your change been tested?
Yes. Added a unit test for every function. The API itself is stable and is used regularly via the dash.
Screenshots (if appropriate):
Types of changes
What sort of change does your code introduce/modify?
Checklist:
and relies on stable APIs.