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,8 @@ 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+ :type disk_encryption: InstanceDiskEncryptionType or str
14121439
14131440 :returns: The newly generated password, if one was not provided
14141441 (otherwise True)
@@ -1426,6 +1453,10 @@ def rebuild(self, image, root_pass=None, authorized_keys=None, **kwargs):
14261453 "root_pass" : root_pass ,
14271454 "authorized_keys" : authorized_keys ,
14281455 }
1456+
1457+ if disk_encryption is not None :
1458+ params ["disk_encryption" ] = str (disk_encryption )
1459+
14291460 params .update (kwargs )
14301461
14311462 result = self ._client .post (
@@ -1755,6 +1786,22 @@ def stats(self):
17551786 "{}/stats" .format (Instance .api_endpoint ), model = self
17561787 )
17571788
1789+ @property
1790+ def lke_cluster (self ) -> Optional ["LKECluster" ]:
1791+ """
1792+ Returns the LKE Cluster this Instance is a node of.
1793+
1794+ :returns: The LKE Cluster this Instance is a node of.
1795+ :rtype: Optional[LKECluster]
1796+ """
1797+
1798+ # Local import to prevent circular dependency
1799+ from linode_api4 .objects .lke import ( # pylint: disable=import-outside-toplevel
1800+ LKECluster ,
1801+ )
1802+
1803+ return LKECluster (self ._client , self .lke_cluster_id )
1804+
17581805 def stats_for (self , dt ):
17591806 """
17601807 Returns stats for the month containing the given datetime
0 commit comments