Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for missing Obj-related endpoints #634

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
55 changes: 55 additions & 0 deletions object_storage_buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package linodego
import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/linode/linodego/internal/parseabletime"
Expand Down Expand Up @@ -34,6 +35,22 @@ type ObjectStorageBucketAccess struct {
CorsEnabled bool `json:"cors_enabled"`
}

// ObjectStorageBucketContent holds the content of an ObjectStorageBucket
type ObjectStorageBucketContent struct {
Data []ObjectStorageBucketContentData `json:"data"`
IsTruncated bool `json:"is_truncated"`
NextMarker *string `json:"next_marker"`
}

// ObjectStorageBucketContentData holds the data of the content of an ObjectStorageBucket
type ObjectStorageBucketContentData struct {
Etag string `json:"etag"`
LastModified *time.Time `json:"last_modified"`
Name string `json:"name"`
Owner string `json:"owner"`
Size int `json:"size"`
}

// UnmarshalJSON implements the json.Unmarshaler interface
func (i *ObjectStorageBucket) UnmarshalJSON(b []byte) error {
type Mask ObjectStorageBucket
Expand Down Expand Up @@ -76,6 +93,14 @@ type ObjectStorageBucketUpdateAccessOptions struct {
CorsEnabled *bool `json:"cors_enabled,omitempty"`
}

// ObjectStorageBucketListContentsParams fields are the query parameters for ListObjectStorageBucketContents
type ObjectStorageBucketListContentsParams struct {
Marker *string
Delimiter *string
Prefix *string
PageSize *int
}

// ObjectStorageACL options start with ACL and include all known ACL types
type ObjectStorageACL string

Expand Down Expand Up @@ -154,3 +179,33 @@ func (c *Client) DeleteObjectStorageBucket(ctx context.Context, clusterOrRegionI
err := doDELETERequest(ctx, c, e)
return err
}

// Lists the contents of the specified ObjectStorageBucket
func (c *Client) ListObjectStorageBucketContents(ctx context.Context, clusterOrRegionID, label string, params *ObjectStorageBucketListContentsParams) (*ObjectStorageBucketContent, error) {
basePath := formatAPIPath("object-storage/buckets/%s/%s/object-list", clusterOrRegionID, label)
queryString := ""

// nolint:nestif
if params != nil {
if params.Marker != nil && *params.Marker != "" {
queryString += fmt.Sprintf("marker=%s&", *params.Marker)
}
if params.Delimiter != nil && *params.Delimiter != "" {
queryString += fmt.Sprintf("delimiter=%s&", *params.Delimiter)
}
if params.Prefix != nil && *params.Prefix != "" {
queryString += fmt.Sprintf("prefix=%s&", *params.Prefix)
}
if params.PageSize != nil && *params.PageSize > 0 {
queryString += fmt.Sprintf("page_size=%d&", *params.PageSize)
}

// Remove trailing '&' and prepend '?' if parameters exist
if len(queryString) > 0 {
queryString = "?" + queryString[:len(queryString)-1]
}
}

e := basePath + queryString
return doGETRequest[ObjectStorageBucketContent](ctx, c, e)
}
184 changes: 92 additions & 92 deletions test/integration/fixtures/TestIPAddress_GetFound.yaml

Large diffs are not rendered by default.

184 changes: 92 additions & 92 deletions test/integration/fixtures/TestIPAddress_Instance_Allocate.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

82 changes: 41 additions & 41 deletions test/integration/fixtures/TestIPAddress_Update.yaml

Large diffs are not rendered by default.

580 changes: 290 additions & 290 deletions test/integration/fixtures/TestIPAddresses_List.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interactions:
response:
body: '{"id": 64649882, "label": "go-test-ins-reserved-ip-c1t2pb490c1p", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["69.164.211.224"], "ipv6": "2600:3c03::f03c:95ff:feb1:d75c/128",
"type": "g6-nanode-1", "ipv4": ["69.164.211.224"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down Expand Up @@ -274,7 +274,7 @@ interactions:
response:
body: '{"id": 64649889, "label": "test-instance-freed-ip", "group": "", "status":
"provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["69.164.211.224"], "ipv6": "2600:3c03::f03c:95ff:feb1:d72f/128",
"type": "g6-nanode-1", "ipv4": ["69.164.211.224"], "ipv6": "1234::5678/128",
"image": null, "region": "us-east", "site_type": "core", "specs": {"disk": 25600,
"memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu":
90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000},
Expand Down Expand Up @@ -410,7 +410,7 @@ interactions:
response:
body: '{"id": 64649890, "label": "ephemeral-ip-test", "group": "", "status": "provisioning",
"created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "type":
"g6-nanode-1", "ipv4": ["69.164.215.150"], "ipv6": "2600:3c03::f03c:95ff:feb1:d7eb/128",
"g6-nanode-1", "ipv4": ["69.164.215.150"], "ipv6": "1234::5678/128",
"image": null, "region": "us-east", "site_type": "core", "specs": {"disk": 25600,
"memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu":
90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ interactions:
body: ""
form: {}
headers: {}
url: https://us-east-1.linodeobjects.com:443/go-bucket-test-def/test?Signature=RbVnqyWJd6OMpr7Sn7kQOBezqfU%3D&Expires=1720635223&AWSAccessKeyID=SANITIZED
url: https://us-east-1.linodeobjects.com:443/go-bucket-test-def/test?Signature=IRuyHRdpyXWhh2aQjNZwsCI4Zw0%3D&Expires=1732717668&AWSAccessKeyID=SANITIZED
method: DELETE
response:
body: ""
headers:
Connection:
- keep-alive
X-Amz-Request-Id:
- tx0000076a0ecf723c8a652-00668ecdef-9e8b82a1-default
- tx00000a853072ba4ae0eeb-0067472afc-ef83577d-default
status: 204 No Content
code: 204
duration: ""
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interactions:
headers:
Content-Type:
- text/plain
url: https://us-east-1.linodeobjects.com:443/go-bucket-test-def/test?Signature=GShs5R09JONsfP%2Fb5k802GBEQjA%3D&Expires=1720635214&AWSAccessKeyID=SANITIZED
url: https://us-east-1.linodeobjects.com:443/go-bucket-test-def/test?Signature=k0XyLLvzmzaHLogj2FDHySorg6E%3D&Expires=1732717660&AWSAccessKeyID=SANITIZED
method: PUT
response:
body: ""
Expand All @@ -21,7 +21,7 @@ interactions:
Etag:
- '"7f2ababa423061c509f4923dd04b6cf1"'
X-Amz-Request-Id:
- tx0000063a9f63cc823d175-00668ecde6-9e8b8d69-default
- tx00000640ed2ef823b369b-0067472af5-f0b7e689-default
status: 200 OK
code: 200
duration: ""
Loading
Loading