From 031a78a4ab95a5402c2952c5e5907e73f6d27457 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 02:43:14 +0000 Subject: [PATCH] Bump github.com/digitalocean/godo from 1.134.0 to 1.141.0 Bumps [github.com/digitalocean/godo](https://github.com/digitalocean/godo) from 1.134.0 to 1.141.0. - [Release notes](https://github.com/digitalocean/godo/releases) - [Changelog](https://github.com/digitalocean/godo/blob/main/CHANGELOG.md) - [Commits](https://github.com/digitalocean/godo/compare/v1.134.0...v1.141.0) --- updated-dependencies: - dependency-name: github.com/digitalocean/godo dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../github.com/digitalocean/godo/CHANGELOG.md | 42 ++ .../github.com/digitalocean/godo/apps.gen.go | 4 +- .../digitalocean/godo/apps_accessors.go | 8 + .../github.com/digitalocean/godo/databases.go | 75 +++ vendor/github.com/digitalocean/godo/godo.go | 86 ++-- .../digitalocean/godo/kubernetes.go | 131 ++++- .../digitalocean/godo/load_balancers.go | 75 +++ .../godo/partner_interconnect_attachments.go | 278 ----------- .../godo/partner_network_connect.go | 457 ++++++++++++++++++ .../github.com/digitalocean/godo/snapshots.go | 8 + .../digitalocean/godo/spaces_keys.go | 21 + vendor/modules.txt | 2 +- 14 files changed, 852 insertions(+), 341 deletions(-) delete mode 100644 vendor/github.com/digitalocean/godo/partner_interconnect_attachments.go create mode 100644 vendor/github.com/digitalocean/godo/partner_network_connect.go diff --git a/go.mod b/go.mod index 3fc49531..8d178e8c 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ go 1.23.5 // replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.6 require ( - github.com/digitalocean/godo v1.134.0 + github.com/digitalocean/godo v1.141.0 github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 github.com/onsi/ginkgo v1.16.5 diff --git a/go.sum b/go.sum index 302e7385..9be200f8 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/digitalocean/godo v1.134.0 h1:dT7aQR9jxNOQEZwzP+tAYcxlj5szFZScC33+PAYGQVM= -github.com/digitalocean/godo v1.134.0/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc= +github.com/digitalocean/godo v1.141.0 h1:g4vKl9VZvgzE0EEFv8Y3SYiKqdteKS18BrVPatKFSVE= +github.com/digitalocean/godo v1.141.0/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc= github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU= github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k= diff --git a/vendor/github.com/digitalocean/godo/CHANGELOG.md b/vendor/github.com/digitalocean/godo/CHANGELOG.md index 091f2ec8..947e9154 100644 --- a/vendor/github.com/digitalocean/godo/CHANGELOG.md +++ b/vendor/github.com/digitalocean/godo/CHANGELOG.md @@ -1,5 +1,47 @@ # Change Log +## [v1.141.0] - 2025-03-20 + +- #805 - @singhsaubhikdo - BLOCK-4316: Adds region param in ListSnapshot for resource type volume +- #802 - @apinonformoso - VPC-4312: rename partner interconnect attachment to partner network connect +- #774 - @blesswinsamuel - APPS-10284 Remove "closed beta" note in archive feature to prep for GA release +- #797 - @kperath - add support for cluster status messages + +## [v1.140.0] - 2025-03-14 + +- #800 - @lee-aaron - support Spaces Keys GET by Access Key ID + +## [v1.139.0] - 2025-03-12 + +- #798 - @dylanrhysscott - Fix: Update godo to use simplified template response and provide consistent struct naming +- #796 - @apinonformoso - fix partner interconnect attachment json request response +- #795 - @dylanrhysscott - CON-11904 Ensure taints are correctly returned via node template endpoint +- #794 - @brunograsselli - Update partner interconnect attachment comments +- #793 - @apinonformoso - add auth_key field +- #789 - @guptado - [VPC-3917] Update get service key response model + +## [v1.138.0] - 2025-03-18 + +- #785 - @guptado - Support partner interconnect GetBgpAuthKey and RegenerateServiceKey operations +- #787 - @andrewsomething - ci: upgrade to actions/cache@v4 +- #786 - @m3co-code - add flags for doks routing-agent plugin +- #784 - @asaha2 - Support name and id filters for list op + +## [v1.137.0] - 2025-02-12 + +- #782 - @apinonformoso - fix partner interconnect json tag +- #781 - @dylanrhysscott - CON-11810 Implement GetNodePoolTemplate endpoint for DOKS godo client + +## [v1.136.0] - 2025-01-28 + +- #776 - @danaelhe - Databases: Support online-migrations +- #777 - @apinonformoso - update bgp to be a pointer + +## [v1.135.0] - 2025-01-27 +- #766 - @dhij - kubernetes: add cluster autoscaler config +- #775 - @jvasilevsky - LBASA-3620: add network_stack field to load balancers model +- #773 - @blesswinsamuel - Add field to customize the offline page during app maintenance + ## [v1.134.0] - 2025-01-15 - #771 - @d-honeybadger - add ID field to KubernetesClusterUser response - #768 - @lee-aaron - support Spaces Keys API diff --git a/vendor/github.com/digitalocean/godo/apps.gen.go b/vendor/github.com/digitalocean/godo/apps.gen.go index 63457cda..99fc2e90 100644 --- a/vendor/github.com/digitalocean/godo/apps.gen.go +++ b/vendor/github.com/digitalocean/godo/apps.gen.go @@ -468,8 +468,10 @@ type AppLogDestinationSpecPapertrail struct { type AppMaintenanceSpec struct { // Indicates whether maintenance mode should be enabled for the app. Enabled bool `json:"enabled,omitempty"` - // Indicates whether the app should be archived. Setting this to true implies that enabled is set to true. Note that this feature is currently in closed beta. + // Indicates whether the app should be archived. Setting this to true implies that enabled is set to true. Archive bool `json:"archive,omitempty"` + // A custom offline page to display when maintenance mode is enabled or the app is archived. + OfflinePageURL string `json:"offline_page_url,omitempty"` } // AppRouteSpec struct for AppRouteSpec diff --git a/vendor/github.com/digitalocean/godo/apps_accessors.go b/vendor/github.com/digitalocean/godo/apps_accessors.go index 4d9a214a..9a5bf601 100644 --- a/vendor/github.com/digitalocean/godo/apps_accessors.go +++ b/vendor/github.com/digitalocean/godo/apps_accessors.go @@ -1453,6 +1453,14 @@ func (a *AppMaintenanceSpec) GetEnabled() bool { return a.Enabled } +// GetOfflinePageURL returns the OfflinePageURL field. +func (a *AppMaintenanceSpec) GetOfflinePageURL() string { + if a == nil { + return "" + } + return a.OfflinePageURL +} + // GetAppID returns the AppID field. func (a *AppProposeRequest) GetAppID() string { if a == nil { diff --git a/vendor/github.com/digitalocean/godo/databases.go b/vendor/github.com/digitalocean/godo/databases.go index 1217ef05..ed4b4f8b 100644 --- a/vendor/github.com/digitalocean/godo/databases.go +++ b/vendor/github.com/digitalocean/godo/databases.go @@ -42,6 +42,8 @@ const ( databaseIndexPath = databaseBasePath + "/%s/indexes/%s" databaseLogsinkPath = databaseBasePath + "/%s/logsink/%s" databaseLogsinksPath = databaseBasePath + "/%s/logsink" + databaseOnlineMigrationsPath = databaseBasePath + "/%s/online-migration" + databaseOnlineMigrationPath = databaseBasePath + "/%s/online-migration/%s" ) // SQL Mode constants allow for MySQL-specific SQL flavor configuration. @@ -179,6 +181,9 @@ type DatabasesService interface { ListLogsinks(ctx context.Context, databaseID string, opts *ListOptions) ([]DatabaseLogsink, *Response, error) UpdateLogsink(ctx context.Context, databaseID string, logsinkID string, updateLogsink *DatabaseUpdateLogsinkRequest) (*Response, error) DeleteLogsink(ctx context.Context, databaseID, logsinkID string) (*Response, error) + StartOnlineMigration(ctx context.Context, databaseID string, onlineMigrationRequest *DatabaseStartOnlineMigrationRequest) (*DatabaseOnlineMigrationStatus, *Response, error) + StopOnlineMigration(ctx context.Context, databaseID, migrationID string) (*Response, error) + GetOnlineMigrationStatus(ctx context.Context, databaseID string) (*DatabaseOnlineMigrationStatus, *Response, error) } // DatabasesServiceOp handles communication with the Databases related methods @@ -366,6 +371,13 @@ type DatabaseLogsink struct { Config *DatabaseLogsinkConfig `json:"config,omitempty"` } +// DatabaseOnlineMigrationStatus represents an online migration status +type DatabaseOnlineMigrationStatus struct { + ID string `json:"id"` + Status string `json:"status"` + CreatedAt string `json:"created_at"` +} + // TopicPartition represents the state of a Kafka topic partition type TopicPartition struct { EarliestOffset uint64 `json:"earliest_offset,omitempty"` @@ -515,6 +527,13 @@ type DatabaseFirewallRule struct { CreatedAt time.Time `json:"created_at"` } +// DatabaseStartOnlineMigrationRequest is used to start an online migration for a database cluster +type DatabaseStartOnlineMigrationRequest struct { + Source *DatabaseOnlineMigrationConfig `json:"source"` + DisableSSL bool `json:"disable_ssl,omitempty"` + IgnoreDBs []string `json:"ignore_dbs,omitempty"` +} + // DatabaseCreateLogsinkRequest is used to create logsink for a database cluster type DatabaseCreateLogsinkRequest struct { Name string `json:"sink_name"` @@ -544,6 +563,15 @@ type DatabaseLogsinkConfig struct { Cert string `json:"cert,omitempty"` } +// DatabaseOnlineMigrationConfig represents the configuration options for database online migrations. +type DatabaseOnlineMigrationConfig struct { + Host string `json:"host,omitempty"` + Port int `json:"port,omitempty"` + DatabaseName string `json:"dbname,omitempty"` + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` +} + // PostgreSQLConfig holds advanced configurations for PostgreSQL database clusters. type PostgreSQLConfig struct { AutovacuumFreezeMaxAge *int `json:"autovacuum_freeze_max_age,omitempty"` @@ -1975,3 +2003,50 @@ func (svc *DatabasesServiceOp) DeleteLogsink(ctx context.Context, databaseID, lo } return resp, nil } + +// StartOnlineMigration starts an online migration for a database. Migrating a cluster establishes a connection with an existing cluster +// and replicates its contents to the target cluster. Online migration is only available for MySQL, PostgreSQL, and Redis clusters. +func (svc *DatabasesServiceOp) StartOnlineMigration(ctx context.Context, databaseID string, onlineMigration *DatabaseStartOnlineMigrationRequest) (*DatabaseOnlineMigrationStatus, *Response, error) { + path := fmt.Sprintf(databaseOnlineMigrationsPath, databaseID) + req, err := svc.client.NewRequest(ctx, http.MethodPut, path, onlineMigration) + if err != nil { + return nil, nil, err + } + + root := new(DatabaseOnlineMigrationStatus) + resp, err := svc.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + return root, resp, nil +} + +// GetOnlineMigrationStatus retrieves the status of the most recent online migration +func (svc *DatabasesServiceOp) GetOnlineMigrationStatus(ctx context.Context, databaseID string) (*DatabaseOnlineMigrationStatus, *Response, error) { + path := fmt.Sprintf(databaseOnlineMigrationsPath, databaseID) + req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(DatabaseOnlineMigrationStatus) + resp, err := svc.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + return root, resp, nil +} + +// StopOnlineMigration stops an online migration +func (svc *DatabasesServiceOp) StopOnlineMigration(ctx context.Context, databaseID, migrationID string) (*Response, error) { + path := fmt.Sprintf(databaseOnlineMigrationPath, databaseID, migrationID) + req, err := svc.client.NewRequest(ctx, http.MethodDelete, path, nil) + if err != nil { + return nil, err + } + resp, err := svc.client.Do(ctx, req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index f3bdca9b..ac0dc093 100644 --- a/vendor/github.com/digitalocean/godo/godo.go +++ b/vendor/github.com/digitalocean/godo/godo.go @@ -21,7 +21,7 @@ import ( ) const ( - libraryVersion = "1.134.0" + libraryVersion = "1.141.0" defaultBaseURL = "https://api.digitalocean.com/" userAgent = "godo/" + libraryVersion mediaType = "application/json" @@ -54,47 +54,47 @@ type Client struct { ratemtx sync.Mutex // Services used for communicating with the API - Account AccountService - Actions ActionsService - Apps AppsService - Balance BalanceService - BillingHistory BillingHistoryService - CDNs CDNService - Certificates CertificatesService - Databases DatabasesService - Domains DomainsService - Droplets DropletsService - DropletActions DropletActionsService - DropletAutoscale DropletAutoscaleService - Firewalls FirewallsService - FloatingIPs FloatingIPsService - FloatingIPActions FloatingIPActionsService - Functions FunctionsService - Images ImagesService - ImageActions ImageActionsService - Invoices InvoicesService - Keys KeysService - Kubernetes KubernetesService - LoadBalancers LoadBalancersService - Monitoring MonitoringService - OneClick OneClickService - Projects ProjectsService - Regions RegionsService - Registry RegistryService - Registries RegistriesService - ReservedIPs ReservedIPsService - ReservedIPV6s ReservedIPV6sService - ReservedIPActions ReservedIPActionsService - ReservedIPV6Actions ReservedIPV6ActionsService - Sizes SizesService - Snapshots SnapshotsService - SpacesKeys SpacesKeysService - Storage StorageService - StorageActions StorageActionsService - Tags TagsService - UptimeChecks UptimeChecksService - VPCs VPCsService - PartnerInterconnectAttachments PartnerInterconnectAttachmentsService + Account AccountService + Actions ActionsService + Apps AppsService + Balance BalanceService + BillingHistory BillingHistoryService + CDNs CDNService + Certificates CertificatesService + Databases DatabasesService + Domains DomainsService + Droplets DropletsService + DropletActions DropletActionsService + DropletAutoscale DropletAutoscaleService + Firewalls FirewallsService + FloatingIPs FloatingIPsService + FloatingIPActions FloatingIPActionsService + Functions FunctionsService + Images ImagesService + ImageActions ImageActionsService + Invoices InvoicesService + Keys KeysService + Kubernetes KubernetesService + LoadBalancers LoadBalancersService + Monitoring MonitoringService + OneClick OneClickService + Projects ProjectsService + Regions RegionsService + Registry RegistryService + Registries RegistriesService + ReservedIPs ReservedIPsService + ReservedIPV6s ReservedIPV6sService + ReservedIPActions ReservedIPActionsService + ReservedIPV6Actions ReservedIPV6ActionsService + Sizes SizesService + Snapshots SnapshotsService + SpacesKeys SpacesKeysService + Storage StorageService + StorageActions StorageActionsService + Tags TagsService + UptimeChecks UptimeChecksService + VPCs VPCsService + PartnerNetworkConnect PartnerNetworkConnectService // Optional function called after every successful request made to the DO APIs onRequestCompleted RequestCompletionCallback @@ -310,7 +310,7 @@ func NewClient(httpClient *http.Client) *Client { c.Tags = &TagsServiceOp{client: c} c.UptimeChecks = &UptimeChecksServiceOp{client: c} c.VPCs = &VPCsServiceOp{client: c} - c.PartnerInterconnectAttachments = &PartnerInterconnectAttachmentsServiceOp{client: c} + c.PartnerNetworkConnect = &PartnerNetworkConnectsServiceOp{client: c} c.headers = make(map[string]string) diff --git a/vendor/github.com/digitalocean/godo/kubernetes.go b/vendor/github.com/digitalocean/godo/kubernetes.go index 8a4085a0..9d974321 100644 --- a/vendor/github.com/digitalocean/godo/kubernetes.go +++ b/vendor/github.com/digitalocean/godo/kubernetes.go @@ -40,6 +40,7 @@ type KubernetesService interface { CreateNodePool(ctx context.Context, clusterID string, req *KubernetesNodePoolCreateRequest) (*KubernetesNodePool, *Response, error) GetNodePool(ctx context.Context, clusterID, poolID string) (*KubernetesNodePool, *Response, error) + GetNodePoolTemplate(ctx context.Context, clusterID string, nodePoolName string) (*KubernetesNodePoolTemplate, *Response, error) ListNodePools(ctx context.Context, clusterID string, opts *ListOptions) ([]*KubernetesNodePool, *Response, error) UpdateNodePool(ctx context.Context, clusterID, poolID string, req *KubernetesNodePoolUpdateRequest) (*KubernetesNodePool, *Response, error) // RecycleNodePoolNodes is DEPRECATED please use DeleteNode @@ -54,6 +55,8 @@ type KubernetesService interface { RunClusterlint(ctx context.Context, clusterID string, req *KubernetesRunClusterlintRequest) (string, *Response, error) GetClusterlintResults(ctx context.Context, clusterID string, req *KubernetesGetClusterlintRequest) ([]*ClusterlintDiagnostic, *Response, error) + + GetClusterStatusMessages(ctx context.Context, clusterID string, req *KubernetesGetClusterStatusMessagesRequest) ([]*KubernetesClusterStatusMessage, *Response, error) } var _ KubernetesService = &KubernetesServiceOp{} @@ -78,20 +81,24 @@ type KubernetesClusterCreateRequest struct { NodePools []*KubernetesNodePoolCreateRequest `json:"node_pools,omitempty"` - MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy"` - AutoUpgrade bool `json:"auto_upgrade"` - SurgeUpgrade bool `json:"surge_upgrade"` - ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` + MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy"` + AutoUpgrade bool `json:"auto_upgrade"` + SurgeUpgrade bool `json:"surge_upgrade"` + ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` + ClusterAutoscalerConfiguration *KubernetesClusterAutoscalerConfiguration `json:"cluster_autoscaler_configuration,omitempty"` + RoutingAgent *KubernetesRoutingAgent `json:"routing_agent,omitempty"` } // KubernetesClusterUpdateRequest represents a request to update a Kubernetes cluster. type KubernetesClusterUpdateRequest struct { - Name string `json:"name,omitempty"` - Tags []string `json:"tags,omitempty"` - MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy,omitempty"` - AutoUpgrade *bool `json:"auto_upgrade,omitempty"` - SurgeUpgrade bool `json:"surge_upgrade,omitempty"` - ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` + Name string `json:"name,omitempty"` + Tags []string `json:"tags,omitempty"` + MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy,omitempty"` + AutoUpgrade *bool `json:"auto_upgrade,omitempty"` + SurgeUpgrade bool `json:"surge_upgrade,omitempty"` + ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` + ClusterAutoscalerConfiguration *KubernetesClusterAutoscalerConfiguration `json:"cluster_autoscaler_configuration,omitempty"` + RoutingAgent *KubernetesRoutingAgent `json:"routing_agent,omitempty"` // Convert cluster to run highly available control plane HA *bool `json:"ha,omitempty"` @@ -187,6 +194,19 @@ type KubernetesGetClusterlintRequest struct { RunId string `json:"run_id"` } +type clusterStatusMessagesRoot struct { + Messages []*KubernetesClusterStatusMessage `json:"messages"` +} + +type KubernetesClusterStatusMessage struct { + Message string `json:"message"` + Timestamp time.Time `json:"timestamp"` +} + +type KubernetesGetClusterStatusMessagesRequest struct { + Since *time.Time `json:"since"` +} + // KubernetesCluster represents a Kubernetes cluster. type KubernetesCluster struct { ID string `json:"id,omitempty"` @@ -205,11 +225,13 @@ type KubernetesCluster struct { NodePools []*KubernetesNodePool `json:"node_pools,omitempty"` - MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy,omitempty"` - AutoUpgrade bool `json:"auto_upgrade,omitempty"` - SurgeUpgrade bool `json:"surge_upgrade,omitempty"` - RegistryEnabled bool `json:"registry_enabled,omitempty"` - ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` + MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy,omitempty"` + AutoUpgrade bool `json:"auto_upgrade,omitempty"` + SurgeUpgrade bool `json:"surge_upgrade,omitempty"` + RegistryEnabled bool `json:"registry_enabled,omitempty"` + ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` + ClusterAutoscalerConfiguration *KubernetesClusterAutoscalerConfiguration `json:"cluster_autoscaler_configuration,omitempty"` + RoutingAgent *KubernetesRoutingAgent `json:"routing_agent,omitempty"` Status *KubernetesClusterStatus `json:"status,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` @@ -252,6 +274,17 @@ type KubernetesControlPlaneFirewall struct { AllowedAddresses []string `json:"allowed_addresses"` } +// KubernetesRoutingAgent represents information about the routing-agent cluster plugin. +type KubernetesRoutingAgent struct { + Enabled *bool `json:"enabled"` +} + +// KubernetesClusterAutoscalerConfiguration represents Kubernetes cluster autoscaler configuration. +type KubernetesClusterAutoscalerConfiguration struct { + ScaleDownUtilizationThreshold *float64 `json:"scale_down_utilization_threshold"` + ScaleDownUnneededTime *string `json:"scale_down_unneeded_time"` +} + // KubernetesMaintenancePolicyDay represents the possible days of a maintenance // window type KubernetesMaintenancePolicyDay int @@ -417,6 +450,20 @@ type KubernetesNodePool struct { Nodes []*KubernetesNode `json:"nodes,omitempty"` } +// KubernetesNodePool represents the node pool template data for a given pool. +type KubernetesNodePoolTemplate struct { + Template *KubernetesNodeTemplate +} + +// KubernetesNodePoolResources represents the resources within a given template for a node pool +// This follows https://pkg.go.dev/k8s.io/kubernetes@v1.32.1/pkg/scheduler/framework#Resource to represent +// node resources within the node object. +type KubernetesNodePoolResources struct { + CPU int64 `json:"cpu,omitempty"` + Memory string `json:"memory,omitempty"` + Pods int64 `json:"pods,omitempty"` +} + // KubernetesNode represents a Node in a node pool in a Kubernetes cluster. type KubernetesNode struct { ID string `json:"id,omitempty"` @@ -428,6 +475,17 @@ type KubernetesNode struct { UpdatedAt time.Time `json:"updated_at,omitempty"` } +// KubernetesNodeTemplate represents a template in a node pool in a Kubernetes cluster. +type KubernetesNodeTemplate struct { + ClusterUUID string `json:"cluster_uuid,omitempty"` + Name string `json:"name,omitempty"` + Slug string `json:"slug,omitempty"` + Labels map[string]string `json:"labels,omitempty"` + Taints []string `json:"taints,omitempty"` + Capacity *KubernetesNodePoolResources `json:"capacity,omitempty"` + Allocatable *KubernetesNodePoolResources `json:"allocatable,omitempty"` +} + // KubernetesNodeStatus represents the status of a particular Node in a Kubernetes cluster. type KubernetesNodeStatus struct { State string `json:"state,omitempty"` @@ -795,6 +853,24 @@ func (svc *KubernetesServiceOp) GetNodePool(ctx context.Context, clusterID, pool return root.NodePool, resp, nil } +// GetNodePoolTemplate retrieves the template used for a given node pool to scale up from zero. +func (svc *KubernetesServiceOp) GetNodePoolTemplate(ctx context.Context, clusterID string, nodePoolName string) (*KubernetesNodePoolTemplate, *Response, error) { + path, err := url.JoinPath(kubernetesClustersPath, clusterID, "node_pools_template", nodePoolName) + if err != nil { + return nil, nil, err + } + req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + root := new(KubernetesNodePoolTemplate) + resp, err := svc.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + return root, resp, nil +} + // ListNodePools lists all the node pools found in a Kubernetes cluster. func (svc *KubernetesServiceOp) ListNodePools(ctx context.Context, clusterID string, opts *ListOptions) ([]*KubernetesNodePool, *Response, error) { path := fmt.Sprintf("%s/%s/node_pools", kubernetesClustersPath, clusterID) @@ -981,3 +1057,28 @@ func (svc *KubernetesServiceOp) GetClusterlintResults(ctx context.Context, clust } return root.Diagnostics, resp, nil } + +func (svc *KubernetesServiceOp) GetClusterStatusMessages(ctx context.Context, clusterID string, req *KubernetesGetClusterStatusMessagesRequest) ([]*KubernetesClusterStatusMessage, *Response, error) { + path := fmt.Sprintf("%s/%s/status_messages", kubernetesClustersPath, clusterID) + + if req != nil { + v := make(url.Values) + if req.Since != nil { + v.Set("since", req.Since.Format(time.RFC3339)) + } + if query := v.Encode(); query != "" { + path = path + "?" + query + } + } + + request, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + root := new(clusterStatusMessagesRoot) + resp, err := svc.client.Do(ctx, request, root) + if err != nil { + return nil, resp, err + } + return root.Messages, resp, nil +} diff --git a/vendor/github.com/digitalocean/godo/load_balancers.go b/vendor/github.com/digitalocean/godo/load_balancers.go index a12729dd..a1b833b6 100644 --- a/vendor/github.com/digitalocean/godo/load_balancers.go +++ b/vendor/github.com/digitalocean/godo/load_balancers.go @@ -22,6 +22,10 @@ const ( // Load Balancer network types LoadBalancerNetworkTypeExternal = "EXTERNAL" LoadBalancerNetworkTypeInternal = "INTERNAL" + + // Load Balancer network_stack types + LoadBalancerNetworkStackIPv4 = "IPV4" + LoadBalancerNetworkStackDualstack = "DUALSTACK" ) // LoadBalancersService is an interface for managing load balancers with the DigitalOcean API. @@ -29,6 +33,8 @@ const ( type LoadBalancersService interface { Get(context.Context, string) (*LoadBalancer, *Response, error) List(context.Context, *ListOptions) ([]LoadBalancer, *Response, error) + ListByNames(context.Context, []string, *ListOptions) ([]LoadBalancer, *Response, error) + ListByUUIDs(context.Context, []string, *ListOptions) ([]LoadBalancer, *Response, error) Create(context.Context, *LoadBalancerRequest) (*LoadBalancer, *Response, error) Update(ctx context.Context, lbID string, lbr *LoadBalancerRequest) (*LoadBalancer, *Response, error) Delete(ctx context.Context, lbID string) (*Response, error) @@ -74,6 +80,7 @@ type LoadBalancer struct { GLBSettings *GLBSettings `json:"glb_settings,omitempty"` TargetLoadBalancerIDs []string `json:"target_load_balancer_ids,omitempty"` Network string `json:"network,omitempty"` + NetworkStack string `json:"network_stack,omitempty"` } // String creates a human-readable description of a LoadBalancer. @@ -108,6 +115,7 @@ func (l LoadBalancer) AsRequest() *LoadBalancerRequest { HTTPIdleTimeoutSeconds: l.HTTPIdleTimeoutSeconds, TargetLoadBalancerIDs: append([]string(nil), l.TargetLoadBalancerIDs...), Network: l.Network, + NetworkStack: l.NetworkStack, } if l.DisableLetsEncryptDNSRecords != nil { @@ -247,6 +255,7 @@ type LoadBalancerRequest struct { GLBSettings *GLBSettings `json:"glb_settings,omitempty"` TargetLoadBalancerIDs []string `json:"target_load_balancer_ids,omitempty"` Network string `json:"network,omitempty"` + NetworkStack string `json:"network_stack,omitempty"` } // String creates a human-readable description of a LoadBalancerRequest. @@ -396,6 +405,72 @@ func (l *LoadBalancersServiceOp) List(ctx context.Context, opt *ListOptions) ([] return root.LoadBalancers, resp, err } +// ListByNames lists load balancers filtered by resource names, with optional pagination. +func (l *LoadBalancersServiceOp) ListByNames(ctx context.Context, names []string, opt *ListOptions) ([]LoadBalancer, *Response, error) { + path, err := addOptions(loadBalancersBasePath, opt) + if err != nil { + return nil, nil, err + } + + req, err := l.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + q := req.URL.Query() + for _, name := range names { + q.Add("names", name) + } + req.URL.RawQuery = q.Encode() + + root := new(loadBalancersRoot) + resp, err := l.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + if l := root.Links; l != nil { + resp.Links = l + } + if m := root.Meta; m != nil { + resp.Meta = m + } + + return root.LoadBalancers, resp, err +} + +// ListByUUIDs lists load balancers filtered by resource UUIDs, with optional pagination. +func (l *LoadBalancersServiceOp) ListByUUIDs(ctx context.Context, uuids []string, opt *ListOptions) ([]LoadBalancer, *Response, error) { + path, err := addOptions(loadBalancersBasePath, opt) + if err != nil { + return nil, nil, err + } + + req, err := l.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + q := req.URL.Query() + for _, uuid := range uuids { + q.Add("uuids", uuid) + } + req.URL.RawQuery = q.Encode() + + root := new(loadBalancersRoot) + resp, err := l.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + if l := root.Links; l != nil { + resp.Links = l + } + if m := root.Meta; m != nil { + resp.Meta = m + } + + return root.LoadBalancers, resp, err +} + // Create a new load balancer with a given configuration. func (l *LoadBalancersServiceOp) Create(ctx context.Context, lbr *LoadBalancerRequest) (*LoadBalancer, *Response, error) { req, err := l.client.NewRequest(ctx, http.MethodPost, loadBalancersBasePath, lbr) diff --git a/vendor/github.com/digitalocean/godo/partner_interconnect_attachments.go b/vendor/github.com/digitalocean/godo/partner_interconnect_attachments.go deleted file mode 100644 index 87a0e9ed..00000000 --- a/vendor/github.com/digitalocean/godo/partner_interconnect_attachments.go +++ /dev/null @@ -1,278 +0,0 @@ -package godo - -import ( - "context" - "fmt" - "net/http" - "time" -) - -const partnerInterconnectAttachmentsBasePath = "/v2/partner_interconnect/attachments" - -// PartnerInterconnectAttachmentsService is an interface for managing Partner Interconnect Attachments with the -// DigitalOcean API. -// See: https://docs.digitalocean.com/reference/api/api-reference/#tag/PartnerInterconnectAttachments -type PartnerInterconnectAttachmentsService interface { - List(context.Context, *ListOptions) ([]*PartnerInterconnectAttachment, *Response, error) - Create(context.Context, *PartnerInterconnectAttachmentCreateRequest) (*PartnerInterconnectAttachment, *Response, error) - Get(context.Context, string) (*PartnerInterconnectAttachment, *Response, error) - Update(context.Context, string, *PartnerInterconnectAttachmentUpdateRequest) (*PartnerInterconnectAttachment, *Response, error) - Delete(context.Context, string) (*Response, error) - GetServiceKey(context.Context, string) (*ServiceKey, *Response, error) - SetRoutes(context.Context, string, *PartnerInterconnectAttachmentSetRoutesRequest) (*PartnerInterconnectAttachment, *Response, error) - ListRoutes(context.Context, string, *ListOptions) ([]*RemoteRoute, *Response, error) -} - -var _ PartnerInterconnectAttachmentsService = &PartnerInterconnectAttachmentsServiceOp{} - -// PartnerInterconnectAttachmentsServiceOp interfaces with the Partner Interconnect Attachment endpoints in the DigitalOcean API. -type PartnerInterconnectAttachmentsServiceOp struct { - client *Client -} - -// PartnerInterconnectAttachmentCreateRequest represents a request to create a Partner Interconnect Attachment. -type PartnerInterconnectAttachmentCreateRequest struct { - // Name is the name of the Partner Interconnect Attachment - Name string `json:"name,omitempty"` - // ConnectionBandwidthInMbps is the bandwidth of the connection in Mbps - ConnectionBandwidthInMbps int `json:"connection_bandwidth_in_mbps,omitempty"` - // Region is the region where the Partner Interconnect Attachment is created - Region string `json:"region,omitempty"` - // NaaSProvider is the name of the Network as a Service provider - NaaSProvider string `json:"naas_provider,omitempty"` - // VPCIDs is the IDs of the VPCs to which the Partner Interconnect Attachment is connected - VPCIDs []string `json:"vpc_ids,omitempty"` - // BGP is the BGP configuration of the Partner Interconnect Attachment - BGP BGP `json:"bgp,omitempty"` -} - -// PartnerInterconnectAttachmentUpdateRequest represents a request to update a Partner Interconnect Attachment. -type PartnerInterconnectAttachmentUpdateRequest struct { - // Name is the name of the Partner Interconnect Attachment - Name string `json:"name,omitempty"` - //VPCIDs is the IDs of the VPCs to which the Partner Interconnect Attachment is connected - VPCIDs []string `json:"vpc_ids,omitempty"` -} - -type PartnerInterconnectAttachmentSetRoutesRequest struct { - // Routes is the list of routes to be used for the Partner Interconnect Attachment - Routes []string `json:"routes,omitempty"` -} - -// BGP represents the BGP configuration of a Partner Interconnect Attachment. -type BGP struct { - // LocalASN is the local ASN - LocalASN int `json:"local_asn,omitempty"` - // LocalRouterIP is the local router IP - LocalRouterIP string `json:"local_router_ip,omitempty"` - // PeerASN is the peer ASN - PeerASN int `json:"peer_asn,omitempty"` - // PeerRouterIP is the peer router IP - PeerRouterIP string `json:"peer_router_ip,omitempty"` -} - -// ServiceKey represents the service key of a Partner Interconnect Attachment. -type ServiceKey struct { - ServiceKey string `json:"service_key,omitempty"` -} - -// RemoteRoute represents a route for a Partner Interconnect Attachment. -type RemoteRoute struct { - // ID is the generated ID of the Route - ID string `json:"id,omitempty"` - // Cidr is the CIDR of the route - Cidr string `json:"cidr,omitempty"` -} - -// PartnerInterconnectAttachment represents a DigitalOcean Partner Interconnect Attachment. -type PartnerInterconnectAttachment struct { - // ID is the generated ID of the Partner Interconnect Attachment - ID string `json:"id,omitempty"` - // Name is the name of the Partner Interconnect Attachment - Name string `json:"name,omitempty"` - // State is the state of the Partner Interconnect Attachment - State string `json:"state,omitempty"` - // ConnectionBandwidthInMbps is the bandwidth of the connection in Mbps - ConnectionBandwidthInMbps int `json:"connection_bandwidth_in_mbps,omitempty"` - // Region is the region where the Partner Interconnect Attachment is created - Region string `json:"region,omitempty"` - // NaaSProvider is the name of the Network as a Service provider - NaaSProvider string `json:"naas_provider,omitempty"` - // VPCIDs is the IDs of the VPCs to which the Partner Interconnect Attachment is connected - VPCIDs []string `json:"vpc_ids,omitempty"` - // BGP is the BGP configuration of the Partner Interconnect Attachment - BGP BGP `json:"bgp,omitempty"` - // CreatedAt is time when this Partner Interconnect Attachment was first created - CreatedAt time.Time `json:"created_at,omitempty"` -} - -type partnerInterconnectAttachmentRoot struct { - PartnerInterconnectAttachment *PartnerInterconnectAttachment `json:"partner_interconnect_attachment"` -} - -type partnerInterconnectAttachmentsRoot struct { - PartnerInterconnectAttachments []*PartnerInterconnectAttachment `json:"partner_interconnect_attachments"` - Links *Links `json:"links"` - Meta *Meta `json:"meta"` -} - -type serviceKeyRoot struct { - ServiceKey *ServiceKey `json:"service_key"` -} - -type remoteRoutesRoot struct { - RemoteRoutes []*RemoteRoute `json:"remote_routes"` - Links *Links `json:"links"` - Meta *Meta `json:"meta"` -} - -// List returns a list of all Partner Interconnect Attachments, with optional pagination. -func (s *PartnerInterconnectAttachmentsServiceOp) List(ctx context.Context, opt *ListOptions) ([]*PartnerInterconnectAttachment, *Response, error) { - path, err := addOptions(partnerInterconnectAttachmentsBasePath, opt) - if err != nil { - return nil, nil, err - } - req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) - if err != nil { - return nil, nil, err - } - - root := new(partnerInterconnectAttachmentsRoot) - resp, err := s.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - if l := root.Links; l != nil { - resp.Links = l - } - if m := root.Meta; m != nil { - resp.Meta = m - } - return root.PartnerInterconnectAttachments, resp, nil -} - -// Create creates a new Partner Interconnect Attachment. -func (s *PartnerInterconnectAttachmentsServiceOp) Create(ctx context.Context, create *PartnerInterconnectAttachmentCreateRequest) (*PartnerInterconnectAttachment, *Response, error) { - path := partnerInterconnectAttachmentsBasePath - req, err := s.client.NewRequest(ctx, http.MethodPost, path, create) - if err != nil { - return nil, nil, err - } - - root := new(partnerInterconnectAttachmentRoot) - resp, err := s.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - - return root.PartnerInterconnectAttachment, resp, nil -} - -// Get returns the details of a Partner Interconnect Attachment. -func (s *PartnerInterconnectAttachmentsServiceOp) Get(ctx context.Context, id string) (*PartnerInterconnectAttachment, *Response, error) { - path := fmt.Sprintf("%s/%s", partnerInterconnectAttachmentsBasePath, id) - req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) - if err != nil { - return nil, nil, err - } - - root := new(partnerInterconnectAttachmentRoot) - resp, err := s.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - - return root.PartnerInterconnectAttachment, resp, nil -} - -// Update updates a Partner Interconnect Attachment properties. -func (s *PartnerInterconnectAttachmentsServiceOp) Update(ctx context.Context, id string, update *PartnerInterconnectAttachmentUpdateRequest) (*PartnerInterconnectAttachment, *Response, error) { - path := fmt.Sprintf("%s/%s", partnerInterconnectAttachmentsBasePath, id) - req, err := s.client.NewRequest(ctx, http.MethodPatch, path, update) - if err != nil { - return nil, nil, err - } - - root := new(partnerInterconnectAttachmentRoot) - resp, err := s.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - - return root.PartnerInterconnectAttachment, resp, nil -} - -// Delete deletes a Partner Interconnect Attachment. -func (s *PartnerInterconnectAttachmentsServiceOp) Delete(ctx context.Context, id string) (*Response, error) { - path := fmt.Sprintf("%s/%s", partnerInterconnectAttachmentsBasePath, id) - req, err := s.client.NewRequest(ctx, http.MethodDelete, path, nil) - if err != nil { - return nil, err - } - - resp, err := s.client.Do(ctx, req, nil) - if err != nil { - return resp, err - } - - return resp, nil -} - -func (s *PartnerInterconnectAttachmentsServiceOp) GetServiceKey(ctx context.Context, id string) (*ServiceKey, *Response, error) { - path := fmt.Sprintf("%s/%s/service_key", partnerInterconnectAttachmentsBasePath, id) - req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) - if err != nil { - return nil, nil, err - } - - root := new(serviceKeyRoot) - resp, err := s.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - - return root.ServiceKey, resp, nil -} - -// ListRoutes lists all routes for a Partner Interconnect Attachment. -func (s *PartnerInterconnectAttachmentsServiceOp) ListRoutes(ctx context.Context, id string, opt *ListOptions) ([]*RemoteRoute, *Response, error) { - path, err := addOptions(fmt.Sprintf("%s/%s/remote_routes", partnerInterconnectAttachmentsBasePath, id), opt) - if err != nil { - return nil, nil, err - } - req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) - if err != nil { - return nil, nil, err - } - - root := new(remoteRoutesRoot) - resp, err := s.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - if l := root.Links; l != nil { - resp.Links = l - } - if m := root.Meta; m != nil { - resp.Meta = m - } - - return root.RemoteRoutes, resp, nil -} - -// SetRoutes updates specific properties of a Partner Interconnect Attachment. -func (s *PartnerInterconnectAttachmentsServiceOp) SetRoutes(ctx context.Context, id string, set *PartnerInterconnectAttachmentSetRoutesRequest) (*PartnerInterconnectAttachment, *Response, error) { - path := fmt.Sprintf("%s/%s/remote_routes", partnerInterconnectAttachmentsBasePath, id) - req, err := s.client.NewRequest(ctx, http.MethodPut, path, set) - if err != nil { - return nil, nil, err - } - - root := new(partnerInterconnectAttachmentRoot) - resp, err := s.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - - return root.PartnerInterconnectAttachment, resp, nil -} diff --git a/vendor/github.com/digitalocean/godo/partner_network_connect.go b/vendor/github.com/digitalocean/godo/partner_network_connect.go new file mode 100644 index 00000000..0c4d0c0b --- /dev/null +++ b/vendor/github.com/digitalocean/godo/partner_network_connect.go @@ -0,0 +1,457 @@ +package godo + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "time" +) + +const partnerNetworkConnectBasePath = "/v2/partner_network_connect/attachments" + +// PartnerNetworkConnectService is an interface for managing Partner Connect with the +// DigitalOcean API. +// See: https://docs.digitalocean.com/reference/api/api-reference/#tag/PartnerNetworkConnect +type PartnerNetworkConnectService interface { + List(context.Context, *ListOptions) ([]*PartnerNetworkConnect, *Response, error) + Create(context.Context, *PartnerNetworkConnectCreateRequest) (*PartnerNetworkConnect, *Response, error) + Get(context.Context, string) (*PartnerNetworkConnect, *Response, error) + Update(context.Context, string, *PartnerNetworkConnectUpdateRequest) (*PartnerNetworkConnect, *Response, error) + Delete(context.Context, string) (*Response, error) + GetServiceKey(context.Context, string) (*ServiceKey, *Response, error) + SetRoutes(context.Context, string, *PartnerNetworkConnectSetRoutesRequest) (*PartnerNetworkConnect, *Response, error) + ListRoutes(context.Context, string, *ListOptions) ([]*RemoteRoute, *Response, error) + GetBGPAuthKey(ctx context.Context, iaID string) (*BgpAuthKey, *Response, error) + RegenerateServiceKey(ctx context.Context, iaID string) (*RegenerateServiceKey, *Response, error) +} + +var _ PartnerNetworkConnectService = &PartnerNetworkConnectsServiceOp{} + +// PartnerNetworkConnectsServiceOp interfaces with the Partner Connect endpoints in the DigitalOcean API. +type PartnerNetworkConnectsServiceOp struct { + client *Client +} + +// PartnerNetworkConnectCreateRequest represents a request to create a Partner Connect. +type PartnerNetworkConnectCreateRequest struct { + // Name is the name of the Partner Connect + Name string `json:"name,omitempty"` + // ConnectionBandwidthInMbps is the bandwidth of the connection in Mbps + ConnectionBandwidthInMbps int `json:"connection_bandwidth_in_mbps,omitempty"` + // Region is the region where the Partner Connect is created + Region string `json:"region,omitempty"` + // NaaSProvider is the name of the Network as a Service provider + NaaSProvider string `json:"naas_provider,omitempty"` + // VPCIDs is the IDs of the VPCs to which the Partner Connect is connected + VPCIDs []string `json:"vpc_ids,omitempty"` + // BGP is the BGP configuration of the Partner Connect + BGP BGP `json:"bgp,omitempty"` +} + +type partnerNetworkConnectRequestBody struct { + // Name is the name of the Partner Connect + Name string `json:"name,omitempty"` + // ConnectionBandwidthInMbps is the bandwidth of the connection in Mbps + ConnectionBandwidthInMbps int `json:"connection_bandwidth_in_mbps,omitempty"` + // Region is the region where the Partner Connect is created + Region string `json:"region,omitempty"` + // NaaSProvider is the name of the Network as a Service provider + NaaSProvider string `json:"naas_provider,omitempty"` + // VPCIDs is the IDs of the VPCs to which the Partner Connect is connected + VPCIDs []string `json:"vpc_ids,omitempty"` + // BGP is the BGP configuration of the Partner Connect + BGP *BGPInput `json:"bgp,omitempty"` +} + +func (req *PartnerNetworkConnectCreateRequest) buildReq() *partnerNetworkConnectRequestBody { + request := &partnerNetworkConnectRequestBody{ + Name: req.Name, + ConnectionBandwidthInMbps: req.ConnectionBandwidthInMbps, + Region: req.Region, + NaaSProvider: req.NaaSProvider, + VPCIDs: req.VPCIDs, + } + + if req.BGP != (BGP{}) { + request.BGP = &BGPInput{ + LocalASN: req.BGP.LocalASN, + LocalRouterIP: req.BGP.LocalRouterIP, + PeerASN: req.BGP.PeerASN, + PeerRouterIP: req.BGP.PeerRouterIP, + AuthKey: req.BGP.AuthKey, + } + } + + return request +} + +// PartnerNetworkConnectUpdateRequest represents a request to update a Partner Connect. +type PartnerNetworkConnectUpdateRequest struct { + // Name is the name of the Partner Connect + Name string `json:"name,omitempty"` + //VPCIDs is the IDs of the VPCs to which the Partner Connect is connected + VPCIDs []string `json:"vpc_ids,omitempty"` +} + +type PartnerNetworkConnectSetRoutesRequest struct { + // Routes is the list of routes to be used for the Partner Connect + Routes []string `json:"routes,omitempty"` +} + +// BGP represents the BGP configuration of a Partner Connect. +type BGP struct { + // LocalASN is the local ASN + LocalASN int `json:"local_asn,omitempty"` + // LocalRouterIP is the local router IP + LocalRouterIP string `json:"local_router_ip,omitempty"` + // PeerASN is the peer ASN + PeerASN int `json:"peer_asn,omitempty"` + // PeerRouterIP is the peer router IP + PeerRouterIP string `json:"peer_router_ip,omitempty"` + // AuthKey is the authentication key + AuthKey string `json:"auth_key,omitempty"` +} + +func (b *BGP) UnmarshalJSON(data []byte) error { + type Alias BGP + aux := &struct { + LocalASN *int `json:"local_asn,omitempty"` + LocalRouterASN *int `json:"local_router_asn,omitempty"` + PeerASN *int `json:"peer_asn,omitempty"` + PeerRouterASN *int `json:"peer_router_asn,omitempty"` + *Alias + }{ + Alias: (*Alias)(b), + } + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + + if aux.LocalASN != nil { + b.LocalASN = *aux.LocalASN + } else if aux.LocalRouterASN != nil { + b.LocalASN = *aux.LocalRouterASN + } + + if aux.PeerASN != nil { + b.PeerASN = *aux.PeerASN + } else if aux.PeerRouterASN != nil { + b.PeerASN = *aux.PeerRouterASN + } + return nil +} + +// BGPInput represents the BGP configuration of a Partner Connect. +type BGPInput struct { + // LocalASN is the local ASN + LocalASN int `json:"local_router_asn,omitempty"` + // LocalRouterIP is the local router IP + LocalRouterIP string `json:"local_router_ip,omitempty"` + // PeerASN is the peer ASN + PeerASN int `json:"peer_router_asn,omitempty"` + // PeerRouterIP is the peer router IP + PeerRouterIP string `json:"peer_router_ip,omitempty"` + // AuthKey is the authentication key + AuthKey string `json:"auth_key,omitempty"` +} + +// ServiceKey represents the service key of a Partner Connect. +type ServiceKey struct { + Value string `json:"value,omitempty"` + State string `json:"state,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` +} + +// RemoteRoute represents a route for a Partner Connect. +type RemoteRoute struct { + // ID is the generated ID of the Route + ID string `json:"id,omitempty"` + // Cidr is the CIDR of the route + Cidr string `json:"cidr,omitempty"` +} + +// PartnerNetworkConnect represents a DigitalOcean Partner Connect. +type PartnerNetworkConnect struct { + // ID is the generated ID of the Partner Connect + ID string `json:"id,omitempty"` + // Name is the name of the Partner Connect + Name string `json:"name,omitempty"` + // State is the state of the Partner Connect + State string `json:"state,omitempty"` + // ConnectionBandwidthInMbps is the bandwidth of the connection in Mbps + ConnectionBandwidthInMbps int `json:"connection_bandwidth_in_mbps,omitempty"` + // Region is the region where the Partner Connect is created + Region string `json:"region,omitempty"` + // NaaSProvider is the name of the Network as a Service provider + NaaSProvider string `json:"naas_provider,omitempty"` + // VPCIDs is the IDs of the VPCs to which the Partner Connect is connected + VPCIDs []string `json:"vpc_ids,omitempty"` + // BGP is the BGP configuration of the Partner Connect + BGP BGP `json:"bgp,omitempty"` + // CreatedAt is time when this Partner Connect was first created + CreatedAt time.Time `json:"created_at,omitempty"` +} + +type partnerNetworkConnectAttachmentRoot struct { + PartnerNetworkConnect *PartnerNetworkConnect `json:"-"` +} + +func (r *partnerNetworkConnectAttachmentRoot) UnmarshalJSON(data []byte) error { + // auxiliary structure to capture both potential keys + var aux struct { + PartnerNetworkConnect *PartnerNetworkConnect `json:"partner_network_connect"` + PartnerInterconnectAttachment *PartnerNetworkConnect `json:"partner_interconnect_attachment"` + } + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + + if aux.PartnerNetworkConnect != nil { + r.PartnerNetworkConnect = aux.PartnerNetworkConnect + } else { + r.PartnerNetworkConnect = aux.PartnerInterconnectAttachment + } + return nil +} + +type partnerNetworkConnectsRoot struct { + PartnerNetworkConnects []*PartnerNetworkConnect `json:"-"` + Links *Links `json:"links"` + Meta *Meta `json:"meta"` +} + +func (r *partnerNetworkConnectsRoot) UnmarshalJSON(data []byte) error { + var aux struct { + PartnerInterconnectAttachments []*PartnerNetworkConnect `json:"partner_interconnect_attachments"` + PartnerNetworkConnects []*PartnerNetworkConnect `json:"partner_network_connects"` + Links *Links `json:"links"` + Meta *Meta `json:"meta"` + } + + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + + if aux.PartnerNetworkConnects != nil { + r.PartnerNetworkConnects = aux.PartnerNetworkConnects + } else { + r.PartnerNetworkConnects = aux.PartnerInterconnectAttachments + } + + r.Links = aux.Links + r.Meta = aux.Meta + + return nil +} + +type serviceKeyRoot struct { + ServiceKey *ServiceKey `json:"service_key"` +} + +type remoteRoutesRoot struct { + RemoteRoutes []*RemoteRoute `json:"remote_routes"` + Links *Links `json:"links"` + Meta *Meta `json:"meta"` +} + +type BgpAuthKey struct { + Value string `json:"value"` +} + +type bgpAuthKeyRoot struct { + BgpAuthKey *BgpAuthKey `json:"bgp_auth_key"` +} + +type RegenerateServiceKey struct { +} + +type regenerateServiceKeyRoot struct { + RegenerateServiceKey *RegenerateServiceKey `json:"-"` +} + +// List returns a list of all Partner Connect, with optional pagination. +func (s *PartnerNetworkConnectsServiceOp) List(ctx context.Context, opt *ListOptions) ([]*PartnerNetworkConnect, *Response, error) { + path, err := addOptions(partnerNetworkConnectBasePath, opt) + if err != nil { + return nil, nil, err + } + req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(partnerNetworkConnectsRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + if l := root.Links; l != nil { + resp.Links = l + } + if m := root.Meta; m != nil { + resp.Meta = m + } + return root.PartnerNetworkConnects, resp, nil +} + +// Create creates a new Partner Connect. +func (s *PartnerNetworkConnectsServiceOp) Create(ctx context.Context, create *PartnerNetworkConnectCreateRequest) (*PartnerNetworkConnect, *Response, error) { + path := partnerNetworkConnectBasePath + + req, err := s.client.NewRequest(ctx, http.MethodPost, path, create.buildReq()) + if err != nil { + return nil, nil, err + } + + root := new(partnerNetworkConnectAttachmentRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.PartnerNetworkConnect, resp, nil +} + +// Get returns the details of a Partner Connect. +func (s *PartnerNetworkConnectsServiceOp) Get(ctx context.Context, id string) (*PartnerNetworkConnect, *Response, error) { + path := fmt.Sprintf("%s/%s", partnerNetworkConnectBasePath, id) + req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(partnerNetworkConnectAttachmentRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.PartnerNetworkConnect, resp, nil +} + +// Update updates a Partner Connect properties. +func (s *PartnerNetworkConnectsServiceOp) Update(ctx context.Context, id string, update *PartnerNetworkConnectUpdateRequest) (*PartnerNetworkConnect, *Response, error) { + path := fmt.Sprintf("%s/%s", partnerNetworkConnectBasePath, id) + req, err := s.client.NewRequest(ctx, http.MethodPatch, path, update) + if err != nil { + return nil, nil, err + } + + root := new(partnerNetworkConnectAttachmentRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.PartnerNetworkConnect, resp, nil +} + +// Delete deletes a Partner Connect. +func (s *PartnerNetworkConnectsServiceOp) Delete(ctx context.Context, id string) (*Response, error) { + path := fmt.Sprintf("%s/%s", partnerNetworkConnectBasePath, id) + req, err := s.client.NewRequest(ctx, http.MethodDelete, path, nil) + if err != nil { + return nil, err + } + + resp, err := s.client.Do(ctx, req, nil) + if err != nil { + return resp, err + } + + return resp, nil +} + +func (s *PartnerNetworkConnectsServiceOp) GetServiceKey(ctx context.Context, id string) (*ServiceKey, *Response, error) { + path := fmt.Sprintf("%s/%s/service_key", partnerNetworkConnectBasePath, id) + req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(serviceKeyRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.ServiceKey, resp, nil +} + +// ListRoutes lists all remote routes for a Partner Connect. +func (s *PartnerNetworkConnectsServiceOp) ListRoutes(ctx context.Context, id string, opt *ListOptions) ([]*RemoteRoute, *Response, error) { + path, err := addOptions(fmt.Sprintf("%s/%s/remote_routes", partnerNetworkConnectBasePath, id), opt) + if err != nil { + return nil, nil, err + } + req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(remoteRoutesRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + if l := root.Links; l != nil { + resp.Links = l + } + if m := root.Meta; m != nil { + resp.Meta = m + } + + return root.RemoteRoutes, resp, nil +} + +// SetRoutes updates specific properties of a Partner Connect. +func (s *PartnerNetworkConnectsServiceOp) SetRoutes(ctx context.Context, id string, set *PartnerNetworkConnectSetRoutesRequest) (*PartnerNetworkConnect, *Response, error) { + path := fmt.Sprintf("%s/%s/remote_routes", partnerNetworkConnectBasePath, id) + req, err := s.client.NewRequest(ctx, http.MethodPut, path, set) + if err != nil { + return nil, nil, err + } + + root := new(partnerNetworkConnectAttachmentRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.PartnerNetworkConnect, resp, nil +} + +// GetBGPAuthKey returns Partner Connect bgp auth key +func (s *PartnerNetworkConnectsServiceOp) GetBGPAuthKey(ctx context.Context, iaID string) (*BgpAuthKey, *Response, error) { + path := fmt.Sprintf("%s/%s/bgp_auth_key", partnerNetworkConnectBasePath, iaID) + req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(bgpAuthKeyRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.BgpAuthKey, resp, nil +} + +// RegenerateServiceKey regenerates the service key of a Partner Connect. +func (s *PartnerNetworkConnectsServiceOp) RegenerateServiceKey(ctx context.Context, iaID string) (*RegenerateServiceKey, *Response, error) { + path := fmt.Sprintf("%s/%s/service_key", partnerNetworkConnectBasePath, iaID) + req, err := s.client.NewRequest(ctx, http.MethodPost, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(regenerateServiceKeyRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.RegenerateServiceKey, resp, nil +} diff --git a/vendor/github.com/digitalocean/godo/snapshots.go b/vendor/github.com/digitalocean/godo/snapshots.go index 13a06ca3..31fd494c 100644 --- a/vendor/github.com/digitalocean/godo/snapshots.go +++ b/vendor/github.com/digitalocean/godo/snapshots.go @@ -14,6 +14,7 @@ const snapshotBasePath = "v2/snapshots" type SnapshotsService interface { List(context.Context, *ListOptions) ([]Snapshot, *Response, error) ListVolume(context.Context, *ListOptions) ([]Snapshot, *Response, error) + ListVolumeSnapshotByRegion(context.Context, string, *ListOptions) ([]Snapshot, *Response, error) ListDroplet(context.Context, *ListOptions) ([]Snapshot, *Response, error) Get(context.Context, string) (*Snapshot, *Response, error) Delete(context.Context, string) (*Response, error) @@ -52,6 +53,7 @@ type snapshotsRoot struct { type listSnapshotOptions struct { ResourceType string `url:"resource_type,omitempty"` + Region string `url:"region,omitempty"` } func (s Snapshot) String() string { @@ -75,6 +77,12 @@ func (s *SnapshotsServiceOp) ListVolume(ctx context.Context, opt *ListOptions) ( return s.list(ctx, opt, &listOpt) } +// ListVolumeSnapshotByRegion lists all the volume snapshot for given region +func (s *SnapshotsServiceOp) ListVolumeSnapshotByRegion(ctx context.Context, region string, opt *ListOptions) ([]Snapshot, *Response, error) { + listOpt := listSnapshotOptions{ResourceType: "volume", Region: region} + return s.list(ctx, opt, &listOpt) +} + // Get retrieves a snapshot by id. func (s *SnapshotsServiceOp) Get(ctx context.Context, snapshotID string) (*Snapshot, *Response, error) { return s.get(ctx, snapshotID) diff --git a/vendor/github.com/digitalocean/godo/spaces_keys.go b/vendor/github.com/digitalocean/godo/spaces_keys.go index 371d8a14..8aee31db 100644 --- a/vendor/github.com/digitalocean/godo/spaces_keys.go +++ b/vendor/github.com/digitalocean/godo/spaces_keys.go @@ -14,6 +14,7 @@ type SpacesKeysService interface { Update(context.Context, string, *SpacesKeyUpdateRequest) (*SpacesKey, *Response, error) Create(context.Context, *SpacesKeyCreateRequest) (*SpacesKey, *Response, error) Delete(context.Context, string) (*Response, error) + Get(context.Context, string) (*SpacesKey, *Response, error) } // SpacesKeysServiceOp handles communication with the Spaces key related methods of the @@ -163,3 +164,23 @@ func (s *SpacesKeysServiceOp) List(ctx context.Context, opts *ListOptions) ([]*S return root.Keys, resp, nil } + +// Get retrieves a Spaces key. +func (s *SpacesKeysServiceOp) Get(ctx context.Context, accessKey string) (*SpacesKey, *Response, error) { + if accessKey == "" { + return nil, nil, NewArgError("accessKey", "cannot be empty") + } + + path := fmt.Sprintf("%s/%s", spacesKeysBasePath, accessKey) + req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + root := new(spacesKeyRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.Key, resp, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6acadccb..f3da58cb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/cespare/xxhash/v2 # github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc ## explicit github.com/davecgh/go-spew/spew -# github.com/digitalocean/godo v1.134.0 +# github.com/digitalocean/godo v1.141.0 ## explicit; go 1.22 github.com/digitalocean/godo github.com/digitalocean/godo/metrics