diff --git a/linode_api4/objects/account.py b/linode_api4/objects/account.py index 375e5fc03..44aeaa715 100644 --- a/linode_api4/objects/account.py +++ b/linode_api4/objects/account.py @@ -16,6 +16,7 @@ from linode_api4.objects.networking import Firewall from linode_api4.objects.nodebalancer import NodeBalancer from linode_api4.objects.profile import PersonalAccessToken +from linode_api4.objects.serializable import StrEnum from linode_api4.objects.support import SupportTicket from linode_api4.objects.volume import Volume from linode_api4.objects.vpc import VPC @@ -179,6 +180,24 @@ class Login(Base): } +class AccountSettingsInterfacesForNewLinodes(StrEnum): + """ + A string enum corresponding to valid values + for the AccountSettings(...).interfaces_for_new_linodes field. + + NOTE: This feature may not currently be available to all users. + """ + + legacy_config_only = "legacy_config_only" + legacy_config_default_but_linode_allowed = ( + "legacy_config_default_but_linode_allowed" + ) + linode_default_but_legacy_config_allowed = ( + "linode_default_but_legacy_config_allowed" + ) + linode_only = "linode_only" + + class AccountSettings(Base): """ Information related to your Account settings. @@ -197,6 +216,7 @@ class AccountSettings(Base): ), "object_storage": Property(), "backups_enabled": Property(mutable=True), + "interfaces_for_new_linodes": Property(mutable=True), } diff --git a/test/fixtures/account.json b/test/fixtures/account.json index 1d823798b..001d7adad 100644 --- a/test/fixtures/account.json +++ b/test/fixtures/account.json @@ -16,7 +16,8 @@ "Linodes", "NodeBalancers", "Block Storage", - "Object Storage" + "Object Storage", + "Linode Interfaces" ], "active_promotions": [ { diff --git a/test/fixtures/account_settings.json b/test/fixtures/account_settings.json index 77a2fdac3..02b711aa6 100644 --- a/test/fixtures/account_settings.json +++ b/test/fixtures/account_settings.json @@ -3,5 +3,6 @@ "managed": false, "network_helper": false, "object_storage": "active", - "backups_enabled": true + "backups_enabled": true, + "interfaces_for_new_linodes": "linode_default_but_legacy_config_allowed" } diff --git a/test/integration/models/account/test_account.py b/test/integration/models/account/test_account.py index decad434f..1ee700495 100644 --- a/test/integration/models/account/test_account.py +++ b/test/integration/models/account/test_account.py @@ -59,6 +59,7 @@ def test_get_account_settings(test_linode_client): assert "longview_subscription" in str(account_settings._raw_json) assert "backups_enabled" in str(account_settings._raw_json) assert "object_storage" in str(account_settings._raw_json) + assert isinstance(account_settings.interfaces_for_new_linodes, str) @pytest.mark.smoke diff --git a/test/unit/linode_client_test.py b/test/unit/linode_client_test.py index c79c0a88d..d2237a366 100644 --- a/test/unit/linode_client_test.py +++ b/test/unit/linode_client_test.py @@ -44,7 +44,13 @@ def test_get_account(self): self.assertEqual(a.balance, 0) self.assertEqual( a.capabilities, - ["Linodes", "NodeBalancers", "Block Storage", "Object Storage"], + [ + "Linodes", + "NodeBalancers", + "Block Storage", + "Object Storage", + "Linode Interfaces", + ], ) def test_get_regions(self): diff --git a/test/unit/objects/account_test.py b/test/unit/objects/account_test.py index 1f9da98fb..650874f45 100644 --- a/test/unit/objects/account_test.py +++ b/test/unit/objects/account_test.py @@ -3,6 +3,7 @@ from datetime import datetime from test.unit.base import ClientBaseCase +from linode_api4 import AccountSettingsInterfacesForNewLinodes from linode_api4.objects import ( Account, AccountAvailability, @@ -97,6 +98,7 @@ def test_get_account(self): self.assertEqual(account.balance_uninvoiced, 145) self.assertEqual(account.billing_source, "akamai") self.assertEqual(account.euuid, "E1AF5EEC-526F-487D-B317EBEB34C87D71") + self.assertIn("Linode Interfaces", account.capabilities) def test_get_login(self): """ @@ -121,6 +123,31 @@ def test_get_account_settings(self): self.assertEqual(settings.network_helper, False) self.assertEqual(settings.object_storage, "active") self.assertEqual(settings.backups_enabled, True) + self.assertEqual( + settings.interfaces_for_new_linodes, + AccountSettingsInterfacesForNewLinodes.linode_default_but_legacy_config_allowed, + ) + + def test_post_account_settings(self): + """ + Tests that account settings can be updated successfully + """ + settings = self.client.account.settings() + + settings.network_helper = True + settings.backups_enabled = False + settings.interfaces_for_new_linodes = ( + AccountSettingsInterfacesForNewLinodes.linode_only + ) + + with self.mock_put("/account/settings") as m: + settings.save() + + assert m.call_data == { + "network_helper": True, + "backups_enabled": False, + "interfaces_for_new_linodes": AccountSettingsInterfacesForNewLinodes.linode_only, + } def test_get_event(self): """