@@ -19,6 +19,9 @@ type ObjectStorageService interface {
19
19
20
20
ListCluster (ctx context.Context , options * ListOptions ) ([]ObjectStorageCluster , * Meta , * http.Response , error )
21
21
RegenerateKeys (ctx context.Context , id string ) (* S3Keys , * http.Response , error )
22
+
23
+ ListTiers (ctx context.Context ) ([]ObjectStorageTier , * http.Response , error )
24
+ ListClusterTiers (ctx context.Context , clusterID int ) ([]ObjectStorageTier , * http.Response , error )
22
25
}
23
26
24
27
// ObjectStorageServiceHandler handles interaction between the object storage service and the Vultr API.
@@ -49,10 +52,26 @@ type S3Keys struct {
49
52
type ObjectStorageCluster struct {
50
53
ID int `json:"id"`
51
54
Region string `json:"region"`
55
+ Name string `json:"name,omitempty"`
52
56
Hostname string `json:"hostname"`
53
57
Deploy string `json:"deploy"`
54
58
}
55
59
60
+ // ObjectStorageTier represents the object storage tier data
61
+ type ObjectStorageTier struct {
62
+ ID int `json:"id"`
63
+ Name string `json:"sales_name"`
64
+ Description string `json:"sales_desc"`
65
+ Price float32 `json:"price"`
66
+ PriceBandwidthGB float32 `json:"bw_gb_price"`
67
+ PriceDiskGB float32 `json:"disk_gb_price"`
68
+ RateLimitBytesSec int `json:"ratelimit_ops_bytes"`
69
+ RateLimitOpsSec int `json:"ratelimit_ops_secs"`
70
+ Default string `json:"is_default"`
71
+ Locations []ObjectStorageCluster `json:"locations,omitempty"`
72
+ Slug string `json:"slug"`
73
+ }
74
+
56
75
type objectStoragesBase struct {
57
76
ObjectStorages []ObjectStorage `json:"object_storages"`
58
77
Meta * Meta `json:"meta"`
@@ -67,6 +86,10 @@ type objectStorageClustersBase struct {
67
86
Meta * Meta `json:"meta"`
68
87
}
69
88
89
+ type objectStorageTiersBase struct {
90
+ Tiers []ObjectStorageTier `json:"tiers"`
91
+ }
92
+
70
93
type s3KeysBase struct {
71
94
S3Credentials * S3Keys `json:"s3_credentials"`
72
95
}
@@ -195,3 +218,37 @@ func (o *ObjectStorageServiceHandler) RegenerateKeys(ctx context.Context, id str
195
218
196
219
return s3Keys .S3Credentials , resp , nil
197
220
}
221
+
222
+ // ListTiers retrieves all tiers for object storage deployments
223
+ func (o * ObjectStorageServiceHandler ) ListTiers (ctx context.Context ) ([]ObjectStorageTier , * http.Response , error ) {
224
+ uri := "/v2/object-storage/tiers"
225
+ req , err := o .client .NewRequest (ctx , http .MethodGet , uri , nil )
226
+ if err != nil {
227
+ return nil , nil , err
228
+ }
229
+
230
+ tiers := new (objectStorageTiersBase )
231
+ resp , err := o .client .DoWithContext (ctx , req , tiers )
232
+ if err != nil {
233
+ return nil , resp , err
234
+ }
235
+
236
+ return tiers .Tiers , resp , nil
237
+ }
238
+
239
+ // ListClusterTiers retrieves all tiers for object storage deployments on a specific cluster
240
+ func (o * ObjectStorageServiceHandler ) ListClusterTiers (ctx context.Context , clusterID int ) ([]ObjectStorageTier , * http.Response , error ) {
241
+ uri := fmt .Sprintf ("/v2/object-storage/clusters/%d/tiers" , clusterID )
242
+ req , err := o .client .NewRequest (ctx , http .MethodGet , uri , nil )
243
+ if err != nil {
244
+ return nil , nil , err
245
+ }
246
+
247
+ tiers := new (objectStorageTiersBase )
248
+ resp , err := o .client .DoWithContext (ctx , req , tiers )
249
+ if err != nil {
250
+ return nil , resp , err
251
+ }
252
+
253
+ return tiers .Tiers , resp , nil
254
+ }
0 commit comments