@@ -13,8 +13,17 @@ import (
13
13
14
14
// ObjectStorageBucket represents a ObjectStorage object
15
15
type ObjectStorageBucket struct {
16
- Label string `json:"label"`
16
+ Label string `json:"label"`
17
+
18
+ // Deprecated: The 'Cluster' field has been deprecated in favor of the 'Region' field.
19
+ // For example, a Cluster value of `us-mia-1` will translate to a Region value of `us-mia`.
20
+ //
21
+ // This is necessary because there are now multiple Object Storage clusters to a region.
22
+ //
23
+ // NOTE: The 'Cluster' field will always return a value similar to `<REGION>-1` (e.g., `us-mia-1`)
24
+ // for backward compatibility purposes.
17
25
Cluster string `json:"cluster"`
26
+ Region string `json:"region"`
18
27
19
28
Created * time.Time `json:"-"`
20
29
Hostname string `json:"hostname"`
@@ -50,8 +59,15 @@ func (i *ObjectStorageBucket) UnmarshalJSON(b []byte) error {
50
59
51
60
// ObjectStorageBucketCreateOptions fields are those accepted by CreateObjectStorageBucket
52
61
type ObjectStorageBucketCreateOptions struct {
53
- Cluster string `json:"cluster"`
54
- Label string `json:"label"`
62
+ // Deprecated: The 'Cluster' field has been deprecated.
63
+ //
64
+ // Going forward, the 'Region' field will be the supported way to designate where an
65
+ // Object Storage Bucket should be created. For example, a 'Cluster' value of `us-mia-1`
66
+ // will translate to a Region value of `us-mia`.
67
+ Cluster string `json:"cluster,omitempty"`
68
+ Region string `json:"region,omitempty"`
69
+
70
+ Label string `json:"label"`
55
71
56
72
ACL ObjectStorageACL `json:"acl,omitempty"`
57
73
CorsEnabled * bool `json:"cors_enabled,omitempty"`
@@ -110,20 +126,20 @@ func (c *Client) ListObjectStorageBuckets(ctx context.Context, opts *ListOptions
110
126
}
111
127
112
128
// ListObjectStorageBucketsInCluster lists all ObjectStorageBuckets of a cluster
113
- func (c * Client ) ListObjectStorageBucketsInCluster (ctx context.Context , opts * ListOptions , clusterID string ) ([]ObjectStorageBucket , error ) {
129
+ func (c * Client ) ListObjectStorageBucketsInCluster (ctx context.Context , opts * ListOptions , clusterOrRegionID string ) ([]ObjectStorageBucket , error ) {
114
130
response := ObjectStorageBucketsPagedResponse {}
115
- err := c .listHelper (ctx , & response , opts , clusterID )
131
+ err := c .listHelper (ctx , & response , opts , clusterOrRegionID )
116
132
if err != nil {
117
133
return nil , err
118
134
}
119
135
return response .Data , nil
120
136
}
121
137
122
138
// GetObjectStorageBucket gets the ObjectStorageBucket with the provided label
123
- func (c * Client ) GetObjectStorageBucket (ctx context.Context , clusterID , label string ) (* ObjectStorageBucket , error ) {
139
+ func (c * Client ) GetObjectStorageBucket (ctx context.Context , clusterOrRegionID , label string ) (* ObjectStorageBucket , error ) {
124
140
label = url .PathEscape (label )
125
- clusterID = url .PathEscape (clusterID )
126
- e := fmt .Sprintf ("object-storage/buckets/%s/%s" , clusterID , label )
141
+ clusterOrRegionID = url .PathEscape (clusterOrRegionID )
142
+ e := fmt .Sprintf ("object-storage/buckets/%s/%s" , clusterOrRegionID , label )
127
143
req := c .R (ctx ).SetResult (& ObjectStorageBucket {})
128
144
r , err := coupleAPIErrors (req .Get (e ))
129
145
if err != nil {
@@ -149,10 +165,10 @@ func (c *Client) CreateObjectStorageBucket(ctx context.Context, opts ObjectStora
149
165
}
150
166
151
167
// GetObjectStorageBucketAccess gets the current access config for a bucket
152
- func (c * Client ) GetObjectStorageBucketAccess (ctx context.Context , clusterID , label string ) (* ObjectStorageBucketAccess , error ) {
168
+ func (c * Client ) GetObjectStorageBucketAccess (ctx context.Context , clusterOrRegionID , label string ) (* ObjectStorageBucketAccess , error ) {
153
169
label = url .PathEscape (label )
154
- clusterID = url .PathEscape (clusterID )
155
- e := fmt .Sprintf ("object-storage/buckets/%s/%s/access" , clusterID , label )
170
+ clusterOrRegionID = url .PathEscape (clusterOrRegionID )
171
+ e := fmt .Sprintf ("object-storage/buckets/%s/%s/access" , clusterOrRegionID , label )
156
172
req := c .R (ctx ).SetResult (& ObjectStorageBucketAccess {})
157
173
r , err := coupleAPIErrors (req .Get (e ))
158
174
if err != nil {
@@ -163,15 +179,15 @@ func (c *Client) GetObjectStorageBucketAccess(ctx context.Context, clusterID, la
163
179
}
164
180
165
181
// UpdateObjectStorageBucketAccess updates the access configuration for an ObjectStorageBucket
166
- func (c * Client ) UpdateObjectStorageBucketAccess (ctx context.Context , clusterID , label string , opts ObjectStorageBucketUpdateAccessOptions ) error {
182
+ func (c * Client ) UpdateObjectStorageBucketAccess (ctx context.Context , clusterOrRegionID , label string , opts ObjectStorageBucketUpdateAccessOptions ) error {
167
183
body , err := json .Marshal (opts )
168
184
if err != nil {
169
185
return err
170
186
}
171
187
172
188
label = url .PathEscape (label )
173
- clusterID = url .PathEscape (clusterID )
174
- e := fmt .Sprintf ("object-storage/buckets/%s/%s/access" , clusterID , label )
189
+ clusterOrRegionID = url .PathEscape (clusterOrRegionID )
190
+ e := fmt .Sprintf ("object-storage/buckets/%s/%s/access" , clusterOrRegionID , label )
175
191
_ , err = coupleAPIErrors (c .R (ctx ).SetBody (string (body )).Post (e ))
176
192
if err != nil {
177
193
return err
@@ -181,9 +197,9 @@ func (c *Client) UpdateObjectStorageBucketAccess(ctx context.Context, clusterID,
181
197
}
182
198
183
199
// DeleteObjectStorageBucket deletes the ObjectStorageBucket with the specified label
184
- func (c * Client ) DeleteObjectStorageBucket (ctx context.Context , clusterID , label string ) error {
200
+ func (c * Client ) DeleteObjectStorageBucket (ctx context.Context , clusterOrRegionID , label string ) error {
185
201
label = url .PathEscape (label )
186
- e := fmt .Sprintf ("object-storage/buckets/%s/%s" , clusterID , label )
202
+ e := fmt .Sprintf ("object-storage/buckets/%s/%s" , clusterOrRegionID , label )
187
203
_ , err := coupleAPIErrors (c .R (ctx ).Delete (e ))
188
204
return err
189
205
}
0 commit comments