|
| 1 | +from typing import Any, Dict, Union |
| 2 | + |
1 | 3 | from linode_api4.errors import UnexpectedResponseError
|
2 | 4 | from linode_api4.groups import Group
|
3 |
| -from linode_api4.objects import Base, KubeVersion, LKECluster |
| 5 | +from linode_api4.objects import ( |
| 6 | + Base, |
| 7 | + JSONObject, |
| 8 | + KubeVersion, |
| 9 | + LKECluster, |
| 10 | + LKEClusterControlPlaneOptions, |
| 11 | + drop_null_keys, |
| 12 | +) |
4 | 13 |
|
5 | 14 |
|
6 | 15 | class LKEGroup(Group):
|
@@ -47,7 +56,17 @@ def clusters(self, *filters):
|
47 | 56 | """
|
48 | 57 | return self.client._get_and_filter(LKECluster, *filters)
|
49 | 58 |
|
50 |
| - def cluster_create(self, region, label, node_pools, kube_version, **kwargs): |
| 59 | + def cluster_create( |
| 60 | + self, |
| 61 | + region, |
| 62 | + label, |
| 63 | + node_pools, |
| 64 | + kube_version, |
| 65 | + control_plane: Union[ |
| 66 | + LKEClusterControlPlaneOptions, Dict[str, Any] |
| 67 | + ] = None, |
| 68 | + **kwargs, |
| 69 | + ): |
51 | 70 | """
|
52 | 71 | Creates an :any:`LKECluster` on this account in the given region, with
|
53 | 72 | the given label, and with node pools as described. For example::
|
@@ -80,6 +99,8 @@ def cluster_create(self, region, label, node_pools, kube_version, **kwargs):
|
80 | 99 | formatted dicts.
|
81 | 100 | :param kube_version: The version of Kubernetes to use
|
82 | 101 | :type kube_version: KubeVersion or str
|
| 102 | + :param control_plane: Dict[str, Any] or LKEClusterControlPlaneRequest |
| 103 | + :type control_plane: The control plane configuration of this LKE cluster. |
83 | 104 | :param kwargs: Any other arguments to pass along to the API. See the API
|
84 | 105 | docs for possible values.
|
85 | 106 |
|
@@ -112,10 +133,15 @@ def cluster_create(self, region, label, node_pools, kube_version, **kwargs):
|
112 | 133 | if issubclass(type(kube_version), Base)
|
113 | 134 | else kube_version
|
114 | 135 | ),
|
| 136 | + "control_plane": ( |
| 137 | + control_plane.dict |
| 138 | + if issubclass(type(control_plane), JSONObject) |
| 139 | + else control_plane |
| 140 | + ), |
115 | 141 | }
|
116 | 142 | params.update(kwargs)
|
117 | 143 |
|
118 |
| - result = self.client.post("/lke/clusters", data=params) |
| 144 | + result = self.client.post("/lke/clusters", data=drop_null_keys(params)) |
119 | 145 |
|
120 | 146 | if "id" not in result:
|
121 | 147 | raise UnexpectedResponseError(
|
|
0 commit comments