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

GATE-1703 team rules + accounts + config api #693

Merged
merged 2 commits into from
Aug 18, 2021

Conversation

rexscaria
Copy link
Contributor

The pr has newly publicized Teams api for rules + account config

Description

This is the new teams rules api.

Has your change been tested?

Explain how the change has been tested and what you ran to confirm your
change affects other parts of the code. Automated tests are generally
expected and changes without tests should explain why they aren't
required.

Types of changes

Mew features- Teams rules + accounts api

teams_accounts.go Show resolved Hide resolved
teams_rules.go Outdated Show resolved Hide resolved
@rexscaria rexscaria force-pushed the rex/GATE-1703-teams-api branch 2 times, most recently from f703fff to 1f82abf Compare August 12, 2021 14:56
teams_rules.go Outdated Show resolved Hide resolved
teams_accounts.go Outdated Show resolved Hide resolved
teams_accounts.go Outdated Show resolved Hide resolved
Comment on lines 13 to 15
GatewayID string `json:"gateway_tag"` // Internal teams ID
ProviderName string `json:"provider_name"` // Auth provider
CloudflareID string `json:"id"` // cloudflare account ID
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
GatewayID string `json:"gateway_tag"` // Internal teams ID
ProviderName string `json:"provider_name"` // Auth provider
CloudflareID string `json:"id"` // cloudflare account ID
GatewayTag string `json:"gateway_tag"` // Internal teams ID
ProviderName string `json:"provider_name"` // Auth provider
ID string `json:"id"` // cloudflare account ID

is there a reason the struct field is different to the JSON tag? generally we've used a 1:1 for simplicity and reduce confusion between the API and the SDK counterpart.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I changed the variable names to give a little more readability to the user. The original struct json tags we use in the API are confusing.

Copy link
Member

Choose a reason for hiding this comment

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

i agree it can be confusing here, but i think we need to go one way or another as right now it's in limbo and hard to grok if you don't know the reasoning. i think we should rename the fields to match the JSON to avoid further confusion especially seeing how the API docs reference the JSON tags.

teams_rules.go Outdated Show resolved Hide resolved
teams_rules.go Outdated
BISOAdminControls *TeamsBISOAdminControlSettings `json:"biso_admin_controls"`
}

// TeamsL4OverrideSettings : only used in l4 filter type rule with action set to override
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// TeamsL4OverrideSettings : only used in l4 filter type rule with action set to override
// TeamsL4OverrideSettings used in l4 filter type rule with action set to override.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

@rexscaria rexscaria force-pushed the rex/GATE-1703-teams-api branch 2 times, most recently from f92e554 to 5cb6d3e Compare August 16, 2021 17:54
@rexscaria
Copy link
Contributor Author

@jacobbednarz : i have resolved all the comments. Thanks

teams_rules.go Outdated
Comment on lines 101 to 107
UUID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Precedence uint64 `json:"precedence"`
Enabled bool `json:"enabled"`
Action TeamsGatewayAction `json:"action"`
Settings TeamsRuleSettings `json:"rule_settings,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
UUID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Precedence uint64 `json:"precedence"`
Enabled bool `json:"enabled"`
Action TeamsGatewayAction `json:"action"`
Settings TeamsRuleSettings `json:"rule_settings,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Precedence uint64 `json:"precedence"`
Enabled bool `json:"enabled"`
Action TeamsGatewayAction `json:"action"`
RuleSettings TeamsRuleSettings `json:"rule_settings,omitempty"`

these should also match the JSON tag names

teams_rules.go Outdated
Traffic string `json:"traffic"`
Identity string `json:"identity"`
Version uint64 `json:"version"`
Settings TeamsRuleSettings `json:"rule_settings,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Settings TeamsRuleSettings `json:"rule_settings,omitempty"`
RuleSettings TeamsRuleSettings `json:"rule_settings,omitempty"`

//
// API reference: https://api.cloudflare.com/#teams-rules-properties
func (api *API) TeamsRule(ctx context.Context, accountID string, ruleId string, ) (TeamsRule, error) {
uri := fmt.Sprintf("/accounts/%s/gateway/rules/%s", accountID, ruleId)
Copy link
Member

Choose a reason for hiding this comment

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

looking between the API and this PR, we've got a difference in how the rule ID is stored and retrieved.

in the API (the RESTful route), we want a hash style value, however on the resource itself it is a UUIDv4 value. this is very confusing and will make handling this in Terraform/cf-terraforming very painful as the identifier is used as an anchor for subsequent API calls. ideally, we decide on one and continue with it to avoid extra work going forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns we have new change in api, that accepts uuid with dashes. I have updated the comment. Resolving this.

@rexscaria rexscaria force-pushed the rex/GATE-1703-teams-api branch from 5cb6d3e to cc8a68b Compare August 17, 2021 19:50
@rexscaria
Copy link
Contributor Author

I have made all the json tags match variable names.

@rexscaria rexscaria force-pushed the rex/GATE-1703-teams-api branch from cc8a68b to 03129da Compare August 17, 2021 19:52
@jacobbednarz jacobbednarz force-pushed the rex/GATE-1703-teams-api branch from 28995eb to 44b952d Compare August 18, 2021 22:55
@jacobbednarz jacobbednarz merged commit c26ab13 into cloudflare:master Aug 18, 2021
@jacobbednarz
Copy link
Member

thanks @rexscaria, this is awesome! when the public documentation links are available we can get those updated.

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