Skip to content

Commit cdc2ecc

Browse files
authored
Support new tags from the API (#218)
1 parent e8b1787 commit cdc2ecc

4 files changed

+118
-106
lines changed

bare_metal_server.go

+33-27
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,31 @@ type BareMetalServerServiceHandler struct {
4545

4646
// BareMetalServer represents a Bare Metal server on Vultr
4747
type BareMetalServer struct {
48-
ID string `json:"id"`
49-
Os string `json:"os"`
50-
RAM string `json:"ram"`
51-
Disk string `json:"disk"`
52-
MainIP string `json:"main_ip"`
53-
CPUCount int `json:"cpu_count"`
54-
Region string `json:"region"`
55-
DefaultPassword string `json:"default_password"`
56-
DateCreated string `json:"date_created"`
57-
Status string `json:"status"`
58-
NetmaskV4 string `json:"netmask_v4"`
59-
GatewayV4 string `json:"gateway_v4"`
60-
Plan string `json:"plan"`
61-
V6Network string `json:"v6_network"`
62-
V6MainIP string `json:"v6_main_ip"`
63-
V6NetworkSize int `json:"v6_network_size"`
64-
MacAddress int `json:"mac_address"`
65-
Label string `json:"label"`
66-
Tag string `json:"tag"`
67-
OsID int `json:"os_id"`
68-
AppID int `json:"app_id"`
69-
ImageID string `json:"image_id"`
70-
Features []string `json:"features"`
48+
ID string `json:"id"`
49+
Os string `json:"os"`
50+
RAM string `json:"ram"`
51+
Disk string `json:"disk"`
52+
MainIP string `json:"main_ip"`
53+
CPUCount int `json:"cpu_count"`
54+
Region string `json:"region"`
55+
DefaultPassword string `json:"default_password"`
56+
DateCreated string `json:"date_created"`
57+
Status string `json:"status"`
58+
NetmaskV4 string `json:"netmask_v4"`
59+
GatewayV4 string `json:"gateway_v4"`
60+
Plan string `json:"plan"`
61+
V6Network string `json:"v6_network"`
62+
V6MainIP string `json:"v6_main_ip"`
63+
V6NetworkSize int `json:"v6_network_size"`
64+
MacAddress int `json:"mac_address"`
65+
Label string `json:"label"`
66+
// Deprecated: Tag should no longer be used. Instead, use Tags.
67+
Tag string `json:"tag"`
68+
OsID int `json:"os_id"`
69+
AppID int `json:"app_id"`
70+
ImageID string `json:"image_id"`
71+
Features []string `json:"features"`
72+
Tags []string `json:"tags"`
7173
}
7274

7375
// BareMetalCreate represents the optional parameters that can be set when creating a Bare Metal server
@@ -85,9 +87,11 @@ type BareMetalCreate struct {
8587
UserData string `json:"user_data,omitempty"`
8688
ActivationEmail *bool `json:"activation_email,omitempty"`
8789
Hostname string `json:"hostname,omitempty"`
88-
Tag string `json:"tag,omitempty"`
89-
ReservedIPv4 string `json:"reserved_ipv4,omitempty"`
90-
PersistentPxe *bool `json:"persistent_pxe,omitempty"`
90+
// Deprecated: Tag should no longer be used. Instead, use Tags.
91+
Tag string `json:"tag,omitempty"`
92+
ReservedIPv4 string `json:"reserved_ipv4,omitempty"`
93+
PersistentPxe *bool `json:"persistent_pxe,omitempty"`
94+
Tags []string `json:"tags"`
9195
}
9296

9397
// BareMetalUpdate represents the optional parameters that can be set when updating a Bare Metal server
@@ -98,7 +102,9 @@ type BareMetalUpdate struct {
98102
AppID int `json:"app_id,omitempty"`
99103
ImageID string `json:"image_id,omitempty"`
100104
UserData string `json:"user_data,omitempty"`
101-
Tag string `json:"tag,omitempty"`
105+
// Deprecated: Tag should no longer be used. Instead, use Tags.
106+
Tag string `json:"tag,omitempty"`
107+
Tags []string `json:"tags"`
102108
}
103109

104110
// BareMetalServerBandwidth represents bandwidth information for a Bare Metal server

bare_metal_server_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestBareMetalServerServiceHandler_GetServer(t *testing.T) {
3232
"v6_network_size": 64,
3333
"mac_address": 2199756823533,
3434
"label": "my label",
35-
"tag": "my tag",
35+
"tags": ["my tag"],
3636
"os_id": 127,
3737
"app_id": 0
3838
}
@@ -64,7 +64,7 @@ func TestBareMetalServerServiceHandler_GetServer(t *testing.T) {
6464
V6NetworkSize: 64,
6565
MacAddress: 2199756823533,
6666
Label: "my label",
67-
Tag: "my tag",
67+
Tags: []string{"my tag"},
6868
OsID: 127,
6969
AppID: 0,
7070
}
@@ -100,7 +100,7 @@ func TestBareMetalServerServiceHandler_Create(t *testing.T) {
100100
"v6_network_size": 64,
101101
"mac_address": 0,
102102
"label": "go-bm-test",
103-
"tag": "my tag",
103+
"tags": ["my tag"],
104104
"os_id": 127,
105105
"app_id": 0
106106
}
@@ -121,7 +121,7 @@ func TestBareMetalServerServiceHandler_Create(t *testing.T) {
121121
UserData: "echo Hello World",
122122
ActivationEmail: BoolToBoolPtr(true),
123123
Hostname: "test",
124-
Tag: "go-test",
124+
Tags: []string{"my tag"},
125125
ReservedIPv4: "111.111.111.111",
126126
PersistentPxe: BoolToBoolPtr(true),
127127
}
@@ -149,7 +149,7 @@ func TestBareMetalServerServiceHandler_Create(t *testing.T) {
149149
V6MainIP: "2001:DB8:9000::100",
150150
V6NetworkSize: 64,
151151
Label: "go-bm-test",
152-
Tag: "my tag",
152+
Tags: []string{"my tag"},
153153
MacAddress: 0,
154154
OsID: 127,
155155
Region: "ewr",
@@ -186,7 +186,7 @@ func TestBareMetalServerServiceHandler_Update(t *testing.T) {
186186
"v6_main_ip": "2001:DB8:9000::100",
187187
"v6_network_size": 64,
188188
"label": "my new label",
189-
"tag": "my tag",
189+
"tags": ["my tag"],
190190
"os_id": 127,
191191
"app_id": 0
192192
}
@@ -221,7 +221,7 @@ func TestBareMetalServerServiceHandler_Update(t *testing.T) {
221221
V6MainIP: "2001:DB8:9000::100",
222222
V6NetworkSize: 64,
223223
Label: "my new label",
224-
Tag: "my tag",
224+
Tags: []string{"my tag"},
225225
OsID: 127,
226226
Region: "ewr",
227227
AppID: 0,
@@ -272,7 +272,7 @@ func TestBareMetalServerServiceHandler_List(t *testing.T) {
272272
"v6_network_size": 64,
273273
"mac_address": 2199756823533,
274274
"label": "my label",
275-
"tag": "my tag",
275+
"tags": ["my tag"],
276276
"os_id": 127,
277277
"app_id": 0
278278
}]
@@ -306,7 +306,7 @@ func TestBareMetalServerServiceHandler_List(t *testing.T) {
306306
V6NetworkSize: 64,
307307
MacAddress: 2199756823533,
308308
Label: "my label",
309-
Tag: "my tag",
309+
Tags: []string{"my tag"},
310310
OsID: 127,
311311
AppID: 0,
312312
},
@@ -500,7 +500,7 @@ func TestBareMetalServerServiceHandler_Reinstall(t *testing.T) {
500500
"v6_main_ip": "2001:DB8:9000::100",
501501
"v6_network_size": 64,
502502
"label": "go-bm-test",
503-
"tag": "my tag",
503+
"tags": ["my tag"],
504504
"os_id": 127,
505505
"app_id": 0
506506
}
@@ -531,7 +531,7 @@ func TestBareMetalServerServiceHandler_Reinstall(t *testing.T) {
531531
V6MainIP: "2001:DB8:9000::100",
532532
V6NetworkSize: 64,
533533
Label: "go-bm-test",
534-
Tag: "my tag",
534+
Tags: []string{"my tag"},
535535
OsID: 127,
536536
Region: "ewr",
537537
AppID: 0,
@@ -733,7 +733,7 @@ func TestBareMetalServerServiceHandler_CreateMarketplaceImage(t *testing.T) {
733733
"v6_network_size": 64,
734734
"mac_address": 0,
735735
"label": "go-bm-test",
736-
"tag": "my tag",
736+
"tags": ["my tag"],
737737
"os_id": 127,
738738
"app_id": 0,
739739
"image_id": "test"
@@ -755,7 +755,7 @@ func TestBareMetalServerServiceHandler_CreateMarketplaceImage(t *testing.T) {
755755
UserData: "echo Hello World",
756756
ActivationEmail: BoolToBoolPtr(true),
757757
Hostname: "test",
758-
Tag: "go-test",
758+
Tags: []string{"go-test"},
759759
ReservedIPv4: "111.111.111.111",
760760
PersistentPxe: BoolToBoolPtr(true),
761761
ImageID: "test",
@@ -784,7 +784,7 @@ func TestBareMetalServerServiceHandler_CreateMarketplaceImage(t *testing.T) {
784784
V6MainIP: "2001:DB8:9000::100",
785785
V6NetworkSize: 64,
786786
Label: "go-bm-test",
787-
Tag: "my tag",
787+
Tags: []string{"my tag"},
788788
MacAddress: 0,
789789
OsID: 127,
790790
Region: "ewr",

instance.go

+56-50
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,37 @@ type InstanceServiceHandler struct {
7575

7676
// Instance represents a VPS
7777
type Instance struct {
78-
ID string `json:"id"`
79-
Os string `json:"os"`
80-
RAM int `json:"ram"`
81-
Disk int `json:"disk"`
82-
Plan string `json:"plan"`
83-
MainIP string `json:"main_ip"`
84-
VCPUCount int `json:"vcpu_count"`
85-
Region string `json:"region"`
86-
DefaultPassword string `json:"default_password,omitempty"`
87-
DateCreated string `json:"date_created"`
88-
Status string `json:"status"`
89-
AllowedBandwidth int `json:"allowed_bandwidth"`
90-
NetmaskV4 string `json:"netmask_v4"`
91-
GatewayV4 string `json:"gateway_v4"`
92-
PowerStatus string `json:"power_status"`
93-
ServerStatus string `json:"server_status"`
94-
V6Network string `json:"v6_network"`
95-
V6MainIP string `json:"v6_main_ip"`
96-
V6NetworkSize int `json:"v6_network_size"`
97-
Label string `json:"label"`
98-
InternalIP string `json:"internal_ip"`
99-
KVM string `json:"kvm"`
100-
Tag string `json:"tag"`
101-
OsID int `json:"os_id"`
102-
AppID int `json:"app_id"`
103-
ImageID string `json:"image_id"`
104-
FirewallGroupID string `json:"firewall_group_id"`
105-
Features []string `json:"features"`
106-
Hostname string `json:"hostname"`
78+
ID string `json:"id"`
79+
Os string `json:"os"`
80+
RAM int `json:"ram"`
81+
Disk int `json:"disk"`
82+
Plan string `json:"plan"`
83+
MainIP string `json:"main_ip"`
84+
VCPUCount int `json:"vcpu_count"`
85+
Region string `json:"region"`
86+
DefaultPassword string `json:"default_password,omitempty"`
87+
DateCreated string `json:"date_created"`
88+
Status string `json:"status"`
89+
AllowedBandwidth int `json:"allowed_bandwidth"`
90+
NetmaskV4 string `json:"netmask_v4"`
91+
GatewayV4 string `json:"gateway_v4"`
92+
PowerStatus string `json:"power_status"`
93+
ServerStatus string `json:"server_status"`
94+
V6Network string `json:"v6_network"`
95+
V6MainIP string `json:"v6_main_ip"`
96+
V6NetworkSize int `json:"v6_network_size"`
97+
Label string `json:"label"`
98+
InternalIP string `json:"internal_ip"`
99+
KVM string `json:"kvm"`
100+
// Deprecated: Tag should no longer be used. Instead, use Tags.
101+
Tag string `json:"tag"`
102+
OsID int `json:"os_id"`
103+
AppID int `json:"app_id"`
104+
ImageID string `json:"image_id"`
105+
FirewallGroupID string `json:"firewall_group_id"`
106+
Features []string `json:"features"`
107+
Hostname string `json:"hostname"`
108+
Tags []string `json:"tags"`
107109
}
108110

109111
type instanceBase struct {
@@ -229,20 +231,22 @@ type Upgrades struct {
229231

230232
// InstanceCreateReq struct used to create an instance.
231233
type InstanceCreateReq struct {
232-
Region string `json:"region,omitempty"`
233-
Plan string `json:"plan,omitempty"`
234-
Label string `json:"label,omitempty"`
235-
Tag string `json:"tag,omitempty"`
236-
OsID int `json:"os_id,omitempty"`
237-
ISOID string `json:"iso_id,omitempty"`
238-
AppID int `json:"app_id,omitempty"`
239-
ImageID string `json:"image_id,omitempty"`
240-
FirewallGroupID string `json:"firewall_group_id,omitempty"`
241-
Hostname string `json:"hostname,omitempty"`
242-
IPXEChainURL string `json:"ipxe_chain_url,omitempty"`
243-
ScriptID string `json:"script_id,omitempty"`
244-
SnapshotID string `json:"snapshot_id,omitempty"`
245-
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
234+
Region string `json:"region,omitempty"`
235+
Plan string `json:"plan,omitempty"`
236+
Label string `json:"label,omitempty"`
237+
// Deprecated: Tag should no longer be used. Instead, use Tags.
238+
Tag string `json:"tag,omitempty"`
239+
Tags []string `json:"tags"`
240+
OsID int `json:"os_id,omitempty"`
241+
ISOID string `json:"iso_id,omitempty"`
242+
AppID int `json:"app_id,omitempty"`
243+
ImageID string `json:"image_id,omitempty"`
244+
FirewallGroupID string `json:"firewall_group_id,omitempty"`
245+
Hostname string `json:"hostname,omitempty"`
246+
IPXEChainURL string `json:"ipxe_chain_url,omitempty"`
247+
ScriptID string `json:"script_id,omitempty"`
248+
SnapshotID string `json:"snapshot_id,omitempty"`
249+
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
246250
// Deprecated: EnablePrivateNetwork should no longer be used. Instead, use EnableVPC.
247251
EnablePrivateNetwork *bool `json:"enable_private_network,omitempty"`
248252
// Deprecated: AttachPrivateNetwork should no longer be used. Instead, use AttachVPC.
@@ -259,13 +263,15 @@ type InstanceCreateReq struct {
259263

260264
// InstanceUpdateReq struct used to update an instance.
261265
type InstanceUpdateReq struct {
262-
Plan string `json:"plan,omitempty"`
263-
Label string `json:"label,omitempty"`
264-
Tag string `json:"tag,omitempty"`
265-
OsID int `json:"os_id,omitempty"`
266-
AppID int `json:"app_id,omitempty"`
267-
ImageID string `json:"image_id,omitempty"`
268-
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
266+
Plan string `json:"plan,omitempty"`
267+
Label string `json:"label,omitempty"`
268+
// Deprecated: Tag should no longer be used. Instead, use Tags.
269+
Tag string `json:"tag,omitempty"`
270+
Tags []string `json:"tags"`
271+
OsID int `json:"os_id,omitempty"`
272+
AppID int `json:"app_id,omitempty"`
273+
ImageID string `json:"image_id,omitempty"`
274+
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
269275
// Deprecated: EnablePrivateNetwork should no longer be used. Instead, use EnableVPC.
270276
EnablePrivateNetwork *bool `json:"enable_private_network,omitempty"`
271277
// Deprecated: AttachPrivateNetwork should no longer be used. Instead, use AttachVPC.

0 commit comments

Comments
 (0)