Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into unit_test
Browse files Browse the repository at this point in the history
  • Loading branch information
vshanthe committed Jan 15, 2025
2 parents 13271d0 + 9193012 commit b4dbebc
Show file tree
Hide file tree
Showing 46 changed files with 3,343 additions and 1,009 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/linode/linodego

require (
github.com/go-resty/resty/v2 v2.16.2
github.com/go-resty/resty/v2 v2.16.3
github.com/google/go-cmp v0.6.0
github.com/google/go-querystring v1.1.0
github.com/jarcoal/httpmock v1.3.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-resty/resty/v2 v2.16.2 h1:CpRqTjIzq/rweXUt9+GxzzQdlkqMdt8Lm/fuK/CAbAg=
github.com/go-resty/resty/v2 v2.16.2/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
github.com/go-resty/resty/v2 v2.16.3 h1:zacNT7lt4b8M/io2Ahj6yPypL7bqx9n1iprfQuodV+E=
github.com/go-resty/resty/v2 v2.16.3/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand Down
11 changes: 6 additions & 5 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ type Instance struct {

// InstanceSpec represents a linode spec
type InstanceSpec struct {
Disk int `json:"disk"`
Memory int `json:"memory"`
VCPUs int `json:"vcpus"`
Transfer int `json:"transfer"`
GPUs int `json:"gpus"`
Disk int `json:"disk"`
Memory int `json:"memory"`
VCPUs int `json:"vcpus"`
Transfer int `json:"transfer"`
GPUs int `json:"gpus"`
AcceleratedDevices int `json:"accelerated_devices"`
}

// InstanceAlert represents a metric alert
Expand Down
2 changes: 1 addition & 1 deletion k8s/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-resty/resty/v2 v2.16.2 // indirect
github.com/go-resty/resty/v2 v2.16.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
Expand Down
4 changes: 2 additions & 2 deletions k8s/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2Kv
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-resty/resty/v2 v2.16.2 h1:CpRqTjIzq/rweXUt9+GxzzQdlkqMdt8Lm/fuK/CAbAg=
github.com/go-resty/resty/v2 v2.16.2/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
github.com/go-resty/resty/v2 v2.16.3 h1:zacNT7lt4b8M/io2Ahj6yPypL7bqx9n1iprfQuodV+E=
github.com/go-resty/resty/v2 v2.16.3/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
Expand Down
6 changes: 6 additions & 0 deletions lke_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type LKECluster struct {
K8sVersion string `json:"k8s_version"`
Tags []string `json:"tags"`
ControlPlane LKEClusterControlPlane `json:"control_plane"`

// NOTE: Tier may not currently be available to all users and can only be used with v4beta.
Tier string `json:"tier"`
}

// LKEClusterCreateOptions fields are those accepted by CreateLKECluster
Expand All @@ -38,6 +41,9 @@ type LKEClusterCreateOptions struct {
K8sVersion string `json:"k8s_version"`
Tags []string `json:"tags,omitempty"`
ControlPlane *LKEClusterControlPlaneOptions `json:"control_plane,omitempty"`

// NOTE: Tier may not currently be available to all users and can only be used with v4beta.
Tier string `json:"tier,omitempty"`
}

// LKEClusterUpdateOptions fields are those accepted by UpdateLKECluster
Expand Down
31 changes: 20 additions & 11 deletions object_storage_bucket_certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,44 @@ import (
"context"
)

// Deprecated: Please use ObjectStorageBucketCertV2 for all new implementations.
type ObjectStorageBucketCert struct {
SSL bool `json:"ssl"`
}

type ObjectStorageBucketCertV2 struct {
SSL *bool `json:"ssl"`
}

type ObjectStorageBucketCertUploadOptions struct {
Certificate string `json:"certificate"`
PrivateKey string `json:"private_key"`
}

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

return response, nil
return doPOSTRequest[ObjectStorageBucketCert](ctx, c, e, opts)
}

// GetObjectStorageBucketCert gets an ObjectStorageBucketCert
// Deprecated: Please use GetObjectStorageBucketCertV2 for all new implementations.
func (c *Client) GetObjectStorageBucketCert(ctx context.Context, clusterOrRegionID, bucket string) (*ObjectStorageBucketCert, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
response, err := doGETRequest[ObjectStorageBucketCert](ctx, c, e)
if err != nil {
return nil, err
}
return doGETRequest[ObjectStorageBucketCert](ctx, c, e)
}

return response, nil
// UploadObjectStorageBucketCert uploads a TLS/SSL Cert to be used with an Object Storage Bucket.
func (c *Client) UploadObjectStorageBucketCertV2(ctx context.Context, clusterOrRegionID, bucket string, opts ObjectStorageBucketCertUploadOptions) (*ObjectStorageBucketCertV2, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
return doPOSTRequest[ObjectStorageBucketCertV2](ctx, c, e, opts)
}

// GetObjectStorageBucketCertV2 gets an ObjectStorageBucketCert
func (c *Client) GetObjectStorageBucketCertV2(ctx context.Context, clusterOrRegionID, bucket string) (*ObjectStorageBucketCertV2, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
return doGETRequest[ObjectStorageBucketCertV2](ctx, c, e)
}

// DeleteObjectStorageBucketCert deletes an ObjectStorageBucketCert
Expand Down
66 changes: 29 additions & 37 deletions object_storage_buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ type ObjectStorageBucket struct {
Cluster string `json:"cluster"`
Region string `json:"region"`

Created *time.Time `json:"-"`
Hostname string `json:"hostname"`
Objects int `json:"objects"`
Size int `json:"size"`
S3Endpoint string `json:"s3_endpoint"`
EndpointType ObjectStorageEndpointType `json:"endpoint_type"`
Created *time.Time `json:"-"`
Hostname string `json:"hostname"`
Objects int `json:"objects"`
Size int `json:"size"`
}

// ObjectStorageBucketAccess holds Object Storage access info
Expand All @@ -36,6 +38,13 @@ type ObjectStorageBucketAccess struct {
CorsEnabled bool `json:"cors_enabled"`
}

type ObjectStorageBucketAccessV2 struct {
ACL ObjectStorageACL `json:"acl"`
ACLXML string `json:"acl_xml"`
CorsEnabled *bool `json:"cors_enabled"`
CorsXML *string `json:"cors_xml"`
}

// ObjectStorageBucketContent holds the content of an ObjectStorageBucket
type ObjectStorageBucketContent struct {
Data []ObjectStorageBucketContentData `json:"data"`
Expand Down Expand Up @@ -82,7 +91,9 @@ type ObjectStorageBucketCreateOptions struct {
Cluster string `json:"cluster,omitempty"`
Region string `json:"region,omitempty"`

Label string `json:"label"`
Label string `json:"label"`
S3Endpoint string `json:"s3_endpoint,omitempty"`
EndpointType ObjectStorageEndpointType `json:"endpoint_type,omitempty"`

ACL ObjectStorageACL `json:"acl,omitempty"`
CorsEnabled *bool `json:"cors_enabled,omitempty"`
Expand Down Expand Up @@ -115,55 +126,31 @@ const (

// ListObjectStorageBuckets lists ObjectStorageBuckets
func (c *Client) ListObjectStorageBuckets(ctx context.Context, opts *ListOptions) ([]ObjectStorageBucket, error) {
response, err := getPaginatedResults[ObjectStorageBucket](ctx, c, "object-storage/buckets", opts)
if err != nil {
return nil, err
}

return response, nil
return getPaginatedResults[ObjectStorageBucket](ctx, c, "object-storage/buckets", opts)
}

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

return response, nil
return getPaginatedResults[ObjectStorageBucket](ctx, c, formatAPIPath("object-storage/buckets/%s", clusterOrRegionID), opts)
}

// GetObjectStorageBucket gets the ObjectStorageBucket with the provided label
func (c *Client) GetObjectStorageBucket(ctx context.Context, clusterOrRegionID, label string) (*ObjectStorageBucket, error) {
e := formatAPIPath("object-storage/buckets/%s/%s", clusterOrRegionID, label)
response, err := doGETRequest[ObjectStorageBucket](ctx, c, e)
if err != nil {
return nil, err
}

return response, nil
return doGETRequest[ObjectStorageBucket](ctx, c, e)
}

// CreateObjectStorageBucket creates an ObjectStorageBucket
func (c *Client) CreateObjectStorageBucket(ctx context.Context, opts ObjectStorageBucketCreateOptions) (*ObjectStorageBucket, error) {
e := "object-storage/buckets"
response, err := doPOSTRequest[ObjectStorageBucket](ctx, c, e, opts)
if err != nil {
return nil, err
}

return response, nil
return doPOSTRequest[ObjectStorageBucket](ctx, c, e, opts)
}

// GetObjectStorageBucketAccess gets the current access config for a bucket
// Deprecated: use GetObjectStorageBucketAccessV2 for new implementations
func (c *Client) GetObjectStorageBucketAccess(ctx context.Context, clusterOrRegionID, label string) (*ObjectStorageBucketAccess, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/access", clusterOrRegionID, label)
response, err := doGETRequest[ObjectStorageBucketAccess](ctx, c, e)
if err != nil {
return nil, err
}

return response, nil
return doGETRequest[ObjectStorageBucketAccess](ctx, c, e)
}

// UpdateObjectStorageBucketAccess updates the access configuration for an ObjectStorageBucket
Expand All @@ -174,11 +161,16 @@ func (c *Client) UpdateObjectStorageBucketAccess(ctx context.Context, clusterOrR
return err
}

// GetObjectStorageBucketAccess gets the current access config for a bucket
func (c *Client) GetObjectStorageBucketAccessV2(ctx context.Context, clusterOrRegionID, label string) (*ObjectStorageBucketAccessV2, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/access", clusterOrRegionID, label)
return doGETRequest[ObjectStorageBucketAccessV2](ctx, c, e)
}

// DeleteObjectStorageBucket deletes the ObjectStorageBucket with the specified label
func (c *Client) DeleteObjectStorageBucket(ctx context.Context, clusterOrRegionID, label string) error {
e := formatAPIPath("object-storage/buckets/%s/%s", clusterOrRegionID, label)
err := doDELETERequest(ctx, c, e)
return err
return doDELETERequest(ctx, c, e)
}

// Lists the contents of the specified ObjectStorageBucket
Expand Down
26 changes: 26 additions & 0 deletions object_storage_endpoints.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package linodego

import "context"

// NotificationType constants start with Notification and include all known Linode API Notification Types.
type ObjectStorageEndpointType string

// NotificationType constants represent the actions that cause a Notification. New types may be added in the future.
const (
ObjectStorageEndpointE0 ObjectStorageEndpointType = "E0"
ObjectStorageEndpointE1 ObjectStorageEndpointType = "E1"
ObjectStorageEndpointE2 ObjectStorageEndpointType = "E2"
ObjectStorageEndpointE3 ObjectStorageEndpointType = "E3"
)

// ObjectStorageEndpoint represents a linode object storage endpoint object
type ObjectStorageEndpoint struct {
Region string `json:"region"`
S3Endpoint *string `json:"s3_endpoint"`
EndpointType ObjectStorageEndpointType `json:"endpoint_type"`
}

// ListObjectStorageEndpoints lists all endpoints in all regions
func (c *Client) ListObjectStorageEndpoints(ctx context.Context, opts *ListOptions) ([]ObjectStorageEndpoint, error) {
return getPaginatedResults[ObjectStorageEndpoint](ctx, c, "object-storage/endpoints", opts)
}
5 changes: 3 additions & 2 deletions object_storage_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
)

type ObjectStorageKeyRegion struct {
ID string `json:"id"`
S3Endpoint string `json:"s3_endpoint"`
ID string `json:"id"`
S3Endpoint string `json:"s3_endpoint"`
EndpointType ObjectStorageEndpointType `json:"endpoint_type"`
}

// ObjectStorageKey represents a linode object storage key object
Expand Down
27 changes: 21 additions & 6 deletions object_storage_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,45 @@ type ObjectStorageObjectURL struct {
Exists bool `json:"exists"`
}

// Deprecated: Please use ObjectStorageObjectACLConfigV2 for all new implementations.
type ObjectStorageObjectACLConfig struct {
ACL string `json:"acl"`
ACLXML string `json:"acl_xml"`
}

type ObjectStorageObjectACLConfigV2 struct {
ACL *string `json:"acl"`
ACLXML *string `json:"acl_xml"`
}

type ObjectStorageObjectACLConfigUpdateOptions struct {
Name string `json:"name"`
ACL string `json:"acl"`
}

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

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

// Deprecated: use UpdateObjectStorageObjectACLConfigV2 for new implementations
func (c *Client) UpdateObjectStorageObjectACLConfig(ctx context.Context, objectID, label string, opts ObjectStorageObjectACLConfigUpdateOptions) (*ObjectStorageObjectACLConfig, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl", objectID, label)
response, err := doPUTRequest[ObjectStorageObjectACLConfig](ctx, c, e, opts)
return response, err
return doPUTRequest[ObjectStorageObjectACLConfig](ctx, c, e, opts)
}

func (c *Client) GetObjectStorageObjectACLConfigV2(ctx context.Context, objectID, label, object string) (*ObjectStorageObjectACLConfigV2, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl?name=%s", objectID, label, object)
return doGETRequest[ObjectStorageObjectACLConfigV2](ctx, c, e)
}

func (c *Client) UpdateObjectStorageObjectACLConfigV2(ctx context.Context, objectID, label string, opts ObjectStorageObjectACLConfigUpdateOptions) (*ObjectStorageObjectACLConfigV2, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl", objectID, label)
return doPUTRequest[ObjectStorageObjectACLConfigV2](ctx, c, e, opts)
}
Loading

0 comments on commit b4dbebc

Please sign in to comment.