Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@uzaxirr
Copy link
Contributor

@uzaxirr uzaxirr commented Jun 4, 2025

No description provided.

@uzaxirr uzaxirr self-assigned this Jun 4, 2025
func (c *Client) UpdateInstanceAllowedIPs(id string, allowedIPs []string) (*SimpleResponse, error) {
resp, err := c.SendPutRequest(fmt.Sprintf("/v2/instances/%s/allowed_ips", id), allowedIPs)
// Create a map to match the expected JSON structure
payload := map[string][]string{

Choose a reason for hiding this comment

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

why the payload is a generic map instead of a struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

beacuse the API expects it in this format.

{"Message":{"code":"invalid_request_body","reason":"Invalid request body","details":"Field  should be of type map[string]interface {}, but array was provided"},"status":400}

above is the error i get from the SDK before modification.

// UpdateInstanceBandwidth sets the list of IP addresses that an instance is allowed to use
func (c *Client) UpdateInstanceBandwidth(id string, bandwidthLimit int) (*SimpleResponse, error) {
resp, err := c.SendPutRequest(fmt.Sprintf("/v2/instances/%s/network_bandwidth_limit", id), bandwidthLimit)
payload := map[string]int{

Choose a reason for hiding this comment

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

same as above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yess

@alessandroargentieri alessandroargentieri merged commit bd68579 into master Jun 4, 2025
16 checks passed
@uzaxirr uzaxirr deleted the allowed-pis-instance branch June 4, 2025 08:59
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