2222from linode_api4 .objects .base import MappedObject
2323from linode_api4 .objects .filtering import FilterableAttribute
2424from linode_api4 .objects .networking import IPAddress , IPv6Range , VPCIPAddress
25+ from linode_api4 .objects .serializable import StrEnum
2526from linode_api4 .objects .vpc import VPC , VPCSubnet
2627from linode_api4 .paginated_list import PaginatedList
2728
2829PASSWORD_CHARS = string .ascii_letters + string .digits + string .punctuation
2930
3031
32+ class InstanceDiskEncryptionType (StrEnum ):
33+ """
34+ InstanceDiskEncryptionType defines valid values for the
35+ Instance(...).disk_encryption field.
36+
37+ API Documentation: TODO
38+ """
39+
40+ enabled = "enabled"
41+ disabled = "disabled"
42+
43+
3144class Backup (DerivedBase ):
3245 """
3346 A Backup of a Linode Instance.
@@ -114,6 +127,7 @@ class Disk(DerivedBase):
114127 "filesystem" : Property (),
115128 "updated" : Property (is_datetime = True ),
116129 "linode_id" : Property (identifier = True ),
130+ "disk_encryption" : Property (),
117131 }
118132
119133 def duplicate (self ):
@@ -662,6 +676,8 @@ class Instance(Base):
662676 "host_uuid" : Property (),
663677 "watchdog_enabled" : Property (mutable = True ),
664678 "has_user_data" : Property (),
679+ "disk_encryption" : Property (),
680+ "lke_cluster_id" : Property (),
665681 }
666682
667683 @property
@@ -1391,7 +1407,16 @@ def ip_allocate(self, public=False):
13911407 i = IPAddress (self ._client , result ["address" ], result )
13921408 return i
13931409
1394- def rebuild (self , image , root_pass = None , authorized_keys = None , ** kwargs ):
1410+ def rebuild (
1411+ self ,
1412+ image ,
1413+ root_pass = None ,
1414+ authorized_keys = None ,
1415+ disk_encryption : Optional [
1416+ Union [InstanceDiskEncryptionType , str ]
1417+ ] = None ,
1418+ ** kwargs ,
1419+ ):
13951420 """
13961421 Rebuilding an Instance deletes all existing Disks and Configs and deploys
13971422 a new :any:`Image` to it. This can be used to reset an existing
@@ -1409,6 +1434,9 @@ def rebuild(self, image, root_pass=None, authorized_keys=None, **kwargs):
14091434 be a single key, or a path to a file containing
14101435 the key.
14111436 :type authorized_keys: list or str
1437+ :param disk_encryption: The disk encryption policy for this Linode.
1438+ NOTE: Disk encryption may not currently be available to all users.
1439+ :type disk_encryption: InstanceDiskEncryptionType or str
14121440
14131441 :returns: The newly generated password, if one was not provided
14141442 (otherwise True)
@@ -1426,6 +1454,10 @@ def rebuild(self, image, root_pass=None, authorized_keys=None, **kwargs):
14261454 "root_pass" : root_pass ,
14271455 "authorized_keys" : authorized_keys ,
14281456 }
1457+
1458+ if disk_encryption is not None :
1459+ params ["disk_encryption" ] = str (disk_encryption )
1460+
14291461 params .update (kwargs )
14301462
14311463 result = self ._client .post (
@@ -1755,6 +1787,22 @@ def stats(self):
17551787 "{}/stats" .format (Instance .api_endpoint ), model = self
17561788 )
17571789
1790+ @property
1791+ def lke_cluster (self ) -> Optional ["LKECluster" ]:
1792+ """
1793+ Returns the LKE Cluster this Instance is a node of.
1794+
1795+ :returns: The LKE Cluster this Instance is a node of.
1796+ :rtype: Optional[LKECluster]
1797+ """
1798+
1799+ # Local import to prevent circular dependency
1800+ from linode_api4 .objects .lke import ( # pylint: disable=import-outside-toplevel
1801+ LKECluster ,
1802+ )
1803+
1804+ return LKECluster (self ._client , self .lke_cluster_id )
1805+
17581806 def stats_for (self , dt ):
17591807 """
17601808 Returns stats for the month containing the given datetime
0 commit comments