Skip to content

Commit b35ffe2

Browse files
committed
Add v2 functions and structs
1 parent 57752c4 commit b35ffe2

File tree

3 files changed

+60
-50
lines changed

3 files changed

+60
-50
lines changed

object_storage_bucket_certs.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import (
44
"context"
55
)
66

7+
// Deprecated: Please use ObjectStorageBucketCertV2 for all new implementations.
78
type ObjectStorageBucketCert struct {
9+
SSL bool `json:"ssl"`
10+
}
11+
12+
type ObjectStorageBucketCertV2 struct {
813
SSL *bool `json:"ssl"`
914
}
1015

@@ -14,25 +19,29 @@ type ObjectStorageBucketCertUploadOptions struct {
1419
}
1520

1621
// UploadObjectStorageBucketCert uploads a TLS/SSL Cert to be used with an Object Storage Bucket.
22+
// Deprecated: Please use UploadObjectStorageBucketCertV2 for all new implementations.
1723
func (c *Client) UploadObjectStorageBucketCert(ctx context.Context, clusterOrRegionID, bucket string, opts ObjectStorageBucketCertUploadOptions) (*ObjectStorageBucketCert, error) {
1824
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
19-
response, err := doPOSTRequest[ObjectStorageBucketCert](ctx, c, e, opts)
20-
if err != nil {
21-
return nil, err
22-
}
23-
24-
return response, nil
25+
return doPOSTRequest[ObjectStorageBucketCert](ctx, c, e, opts)
2526
}
2627

2728
// GetObjectStorageBucketCert gets an ObjectStorageBucketCert
29+
// Deprecated: Please use GetObjectStorageBucketCertV2 for all new implementations.
2830
func (c *Client) GetObjectStorageBucketCert(ctx context.Context, clusterOrRegionID, bucket string) (*ObjectStorageBucketCert, error) {
2931
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
30-
response, err := doGETRequest[ObjectStorageBucketCert](ctx, c, e)
31-
if err != nil {
32-
return nil, err
33-
}
32+
return doGETRequest[ObjectStorageBucketCert](ctx, c, e)
33+
}
34+
35+
// UploadObjectStorageBucketCert uploads a TLS/SSL Cert to be used with an Object Storage Bucket.
36+
func (c *Client) UploadObjectStorageBucketCertV2(ctx context.Context, clusterOrRegionID, bucket string, opts ObjectStorageBucketCertUploadOptions) (*ObjectStorageBucketCertV2, error) {
37+
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
38+
return doPOSTRequest[ObjectStorageBucketCertV2](ctx, c, e, opts)
39+
}
3440

35-
return response, nil
41+
// GetObjectStorageBucketCert gets an ObjectStorageBucketCert
42+
func (c *Client) GetObjectStorageBucketCertV2(ctx context.Context, clusterOrRegionID, bucket string) (*ObjectStorageBucketCertV2, error) {
43+
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
44+
return doGETRequest[ObjectStorageBucketCertV2](ctx, c, e)
3645
}
3746

3847
// DeleteObjectStorageBucketCert deletes an ObjectStorageBucketCert

object_storage_buckets.go

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ type ObjectStorageBucket struct {
3535
// ObjectStorageBucketAccess holds Object Storage access info
3636
type ObjectStorageBucketAccess struct {
3737
ACL ObjectStorageACL `json:"acl"`
38-
ACLXML string `json:"acl_xml"`
3938
CorsEnabled bool `json:"cors_enabled"`
39+
}
40+
41+
type ObjectStorageBucketAccessV2 struct {
42+
ACL ObjectStorageACL `json:"acl"`
43+
ACLXML string `json:"acl_xml"`
44+
CorsEnabled *bool `json:"cors_enabled"`
4045
CorsXML *string `json:"cors_xml"`
4146
}
4247

@@ -121,55 +126,31 @@ const (
121126

122127
// ListObjectStorageBuckets lists ObjectStorageBuckets
123128
func (c *Client) ListObjectStorageBuckets(ctx context.Context, opts *ListOptions) ([]ObjectStorageBucket, error) {
124-
response, err := getPaginatedResults[ObjectStorageBucket](ctx, c, "object-storage/buckets", opts)
125-
if err != nil {
126-
return nil, err
127-
}
128-
129-
return response, nil
129+
return getPaginatedResults[ObjectStorageBucket](ctx, c, "object-storage/buckets", opts)
130130
}
131131

132132
// ListObjectStorageBucketsInCluster lists all ObjectStorageBuckets of a cluster
133133
func (c *Client) ListObjectStorageBucketsInCluster(ctx context.Context, opts *ListOptions, clusterOrRegionID string) ([]ObjectStorageBucket, error) {
134-
response, err := getPaginatedResults[ObjectStorageBucket](ctx, c, formatAPIPath("object-storage/buckets/%s", clusterOrRegionID), opts)
135-
if err != nil {
136-
return nil, err
137-
}
138-
139-
return response, nil
134+
return getPaginatedResults[ObjectStorageBucket](ctx, c, formatAPIPath("object-storage/buckets/%s", clusterOrRegionID), opts)
140135
}
141136

142137
// GetObjectStorageBucket gets the ObjectStorageBucket with the provided label
143138
func (c *Client) GetObjectStorageBucket(ctx context.Context, clusterOrRegionID, label string) (*ObjectStorageBucket, error) {
144139
e := formatAPIPath("object-storage/buckets/%s/%s", clusterOrRegionID, label)
145-
response, err := doGETRequest[ObjectStorageBucket](ctx, c, e)
146-
if err != nil {
147-
return nil, err
148-
}
149-
150-
return response, nil
140+
return doGETRequest[ObjectStorageBucket](ctx, c, e)
151141
}
152142

153143
// CreateObjectStorageBucket creates an ObjectStorageBucket
154144
func (c *Client) CreateObjectStorageBucket(ctx context.Context, opts ObjectStorageBucketCreateOptions) (*ObjectStorageBucket, error) {
155145
e := "object-storage/buckets"
156-
response, err := doPOSTRequest[ObjectStorageBucket](ctx, c, e, opts)
157-
if err != nil {
158-
return nil, err
159-
}
160-
161-
return response, nil
146+
return doPOSTRequest[ObjectStorageBucket](ctx, c, e, opts)
162147
}
163148

164149
// GetObjectStorageBucketAccess gets the current access config for a bucket
150+
// Deprecated: use GetObjectStorageBucketAccessV2 for new implementations
165151
func (c *Client) GetObjectStorageBucketAccess(ctx context.Context, clusterOrRegionID, label string) (*ObjectStorageBucketAccess, error) {
166152
e := formatAPIPath("object-storage/buckets/%s/%s/access", clusterOrRegionID, label)
167-
response, err := doGETRequest[ObjectStorageBucketAccess](ctx, c, e)
168-
if err != nil {
169-
return nil, err
170-
}
171-
172-
return response, nil
153+
return doGETRequest[ObjectStorageBucketAccess](ctx, c, e)
173154
}
174155

175156
// UpdateObjectStorageBucketAccess updates the access configuration for an ObjectStorageBucket
@@ -180,11 +161,16 @@ func (c *Client) UpdateObjectStorageBucketAccess(ctx context.Context, clusterOrR
180161
return err
181162
}
182163

164+
// GetObjectStorageBucketAccess gets the current access config for a bucket
165+
func (c *Client) GetObjectStorageBucketAccessV2(ctx context.Context, clusterOrRegionID, label string) (*ObjectStorageBucketAccessV2, error) {
166+
e := formatAPIPath("object-storage/buckets/%s/%s/access", clusterOrRegionID, label)
167+
return doGETRequest[ObjectStorageBucketAccessV2](ctx, c, e)
168+
}
169+
183170
// DeleteObjectStorageBucket deletes the ObjectStorageBucket with the specified label
184171
func (c *Client) DeleteObjectStorageBucket(ctx context.Context, clusterOrRegionID, label string) error {
185172
e := formatAPIPath("object-storage/buckets/%s/%s", clusterOrRegionID, label)
186-
err := doDELETERequest(ctx, c, e)
187-
return err
173+
return doDELETERequest(ctx, c, e)
188174
}
189175

190176
// Lists the contents of the specified ObjectStorageBucket

object_storage_object.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,45 @@ type ObjectStorageObjectURL struct {
1717
Exists bool `json:"exists"`
1818
}
1919

20+
// Deprecated: Please use ObjectStorageObjectACLConfigV2 for all new implementations.
2021
type ObjectStorageObjectACLConfig struct {
2122
ACL string `json:"acl"`
2223
ACLXML string `json:"acl_xml"`
2324
}
2425

26+
type ObjectStorageObjectACLConfigV2 struct {
27+
ACL *string `json:"acl"`
28+
ACLXML *string `json:"acl_xml"`
29+
}
30+
2531
type ObjectStorageObjectACLConfigUpdateOptions struct {
2632
Name string `json:"name"`
2733
ACL string `json:"acl"`
2834
}
2935

3036
func (c *Client) CreateObjectStorageObjectURL(ctx context.Context, objectID, label string, opts ObjectStorageObjectURLCreateOptions) (*ObjectStorageObjectURL, error) {
3137
e := formatAPIPath("object-storage/buckets/%s/%s/object-url", objectID, label)
32-
response, err := doPOSTRequest[ObjectStorageObjectURL](ctx, c, e, opts)
33-
return response, err
38+
return doPOSTRequest[ObjectStorageObjectURL](ctx, c, e, opts)
3439
}
3540

41+
// Deprecated: use GetObjectStorageObjectACLConfigV2 for new implementations
3642
func (c *Client) GetObjectStorageObjectACLConfig(ctx context.Context, objectID, label, object string) (*ObjectStorageObjectACLConfig, error) {
3743
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl?name=%s", objectID, label, object)
38-
response, err := doGETRequest[ObjectStorageObjectACLConfig](ctx, c, e)
39-
return response, err
44+
return doGETRequest[ObjectStorageObjectACLConfig](ctx, c, e)
4045
}
4146

47+
// Deprecated: use UpdateObjectStorageObjectACLConfigV2 for new implementations
4248
func (c *Client) UpdateObjectStorageObjectACLConfig(ctx context.Context, objectID, label string, opts ObjectStorageObjectACLConfigUpdateOptions) (*ObjectStorageObjectACLConfig, error) {
4349
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl", objectID, label)
44-
response, err := doPUTRequest[ObjectStorageObjectACLConfig](ctx, c, e, opts)
45-
return response, err
50+
return doPUTRequest[ObjectStorageObjectACLConfig](ctx, c, e, opts)
51+
}
52+
53+
func (c *Client) GetObjectStorageObjectACLConfigV2(ctx context.Context, objectID, label, object string) (*ObjectStorageObjectACLConfigV2, error) {
54+
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl?name=%s", objectID, label, object)
55+
return doGETRequest[ObjectStorageObjectACLConfigV2](ctx, c, e)
56+
}
57+
58+
func (c *Client) UpdateObjectStorageObjectACLConfigV2(ctx context.Context, objectID, label string, opts ObjectStorageObjectACLConfigUpdateOptions) (*ObjectStorageObjectACLConfigV2, error) {
59+
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl", objectID, label)
60+
return doPUTRequest[ObjectStorageObjectACLConfigV2](ctx, c, e, opts)
4661
}

0 commit comments

Comments
 (0)