Skip to content

Commit

Permalink
Add APL-related fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarber-akamai committed Jan 15, 2025
1 parent f1fa70e commit 391c4e7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
11 changes: 9 additions & 2 deletions linode_api4/groups/lke.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def cluster_create(
control_plane: Union[
LKEClusterControlPlaneOptions, Dict[str, Any]
] = None,
apl_enabled: bool = False,
**kwargs,
):
"""
Expand Down Expand Up @@ -100,8 +101,10 @@ def cluster_create(
formatted dicts.
:param kube_version: The version of Kubernetes to use
:type kube_version: KubeVersion or str
:param control_plane: Dict[str, Any] or LKEClusterControlPlaneRequest
:type control_plane: The control plane configuration of this LKE cluster.
:param control_plane: The control plane configuration of this LKE cluster.
:type control_plane: Dict[str, Any] or LKEClusterControlPlaneRequest
:param apl_enabled: Whether this cluster should use APL.
:type apl_enabled: bool
:param kwargs: Any other arguments to pass along to the API. See the API
docs for possible values.
Expand All @@ -120,6 +123,10 @@ def cluster_create(
}
params.update(kwargs)

# Prevent errors for users without access to APL
if apl_enabled:
params["apl_enabled"] = apl_enabled

result = self.client.post(
"/lke/clusters",
data=_flatten_request_body_recursive(drop_null_keys(params)),
Expand Down
31 changes: 31 additions & 0 deletions linode_api4/objects/lke.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class LKECluster(Base):
"k8s_version": Property(slug_relationship=KubeVersion, mutable=True),
"pools": Property(derived_class=LKENodePool),
"control_plane": Property(mutable=True),
"apl_enabled": Property(mutable=True),
}

def invalidate(self):
Expand Down Expand Up @@ -353,6 +354,36 @@ def control_plane_acl(self) -> LKEClusterControlPlaneACL:

return LKEClusterControlPlaneACL.from_json(self._control_plane_acl)

@property
def apl_console_url(self) -> Optional[str]:
"""
Returns the URL of this cluster's APL installation if this cluster
is APL-enabled, else None.
:returns: The URL of the APL console for this cluster.
:rtype: str or None
"""

if not self.apl_enabled:
return None

return f"https://console.lke{self.id}.akamai-apl.net"

@property
def apl_health_check_url(self) -> Optional[str]:
"""
Returns the URL of this cluster's APL health check endpoint if this cluster
is APL-enabled, else None.
:returns: The URL of the APL console for this cluster.
:rtype: str or None
"""

if not self.apl_enabled:
return None

return f"https://auth.lke{self.id}.akamai-apl.net/ready"

def node_pool_create(
self,
node_type: Union[Type, str],
Expand Down

0 comments on commit 391c4e7

Please sign in to comment.