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 ):
@@ -650,6 +664,8 @@ class Instance(Base):
650664 "host_uuid" : Property (),
651665 "watchdog_enabled" : Property (mutable = True ),
652666 "has_user_data" : Property (),
667+ "disk_encryption" : Property (),
668+ "lke_cluster_id" : Property (),
653669 }
654670
655671 @property
@@ -1343,7 +1359,16 @@ def ip_allocate(self, public=False):
13431359 i = IPAddress (self ._client , result ["address" ], result )
13441360 return i
13451361
1346- def rebuild (self , image , root_pass = None , authorized_keys = None , ** kwargs ):
1362+ def rebuild (
1363+ self ,
1364+ image ,
1365+ root_pass = None ,
1366+ authorized_keys = None ,
1367+ disk_encryption : Optional [
1368+ Union [InstanceDiskEncryptionType , str ]
1369+ ] = None ,
1370+ ** kwargs ,
1371+ ):
13471372 """
13481373 Rebuilding an Instance deletes all existing Disks and Configs and deploys
13491374 a new :any:`Image` to it. This can be used to reset an existing
@@ -1361,6 +1386,8 @@ def rebuild(self, image, root_pass=None, authorized_keys=None, **kwargs):
13611386 be a single key, or a path to a file containing
13621387 the key.
13631388 :type authorized_keys: list or str
1389+ :param disk_encryption: The disk encryption policy for this Linode.
1390+ :type disk_encryption: InstanceDiskEncryptionType or str
13641391
13651392 :returns: The newly generated password, if one was not provided
13661393 (otherwise True)
@@ -1378,6 +1405,10 @@ def rebuild(self, image, root_pass=None, authorized_keys=None, **kwargs):
13781405 "root_pass" : root_pass ,
13791406 "authorized_keys" : authorized_keys ,
13801407 }
1408+
1409+ if disk_encryption is not None :
1410+ params ["disk_encryption" ] = str (disk_encryption )
1411+
13811412 params .update (kwargs )
13821413
13831414 result = self ._client .post (
@@ -1683,6 +1714,22 @@ def stats(self):
16831714 "{}/stats" .format (Instance .api_endpoint ), model = self
16841715 )
16851716
1717+ @property
1718+ def lke_cluster (self ) -> Optional ["LKECluster" ]:
1719+ """
1720+ Returns the LKE Cluster this Instance is a node of.
1721+
1722+ :returns: The LKE Cluster this Instance is a node of.
1723+ :rtype: Optional[LKECluster]
1724+ """
1725+
1726+ # Local import to prevent circular dependency
1727+ from linode_api4 .objects .lke import ( # pylint: disable=import-outside-toplevel
1728+ LKECluster ,
1729+ )
1730+
1731+ return LKECluster (self ._client , self .lke_cluster_id )
1732+
16861733 def stats_for (self , dt ):
16871734 """
16881735 Returns stats for the month containing the given datetime
0 commit comments