Skip to content

Commit 53847c9

Browse files
Project: Limits Visibility M1 (#738)
* Support Object Storage quota limits visibility (#717) * obj quota * fmt * address comment * Add obj storage quotas integration tests (#732) * add obj storage quotas tests * format --------- Co-authored-by: Ye Chen <127243817+yec-akamai@users.noreply.github.com> --------- Co-authored-by: Youjung Kim <126618609+ykim-akamai@users.noreply.github.com>
1 parent 55f8152 commit 53847c9

9 files changed

+652
-0
lines changed

object_storage_quota.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package linodego
2+
3+
import (
4+
"context"
5+
)
6+
7+
// ObjectStorageQuota represents a Object Storage related quota information on your account.
8+
type ObjectStorageQuota struct {
9+
QuotaID string `json:"quota_id"`
10+
QuotaName string `json:"quota_name"`
11+
EndpointType string `json:"endpoint_type"`
12+
S3Endpoint string `json:"s3_endpoint"`
13+
Description string `json:"description"`
14+
QuotaLimit int `json:"quota_limit"`
15+
ResourceMetric string `json:"resource_metric"`
16+
}
17+
18+
// ObjectStorageQuotaUsage is the usage data for a specific Object Storage related quota on your account.
19+
type ObjectStorageQuotaUsage struct {
20+
QuotaLimit int `json:"quota_limit"`
21+
Usage *int `json:"usage"`
22+
}
23+
24+
// ListObjectStorageQuotas lists the active ObjectStorage-related quotas applied to your account.
25+
// Object Storage Quota related features are under v4beta and may not currently be available to all users.
26+
func (c *Client) ListObjectStorageQuotas(ctx context.Context, opts *ListOptions) ([]ObjectStorageQuota, error) {
27+
return getPaginatedResults[ObjectStorageQuota](ctx, c, formatAPIPath("object-storage/quotas"), opts)
28+
}
29+
30+
// GetObjectStorageQuota gets information about a specific ObjectStorage-related quota on your account.
31+
// Object Storage Quota related features are under v4beta and may not currently be available to all users.
32+
func (c *Client) GetObjectStorageQuota(ctx context.Context, quotaID string) (*ObjectStorageQuota, error) {
33+
e := formatAPIPath("object-storage/quotas/%s", quotaID)
34+
return doGETRequest[ObjectStorageQuota](ctx, c, e)
35+
}
36+
37+
// GetObjectStorageQuotaUsage gets usage data for a specific ObjectStorage Quota resource you can have on your account and the current usage for that resource.
38+
// Object Storage Quota related features are under v4beta and may not currently be available to all users.
39+
func (c *Client) GetObjectStorageQuotaUsage(ctx context.Context, quotaID string) (*ObjectStorageQuotaUsage, error) {
40+
e := formatAPIPath("object-storage/quotas/%s/usage", quotaID)
41+
return doGETRequest[ObjectStorageQuotaUsage](ctx, c, e)
42+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
Accept:
9+
- application/json
10+
Content-Type:
11+
- application/json
12+
User-Agent:
13+
- linodego/dev https://github.com/linode/linodego
14+
url: https://api.linode.com/v4beta/object-storage/quotas/obj-objects-us-ord-1.linodeobjects.com/usage
15+
method: GET
16+
response:
17+
body: '{"quota_limit": 100000000, "usage": 0}'
18+
headers:
19+
Access-Control-Allow-Credentials:
20+
- "true"
21+
Access-Control-Allow-Headers:
22+
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
23+
Access-Control-Allow-Methods:
24+
- HEAD, GET, OPTIONS, POST, PUT, DELETE
25+
Access-Control-Allow-Origin:
26+
- '*'
27+
Access-Control-Expose-Headers:
28+
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
29+
Akamai-Internal-Account:
30+
- '*'
31+
Cache-Control:
32+
- max-age=0, no-cache, no-store
33+
Connection:
34+
- keep-alive
35+
Content-Length:
36+
- "38"
37+
Content-Security-Policy:
38+
- default-src 'none'
39+
Content-Type:
40+
- application/json
41+
Expires:
42+
- Thu, 24 Apr 2025 17:38:48 GMT
43+
Pragma:
44+
- no-cache
45+
Strict-Transport-Security:
46+
- max-age=31536000
47+
Vary:
48+
- Authorization, X-Filter
49+
- Authorization, X-Filter
50+
X-Accepted-Oauth-Scopes:
51+
- object_storage:read_only
52+
X-Content-Type-Options:
53+
- nosniff
54+
X-Frame-Options:
55+
- DENY
56+
- DENY
57+
X-Oauth-Scopes:
58+
- '*'
59+
X-Ratelimit-Limit:
60+
- "1600"
61+
X-Xss-Protection:
62+
- 1; mode=block
63+
status: 200 OK
64+
code: 200
65+
duration: ""
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
Accept:
9+
- application/json
10+
Content-Type:
11+
- application/json
12+
User-Agent:
13+
- linodego/dev https://github.com/linode/linodego
14+
url: https://api.linode.com/v4beta/object-storage/quotas/obj-objects-us-ord-1.linodeobjects.com
15+
method: GET
16+
response:
17+
body: '{"quota_id": "obj-objects-us-ord-1.linodeobjects.com", "quota_name": "max_objects",
18+
"endpoint_type": "E1", "s3_endpoint": "us-ord-1.linodeobjects.com", "description":
19+
"Maximum number of objects this customer is allowed to have on this endpoint",
20+
"quota_limit": 100000000, "resource_metric": "object"}'
21+
headers:
22+
Access-Control-Allow-Credentials:
23+
- "true"
24+
Access-Control-Allow-Headers:
25+
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
26+
Access-Control-Allow-Methods:
27+
- HEAD, GET, OPTIONS, POST, PUT, DELETE
28+
Access-Control-Allow-Origin:
29+
- '*'
30+
Access-Control-Expose-Headers:
31+
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
32+
Akamai-Internal-Account:
33+
- '*'
34+
Cache-Control:
35+
- max-age=0, no-cache, no-store
36+
Connection:
37+
- keep-alive
38+
Content-Length:
39+
- "300"
40+
Content-Security-Policy:
41+
- default-src 'none'
42+
Content-Type:
43+
- application/json
44+
Expires:
45+
- Thu, 24 Apr 2025 17:38:46 GMT
46+
Pragma:
47+
- no-cache
48+
Strict-Transport-Security:
49+
- max-age=31536000
50+
Vary:
51+
- Authorization, X-Filter
52+
- Authorization, X-Filter
53+
X-Accepted-Oauth-Scopes:
54+
- object_storage:read_only
55+
X-Content-Type-Options:
56+
- nosniff
57+
X-Frame-Options:
58+
- DENY
59+
- DENY
60+
X-Oauth-Scopes:
61+
- '*'
62+
X-Ratelimit-Limit:
63+
- "1600"
64+
X-Xss-Protection:
65+
- 1; mode=block
66+
status: 200 OK
67+
code: 200
68+
duration: ""

0 commit comments

Comments
 (0)