Skip to content

Commit

Permalink
Remove deprecated Tag and Type fields (#327)
Browse files Browse the repository at this point in the history
* Remove deprecated Tag and Type fields

* Remove deprecated firewall fields from test
  • Loading branch information
optik-aper authored Oct 1, 2024
1 parent 6cb2b71 commit e32f33b
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 104 deletions.
108 changes: 51 additions & 57 deletions bare_metal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,71 +53,65 @@ type BareMetalServerServiceHandler struct {

// BareMetalServer represents a Bare Metal server on Vultr
type BareMetalServer struct {
ID string `json:"id"`
Os string `json:"os"`
RAM string `json:"ram"`
Disk string `json:"disk"`
MainIP string `json:"main_ip"`
CPUCount int `json:"cpu_count"`
Region string `json:"region"`
DefaultPassword string `json:"default_password"`
DateCreated string `json:"date_created"`
Status string `json:"status"`
NetmaskV4 string `json:"netmask_v4"`
GatewayV4 string `json:"gateway_v4"`
Plan string `json:"plan"`
V6Network string `json:"v6_network"`
V6MainIP string `json:"v6_main_ip"`
V6NetworkSize int `json:"v6_network_size"`
MacAddress int `json:"mac_address"`
Label string `json:"label"`
// Deprecated: Tag should no longer be used. Instead, use Tags.
Tag string `json:"tag"`
OsID int `json:"os_id"`
AppID int `json:"app_id"`
ImageID string `json:"image_id"`
Features []string `json:"features"`
Tags []string `json:"tags"`
ID string `json:"id"`
Os string `json:"os"`
RAM string `json:"ram"`
Disk string `json:"disk"`
MainIP string `json:"main_ip"`
CPUCount int `json:"cpu_count"`
Region string `json:"region"`
DefaultPassword string `json:"default_password"`
DateCreated string `json:"date_created"`
Status string `json:"status"`
NetmaskV4 string `json:"netmask_v4"`
GatewayV4 string `json:"gateway_v4"`
Plan string `json:"plan"`
V6Network string `json:"v6_network"`
V6MainIP string `json:"v6_main_ip"`
V6NetworkSize int `json:"v6_network_size"`
MacAddress int `json:"mac_address"`
Label string `json:"label"`
OsID int `json:"os_id"`
AppID int `json:"app_id"`
ImageID string `json:"image_id"`
Features []string `json:"features"`
Tags []string `json:"tags"`
}

// BareMetalCreate represents the optional parameters that can be set when creating a Bare Metal server
type BareMetalCreate struct {
Region string `json:"region,omitempty"`
Plan string `json:"plan,omitempty"`
OsID int `json:"os_id,omitempty"`
StartupScriptID string `json:"script_id,omitempty"`
SnapshotID string `json:"snapshot_id,omitempty"`
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
Label string `json:"label,omitempty"`
SSHKeyIDs []string `json:"sshkey_id,omitempty"`
AppID int `json:"app_id,omitempty"`
ImageID string `json:"image_id,omitempty"`
UserData string `json:"user_data,omitempty"`
ActivationEmail *bool `json:"activation_email,omitempty"`
Hostname string `json:"hostname,omitempty"`
MdiskMode string `json:"mdisk_mode,omitempty"`
// Deprecated: Tag should no longer be used. Instead, use Tags.
Tag string `json:"tag,omitempty"`
ReservedIPv4 string `json:"reserved_ipv4,omitempty"`
PersistentPxe *bool `json:"persistent_pxe,omitempty"`
Tags []string `json:"tags"`
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
DetachVPC2 []string `json:"detach_vpc2,omitempty"`
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
AppVariables map[string]string `json:"app_variables,omitempty"`
Region string `json:"region,omitempty"`
Plan string `json:"plan,omitempty"`
OsID int `json:"os_id,omitempty"`
StartupScriptID string `json:"script_id,omitempty"`
SnapshotID string `json:"snapshot_id,omitempty"`
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
Label string `json:"label,omitempty"`
SSHKeyIDs []string `json:"sshkey_id,omitempty"`
AppID int `json:"app_id,omitempty"`
ImageID string `json:"image_id,omitempty"`
UserData string `json:"user_data,omitempty"`
ActivationEmail *bool `json:"activation_email,omitempty"`
Hostname string `json:"hostname,omitempty"`
MdiskMode string `json:"mdisk_mode,omitempty"`
ReservedIPv4 string `json:"reserved_ipv4,omitempty"`
PersistentPxe *bool `json:"persistent_pxe,omitempty"`
Tags []string `json:"tags"`
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
DetachVPC2 []string `json:"detach_vpc2,omitempty"`
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
AppVariables map[string]string `json:"app_variables,omitempty"`
}

// BareMetalUpdate represents the optional parameters that can be set when updating a Bare Metal server
type BareMetalUpdate struct {
OsID int `json:"os_id,omitempty"`
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
Label string `json:"label,omitempty"`
AppID int `json:"app_id,omitempty"`
ImageID string `json:"image_id,omitempty"`
UserData string `json:"user_data,omitempty"`
MdiskMode string `json:"mdisk_mode,omitempty"`
// Deprecated: Tag should no longer be used. Instead, use Tags.
Tag *string `json:"tag,omitempty"`
OsID int `json:"os_id,omitempty"`
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
Label string `json:"label,omitempty"`
AppID int `json:"app_id,omitempty"`
ImageID string `json:"image_id,omitempty"`
UserData string `json:"user_data,omitempty"`
MdiskMode string `json:"mdisk_mode,omitempty"`
Tags []string `json:"tags"`
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
DetachVPC2 []string `json:"detach_vpc2,omitempty"`
Expand Down
6 changes: 2 additions & 4 deletions firewall_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ type FireWallRuleServiceHandler struct {

// FirewallRule represents a Vultr firewall rule
type FirewallRule struct {
ID int `json:"id"`
Action string `json:"action"`
// Deprecated: Type should no longer be used. Instead, use IPType.
Type string `json:"type"`
ID int `json:"id"`
Action string `json:"action"`
IPType string `json:"ip_type"`
Protocol string `json:"protocol"`
Port string `json:"port"`
Expand Down
3 changes: 0 additions & 3 deletions firewall_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func TestFireWallRuleServiceHandler_Create(t *testing.T) {
expected := &FirewallRule{
ID: 1,
Action: "accept",
Type: "v4",
IPType: "v4",
Protocol: "tcp",
Port: "80",
Expand Down Expand Up @@ -81,7 +80,6 @@ func TestFireWallRuleServiceHandler_List(t *testing.T) {
{
ID: 1,
Action: "accept",
Type: "v4",
IPType: "v4",
Protocol: "tcp",
Port: "22",
Expand Down Expand Up @@ -123,7 +121,6 @@ func TestFireWallRuleServiceHandler_Get(t *testing.T) {
expectedRule := &FirewallRule{
ID: 1,
Action: "accept",
Type: "v4",
IPType: "v4",
Protocol: "tcp",
Port: "22",
Expand Down
74 changes: 34 additions & 40 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,35 @@ type InstanceServiceHandler struct {

// Instance represents a VPS
type Instance struct {
ID string `json:"id"`
Os string `json:"os"`
RAM int `json:"ram"`
Disk int `json:"disk"`
Plan string `json:"plan"`
MainIP string `json:"main_ip"`
VCPUCount int `json:"vcpu_count"`
Region string `json:"region"`
DefaultPassword string `json:"default_password,omitempty"`
DateCreated string `json:"date_created"`
Status string `json:"status"`
AllowedBandwidth int `json:"allowed_bandwidth"`
NetmaskV4 string `json:"netmask_v4"`
GatewayV4 string `json:"gateway_v4"`
PowerStatus string `json:"power_status"`
ServerStatus string `json:"server_status"`
V6Network string `json:"v6_network"`
V6MainIP string `json:"v6_main_ip"`
V6NetworkSize int `json:"v6_network_size"`
Label string `json:"label"`
InternalIP string `json:"internal_ip"`
KVM string `json:"kvm"`
// Deprecated: Tag should no longer be used. Instead, use Tags.
Tag string `json:"tag"`
OsID int `json:"os_id"`
AppID int `json:"app_id"`
ImageID string `json:"image_id"`
FirewallGroupID string `json:"firewall_group_id"`
Features []string `json:"features"`
Hostname string `json:"hostname"`
Tags []string `json:"tags"`
ID string `json:"id"`
Os string `json:"os"`
RAM int `json:"ram"`
Disk int `json:"disk"`
Plan string `json:"plan"`
MainIP string `json:"main_ip"`
VCPUCount int `json:"vcpu_count"`
Region string `json:"region"`
DefaultPassword string `json:"default_password,omitempty"`
DateCreated string `json:"date_created"`
Status string `json:"status"`
AllowedBandwidth int `json:"allowed_bandwidth"`
NetmaskV4 string `json:"netmask_v4"`
GatewayV4 string `json:"gateway_v4"`
PowerStatus string `json:"power_status"`
ServerStatus string `json:"server_status"`
V6Network string `json:"v6_network"`
V6MainIP string `json:"v6_main_ip"`
V6NetworkSize int `json:"v6_network_size"`
Label string `json:"label"`
InternalIP string `json:"internal_ip"`
KVM string `json:"kvm"`
OsID int `json:"os_id"`
AppID int `json:"app_id"`
ImageID string `json:"image_id"`
FirewallGroupID string `json:"firewall_group_id"`
Features []string `json:"features"`
Hostname string `json:"hostname"`
Tags []string `json:"tags"`
}

type instanceBase struct {
Expand Down Expand Up @@ -233,11 +231,9 @@ type Upgrades struct {

// InstanceCreateReq struct used to create an instance.
type InstanceCreateReq struct {
Region string `json:"region,omitempty"`
Plan string `json:"plan,omitempty"`
Label string `json:"label,omitempty"`
// Deprecated: Tag should no longer be used. Instead, use Tags.
Tag string `json:"tag,omitempty"`
Region string `json:"region,omitempty"`
Plan string `json:"plan,omitempty"`
Label string `json:"label,omitempty"`
Tags []string `json:"tags"`
OsID int `json:"os_id,omitempty"`
ISOID string `json:"iso_id,omitempty"`
Expand Down Expand Up @@ -265,10 +261,8 @@ type InstanceCreateReq struct {

// InstanceUpdateReq struct used to update an instance.
type InstanceUpdateReq struct {
Plan string `json:"plan,omitempty"`
Label string `json:"label,omitempty"`
// Deprecated: Tag should no longer be used. Instead, use Tags.
Tag *string `json:"tag,omitempty"`
Plan string `json:"plan,omitempty"`
Label string `json:"label,omitempty"`
Tags []string `json:"tags"`
OsID int `json:"os_id,omitempty"`
AppID int `json:"app_id,omitempty"`
Expand Down

0 comments on commit e32f33b

Please sign in to comment.