Skip to content

Commit be75a51

Browse files
authored
new: Support available for AccountAvailability (#491)
* add available * update fixture
1 parent 4eb5658 commit be75a51

File tree

4 files changed

+72
-27
lines changed

4 files changed

+72
-27
lines changed

account_availability.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import (
88
"github.com/go-resty/resty/v2"
99
)
1010

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

1616
// the unavailable resources in a region to the customer
1717
Unavailable []string `json:"unavailable"`
18+
19+
// the available resources in a region to the customer
20+
Available []string `json:"available"`
1821
}
1922

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

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

51-
// GetAccountAvailability gets the unavailable resources in a region to the customer.
54+
// GetAccountAvailability gets the resources availability in a region to the customer.
5255
func (c *Client) GetAccountAvailability(ctx context.Context, regionID string) (*AccountAvailability, error) {
5356
req := c.R(ctx).SetResult(&AccountAvailability{})
5457
regionID = url.PathEscape(regionID)

go.work.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,12 @@ golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5h
206206
golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
207207
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
208208
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
209-
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
210-
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
211209
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
212210
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
213211
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
214212
google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o=
215213
google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw=
214+
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
216215
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc h1:8DyZCyvI8mE1IdLy/60bS+52xfymkE72wv1asokgtao=
217216
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:xZnkP7mREFX5MORlOPEzLMr+90PPZQ2QWzrVTWfAq64=
218217
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM=

test/integration/fixtures/TestAccountAvailability_Get.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ interactions:
1414
url: https://api.linode.com/v4beta/account/availability/us-east
1515
method: GET
1616
response:
17-
body: '{"region": "us-east", "unavailable": []}'
17+
body: '{"region": "us-east", "available": ["Linodes", "NodeBalancers", "Block
18+
Storage", "Kubernetes"], "unavailable": []}'
1819
headers:
1920
Access-Control-Allow-Credentials:
2021
- "true"
@@ -27,16 +28,19 @@ interactions:
2728
Access-Control-Expose-Headers:
2829
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
2930
Cache-Control:
30-
- private, max-age=0, s-maxage=0, no-cache, no-store
31-
- private, max-age=60, s-maxage=60
31+
- max-age=0, no-cache, no-store
32+
Connection:
33+
- keep-alive
3234
Content-Length:
33-
- "40"
35+
- "114"
3436
Content-Security-Policy:
3537
- default-src 'none'
3638
Content-Type:
3739
- application/json
38-
Server:
39-
- nginx
40+
Expires:
41+
- Tue, 16 Apr 2024 20:58:13 GMT
42+
Pragma:
43+
- no-cache
4044
Strict-Transport-Security:
4145
- max-age=31536000
4246
Vary:
@@ -50,9 +54,12 @@ interactions:
5054
- DENY
5155
- DENY
5256
X-Oauth-Scopes:
53-
- '*'
57+
- account:read_write databases:read_write domains:read_write events:read_write
58+
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
59+
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
60+
volumes:read_write vpc:read_write
5461
X-Ratelimit-Limit:
55-
- "1200"
62+
- "400"
5663
X-Xss-Protection:
5764
- 1; mode=block
5865
status: 200 OK

test/integration/fixtures/TestAccountAvailability_List.yaml

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,43 @@ interactions:
1414
url: https://api.linode.com/v4beta/account/availability
1515
method: GET
1616
response:
17-
body: '{"data": [{"region": "ap-west", "unavailable": []}, {"region": "ca-central",
18-
"unavailable": []}, {"region": "ap-southeast", "unavailable": []}, {"region":
19-
"us-central", "unavailable": []}, {"region": "us-west", "unavailable": []},
20-
{"region": "us-southeast", "unavailable": []}, {"region": "us-east", "unavailable":
21-
[]}, {"region": "eu-west", "unavailable": []}, {"region": "ap-south", "unavailable":
22-
[]}, {"region": "eu-central", "unavailable": []}, {"region": "ap-northeast",
23-
"unavailable": []}], "page": 1, "pages": 1, "results": 11}'
17+
body: '{"data": [{"region": "us-central", "available": ["Linodes", "NodeBalancers",
18+
"Block Storage", "Kubernetes"], "unavailable": []}, {"region": "us-west", "available":
19+
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
20+
[]}, {"region": "us-southeast", "available": ["Linodes", "NodeBalancers", "Block
21+
Storage", "Kubernetes"], "unavailable": []}, {"region": "us-east", "available":
22+
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
23+
[]}, {"region": "eu-west", "available": ["Linodes", "NodeBalancers", "Block
24+
Storage", "Kubernetes"], "unavailable": []}, {"region": "ap-south", "available":
25+
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
26+
[]}, {"region": "eu-central", "available": ["Linodes", "NodeBalancers", "Block
27+
Storage", "Kubernetes"], "unavailable": []}, {"region": "ap-northeast", "available":
28+
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
29+
[]}, {"region": "ap-west", "available": ["Linodes", "NodeBalancers", "Block
30+
Storage", "Kubernetes"], "unavailable": []}, {"region": "ca-central", "available":
31+
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
32+
[]}, {"region": "ap-southeast", "available": ["Linodes", "NodeBalancers", "Block
33+
Storage", "Kubernetes"], "unavailable": []}, {"region": "us-iad", "available":
34+
["Linodes", "NodeBalancers", "Block Storage"], "unavailable": ["Kubernetes"]},
35+
{"region": "us-ord", "available": ["Linodes", "NodeBalancers", "Block Storage",
36+
"Kubernetes"], "unavailable": []}, {"region": "fr-par", "available": ["Linodes",
37+
"NodeBalancers", "Block Storage", "Kubernetes"], "unavailable": []}, {"region":
38+
"us-sea", "available": ["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"],
39+
"unavailable": []}, {"region": "br-gru", "available": ["Linodes", "NodeBalancers",
40+
"Block Storage", "Kubernetes"], "unavailable": []}, {"region": "nl-ams", "available":
41+
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
42+
[]}, {"region": "se-sto", "available": ["Linodes", "NodeBalancers", "Block Storage",
43+
"Kubernetes"], "unavailable": []}, {"region": "es-mad", "available": ["Linodes",
44+
"NodeBalancers", "Block Storage", "Kubernetes"], "unavailable": []}, {"region":
45+
"in-maa", "available": ["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"],
46+
"unavailable": []}, {"region": "jp-osa", "available": ["Linodes", "NodeBalancers",
47+
"Block Storage", "Kubernetes"], "unavailable": []}, {"region": "it-mil", "available":
48+
["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"], "unavailable":
49+
[]}, {"region": "us-mia", "available": ["Linodes", "NodeBalancers", "Block Storage",
50+
"Kubernetes"], "unavailable": []}, {"region": "id-cgk", "available": ["Linodes",
51+
"NodeBalancers", "Block Storage", "Kubernetes"], "unavailable": []}, {"region":
52+
"us-lax", "available": ["Linodes", "NodeBalancers", "Block Storage", "Kubernetes"],
53+
"unavailable": []}], "page": 1, "pages": 1, "results": 25}'
2454
headers:
2555
Access-Control-Allow-Credentials:
2656
- "true"
@@ -33,20 +63,23 @@ interactions:
3363
Access-Control-Expose-Headers:
3464
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
3565
Cache-Control:
36-
- private, max-age=0, s-maxage=0, no-cache, no-store
37-
- private, max-age=60, s-maxage=60
66+
- max-age=0, no-cache, no-store
67+
Connection:
68+
- keep-alive
3869
Content-Security-Policy:
3970
- default-src 'none'
4071
Content-Type:
4172
- application/json
42-
Server:
43-
- nginx
73+
Expires:
74+
- Tue, 16 Apr 2024 20:58:12 GMT
75+
Pragma:
76+
- no-cache
4477
Strict-Transport-Security:
4578
- max-age=31536000
4679
Vary:
47-
- Accept-Encoding
4880
- Authorization, X-Filter
4981
- Authorization, X-Filter
82+
- Accept-Encoding
5083
X-Accepted-Oauth-Scopes:
5184
- account:read_only
5285
X-Content-Type-Options:
@@ -55,9 +88,12 @@ interactions:
5588
- DENY
5689
- DENY
5790
X-Oauth-Scopes:
58-
- '*'
91+
- account:read_write databases:read_write domains:read_write events:read_write
92+
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
93+
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
94+
volumes:read_write vpc:read_write
5995
X-Ratelimit-Limit:
60-
- "1200"
96+
- "400"
6197
X-Xss-Protection:
6298
- 1; mode=block
6399
status: 200 OK

0 commit comments

Comments
 (0)