Skip to content

Commit

Permalink
Added support for missing LKE-related endpoints (#594)
Browse files Browse the repository at this point in the history
* Added support for missing LKE-related endpoints

* Addressed PR comments

* Added unit tests
  • Loading branch information
ezilber-akamai authored Oct 31, 2024
1 parent e84e404 commit 551a48a
Show file tree
Hide file tree
Showing 22 changed files with 3,142 additions and 27 deletions.
12 changes: 8 additions & 4 deletions lke_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ func (c *Client) UpdateLKECluster(ctx context.Context, clusterID int, opts LKECl
// DeleteLKECluster deletes the LKECluster with the specified id
func (c *Client) DeleteLKECluster(ctx context.Context, clusterID int) error {
e := formatAPIPath("lke/clusters/%d", clusterID)
err := doDELETERequest(ctx, c, e)
return err
return doDELETERequest(ctx, c, e)
}

// GetLKEClusterKubeconfig gets the Kubeconfig for the LKE Cluster specified
Expand All @@ -239,6 +238,12 @@ func (c *Client) GetLKEClusterKubeconfig(ctx context.Context, clusterID int) (*L
return response, nil
}

// DeleteLKEClusterKubeconfig deletes the Kubeconfig for the LKE Cluster specified
func (c *Client) DeleteLKEClusterKubeconfig(ctx context.Context, clusterID int) error {
e := formatAPIPath("lke/clusters/%d/kubeconfig", clusterID)
return doDELETERequest(ctx, c, e)
}

// GetLKEClusterDashboard gets information about the dashboard for an LKE cluster
func (c *Client) GetLKEClusterDashboard(ctx context.Context, clusterID int) (*LKEClusterDashboard, error) {
e := formatAPIPath("lke/clusters/%d/dashboard", clusterID)
Expand Down Expand Up @@ -271,6 +276,5 @@ func (c *Client) RegenerateLKECluster(ctx context.Context, clusterID int, opts L
// DeleteLKEClusterServiceToken deletes and regenerate the service account token for a Cluster.
func (c *Client) DeleteLKEClusterServiceToken(ctx context.Context, clusterID int) error {
e := formatAPIPath("lke/clusters/%d/servicetoken", clusterID)
err := doDELETERequest(ctx, c, e)
return err
return doDELETERequest(ctx, c, e)
}
39 changes: 35 additions & 4 deletions lke_node_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ func (c *Client) CreateLKENodePool(ctx context.Context, clusterID int, opts LKEN
return response, nil
}

// RecycleLKENodePool recycles a LKENodePool
func (c *Client) RecycleLKENodePool(ctx context.Context, clusterID, poolID int) error {
e := formatAPIPath("lke/clusters/%d/pools/%d/recycle", clusterID, poolID)
_, err := doPOSTRequest[LKENodePool, any](ctx, c, e)
if err != nil {
return err
}

return nil
}

// UpdateLKENodePool updates the LKENodePool with the specified id
func (c *Client) UpdateLKENodePool(ctx context.Context, clusterID, poolID int, opts LKENodePoolUpdateOptions) (*LKENodePool, error) {
e := formatAPIPath("lke/clusters/%d/pools/%d", clusterID, poolID)
Expand All @@ -159,13 +170,33 @@ func (c *Client) UpdateLKENodePool(ctx context.Context, clusterID, poolID int, o
// DeleteLKENodePool deletes the LKENodePool with the specified id
func (c *Client) DeleteLKENodePool(ctx context.Context, clusterID, poolID int) error {
e := formatAPIPath("lke/clusters/%d/pools/%d", clusterID, poolID)
err := doDELETERequest(ctx, c, e)
return err
return doDELETERequest(ctx, c, e)
}

// GetLKENodePoolNode gets the LKENodePoolLinode with the provided ID
func (c *Client) GetLKENodePoolNode(ctx context.Context, clusterID int, nodeID string) (*LKENodePoolLinode, error) {
e := formatAPIPath("lke/clusters/%d/nodes/%s", clusterID, nodeID)
response, err := doGETRequest[LKENodePoolLinode](ctx, c, e)
if err != nil {
return nil, err
}

return response, nil
}

// RecycleLKENodePoolNode recycles a LKENodePoolLinode
func (c *Client) RecycleLKENodePoolNode(ctx context.Context, clusterID int, nodeID string) error {
e := formatAPIPath("lke/clusters/%d/nodes/%s/recycle", clusterID, nodeID)
_, err := doPOSTRequest[LKENodePoolLinode, any](ctx, c, e)
if err != nil {
return err
}

return nil
}

// DeleteLKENodePoolNode deletes a given node from a node pool
func (c *Client) DeleteLKENodePoolNode(ctx context.Context, clusterID int, nodeID string) error {
e := formatAPIPath("lke/clusters/%d/nodes/%s", clusterID, nodeID)
err := doDELETERequest(ctx, c, e)
return err
return doDELETERequest(ctx, c, e)
}
4 changes: 2 additions & 2 deletions test/integration/fixtures/TestIPv6Pool_Get.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ interactions:
- application/json
Content-Type:
- application/json
url: https://api.linode.com/v4beta/networking/ipv6/pools/2600:3c00::%2F32
url: https://api.linode.com/v4beta/networking/ipv6/pools/1234::5678%2F32
method: GET
response:
body: '{"range": "2600:3c00::/32", "region": "us-east", "route_target": "2600:3c00::/32"}'
body: '{"range": "1234::5678/32", "region": "us-east", "route_target": "1234::5678/32"}'
headers:
Content-Type:
- application/json
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fixtures/TestIPv6Pool_List.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interactions:
url: https://api.linode.com/v4beta/networking/ipv6/pools?page=1
method: GET
response:
body: '{"data": [{"range": "2600:3c00::/32", "region": "us-east", "route_target": "2600:3c00::/32"}], "page": 1, "pages": 1, "results": 1}'
body: '{"data": [{"range": "1234::5678/32", "region": "us-east", "route_target": "1234::5678/32"}], "page": 1, "pages": 1, "results": 1}'
headers:
Content-Type:
- application/json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interactions:
response:
body: '{"id": 63837282, "label": "test-instance-for-ip-reservation", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["45.79.160.146"], "ipv6": "2600:3c03::f03c:95ff:fe46:25ac/128",
"type": "g6-nanode-1", "ipv4": ["45.79.160.146"], "ipv6": "1234::5678/128",
"image": null, "region": "us-east", "site_type": "core", "specs": {"disk": 25600,
"memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu":
90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000},
Expand Down Expand Up @@ -220,10 +220,10 @@ interactions:
"ipv4", "public": true, "rdns": "45-79-160-146.ip.linodeusercontent.com", "linode_id":
63837282, "region": "us-east", "vpc_nat_1_1": null, "reserved": false}], "private":
[], "shared": [], "reserved": [], "vpc": []}, "ipv6": {"slaac": {"address":
"2600:3c03::f03c:95ff:fe46:25ac", "gateway": "fe80::1", "subnet_mask": "ffff:ffff:ffff:ffff::",
"1234::5678", "gateway": "1234::5678", "subnet_mask": "1234::5678",
"prefix": 64, "type": "ipv6", "rdns": null, "linode_id": 63837282, "region":
"us-east", "public": true}, "link_local": {"address": "fe80::f03c:95ff:fe46:25ac",
"gateway": "fe80::1", "subnet_mask": "ffff:ffff:ffff:ffff::", "prefix": 64,
"us-east", "public": true}, "link_local": {"address": "1234::5678",
"gateway": "1234::5678", "subnet_mask": "1234::5678", "prefix": 64,
"type": "ipv6", "rdns": null, "linode_id": 63837282, "region": "us-east", "public":
false}, "global": []}}'
headers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interactions:
response:
body: '{"id": 63837167, "label": "test-instance-for-ip-reservation", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["97.107.141.56"], "ipv6": "2600:3c03::f03c:95ff:fe46:d62c/128",
"type": "g6-nanode-1", "ipv4": ["97.107.141.56"], "ipv6": "1234::5678/128",
"image": null, "region": "us-east", "site_type": "core", "specs": {"disk": 25600,
"memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu":
90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interactions:
response:
body: '{"id": 63830251, "label": "go-test-ins-reserved-ip-5joh9oqb2908", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["172.104.28.100"], "ipv6": "2600:3c03::f03c:95ff:fea5:b601/128",
"type": "g6-nanode-1", "ipv4": ["172.104.28.100"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interactions:
response:
body: '{"id": 63830264, "label": "go-test-ins-reserved-ip-vym5299ve91d", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["45.56.104.17"], "ipv6": "2600:3c03::f03c:95ff:fea5:b690/128",
"type": "g6-nanode-1", "ipv4": ["45.56.104.17"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interactions:
response:
body: '{"id": 63830249, "label": "go-test-ins-reserved-ip-vsr6v8p5t918", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["172.104.28.70"], "ipv6": "2600:3c03::f03c:95ff:fea5:b656/128",
"type": "g6-nanode-1", "ipv4": ["172.104.28.70"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interactions:
response:
body: '{"id": 63432426, "label": "go-test-ins-reserved-ip-x0or7k0186hu", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["172.104.20.68"], "ipv6": "2600:3c03::f03c:95ff:fec2:4ccc/128",
"type": "g6-nanode-1", "ipv4": ["172.104.20.68"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interactions:
response:
body: '{"id": 63432429, "label": "go-test-ins-reserved-ip-776ugys2x84t", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["172.104.20.77"], "ipv6": "2600:3c03::f03c:95ff:fec2:4c1b/128",
"type": "g6-nanode-1", "ipv4": ["172.104.20.77"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down Expand Up @@ -330,7 +330,7 @@ interactions:
response:
body: '{"id": 63432443, "label": "go-test-ins-reserved-ip-e14gz6bc5p37", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["97.107.138.251"], "ipv6": "2600:3c03::f03c:95ff:fec2:4c10/128",
"type": "g6-nanode-1", "ipv4": ["97.107.138.251"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down Expand Up @@ -446,7 +446,7 @@ interactions:
response:
body: '{"id": 63432444, "label": "go-test-ins-reserved-ip-bw5b43pih670", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["45.33.68.112"], "ipv6": "2600:3c03::f03c:95ff:fec2:4c8b/128",
"type": "g6-nanode-1", "ipv4": ["45.33.68.112"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interactions:
response:
body: '{"id": 63830274, "label": "go-test-ins-reserved-ip-le6w459su62x", "group":
"", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["45.56.104.28"], "ipv6": "2600:3c03::f03c:95ff:fea5:92e5/128",
"type": "g6-nanode-1", "ipv4": ["45.56.104.28"], "ipv6": "1234::5678/128",
"image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs":
{"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts":
{"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io":
Expand Down
Loading

0 comments on commit 551a48a

Please sign in to comment.