diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 34b90e83b..000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: 'Stale issue handler' -on: - workflow_dispatch: null - schedule: - - cron: '0 0 * * *' - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v10 - id: stale - with: - stale-issue-message: 'This issue is stale because it has been open 30 days with - no activity. Remove stale label or comment or this will be closed in - 5 days' - days-before-stale: 30 - days-before-close: 5 - exempt-issue-labels: 'blocked,must,should,keep' - - name: Print outputs - run: echo ${{ join(steps.stale.outputs.*, ',') }} \ No newline at end of file diff --git a/account_events.go b/account_events.go index 2d99656b1..2aa423db1 100644 --- a/account_events.go +++ b/account_events.go @@ -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. diff --git a/account_payment_methods.go b/account_payment_methods.go index 97b0da003..d9d9e117d 100644 --- a/account_payment_methods.go +++ b/account_payment_methods.go @@ -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 diff --git a/client.go b/client.go index bff9a0b78..369c0fa78 100644 --- a/client.go +++ b/client.go @@ -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, @@ -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(), @@ -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) diff --git a/errors.go b/errors.go index 24eb2878a..5b142a21f 100644 --- a/errors.go +++ b/errors.go @@ -7,6 +7,7 @@ import ( "io" "net/http" "reflect" + "slices" "strings" "github.com/go-resty/resty/v2" @@ -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) } diff --git a/firewalls.go b/firewalls.go index 32d140fa0..4c3411ae7 100644 --- a/firewalls.go +++ b/firewalls.go @@ -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"` } // FirewallUpdateOptions is an options struct used when Updating a Firewall diff --git a/instances.go b/instances.go index 36c65d167..068563317 100644 --- a/instances.go +++ b/instances.go @@ -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 @@ -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"` diff --git a/internal/testutil/mock.go b/internal/testutil/mock.go index dc91a4186..42fdd5fab 100644 --- a/internal/testutil/mock.go +++ b/internal/testutil/mock.go @@ -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 { @@ -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 diff --git a/logger.go b/logger.go index b13a669aa..890327e2b 100644 --- a/logger.go +++ b/logger.go @@ -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 @@ -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 diff --git a/monitor_api_services.go b/monitor_api_services.go index ad7aff132..9d379353e 100644 --- a/monitor_api_services.go +++ b/monitor_api_services.go @@ -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 diff --git a/mysql.go b/mysql.go index 02522bcba..ab6c87675 100644 --- a/mysql.go +++ b/mysql.go @@ -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 { @@ -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 { @@ -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) { @@ -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) { @@ -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 { @@ -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 { diff --git a/network_ips.go b/network_ips.go index 72be24c63..d4500c4d6 100644 --- a/network_ips.go +++ b/network_ips.go @@ -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"` @@ -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) @@ -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) diff --git a/object_storage_bucket_certs.go b/object_storage_bucket_certs.go index 4f52859ca..36fb5301f 100644 --- a/object_storage_bucket_certs.go +++ b/object_storage_bucket_certs.go @@ -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, @@ -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) diff --git a/object_storage_buckets.go b/object_storage_buckets.go index bdcb54229..f8eed4963 100644 --- a/object_storage_buckets.go +++ b/object_storage_buckets.go @@ -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) diff --git a/postgres.go b/postgres.go index e15e29aae..75bd0f449 100644 --- a/postgres.go +++ b/postgres.go @@ -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 { @@ -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 { @@ -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) { @@ -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) { @@ -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 { @@ -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 { diff --git a/profile_preferences.go b/profile_preferences.go index 8f1ca5550..174c6816c 100644 --- a/profile_preferences.go +++ b/profile_preferences.go @@ -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 } diff --git a/request_helpers.go b/request_helpers.go index 15adcaa01..1d7fea4eb 100644 --- a/request_helpers.go +++ b/request_helpers.go @@ -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 } diff --git a/waitfor.go b/waitfor.go index db8e04ae4..3a001e619 100644 --- a/waitfor.go +++ b/waitfor.go @@ -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) { @@ -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) {