account_settings.go raw

   1  package linodego
   2  
   3  import (
   4  	"context"
   5  )
   6  
   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  
  16  // AccountSettings are the account wide flags or plans that effect new resources
  17  type AccountSettings struct {
  18  	// The default backups enrollment status for all new Linodes for all users on the account.  When enabled, backups are mandatory per instance.
  19  	BackupsEnabled bool `json:"backups_enabled"`
  20  
  21  	// Whether or not Linode Managed service is enabled for the account.
  22  	Managed bool `json:"managed"`
  23  
  24  	// Whether or not the Network Helper is enabled for all new Linode Instance Configs on the account.
  25  	NetworkHelper bool `json:"network_helper"`
  26  
  27  	// A plan name like "longview-3"..."longview-100", or a nil value for to cancel any existing subscription plan.
  28  	LongviewSubscription *string `json:"longview_subscription"`
  29  
  30  	// A string like "disabled", "suspended", or "active" describing the status of this account’s Object Storage service enrollment.
  31  	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"`
  36  
  37  	// The slug of the maintenance policy associated with the account.
  38  	// NOTE: MaintenancePolicy can only be used with v4beta.
  39  	MaintenancePolicy string `json:"maintenance_policy"`
  40  }
  41  
  42  // AccountSettingsUpdateOptions are the updateable account wide flags or plans that effect new resources.
  43  type AccountSettingsUpdateOptions struct {
  44  	// The default backups enrollment status for all new Linodes for all users on the account.  When enabled, backups are mandatory per instance.
  45  	BackupsEnabled *bool `json:"backups_enabled,omitempty"`
  46  
  47  	// The default network helper setting for all new Linodes and Linode Configs for all users on the account.
  48  	NetworkHelper *bool `json:"network_helper,omitempty"`
  49  
  50  	// NOTE: Interfaces for new linode setting may not currently be available to all users.
  51  	// A new configuration flag defines whether new Linodes can use Linode and/or legacy config interfaces.
  52  	InterfacesForNewLinodes *InterfacesForNewLinodes `json:"interfaces_for_new_linodes"`
  53  
  54  	// The slug of the maintenance policy to set the account to.
  55  	// NOTE: MaintenancePolicy can only be used with v4beta.
  56  	MaintenancePolicy *string `json:"maintenance_policy,omitempty"`
  57  }
  58  
  59  // GetAccountSettings gets the account wide flags or plans that effect new resources
  60  func (c *Client) GetAccountSettings(ctx context.Context) (*AccountSettings, error) {
  61  	return doGETRequest[AccountSettings](ctx, c, "account/settings")
  62  }
  63  
  64  // UpdateAccountSettings updates the settings associated with the account
  65  func (c *Client) UpdateAccountSettings(ctx context.Context, opts AccountSettingsUpdateOptions) (*AccountSettings, error) {
  66  	return doPUTRequest[AccountSettings](ctx, c, "account/settings", opts)
  67  }
  68