Skip to content

Commit a33df71

Browse files
zliang-akamaiezilber-akamaiCopilotChihweiLHBird
authored
linodego v2 (#973)
* TPT-4423: Drop resty as a dependency (#938) * Ported resty removal changes to new branch from up-to-date main and made additional changes to monitor client * Fixed lint * Updated log formatting to more closely resemble Resty's * Fixed lint * redact request header log * Fixes * Fixed CoPilot suggestions * Sanitize log output * Addressed CoPilot comments --------- Co-authored-by: Zhiwei Liang <zliang@akamai.com> * TPT-4421: Remove deprecated fields and methods (#946) * Removed deprecated fields and methods and updated tests * Fix lint * Addressed copilot suggestion * Fixed lint * Removed V2 suffix from various fields and methods * Addressed CoPilot suggestions * Added separate struct for Instance IP Address update options * Address PR suggestions * TPT-4414: Refactor JSON tags to use "omitzero" for optional fields across multiple files (#947) * Refactor JSON struct tags to use "omitzero" for optional fields * Remove url tags in pagination structs * TPT-4414: Change slice pointer types with `omitzero` to be slice (#954) * Refactor: Change pointer slices to slices for various fields with omitzero * Refresh fixtures * Update TestLKECluster_Update to remove pinned lke versions in test * TPT-4434: Added custom type for Region Capabilities and updated tests (#953) * Added custom type for Region Capabilities and updated tests * Fix formatting * Added disctinction between Object Storage Bucket Access POST/PUT endpoints (#951) * TPT-3454: Refactor wait functions to use context for timeouts and polling (#964) * Refactor wait functions to use context for timeouts and polling * fix context cancelled in cleanup * nolint generic return type * Fix grammar Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Make preTask a private function; cleanup unnecessary previousEvents allocation * Fix error msg format Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * TPT-4422: Added options structs for POST/PUT endpoints that were missing them (#968) * Added options structs for POST/PUT endpoints that were missing them * Address PR comments * Address PR comments * TPT-3483: Update NewClient method to return an error rather than just logging errors (#967) * refactor: update NewClient and related functions to handle errors properly * refactor: update SetRootCertificate to return errors and enhance logging * update NewClient instantiation to handle errors * Export PaginatedResponse type in request_helpers (#970) * TPT-3388: Separated GET and POST/PUT options structs where needed (#969) * Separated GET and POST/PUT options structs where needed * Separated additional structs that were reused for options and response * More struct fixes * Fix lint * Rename FirewallRule structs * integration test fixes * Addressed PR comments * FirewallRuleSetRule options; test updates; fixture refreshed * Address more PR comments --------- Co-authored-by: Zhiwei Liang <zliang@akamai.com> * TPT-4464: Update FirewallDeviceEntity Label field to be a pointer (#971) * Update FirewallDeviceEntity Label field to be a pointer and adjust tests accordingly * Fix unit tests * fmt * Fix another unit test * Change `[]*T` to `[]T` in all structs (#972) * Remove LKE cluster dashboard function, tests, and related fixture (#975) * Simplify client.go (#976) Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me> * Apply suggestion from @zliang-akamai * Update region capability in TestImageSharing_Suite to use Linodes --------- Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me> Co-authored-by: Erik Zilber <ezilber@akamai.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Zhiwei Liang <zhiwei.liang@zliang.me>
1 parent 19b7b07 commit a33df71

210 files changed

Lines changed: 10201 additions & 10905 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ func main() {
5454
},
5555
}
5656

57-
linodeClient := linodego.NewClient(oauth2Client)
57+
linodeClient, err := linodego.NewClient(oauth2Client)
58+
if err != nil {
59+
log.Fatal(err)
60+
}
5861
linodeClient.SetDebug(true)
5962

6063
res, err := linodeClient.GetInstance(context.Background(), 4090913)

account.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ type Account struct {
3434

3535
// AccountUpdateOptions fields are those accepted by UpdateAccount
3636
type AccountUpdateOptions struct {
37-
Address1 string `json:"address_1,omitempty"`
38-
Address2 string `json:"address_2,omitempty"`
39-
City string `json:"city,omitempty"`
40-
Company string `json:"company,omitempty"`
41-
Country string `json:"country,omitempty"`
42-
Email string `json:"email,omitempty"`
43-
FirstName string `json:"first_name,omitempty"`
44-
LastName string `json:"last_name,omitempty"`
45-
Phone string `json:"phone,omitempty"`
46-
State string `json:"state,omitempty"`
47-
TaxID string `json:"tax_id,omitempty"`
48-
Zip string `json:"zip,omitempty"`
37+
Address1 string `json:"address_1,omitzero"`
38+
Address2 string `json:"address_2,omitzero"`
39+
City string `json:"city,omitzero"`
40+
Company string `json:"company,omitzero"`
41+
Country string `json:"country,omitzero"`
42+
Email string `json:"email,omitzero"`
43+
FirstName string `json:"first_name,omitzero"`
44+
LastName string `json:"last_name,omitzero"`
45+
Phone string `json:"phone,omitzero"`
46+
State string `json:"state,omitzero"`
47+
TaxID string `json:"tax_id,omitzero"`
48+
Zip string `json:"zip,omitzero"`
4949
}
5050

5151
// GetUpdateOptions converts an Account to AccountUpdateOptions for use in UpdateAccount

account_agreements.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ type AccountAgreements struct {
1111

1212
// AccountAgreementsUpdateOptions fields are those accepted by UpdateAccountAgreements
1313
type AccountAgreementsUpdateOptions struct {
14-
EUModel bool `json:"eu_model,omitempty"`
15-
MasterServiceAgreement bool `json:"master_service_agreement,omitempty"`
16-
PrivacyPolicy bool `json:"privacy_policy,omitempty"`
14+
EUModel bool `json:"eu_model,omitzero"`
15+
MasterServiceAgreement bool `json:"master_service_agreement,omitzero"`
16+
PrivacyPolicy bool `json:"privacy_policy,omitzero"`
1717
}
1818

1919
// GetUpdateOptions converts an AccountAgreements to AccountAgreementsUpdateOptions for use in UpdateAccountAgreements

account_events.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,6 @@ const (
231231
ActionVPCSubnetCreate EventAction = "subnet_create"
232232
ActionVPCSubnetDelete EventAction = "subnet_delete"
233233
ActionVPCSubnetUpdate EventAction = "subnet_update"
234-
235-
// Deprecated: incorrect spelling,
236-
// to be removed in the next major version release.
237-
ActionVolumeDelte EventAction = "volume_delete"
238-
239-
// Deprecated: incorrect spelling,
240-
// to be removed in the next major version
241-
ActionCreateCardUpdated = ActionCreditCardUpdated
242234
)
243235

244236
// EntityType constants start with Entity and include Linode API Event Entity Types
@@ -343,16 +335,6 @@ func (c *Client) GetEvent(ctx context.Context, eventID int) (*Event, error) {
343335
return doGETRequest[Event](ctx, c, e)
344336
}
345337

346-
// MarkEventRead marks a single Event as read.
347-
//
348-
// Deprecated: `MarkEventRead` is a deprecated API, please consider using `MarkEventsSeen` instead.
349-
// Please note that the `MarkEventsSeen` API functions differently and will mark all events up to and
350-
// including the referenced event-id as "seen" rather than individual events.
351-
func (c *Client) MarkEventRead(ctx context.Context, event *Event) error {
352-
e := formatAPIPath("account/events/%d/read", event.ID)
353-
return doPOSTRequestNoRequestResponseBody(ctx, c, e)
354-
}
355-
356338
// MarkEventsSeen marks all Events up to and including this Event by ID as seen.
357339
func (c *Client) MarkEventsSeen(ctx context.Context, event *Event) error {
358340
e := formatAPIPath("account/events/%d/seen", event.ID)

account_maintenance.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ type AccountMaintenance struct {
2222
NotBefore *time.Time `json:"-"`
2323
StartTime *time.Time `json:"-"`
2424
CompleteTime *time.Time `json:"-"`
25-
26-
// Deprecated: When is a deprecated property
27-
When *time.Time `json:"when"`
2825
}
2926

3027
// Entity represents the entity being affected by maintenance
@@ -57,7 +54,6 @@ func (accountMaintenance *AccountMaintenance) UnmarshalJSON(b []byte) error {
5754
accountMaintenance.NotBefore = (*time.Time)(p.NotBefore)
5855
accountMaintenance.StartTime = (*time.Time)(p.StartTime)
5956
accountMaintenance.CompleteTime = (*time.Time)(p.CompleteTime)
60-
accountMaintenance.When = (*time.Time)(p.When)
6157

6258
return nil
6359
}

account_oauth_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ func (c *Client) DeleteOAuthClient(ctx context.Context, clientID string) error {
111111
// ResetOAuthClientSecret resets the OAuth Client secret for a client with a specified id
112112
func (c *Client) ResetOAuthClientSecret(ctx context.Context, clientID string) (*OAuthClient, error) {
113113
e := formatAPIPath("account/oauth-clients/%s/reset-secret", clientID)
114-
return doPOSTRequest[OAuthClient, any](ctx, c, e)
114+
return doPOSTRequestNoRequestBody[OAuthClient](ctx, c, e)
115115
}

account_payments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Payment struct {
2323
// PaymentCreateOptions fields are those accepted by CreatePayment
2424
type PaymentCreateOptions struct {
2525
// CVV (Card Verification Value) of the credit card to be used for the Payment
26-
CVV string `json:"cvv,omitempty"`
26+
CVV string `json:"cvv,omitzero"`
2727

2828
// The amount, in US dollars, of the Payment
2929
USD json.Number `json:"usd"`

account_settings.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ type AccountSettings struct {
4040
// AccountSettingsUpdateOptions are the updateable account wide flags or plans that effect new resources.
4141
type AccountSettingsUpdateOptions struct {
4242
// The default backups enrollment status for all new Linodes for all users on the account. When enabled, backups are mandatory per instance.
43-
BackupsEnabled *bool `json:"backups_enabled,omitempty"`
43+
BackupsEnabled *bool `json:"backups_enabled,omitzero"`
4444

4545
// The default network helper setting for all new Linodes and Linode Configs for all users on the account.
46-
NetworkHelper *bool `json:"network_helper,omitempty"`
46+
NetworkHelper *bool `json:"network_helper,omitzero"`
4747

4848
// NOTE: Interfaces for new linode setting may not currently be available to all users.
4949
// A new configuration flag defines whether new Linodes can use Linode and/or legacy config interfaces.
5050
InterfacesForNewLinodes *InterfacesForNewLinodes `json:"interfaces_for_new_linodes"`
5151

5252
// The slug of the maintenance policy to set the account to.
53-
MaintenancePolicy *string `json:"maintenance_policy,omitempty"`
53+
MaintenancePolicy *string `json:"maintenance_policy,omitzero"`
5454
}
5555

5656
// GetAccountSettings gets the account wide flags or plans that effect new resources

account_user_grants.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ type UserGrants struct {
5656
}
5757

5858
type UserGrantsUpdateOptions struct {
59-
Database []GrantedEntity `json:"database,omitempty"`
60-
Domain []EntityUserGrant `json:"domain,omitempty"`
61-
Firewall []EntityUserGrant `json:"firewall,omitempty"`
62-
Image []EntityUserGrant `json:"image,omitempty"`
63-
Linode []EntityUserGrant `json:"linode,omitempty"`
64-
Longview []EntityUserGrant `json:"longview,omitempty"`
65-
NodeBalancer []EntityUserGrant `json:"nodebalancer,omitempty"`
66-
PlacementGroup []EntityUserGrant `json:"placement_group,omitempty"`
67-
StackScript []EntityUserGrant `json:"stackscript,omitempty"`
68-
Volume []EntityUserGrant `json:"volume,omitempty"`
69-
VPC []EntityUserGrant `json:"vpc,omitempty"`
59+
Database []GrantedEntity `json:"database,omitzero"`
60+
Domain []EntityUserGrant `json:"domain,omitzero"`
61+
Firewall []EntityUserGrant `json:"firewall,omitzero"`
62+
Image []EntityUserGrant `json:"image,omitzero"`
63+
Linode []EntityUserGrant `json:"linode,omitzero"`
64+
Longview []EntityUserGrant `json:"longview,omitzero"`
65+
NodeBalancer []EntityUserGrant `json:"nodebalancer,omitzero"`
66+
PlacementGroup []EntityUserGrant `json:"placement_group,omitzero"`
67+
StackScript []EntityUserGrant `json:"stackscript,omitzero"`
68+
Volume []EntityUserGrant `json:"volume,omitzero"`
69+
VPC []EntityUserGrant `json:"vpc,omitzero"`
7070

7171
Global GlobalUserGrants `json:"global"`
7272
}

account_users.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ type UserCreateOptions struct {
4545

4646
// UserUpdateOptions fields are those accepted by UpdateUser
4747
type UserUpdateOptions struct {
48-
Username string `json:"username,omitempty"`
49-
Restricted *bool `json:"restricted,omitempty"`
50-
Email string `json:"email,omitempty"`
48+
Username string `json:"username,omitzero"`
49+
Restricted *bool `json:"restricted,omitzero"`
50+
Email string `json:"email,omitzero"`
5151
}
5252

5353
// UnmarshalJSON implements the json.Unmarshaler interface

0 commit comments

Comments
 (0)