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

Device policies #1381

Closed
wrathinmind opened this issue Aug 29, 2023 · 1 comment · Fixed by #1433
Closed

Device policies #1381

wrathinmind opened this issue Aug 29, 2023 · 1 comment · Fixed by #1433
Milestone

Comments

@wrathinmind
Copy link

wrathinmind commented Aug 29, 2023

Current cloudflare-go version

0.75

Description

Could you please add support for getting a list of []DeviceSettingsPolicy in some method like ListDeviceSettingsPolicies into cloudflare-go/devices_policy.go file?

Use cases

currently there's no way to list existing device settings policies, though it's available via https://dash.cloudflare.com/api/v4/accounts/{account_id}/devices/policies

thus it'll be possible to add support of generating tf files for all existing policies, not just by id (e.g in cf-terraforming product)

Potential cloudflare-go usage

Something like

type DeviceSettingsPoliciesResponse struct {
	Response
	Result []DeviceSettingsPolicy `json:"result"`
}

func (api *API) ListDeviceSettingsPolicies(ctx context.Context, accountID string) ([]DeviceSettingsPolicy, error) {
	uri := fmt.Sprintf("/accounts/%s/devices/policies", accountID)

	res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
	if err != nil {
		return []DeviceSettingsPolicy{}, err
	}

	var deviceSettingsPoliciesResponse DeviceSettingsPoliciesResponse
	err = json.Unmarshal(res, &deviceSettingsPoliciesResponse)
	if err != nil {
		return []DeviceSettingsPolicy{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
	}

	return deviceSettingsPoliciesResponse.Result, nil
}

References

No response

@github-actions github-actions bot added this to the v0.81.0 milestone Nov 1, 2023
Copy link
Contributor

This functionality has been released in v0.81.0.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant