Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
42 changes: 42 additions & 0 deletions object_storage_quota.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package linodego

import (
"context"
)

// ObjectStorageQuota represents a Object Storage related quota information on your account.
type ObjectStorageQuota struct {
QuotaID string `json:"quota_id"`
QuotaName string `json:"quota_name"`
EndpointType string `json:"endpoint_type"`
S3Endpoint string `json:"s3_endpoint"`
Description string `json:"description"`
QuotaLimit int `json:"quota_limit"`
ResourceMetric string `json:"resource_metric"`
}

// ObjectStorageQuotaUsage is the usage data for a specific Object Storage related quota on your account.
type ObjectStorageQuotaUsage struct {
QuotaLimit int `json:"quota_limit"`
Usage *int `json:"usage"`
}

// ListObjectStorageQuotas lists the active ObjectStorage-related quotas applied to your account.
// Object Storage Quota related features are under v4beta and may not currently be available to all users.
func (c *Client) ListObjectStorageQuotas(ctx context.Context, opts *ListOptions) ([]ObjectStorageQuota, error) {
return getPaginatedResults[ObjectStorageQuota](ctx, c, formatAPIPath("object-storage/quotas"), opts)
}

// GetObjectStorageQuota gets information about a specific ObjectStorage-related quota on your account.
// Object Storage Quota related features are under v4beta and may not currently be available to all users.
func (c *Client) GetObjectStorageQuota(ctx context.Context, quotaID string) (*ObjectStorageQuota, error) {
e := formatAPIPath("object-storage/quotas/%s", quotaID)
return doGETRequest[ObjectStorageQuota](ctx, c, e)
}

// GetObjectStorageQuotaUsage gets usage data for a specific ObjectStorage Quota resource you can have on your account and the current usage for that resource.
// Object Storage Quota related features are under v4beta and may not currently be available to all users.
func (c *Client) GetObjectStorageQuotaUsage(ctx context.Context, quotaID string) (*ObjectStorageQuotaUsage, error) {
e := formatAPIPath("object-storage/quotas/%s/usage", quotaID)
return doGETRequest[ObjectStorageQuotaUsage](ctx, c, e)
}
65 changes: 65 additions & 0 deletions test/integration/fixtures/TestObjectStorageQuotaUsage_Get.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/quotas/obj-objects-us-ord-1.linodeobjects.com/usage
method: GET
response:
body: '{"quota_limit": 100000000, "usage": 0}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
Access-Control-Allow-Methods:
- HEAD, GET, OPTIONS, POST, PUT, DELETE
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Akamai-Internal-Account:
- '*'
Cache-Control:
- max-age=0, no-cache, no-store
Connection:
- keep-alive
Content-Length:
- "38"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Expires:
- Thu, 24 Apr 2025 17:38:48 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- object_storage:read_only
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1600"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
68 changes: 68 additions & 0 deletions test/integration/fixtures/TestObjectStorageQuotas_Get.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/quotas/obj-objects-us-ord-1.linodeobjects.com
method: GET
response:
body: '{"quota_id": "obj-objects-us-ord-1.linodeobjects.com", "quota_name": "max_objects",
"endpoint_type": "E1", "s3_endpoint": "us-ord-1.linodeobjects.com", "description":
"Maximum number of objects this customer is allowed to have on this endpoint",
"quota_limit": 100000000, "resource_metric": "object"}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
Access-Control-Allow-Methods:
- HEAD, GET, OPTIONS, POST, PUT, DELETE
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Akamai-Internal-Account:
- '*'
Cache-Control:
- max-age=0, no-cache, no-store
Connection:
- keep-alive
Content-Length:
- "300"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Expires:
- Thu, 24 Apr 2025 17:38:46 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- object_storage:read_only
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1600"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
Loading