Skip to content

Commit 6fd4b61

Browse files
Implement changes for account APIs (#715)
* Implement changes for account APIs * Cleanup and re-add tests * gofumpt * Add availability notice
1 parent f06e865 commit 6fd4b61

6 files changed

Lines changed: 33 additions & 138 deletions

File tree

account_settings.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ import (
44
"context"
55
)
66

7+
type InterfacesForNewLinodes string
8+
9+
const (
10+
LegacyConfigOnly InterfacesForNewLinodes = "legacy_config_only"
11+
LegacyConfigDefaultButLinodeAllowed InterfacesForNewLinodes = "legacy_config_default_but_linode_allowed"
12+
LinodeDefaultButLegacyConfigAllowed InterfacesForNewLinodes = "linode_default_but_legacy_config_allowed"
13+
LinodeOnly InterfacesForNewLinodes = "linode_only"
14+
)
15+
716
// AccountSettings are the account wide flags or plans that effect new resources
817
type AccountSettings struct {
918
// The default backups enrollment status for all new Linodes for all users on the account. When enabled, backups are mandatory per instance.
@@ -20,19 +29,23 @@ type AccountSettings struct {
2029

2130
// A string like "disabled", "suspended", or "active" describing the status of this account’s Object Storage service enrollment.
2231
ObjectStorage *string `json:"object_storage"`
32+
33+
// NOTE: Interfaces for new linode setting may not currently be available to all users.
34+
// A new configuration flag defines whether new Linodes can use Linode and/or legacy config interfaces.
35+
InterfacesForNewLinodes InterfacesForNewLinodes `json:"interfaces_for_new_linodes"`
2336
}
2437

2538
// AccountSettingsUpdateOptions are the updateable account wide flags or plans that effect new resources.
2639
type AccountSettingsUpdateOptions struct {
2740
// The default backups enrollment status for all new Linodes for all users on the account. When enabled, backups are mandatory per instance.
2841
BackupsEnabled *bool `json:"backups_enabled,omitempty"`
2942

30-
// A plan name like "longview-3"..."longview-100", or a nil value for to cancel any existing subscription plan.
31-
// Deprecated: Use PUT /longview/plan instead to update the LongviewSubscription
32-
LongviewSubscription *string `json:"longview_subscription,omitempty"`
33-
3443
// The default network helper setting for all new Linodes and Linode Configs for all users on the account.
3544
NetworkHelper *bool `json:"network_helper,omitempty"`
45+
46+
// NOTE: Interfaces for new linode setting may not currently be available to all users.
47+
// A new configuration flag defines whether new Linodes can use Linode and/or legacy config interfaces.
48+
InterfacesForNewLinodes *InterfacesForNewLinodes `json:"interfaces_for_new_linodes"`
3649
}
3750

3851
// GetAccountSettings gets the account wide flags or plans that effect new resources

test/integration/account_settings_test.go

Lines changed: 0 additions & 79 deletions
This file was deleted.

test/integration/fixtures/TestAccountSettings.yaml

Lines changed: 0 additions & 51 deletions
This file was deleted.

test/unit/account_settings_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func TestAccountSettings_Get(t *testing.T) {
3131
assert.Nil(t, accountSettings.LongviewSubscription, "Expected 'longview_subscription' to be nil")
3232
assert.True(t, accountSettings.BackupsEnabled, "Expected 'backups_enabled' to be true")
3333
assert.Equal(t, "active", *accountSettings.ObjectStorage, "Expected 'object_storage' to be 'active'")
34+
assert.Equal(
35+
t, linodego.LegacyConfigDefaultButLinodeAllowed, accountSettings.InterfacesForNewLinodes,
36+
"Expected 'object_storage' to be 'active'",
37+
)
3438
}
3539

3640
func TestAccountSettings_Update(t *testing.T) {
@@ -41,9 +45,11 @@ func TestAccountSettings_Update(t *testing.T) {
4145
base.SetUp(t)
4246
defer base.TearDown(t)
4347

48+
i := linodego.LegacyConfigDefaultButLinodeAllowed
4449
requestData := linodego.AccountSettingsUpdateOptions{
45-
BackupsEnabled: Bool(true),
46-
NetworkHelper: Bool(true),
50+
BackupsEnabled: Bool(true),
51+
NetworkHelper: Bool(true),
52+
InterfacesForNewLinodes: &i,
4753
}
4854
base.MockPut("account/settings", fixtureData)
4955

@@ -55,4 +61,8 @@ func TestAccountSettings_Update(t *testing.T) {
5561
assert.Nil(t, accountSettings.LongviewSubscription, "Expected 'longview_subscription' to be nil")
5662
assert.True(t, accountSettings.BackupsEnabled, "Expected 'backups_enabled' to be true")
5763
assert.Equal(t, "active", *accountSettings.ObjectStorage, "Expected 'object_storage' to be 'active'")
64+
assert.Equal(
65+
t, linodego.LegacyConfigDefaultButLinodeAllowed, accountSettings.InterfacesForNewLinodes,
66+
"Expected 'object_storage' to be 'active'",
67+
)
5868
}

test/unit/fixtures/account_settings_get.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"network_helper": true,
44
"longview_subscription": null,
55
"backups_enabled": true,
6-
"object_storage": "active"
6+
"object_storage": "active",
7+
"interfaces_for_new_linodes": "legacy_config_default_but_linode_allowed"
78
}

test/unit/fixtures/account_settings_update.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"network_helper": true,
44
"longview_subscription": null,
55
"backups_enabled": true,
6-
"object_storage": "active"
6+
"object_storage": "active",
7+
"interfaces_for_new_linodes": "legacy_config_default_but_linode_allowed"
78
}

0 commit comments

Comments
 (0)