diff --git a/nodebalancer.go b/nodebalancer.go index c6fd27d67..a6ed82343 100644 --- a/nodebalancer.go +++ b/nodebalancer.go @@ -26,6 +26,8 @@ type NodeBalancer struct { ClientConnThrottle int `json:"client_conn_throttle"` // Information about the amount of transfer this NodeBalancer has had so far this month. Transfer NodeBalancerTransfer `json:"transfer"` + // This NodeBalancer's plan Type + Type NodeBalancerPlanType `json:"type"` // An array of tags applied to this object. Tags are for organizational purposes only. Tags []string `json:"tags"` @@ -58,6 +60,7 @@ type NodeBalancerCreateOptions struct { Configs []*NodeBalancerConfigCreateOptions `json:"configs,omitempty"` Tags []string `json:"tags"` FirewallID int `json:"firewall_id,omitempty"` + Type NodeBalancerPlanType `json:"type,omitempty"` VPCs []NodeBalancerVPCOptions `json:"vpcs,omitempty"` } @@ -68,6 +71,15 @@ type NodeBalancerUpdateOptions struct { Tags *[]string `json:"tags,omitempty"` } +// NodeBalancerPlanType constants start with NBType and include Linode API NodeBalancer's plan types +type NodeBalancerPlanType string + +// NodeBalancerPlanType constants reflect the plan type used by a NodeBalancer Config +const ( + NBTypePremium NodeBalancerPlanType = "premium" + NBTypeCommon NodeBalancerPlanType = "common" +) + // UnmarshalJSON implements the json.Unmarshaler interface func (i *NodeBalancer) UnmarshalJSON(b []byte) error { type Mask NodeBalancer @@ -96,6 +108,7 @@ func (i NodeBalancer) GetCreateOptions() NodeBalancerCreateOptions { Label: i.Label, Region: i.Region, ClientConnThrottle: &i.ClientConnThrottle, + Type: i.Type, Tags: i.Tags, } } diff --git a/test/integration/fixtures/TestNodeBalancer_Create_Type.yaml b/test/integration/fixtures/TestNodeBalancer_Create_Type.yaml new file mode 100644 index 000000000..b1a6279d9 --- /dev/null +++ b/test/integration/fixtures/TestNodeBalancer_Create_Type.yaml @@ -0,0 +1,480 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/regions?page=1 + method: GET + response: + body: '{"data": [{"id": "ap-west", "label": "Mumbai, IN", "country": "in", "capabilities": + ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", "Block Storage", + "GPU Linodes", "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", + "Managed Databases", "Metadata", "Placement Group", "StackScripts"], "status": + "ok", "resolvers": {"ipv4": "172.105.34.5,172.105.35.5,172.105.36.5,172.105.37.5,172.105.38.5,172.105.39.5,172.105.40.5,172.105.41.5,172.105.42.5,172.105.43.5", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "ca-central", "label": "Toronto, CA", "country": + "ca", "capabilities": ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", + "Block Storage", "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", + "Managed Databases", "Metadata", "Placement Group", "StackScripts"], "status": + "ok", "resolvers": {"ipv4": "172.105.0.5,172.105.3.5,172.105.4.5,172.105.5.5,172.105.6.5,172.105.7.5,172.105.8.5,172.105.9.5,172.105.10.5,172.105.11.5", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "ap-southeast", "label": "Sydney, AU", "country": + "au", "capabilities": ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", + "Block Storage", "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", + "Managed Databases", "Metadata", "Placement Group", "StackScripts"], "status": + "ok", "resolvers": {"ipv4": "172.105.166.5,172.105.169.5,172.105.168.5,172.105.172.5,172.105.162.5,172.105.170.5,172.105.167.5,172.105.171.5,172.105.181.5,172.105.161.5", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "us-iad", "label": "Washington, DC", "country": + "us", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "139.144.192.62,139.144.192.60,139.144.192.61,139.144.192.53,139.144.192.54,139.144.192.67,139.144.192.69,139.144.192.66,139.144.192.52,139.144.192.68", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "us-ord", "label": "Chicago, IL", "country": + "us", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", + "Kubernetes", "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed + Databases", "Metadata", "Premium Plans", "Placement Group", "StackScripts"], + "status": "ok", "resolvers": {"ipv4": "172.232.0.17,172.232.0.16,172.232.0.21,172.232.0.13,172.232.0.22,172.232.0.9,172.232.0.19,172.232.0.20,172.232.0.15,172.232.0.18", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "fr-par", "label": "Paris, FR", "country": + "fr", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", + "Kubernetes", "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed + Databases", "Metadata", "Premium Plans", "Placement Group", "StackScripts"], + "status": "ok", "resolvers": {"ipv4": "172.232.32.21,172.232.32.23,172.232.32.17,172.232.32.18,172.232.32.16,172.232.32.22,172.232.32.20,172.232.32.14,172.232.32.11,172.232.32.12", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "us-sea", "label": "Seattle, WA", "country": + "us", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", + "Kubernetes", "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed + Databases", "Metadata", "Premium Plans", "Placement Group", "StackScripts"], + "status": "ok", "resolvers": {"ipv4": "172.232.160.19,172.232.160.21,172.232.160.17,172.232.160.15,172.232.160.18,172.232.160.8,172.232.160.12,172.232.160.11,172.232.160.14,172.232.160.16", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "br-gru", "label": "Sao Paulo, BR", "country": + "br", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "172.233.0.4,172.233.0.9,172.233.0.7,172.233.0.12,172.233.0.5,172.233.0.13,172.233.0.10,172.233.0.6,172.233.0.8,172.233.0.11", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "nl-ams", "label": "Amsterdam, NL", "country": + "nl", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "172.233.33.36,172.233.33.38,172.233.33.35,172.233.33.39,172.233.33.34,172.233.33.33,172.233.33.31,172.233.33.30,172.233.33.37,172.233.33.32", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "se-sto", "label": "Stockholm, SE", "country": + "se", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "172.232.128.24,172.232.128.26,172.232.128.20,172.232.128.22,172.232.128.25,172.232.128.19,172.232.128.23,172.232.128.18,172.232.128.21,172.232.128.27", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "es-mad", "label": "Madrid, ES", "country": + "es", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "172.233.111.6,172.233.111.17,172.233.111.21,172.233.111.25,172.233.111.19,172.233.111.12,172.233.111.26,172.233.111.16,172.233.111.18,172.233.111.9", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "in-maa", "label": "Chennai, IN", "country": + "in", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts", "NETINT Quadra + T1U"], "status": "ok", "resolvers": {"ipv4": "172.232.96.17,172.232.96.26,172.232.96.19,172.232.96.20,172.232.96.25,172.232.96.21,172.232.96.18,172.232.96.22,172.232.96.23,172.232.96.24", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "jp-osa", "label": "Osaka, JP", "country": + "jp", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", + "Kubernetes", "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed + Databases", "Metadata", "Premium Plans", "Placement Group", "StackScripts"], + "status": "ok", "resolvers": {"ipv4": "172.233.64.44,172.233.64.43,172.233.64.37,172.233.64.40,172.233.64.46,172.233.64.41,172.233.64.39,172.233.64.42,172.233.64.45,172.233.64.38", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "it-mil", "label": "Milan, IT", "country": + "it", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "172.232.192.19,172.232.192.18,172.232.192.16,172.232.192.20,172.232.192.24,172.232.192.21,172.232.192.22,172.232.192.17,172.232.192.15,172.232.192.23", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "us-mia", "label": "Miami, FL", "country": + "us", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts", "NETINT Quadra + T1U"], "status": "ok", "resolvers": {"ipv4": "172.233.160.34,172.233.160.27,172.233.160.30,172.233.160.29,172.233.160.32,172.233.160.28,172.233.160.33,172.233.160.26,172.233.160.25,172.233.160.31", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "id-cgk", "label": "Jakarta, ID", "country": + "id", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "172.232.224.23,172.232.224.32,172.232.224.26,172.232.224.27,172.232.224.21,172.232.224.24,172.232.224.22,172.232.224.20,172.232.224.31,172.232.224.28", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "us-lax", "label": "Los Angeles, CA", "country": + "us", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts", "NETINT Quadra + T1U"], "status": "ok", "resolvers": {"ipv4": "172.233.128.45,172.233.128.38,172.233.128.53,172.233.128.37,172.233.128.34,172.233.128.36,172.233.128.33,172.233.128.39,172.233.128.43,172.233.128.44", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "nz-akl-1", "label": "Auckland, NZ", "country": + "nz", "capabilities": ["Linodes", "Disk Encryption", "Cloud Firewall", "Vlans", + "Metadata", "Distributed Plans"], "status": "ok", "resolvers": {"ipv4": "173.223.100.53,173.223.101.53", + "ipv6": "1234::5678,1234::5678"}, "placement_group_limits": {"maximum_pgs_per_customer": + 0, "maximum_linodes_per_pg": 0}, "site_type": "distributed"}, {"id": "us-den-1", + "label": "Denver, CO", "country": "us", "capabilities": ["Linodes", "Disk Encryption", + "Cloud Firewall", "Vlans", "Metadata", "Distributed Plans"], "status": "ok", + "resolvers": {"ipv4": "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "de-ham-1", "label": "Hamburg, DE", + "country": "de", "capabilities": ["Linodes", "Disk Encryption", "Cloud Firewall", + "Vlans", "Metadata", "Distributed Plans"], "status": "ok", "resolvers": {"ipv4": + "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "fr-mrs-1", "label": "Marseille, FR", + "country": "fr", "capabilities": ["Linodes", "Disk Encryption", "Cloud Firewall", + "Vlans", "Metadata", "Distributed Plans"], "status": "ok", "resolvers": {"ipv4": + "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "za-jnb-1", "label": "Johannesburg, + ZA", "country": "za", "capabilities": ["Linodes", "Disk Encryption", "Cloud + Firewall", "Vlans", "Metadata", "Distributed Plans"], "status": "ok", "resolvers": + {"ipv4": "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "my-kul-1", "label": "Kuala Lumpur, + MY", "country": "my", "capabilities": ["Linodes", "Disk Encryption", "Cloud + Firewall", "Vlans", "Metadata", "Distributed Plans"], "status": "ok", "resolvers": + {"ipv4": "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "co-bog-1", "label": "Bogot\u00e1, CO", + "country": "co", "capabilities": ["Linodes", "Disk Encryption", "Cloud Firewall", + "Vlans", "Metadata", "Distributed Plans"], "status": "ok", "resolvers": {"ipv4": + "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "mx-qro-1", "label": "Quer\u00e9taro, + MX", "country": "mx", "capabilities": ["Linodes", "Disk Encryption", "Cloud + Firewall", "Vlans", "Metadata", "Distributed Plans"], "status": "ok", "resolvers": + {"ipv4": "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "us-hou-1", "label": "Houston, TX", + "country": "us", "capabilities": ["Linodes", "Disk Encryption", "Cloud Firewall", + "Vlans", "Metadata", "Distributed Plans"], "status": "ok", "resolvers": {"ipv4": + "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "cl-scl-1", "label": "Santiago, CL", + "country": "cl", "capabilities": ["Linodes", "Disk Encryption", "Cloud Firewall", + "Vlans", "Metadata", "Distributed Plans"], "status": "ok", "resolvers": {"ipv4": + "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0}, "site_type": "distributed"}, {"id": "gb-lon", "label": "London 2, UK", "country": + "gb", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "172.236.0.46,172.236.0.50,172.236.0.47,172.236.0.53,172.236.0.52,172.236.0.45,172.236.0.49,172.236.0.51,172.236.0.54,172.236.0.48", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "au-mel", "label": "Melbourne, AU", "country": + "au", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed Databases", + "Metadata", "Premium Plans", "Placement Group", "StackScripts", "NETINT Quadra + T1U"], "status": "ok", "resolvers": {"ipv4": "172.236.32.23,172.236.32.35,172.236.32.30,172.236.32.28,172.236.32.32,172.236.32.33,172.236.32.27,172.236.32.37,172.236.32.29,172.236.32.34", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "in-bom-2", "label": "Mumbai 2, IN", "country": + "in", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "GPU Linodes", "Cloud Firewall", + "Vlans", "VPCs", "Metadata", "Premium Plans", "Placement Group", "StackScripts"], + "status": "ok", "resolvers": {"ipv4": "172.236.171.41,172.236.171.42,172.236.171.25,172.236.171.44,172.236.171.26,172.236.171.45,172.236.171.24,172.236.171.43,172.236.171.27,172.236.171.28", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "de-fra-2", "label": "Frankfurt 2, DE", "country": + "de", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "GPU Linodes", "Kubernetes", "Cloud + Firewall", "Vlans", "VPCs", "Metadata", "Premium Plans", "Placement Group", + "StackScripts", "NETINT Quadra T1U"], "status": "ok", "resolvers": {"ipv4": + "172.236.203.9,172.236.203.16,172.236.203.19,172.236.203.15,172.236.203.17,172.236.203.11,172.236.203.18,172.236.203.14,172.236.203.13,172.236.203.12", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "sg-sin-2", "label": "Singapore 2, SG", "country": + "sg", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", + "Kubernetes", "Kubernetes Enterprise", "Cloud Firewall", "Vlans", "VPCs", "Managed + Databases", "Metadata", "Premium Plans", "Placement Group", "StackScripts"], + "status": "ok", "resolvers": {"ipv4": "172.236.129.8,172.236.129.42,172.236.129.41,172.236.129.19,172.236.129.46,172.236.129.23,172.236.129.48,172.236.129.20,172.236.129.21,172.236.129.47", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "jp-tyo-3", "label": "Tokyo 3, JP", "country": + "jp", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Kubernetes", "Cloud Firewall", + "Vlans", "VPCs", "Metadata", "Premium Plans", "Placement Group", "StackScripts"], + "status": "ok", "resolvers": {"ipv4": "172.237.4.15,172.237.4.19,172.237.4.17,172.237.4.21,172.237.4.16,172.237.4.18,172.237.4.23,172.237.4.24,172.237.4.20,172.237.4.14", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "us-central", "label": "Dallas, TX", "country": + "us", "capabilities": ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", + "Block Storage", "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", + "Managed Databases", "Metadata", "Placement Group", "StackScripts"], "status": + "ok", "resolvers": {"ipv4": "72.14.179.5,72.14.188.5,173.255.199.5,66.228.53.5,96.126.122.5,96.126.124.5,96.126.127.5,198.58.107.5,198.58.111.5,23.239.24.5", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "us-west", "label": "Fremont, CA", "country": + "us", "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Kubernetes", "Cloud Firewall", + "Vlans", "Block Storage Migrations", "Managed Databases", "Metadata", "Placement + Group", "StackScripts"], "status": "ok", "resolvers": {"ipv4": "173.230.145.5, + 173.230.147.5, 173.230.155.5, 173.255.212.5, 173.255.219.5, 173.255.241.5, 173.255.243.5, + 173.255.244.5, 74.207.241.5, 74.207.242.5", "ipv6": "1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678"}, "placement_group_limits": {"maximum_pgs_per_customer": + null, "maximum_linodes_per_pg": 5}, "site_type": "core"}, {"id": "us-southeast", + "label": "Atlanta, GA", "country": "us", "capabilities": ["Linodes", "Disk Encryption", + "Backups", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", + "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", "Managed + Databases", "Metadata", "Placement Group", "StackScripts"], "status": "ok", + "resolvers": {"ipv4": "74.207.231.5,173.230.128.5,173.230.129.5,173.230.136.5,173.230.140.5,66.228.59.5,66.228.62.5,50.116.35.5,50.116.41.5,23.239.18.5", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "us-east", "label": "Newark, NJ", "country": + "us", "capabilities": ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", + "Vlans", "Block Storage Migrations", "Managed Databases", "Metadata", "Placement + Group", "StackScripts"], "status": "ok", "resolvers": {"ipv4": "66.228.42.5,96.126.106.5,50.116.53.5,50.116.58.5,50.116.61.5,50.116.62.5,66.175.211.5,97.107.133.4,173.255.225.5,66.228.35.5", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "eu-west", "label": "London, UK", "country": + "gb", "capabilities": ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", + "Block Storage", "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", + "Metadata", "Placement Group", "StackScripts"], "status": "ok", "resolvers": + {"ipv4": "178.79.182.5, 176.58.107.5, 176.58.116.5, 176.58.121.5, 151.236.220.5, + 212.71.252.5, 212.71.253.5, 109.74.192.20, 109.74.193.20, 109.74.194.20", "ipv6": + "1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678"}, "placement_group_limits": + {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": 5}, "site_type": + "core"}, {"id": "ap-south", "label": "Singapore, SG", "country": "sg", "capabilities": + ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", "Block Storage", + "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", "Vlans", "Block + Storage Migrations", "Metadata", "Placement Group", "StackScripts"], "status": + "ok", "resolvers": {"ipv4": "139.162.11.5,139.162.13.5,139.162.14.5,139.162.15.5,139.162.16.5,139.162.21.5,139.162.27.5,103.3.60.18,103.3.60.19,103.3.60.20", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "eu-central", "label": "Frankfurt, DE", "country": + "de", "capabilities": ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", + "Vlans", "Block Storage Migrations", "Managed Databases", "Metadata", "Placement + Group", "StackScripts"], "status": "ok", "resolvers": {"ipv4": "139.162.130.5,139.162.131.5,139.162.132.5,139.162.133.5,139.162.134.5,139.162.135.5,139.162.136.5,139.162.137.5,139.162.138.5,139.162.139.5", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}, {"id": "ap-northeast", "label": "Tokyo 2, JP", "country": + "jp", "capabilities": ["Linodes", "Disk Encryption", "Backups", "NodeBalancers", + "Block Storage", "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", + "Managed Databases", "Metadata", "Placement Group", "StackScripts"], "status": + "ok", "resolvers": {"ipv4": "139.162.66.5,139.162.67.5,139.162.68.5,139.162.69.5,139.162.70.5,139.162.71.5,139.162.72.5,139.162.73.5,139.162.74.5,139.162.75.5", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5}, "site_type": "core"}], "page": 1, "pages": 1, "results": 41}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Tue, 25 Feb 2025 18:53:25 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - '*' + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-def","region":"ap-west","client_conn_throttle":20,"tags":null,"firewall_id":1898807,"type":"common"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/nodebalancers + method: POST + response: + body: '{"id": 1315518, "label": "go-test-def", "region": "ap-west", "type": "common", + "hostname": "172-232-87-61.ip.linodeusercontent.com", "ipv4": "172.232.87.61", + "ipv6": "1234::5678", "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "client_conn_throttle": 20, "client_udp_sess_throttle": + 0, "lke_cluster": null, "tags": [], "transfer": {"in": null, "out": null, "total": + null}}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "405" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Tue, 25 Feb 2025 18:53:25 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - nodebalancers:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/nodebalancers/1315518 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Tue, 25 Feb 2025 18:53:25 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - nodebalancers:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/nodebalancer_configs_test.go b/test/integration/nodebalancer_configs_test.go index 4d85837e9..acfb37956 100644 --- a/test/integration/nodebalancer_configs_test.go +++ b/test/integration/nodebalancer_configs_test.go @@ -110,7 +110,7 @@ func TestNodeBalancerConfig_Get(t *testing.T) { func setupNodeBalancerConfig(t *testing.T, fixturesYaml string) (*linodego.Client, *linodego.NodeBalancer, *linodego.NodeBalancerConfig, func(), error) { t.Helper() var fixtureTeardown func() - client, nodebalancer, fixtureTeardown, err := setupNodeBalancer(t, fixturesYaml) + client, nodebalancer, fixtureTeardown, err := setupNodeBalancer(t, fixturesYaml, nil) if err != nil { t.Fatalf("Error creating nodebalancer, got error %v", err) } diff --git a/test/integration/nodebalancer_firewalls_test.go b/test/integration/nodebalancer_firewalls_test.go index c49d675e2..15545aa7f 100644 --- a/test/integration/nodebalancer_firewalls_test.go +++ b/test/integration/nodebalancer_firewalls_test.go @@ -7,7 +7,7 @@ import ( func TestNodeBalancerFirewalls_List_smoke(t *testing.T) { client, nodebalancer, teardown, err := setupNodeBalancer(t, - "fixtures/TestNodeBalancerFirewalls_List") + "fixtures/TestNodeBalancerFirewalls_List", nil) if err != nil { t.Error(err) } diff --git a/test/integration/nodebalancer_stats_test.go b/test/integration/nodebalancer_stats_test.go index 8f07e6184..0317a7e88 100644 --- a/test/integration/nodebalancer_stats_test.go +++ b/test/integration/nodebalancer_stats_test.go @@ -9,7 +9,7 @@ import ( ) func TestNodeBalancerStats_Get(t *testing.T) { - client, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancerStats_Get") + client, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancerStats_Get", nil) defer teardown() if err != nil { t.Error(err) diff --git a/test/integration/nodebalancers_test.go b/test/integration/nodebalancers_test.go index 2959b8098..d986a9834 100644 --- a/test/integration/nodebalancers_test.go +++ b/test/integration/nodebalancers_test.go @@ -14,7 +14,7 @@ var ( ) func TestNodeBalancer_Create_create_smoke(t *testing.T) { - _, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancer_Create") + _, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancer_Create", nil) defer teardown() if err != nil { @@ -30,6 +30,29 @@ func TestNodeBalancer_Create_create_smoke(t *testing.T) { assertDateSet(t, nodebalancer.Updated) } +func TestNodeBalancer_Create_Type(t *testing.T) { + _, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancer_Create_Type", []nbModifier{func(createOpts *linodego.NodeBalancerCreateOptions) { + createOpts.Type = linodego.NBTypeCommon + }}) + defer teardown() + + if err != nil { + t.Errorf("Error creating nodebalancer: %v", err) + } + + // when comparing fixtures to random value Label will differ, compare the known suffix + if !strings.Contains(*nodebalancer.Label, label) { + t.Errorf("nodebalancer returned does not match nodebalancer create request") + } + // add this test case once the api supports returning it + if nodebalancer.Type != linodego.NBTypeCommon { + t.Errorf("nodebalancer returned type does not match the type of the nodebalancer create request") + } + + assertDateSet(t, nodebalancer.Created) + assertDateSet(t, nodebalancer.Updated) +} + func TestNodeBalancer_Create_with_vpc(t *testing.T) { _, nodebalancer, teardown, err := setupNodeBalancerWithVPC(t, "fixtures/TestNodeBalancer_With_VPC_Create") defer teardown() @@ -48,7 +71,7 @@ func TestNodeBalancer_Create_with_vpc(t *testing.T) { } func TestNodeBalancer_Update(t *testing.T) { - client, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancer_Update") + client, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancer_Update", nil) defer teardown() if err != nil { t.Error(err) @@ -69,7 +92,7 @@ func TestNodeBalancer_Update(t *testing.T) { } func TestNodeBalancers_List_smoke(t *testing.T) { - client, _, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancers_List") + client, _, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancers_List", nil) defer teardown() if err != nil { t.Error(err) @@ -85,7 +108,7 @@ func TestNodeBalancers_List_smoke(t *testing.T) { } func TestNodeBalancer_Get(t *testing.T) { - client, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancer_Get") + client, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancer_Get", nil) defer teardown() if err != nil { t.Error(err) @@ -97,7 +120,9 @@ func TestNodeBalancer_Get(t *testing.T) { } } -func setupNodeBalancer(t *testing.T, fixturesYaml string) (*linodego.Client, *linodego.NodeBalancer, func(), error) { +type nbModifier func(options *linodego.NodeBalancerCreateOptions) + +func setupNodeBalancer(t *testing.T, fixturesYaml string, nbModifiers []nbModifier) (*linodego.Client, *linodego.NodeBalancer, func(), error) { t.Helper() var fixtureTeardown func() client, fixtureTeardown := createTestClient(t, fixturesYaml) @@ -107,6 +132,9 @@ func setupNodeBalancer(t *testing.T, fixturesYaml string) (*linodego.Client, *li ClientConnThrottle: &clientConnThrottle, FirewallID: GetFirewallID(), } + for _, modifier := range nbModifiers { + modifier(&createOpts) + } nodebalancer, err := client.CreateNodeBalancer(context.Background(), createOpts) if err != nil {