Skip to content

Commit 391c4e7

Browse files
Add APL-related fields
1 parent f1fa70e commit 391c4e7

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

linode_api4/groups/lke.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def cluster_create(
6666
control_plane: Union[
6767
LKEClusterControlPlaneOptions, Dict[str, Any]
6868
] = None,
69+
apl_enabled: bool = False,
6970
**kwargs,
7071
):
7172
"""
@@ -100,8 +101,10 @@ def cluster_create(
100101
formatted dicts.
101102
:param kube_version: The version of Kubernetes to use
102103
:type kube_version: KubeVersion or str
103-
:param control_plane: Dict[str, Any] or LKEClusterControlPlaneRequest
104-
:type control_plane: The control plane configuration of this LKE cluster.
104+
:param control_plane: The control plane configuration of this LKE cluster.
105+
:type control_plane: Dict[str, Any] or LKEClusterControlPlaneRequest
106+
:param apl_enabled: Whether this cluster should use APL.
107+
:type apl_enabled: bool
105108
:param kwargs: Any other arguments to pass along to the API. See the API
106109
docs for possible values.
107110
@@ -120,6 +123,10 @@ def cluster_create(
120123
}
121124
params.update(kwargs)
122125

126+
# Prevent errors for users without access to APL
127+
if apl_enabled:
128+
params["apl_enabled"] = apl_enabled
129+
123130
result = self.client.post(
124131
"/lke/clusters",
125132
data=_flatten_request_body_recursive(drop_null_keys(params)),

linode_api4/objects/lke.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class LKECluster(Base):
257257
"k8s_version": Property(slug_relationship=KubeVersion, mutable=True),
258258
"pools": Property(derived_class=LKENodePool),
259259
"control_plane": Property(mutable=True),
260+
"apl_enabled": Property(mutable=True),
260261
}
261262

262263
def invalidate(self):
@@ -353,6 +354,36 @@ def control_plane_acl(self) -> LKEClusterControlPlaneACL:
353354

354355
return LKEClusterControlPlaneACL.from_json(self._control_plane_acl)
355356

357+
@property
358+
def apl_console_url(self) -> Optional[str]:
359+
"""
360+
Returns the URL of this cluster's APL installation if this cluster
361+
is APL-enabled, else None.
362+
363+
:returns: The URL of the APL console for this cluster.
364+
:rtype: str or None
365+
"""
366+
367+
if not self.apl_enabled:
368+
return None
369+
370+
return f"https://console.lke{self.id}.akamai-apl.net"
371+
372+
@property
373+
def apl_health_check_url(self) -> Optional[str]:
374+
"""
375+
Returns the URL of this cluster's APL health check endpoint if this cluster
376+
is APL-enabled, else None.
377+
378+
:returns: The URL of the APL console for this cluster.
379+
:rtype: str or None
380+
"""
381+
382+
if not self.apl_enabled:
383+
return None
384+
385+
return f"https://auth.lke{self.id}.akamai-apl.net/ready"
386+
356387
def node_pool_create(
357388
self,
358389
node_type: Union[Type, str],

0 commit comments

Comments
 (0)