@@ -11,9 +11,9 @@ import (
11
11
// ObjectStorageService is the interface to interact with the object storage endpoints on the Vultr API.
12
12
// Link : https://www.vultr.com/api/#tag/s3
13
13
type ObjectStorageService interface {
14
- Create (ctx context.Context , clusterID int , label string ) (* ObjectStorage , * http.Response , error )
14
+ Create (ctx context.Context , objReq * ObjectStorageReq ) (* ObjectStorage , * http.Response , error )
15
15
Get (ctx context.Context , id string ) (* ObjectStorage , * http.Response , error )
16
- Update (ctx context.Context , id , label string ) error
16
+ Update (ctx context.Context , id string , objReq * ObjectStorageReq ) error
17
17
Delete (ctx context.Context , id string ) error
18
18
List (ctx context.Context , options * ListOptions ) ([]ObjectStorage , * Meta , * http.Response , error )
19
19
@@ -41,6 +41,14 @@ type ObjectStorage struct {
41
41
S3Keys
42
42
}
43
43
44
+ // ObjectStorageReq represents the parameters for creating and updating object
45
+ // storages
46
+ type ObjectStorageReq struct {
47
+ ClusterID int `json:"cluster_id,omitempty"`
48
+ TierID int `json:"tier_id,omitempty"`
49
+ Label string `json:"label"`
50
+ }
51
+
44
52
// S3Keys define your api access to your cluster
45
53
type S3Keys struct {
46
54
S3Hostname string `json:"s3_hostname"`
@@ -95,11 +103,10 @@ type s3KeysBase struct {
95
103
}
96
104
97
105
// Create an object storage subscription
98
- func (o * ObjectStorageServiceHandler ) Create (ctx context.Context , clusterID int , label string ) (* ObjectStorage , * http.Response , error ) {
106
+ func (o * ObjectStorageServiceHandler ) Create (ctx context.Context , objReq * ObjectStorageReq ) (* ObjectStorage , * http.Response , error ) {
99
107
uri := "/v2/object-storage"
100
108
101
- values := RequestBody {"cluster_id" : clusterID , "label" : label }
102
- req , err := o .client .NewRequest (ctx , http .MethodPost , uri , values )
109
+ req , err := o .client .NewRequest (ctx , http .MethodPost , uri , objReq )
103
110
if err != nil {
104
111
return nil , nil , err
105
112
}
@@ -132,11 +139,10 @@ func (o *ObjectStorageServiceHandler) Get(ctx context.Context, id string) (*Obje
132
139
}
133
140
134
141
// Update a Object Storage Subscription.
135
- func (o * ObjectStorageServiceHandler ) Update (ctx context.Context , id , label string ) error {
142
+ func (o * ObjectStorageServiceHandler ) Update (ctx context.Context , id string , objReq * ObjectStorageReq ) error {
136
143
uri := fmt .Sprintf ("/v2/object-storage/%s" , id )
137
144
138
- value := RequestBody {"label" : label }
139
- req , err := o .client .NewRequest (ctx , http .MethodPut , uri , value )
145
+ req , err := o .client .NewRequest (ctx , http .MethodPut , uri , objReq )
140
146
if err != nil {
141
147
return err
142
148
}
0 commit comments