Skip to content
Merged
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
21 changes: 0 additions & 21 deletions .github/workflows/stale.yml

This file was deleted.

1 change: 1 addition & 0 deletions account_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func (c *Client) GetEvent(ctx context.Context, eventID int) (*Event, error) {
}

// MarkEventRead marks a single Event as read.
//
// Deprecated: `MarkEventRead` is a deprecated API, please consider using `MarkEventsSeen` instead.
// Please note that the `MarkEventsSeen` API functions differently and will mark all events up to and
// including the referenced event-id as "seen" rather than individual events.
Expand Down
2 changes: 1 addition & 1 deletion account_payment_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type PaymentMethod struct {
Type string `json:"type"`

// The detailed data for the Payment Method, which can be of varying types.
Data interface{} `json:"data"`
Data any `json:"data"`
}

// PaymentMethodDataCreditCard represents a PaymentMethodDataCreditCard object
Expand Down
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func (c *httpClient) logRequest(req *http.Request, method, url string, bodyBuffe

var logBuf bytes.Buffer

err := reqLogTemplate.Execute(&logBuf, map[string]interface{}{
err := reqLogTemplate.Execute(&logBuf, map[string]any{
"Method": method,
"URL": url,
"Headers": req.Header,
Expand Down Expand Up @@ -453,7 +453,7 @@ func (c *httpClient) logResponse(resp *http.Response) (*http.Response, error) {

var logBuf bytes.Buffer

err := respLogTemplate.Execute(&logBuf, map[string]interface{}{
err := respLogTemplate.Execute(&logBuf, map[string]any{
"Status": resp.Status,
"Headers": resp.Header,
"Body": respBody.String(),
Expand All @@ -468,7 +468,7 @@ func (c *httpClient) logResponse(resp *http.Response) (*http.Response, error) {
}

// nolint:unused
func (c *httpClient) decodeResponseBody(resp *http.Response, response interface{}) error {
func (c *httpClient) decodeResponseBody(resp *http.Response, response any) error {
if err := json.NewDecoder(resp.Body).Decode(response); err != nil {
if c.debug && c.logger != nil {
c.logger.Errorf("failed to decode response: %v", err)
Expand Down
8 changes: 2 additions & 6 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"net/http"
"reflect"
"slices"
"strings"

"github.com/go-resty/resty/v2"
Expand Down Expand Up @@ -227,11 +228,6 @@ func ErrHasStatus(err error, code ...int) bool {
}

ec := e.StatusCode()
for _, c := range code {
if ec == c {
return true
}
}

return false
return slices.Contains(code, ec)
}
2 changes: 1 addition & 1 deletion firewalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type FirewallCreateOptions struct {
Label string `json:"label,omitempty"`
Rules FirewallRuleSet `json:"rules"`
Tags []string `json:"tags,omitempty"`
Devices DevicesCreationOptions `json:"devices,omitempty"`
Devices DevicesCreationOptions `json:"devices,omitzero"`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a behavior change, that when Devices is not included when defining an instance of FirewallCreateOptions, it will change from an empty map to omitted from request body.

r, e := json.Marshal(linodego.FirewallCreateOptions{})
if e != nil {
	log.Fatal(e)
}
fmt.Println(string(r))

Original behavior:

{"rules":{"inbound":null,"inbound_policy":"","outbound":null,"outbound_policy":""},"devices":{}}

Updated behavior:

{"rules":{"inbound":null,"inbound_policy":"","outbound":null,"outbound_policy":""}}

I can't think of any actual effect on the API call except this body change, so I don't think this is a breaking change. But let me know if you think about it differently.

}

// FirewallUpdateOptions is an options struct used when Updating a Firewall
Expand Down
5 changes: 3 additions & 2 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type InstanceBackup struct {
Schedule struct {
Day string `json:"day,omitempty"`
Window string `json:"window,omitempty"`
} `json:"schedule,omitempty"`
} `json:"schedule"`
}

type InstanceDiskEncryption string
Expand All @@ -132,8 +132,9 @@ type InstanceTransfer struct {
Quota int `json:"quota"`
}

// MonthlyInstanceTransferStats pool stats for a Linode Instance network transfer statistics for a specific month
// Deprecated: use MonthlyInstanceTransferStatsV2 for new implementations
//
// MonthlyInstanceTransferStats pool stats for a Linode Instance network transfer statistics for a specific month
type MonthlyInstanceTransferStats struct {
// The amount of inbound public network traffic received by this Linode, in bytes, for a specific year/month.
BytesIn int `json:"bytes_in"`
Expand Down
14 changes: 7 additions & 7 deletions internal/testutil/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func CreateMockClient[T any](t *testing.T, createFunc func(*http.Client) T) *T {
}

type Logger interface {
Errorf(format string, v ...interface{})
Warnf(format string, v ...interface{})
Debugf(format string, v ...interface{})
Errorf(format string, v ...any)
Warnf(format string, v ...any)
Debugf(format string, v ...any)
}

func CreateLogger() *TestLogger {
Expand All @@ -108,19 +108,19 @@ type TestLogger struct {
L *log.Logger
}

func (l *TestLogger) Errorf(format string, v ...interface{}) {
func (l *TestLogger) Errorf(format string, v ...any) {
l.outputf("ERROR RESTY "+format, v...)
}

func (l *TestLogger) Warnf(format string, v ...interface{}) {
func (l *TestLogger) Warnf(format string, v ...any) {
l.outputf("WARN RESTY "+format, v...)
}

func (l *TestLogger) Debugf(format string, v ...interface{}) {
func (l *TestLogger) Debugf(format string, v ...any) {
l.outputf("DEBUG RESTY "+format, v...)
}

func (l *TestLogger) outputf(format string, v ...interface{}) {
func (l *TestLogger) outputf(format string, v ...any) {
if len(v) == 0 {
l.L.Print(format)
return
Expand Down
14 changes: 7 additions & 7 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

//nolint:unused
type httpLogger interface {
Errorf(format string, v ...interface{})
Warnf(format string, v ...interface{})
Debugf(format string, v ...interface{})
Errorf(format string, v ...any)
Warnf(format string, v ...any)
Debugf(format string, v ...any)
}

//nolint:unused
Expand All @@ -27,22 +27,22 @@ func createLogger() *logger {
var _ httpLogger = (*logger)(nil)

//nolint:unused
func (l *logger) Errorf(format string, v ...interface{}) {
func (l *logger) Errorf(format string, v ...any) {
l.output("ERROR RESTY "+format, v...)
}

//nolint:unused
func (l *logger) Warnf(format string, v ...interface{}) {
func (l *logger) Warnf(format string, v ...any) {
l.output("WARN RESTY "+format, v...)
}

//nolint:unused
func (l *logger) Debugf(format string, v ...interface{}) {
func (l *logger) Debugf(format string, v ...any) {
l.output("DEBUG RESTY "+format, v...)
}

//nolint:unused
func (l *logger) output(format string, v ...interface{}) { //nolint:goprintffuncname
func (l *logger) output(format string, v ...any) { //nolint:goprintffuncname
if len(v) == 0 {
l.l.Print(format)
return
Expand Down
4 changes: 2 additions & 2 deletions monitor_api_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ type MetricRelativeTimeDuration struct {

// MetricAbsoluteTimeDuration specifies an absolute time range for data queries
type MetricAbsoluteTimeDuration struct {
Start time.Time `json:"start,omitempty"`
End time.Time `json:"end,omitempty"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
}

// FetchEntityMetrics returns metrics information for the individual entities within a specific service type
Expand Down
6 changes: 6 additions & 0 deletions mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ type MySQLUpdateOptions struct {
}

// MySQLDatabaseBackup is information for interacting with a backup for the existing MySQL Database

// Deprecated: MySQLDatabaseBackup is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
type MySQLDatabaseBackup struct {
Expand All @@ -441,6 +442,7 @@ type MySQLDatabaseBackup struct {
}

// MySQLBackupCreateOptions are options used for CreateMySQLDatabaseBackup(...)
//
// Deprecated: MySQLBackupCreateOptions is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
type MySQLBackupCreateOptions struct {
Expand Down Expand Up @@ -485,6 +487,7 @@ func (c *Client) ListMySQLDatabases(ctx context.Context, opts *ListOptions) ([]M
}

// ListMySQLDatabaseBackups lists all MySQL Database Backups associated with the given MySQL Database
//
// Deprecated: ListMySQLDatabaseBackups is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) ListMySQLDatabaseBackups(ctx context.Context, databaseID int, opts *ListOptions) ([]MySQLDatabaseBackup, error) {
Expand Down Expand Up @@ -533,6 +536,7 @@ func (c *Client) ResetMySQLDatabaseCredentials(ctx context.Context, databaseID i
}

// GetMySQLDatabaseBackup returns a specific MySQL Database Backup with the given ids
//
// Deprecated: GetMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) GetMySQLDatabaseBackup(ctx context.Context, databaseID int, backupID int) (*MySQLDatabaseBackup, error) {
Expand All @@ -541,6 +545,7 @@ func (c *Client) GetMySQLDatabaseBackup(ctx context.Context, databaseID int, bac
}

// RestoreMySQLDatabaseBackup returns the given MySQL Database with the given Backup
//
// Deprecated: RestoreMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) RestoreMySQLDatabaseBackup(ctx context.Context, databaseID int, backupID int) error {
Expand All @@ -549,6 +554,7 @@ func (c *Client) RestoreMySQLDatabaseBackup(ctx context.Context, databaseID int,
}

// CreateMySQLDatabaseBackup creates a snapshot for the given MySQL database
//
// Deprecated: CreateMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) CreateMySQLDatabaseBackup(ctx context.Context, databaseID int, opts MySQLBackupCreateOptions) error {
Expand Down
3 changes: 3 additions & 0 deletions network_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type IPAddressUpdateOptionsV2 struct {
}

// IPAddressUpdateOptions fields are those accepted by UpdateIPAddress.
//
// Deprecated: Please use IPAddressUpdateOptionsV2 for all new implementations.
type IPAddressUpdateOptions struct {
RDNS *string `json:"rdns"`
Expand Down Expand Up @@ -66,6 +67,7 @@ func (i InstanceIP) GetUpdateOptionsV2() IPAddressUpdateOptionsV2 {
}

// GetUpdateOptions converts a IPAddress to IPAddressUpdateOptions for use in UpdateIPAddress.
//
// Deprecated: Please use GetUpdateOptionsV2 for all new implementations.
func (i InstanceIP) GetUpdateOptions() (o IPAddressUpdateOptions) {
o.RDNS = copyString(&i.RDNS)
Expand All @@ -90,6 +92,7 @@ func (c *Client) UpdateIPAddressV2(ctx context.Context, address string, opts IPA
}

// UpdateIPAddress updates the IP address with the specified id.
//
// Deprecated: Please use UpdateIPAddressV2 for all new implementation.
func (c *Client) UpdateIPAddress(ctx context.Context, id string, opts IPAddressUpdateOptions) (*InstanceIP, error) {
e := formatAPIPath("networking/ips/%s", id)
Expand Down
2 changes: 2 additions & 0 deletions object_storage_bucket_certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type ObjectStorageBucketCertUploadOptions struct {
}

// 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,
Expand All @@ -30,6 +31,7 @@ func (c *Client) UploadObjectStorageBucketCert(
}

// 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)
Expand Down
1 change: 1 addition & 0 deletions object_storage_buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (c *Client) CreateObjectStorageBucket(ctx context.Context, opts ObjectStora
}

// 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)
Expand Down
6 changes: 6 additions & 0 deletions postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ func (c *Client) ListPostgresDatabases(ctx context.Context, opts *ListOptions) (
}

// PostgresDatabaseBackup is information for interacting with a backup for the existing Postgres Database
//
// Deprecated: PostgresDatabaseBackup is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
type PostgresDatabaseBackup struct {
Expand Down Expand Up @@ -678,6 +679,7 @@ func (d *PostgresDatabaseBackup) UnmarshalJSON(b []byte) error {
}

// PostgresBackupCreateOptions are options used for CreatePostgresDatabaseBackup(...)
//
// Deprecated: PostgresBackupCreateOptions is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
type PostgresBackupCreateOptions struct {
Expand All @@ -686,6 +688,7 @@ type PostgresBackupCreateOptions struct {
}

// ListPostgresDatabaseBackups lists all Postgres Database Backups associated with the given Postgres Database
//
// Deprecated: ListPostgresDatabaseBackups is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) ListPostgresDatabaseBackups(ctx context.Context, databaseID int, opts *ListOptions) ([]PostgresDatabaseBackup, error) {
Expand Down Expand Up @@ -740,6 +743,7 @@ func (c *Client) GetPostgresDatabaseSSL(ctx context.Context, databaseID int) (*P
}

// GetPostgresDatabaseBackup returns a specific Postgres Database Backup with the given ids
//
// Deprecated: GetPostgresDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) GetPostgresDatabaseBackup(ctx context.Context, databaseID int, backupID int) (*PostgresDatabaseBackup, error) {
Expand All @@ -748,6 +752,7 @@ func (c *Client) GetPostgresDatabaseBackup(ctx context.Context, databaseID int,
}

// RestorePostgresDatabaseBackup returns the given Postgres Database with the given Backup
//
// Deprecated: RestorePostgresDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) RestorePostgresDatabaseBackup(ctx context.Context, databaseID int, backupID int) error {
Expand All @@ -756,6 +761,7 @@ func (c *Client) RestorePostgresDatabaseBackup(ctx context.Context, databaseID i
}

// CreatePostgresDatabaseBackup creates a snapshot for the given Postgres database
//
// Deprecated: CreatePostgresDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) CreatePostgresDatabaseBackup(ctx context.Context, databaseID int, opts PostgresBackupCreateOptions) error {
Expand Down
4 changes: 2 additions & 2 deletions profile_preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
// ProfilePreferences represents the user's preferences.
// The user preferences endpoints allow consumers of the API to store arbitrary JSON data,
// such as a user's font size preference or preferred display name.
type ProfilePreferences map[string]interface{}
type ProfilePreferences map[string]any

// UnmarshalJSON implements the json.Unmarshaler interface
func (p *ProfilePreferences) UnmarshalJSON(b []byte) error {
var data map[string]interface{}
var data map[string]any
if err := json.Unmarshal(b, &data); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion request_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func formatAPIPath(format string, args ...any) string {
return fmt.Sprintf(format, escapedArgs...)
}

func isNil(i interface{}) bool {
func isNil(i any) bool {
if i == nil {
return true
}
Expand Down
2 changes: 2 additions & 0 deletions waitfor.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ func (client Client) WaitForImageRegionStatus(ctx context.Context, imageID, regi
}

// WaitForMySQLDatabaseBackup waits for the backup with the given label to be available.
//
// Deprecated: WaitForMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (client Client) WaitForMySQLDatabaseBackup(ctx context.Context, dbID int, label string, timeoutSeconds int) (*MySQLDatabaseBackup, error) {
Expand Down Expand Up @@ -519,6 +520,7 @@ func (client Client) WaitForMySQLDatabaseBackup(ctx context.Context, dbID int, l
}

// WaitForPostgresDatabaseBackup waits for the backup with the given label to be available.
//
// Deprecated: WaitForPostgresDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (client Client) WaitForPostgresDatabaseBackup(ctx context.Context, dbID int, label string, timeoutSeconds int) (*PostgresDatabaseBackup, error) {
Expand Down