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

new: Support available for AccountAvailability #491

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions account_availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import (
"github.com/go-resty/resty/v2"
)

// AccountAvailability returns the resources information in a region which are NOT available to an account.
// AccountAvailability returns the resources availability in a region to an account.
type AccountAvailability struct {
// region id
Region string `json:"region"`

// the unavailable resources in a region to the customer
Unavailable []string `json:"unavailable"`

// the available resources in a region to the customer
Available []string `json:"available"`
}

// AccountAvailabilityPagedResponse represents a paginated Account Availability API response
Expand All @@ -38,7 +41,7 @@ func (resp *AccountAvailabilityPagedResponse) castResult(r *resty.Request, e str
return castedRes.Pages, castedRes.Results, nil
}

// ListAccountAvailabilities lists all available regions and the resources which are NOT available to the account.
// ListAccountAvailabilities lists all regions and the resource availabilities to the account.
func (c *Client) ListAccountAvailabilities(ctx context.Context, opts *ListOptions) ([]AccountAvailability, error) {
response := AccountAvailabilityPagedResponse{}
err := c.listHelper(ctx, &response, opts)
Expand All @@ -48,7 +51,7 @@ func (c *Client) ListAccountAvailabilities(ctx context.Context, opts *ListOption
return response.Data, nil
}

// GetAccountAvailability gets the unavailable resources in a region to the customer.
// GetAccountAvailability gets the resources availability in a region to the customer.
func (c *Client) GetAccountAvailability(ctx context.Context, regionID string) (*AccountAvailability, error) {
req := c.R(ctx).SetResult(&AccountAvailability{})
regionID = url.PathEscape(regionID)
Expand Down
3 changes: 1 addition & 2 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,12 @@ golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o=
google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc h1:8DyZCyvI8mE1IdLy/60bS+52xfymkE72wv1asokgtao=
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:xZnkP7mREFX5MORlOPEzLMr+90PPZQ2QWzrVTWfAq64=
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM=
Expand Down
9 changes: 6 additions & 3 deletions test/integration/fixtures/TestAccountAvailability_Get.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ interactions:
url: https://api.linode.com/v4beta/account/availability/us-east
method: GET
response:
body: '{"region": "us-east", "unavailable": []}'
body: '{"region": "us-east", "available": ["Linodes", "NodeBalancers", "Block
Storage", "Kubernetes"], "unavailable": []}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -29,8 +30,10 @@ interactions:
Cache-Control:
- private, max-age=0, s-maxage=0, no-cache, no-store
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "40"
- "114"
Content-Security-Policy:
- default-src 'none'
Content-Type:
Expand All @@ -52,7 +55,7 @@ interactions:
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1200"
- "400"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand Down
32 changes: 23 additions & 9 deletions test/integration/fixtures/TestAccountAvailability_List.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@ interactions:
url: https://api.linode.com/v4beta/account/availability
method: GET
response:
body: '{"data": [{"region": "ap-west", "unavailable": []}, {"region": "ca-central",
"unavailable": []}, {"region": "ap-southeast", "unavailable": []}, {"region":
"us-central", "unavailable": []}, {"region": "us-west", "unavailable": []},
{"region": "us-southeast", "unavailable": []}, {"region": "us-east", "unavailable":
[]}, {"region": "eu-west", "unavailable": []}, {"region": "ap-south", "unavailable":
[]}, {"region": "eu-central", "unavailable": []}, {"region": "ap-northeast",
"unavailable": []}], "page": 1, "pages": 1, "results": 11}'
body: '{"data": [{"region": "us-central", "available": ["Linodes", "NodeBalancers",
"Block Storage", "Kubernetes"], "unavailable": []}, {"region": "us-west", "available":
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
[]}, {"region": "us-southeast", "available": ["Linodes", "NodeBalancers", "Block
Storage", "Kubernetes"], "unavailable": []}, {"region": "us-east", "available":
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
[]}, {"region": "eu-west", "available": ["Linodes", "NodeBalancers", "Block
Storage", "Kubernetes"], "unavailable": []}, {"region": "ap-south", "available":
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
[]}, {"region": "eu-central", "available": ["Linodes", "NodeBalancers", "Block
Storage", "Kubernetes"], "unavailable": []}, {"region": "ap-northeast", "available":
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
[]}, {"region": "ap-west", "available": ["Linodes", "NodeBalancers", "Block
Storage", "Kubernetes"], "unavailable": []}, {"region": "ca-central", "available":
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
[]}, {"region": "ap-southeast", "available": ["Linodes", "NodeBalancers", "Block
Storage", "Kubernetes"], "unavailable": []}], "page": 1, "pages": 1, "results":
11}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -35,6 +46,10 @@ interactions:
Cache-Control:
- private, max-age=0, s-maxage=0, no-cache, no-store
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "1349"
Content-Security-Policy:
- default-src 'none'
Content-Type:
Expand All @@ -44,7 +59,6 @@ interactions:
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
- Authorization, X-Filter
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
Expand All @@ -57,7 +71,7 @@ interactions:
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1200"
- "400"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand Down