Skip to content

Commit

Permalink
Allow to enable LKE APL (#665)
Browse files Browse the repository at this point in the history
* apl enable

* lint

* nit
  • Loading branch information
yec-akamai authored Feb 7, 2025
1 parent a1d5a13 commit c5cc32a
Show file tree
Hide file tree
Showing 3 changed files with 691 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lke_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package linodego
import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/linode/linodego/internal/parseabletime"
Expand Down Expand Up @@ -31,6 +32,9 @@ type LKECluster struct {

// NOTE: Tier may not currently be available to all users and can only be used with v4beta.
Tier string `json:"tier"`

// NOTE: APLEnabled is currently in beta and may only function with API version v4beta.
APLEnabled bool `json:"apl_enabled"`
}

// LKEClusterCreateOptions fields are those accepted by CreateLKECluster
Expand All @@ -44,6 +48,9 @@ type LKEClusterCreateOptions struct {

// NOTE: Tier may not currently be available to all users and can only be used with v4beta.
Tier string `json:"tier,omitempty"`

// NOTE: APLEnabled is currently in beta and may only function with API version v4beta.
APLEnabled bool `json:"apl_enabled,omitempty"`
}

// LKEClusterUpdateOptions fields are those accepted by UpdateLKECluster
Expand Down Expand Up @@ -246,3 +253,31 @@ func (c *Client) DeleteLKEClusterServiceToken(ctx context.Context, clusterID int
e := formatAPIPath("lke/clusters/%d/servicetoken", clusterID)
return doDELETERequest(ctx, c, e)
}

// GetLKEClusterAPLConsoleURL gets the URL of this cluster's APL installation if this cluster is APL-enabled.
func (c *Client) GetLKEClusterAPLConsoleURL(ctx context.Context, clusterID int) (string, error) {
cluster, err := c.GetLKECluster(ctx, clusterID)
if err != nil {
return "", err
}

if cluster.APLEnabled {
return fmt.Sprintf("https://console.lke%d.akamai-apl.net", cluster.ID), nil
}

return "", nil
}

// GetLKEClusterAPLHealthCheckURL gets the URL of this cluster's APL health check endpoint if this cluster is APL-enabled.
func (c *Client) GetLKEClusterAPLHealthCheckURL(ctx context.Context, clusterID int) (string, error) {
cluster, err := c.GetLKECluster(ctx, clusterID)
if err != nil {
return "", err
}

if cluster.APLEnabled {
return fmt.Sprintf("https://auth.lke%d.akamai-apl.net/ready", cluster.ID), nil
}

return "", nil
}
Loading

0 comments on commit c5cc32a

Please sign in to comment.