From 9780469ed2b6701ef11ab9f8b6c7fd43ce66429e Mon Sep 17 00:00:00 2001 From: Ilja Rotar Date: Fri, 26 Jun 2026 13:44:17 +0200 Subject: [PATCH 1/2] Add admin status to switch nic --- api/models/v1_switch_nic.go | 52 +++++++++++++++++++++++++++++++++++++ metal-api.json | 9 +++++++ 2 files changed, 61 insertions(+) diff --git a/api/models/v1_switch_nic.go b/api/models/v1_switch_nic.go index e79d3df..888847e 100644 --- a/api/models/v1_switch_nic.go +++ b/api/models/v1_switch_nic.go @@ -25,6 +25,11 @@ type V1SwitchNic struct { // Enum: ["DOWN","UNKNOWN","UP"] Actual *string `json:"actual" yaml:"actual"` + // the desired state of the nic + // Required: true + // Enum: ["DOWN","UP"] + AdminStatus *string `json:"admin_status" yaml:"admin_status"` + // the current bgp port state BgpPortState *MetalSwitchBGPPortState `json:"bgp_port_state,omitempty" yaml:"bgp_port_state,omitempty"` @@ -55,6 +60,10 @@ func (m *V1SwitchNic) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateAdminStatus(formats); err != nil { + res = append(res, err) + } + if err := m.validateBgpPortState(formats); err != nil { res = append(res, err) } @@ -127,6 +136,49 @@ func (m *V1SwitchNic) validateActual(formats strfmt.Registry) error { return nil } +var v1SwitchNicTypeAdminStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["DOWN","UP"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + v1SwitchNicTypeAdminStatusPropEnum = append(v1SwitchNicTypeAdminStatusPropEnum, v) + } +} + +const ( + + // V1SwitchNicAdminStatusDOWN captures enum value "DOWN" + V1SwitchNicAdminStatusDOWN string = "DOWN" + + // V1SwitchNicAdminStatusUP captures enum value "UP" + V1SwitchNicAdminStatusUP string = "UP" +) + +// prop value enum +func (m *V1SwitchNic) validateAdminStatusEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, v1SwitchNicTypeAdminStatusPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *V1SwitchNic) validateAdminStatus(formats strfmt.Registry) error { + + if err := validate.Required("admin_status", "body", m.AdminStatus); err != nil { + return err + } + + // value enum + if err := m.validateAdminStatusEnum("admin_status", "body", *m.AdminStatus); err != nil { + return err + } + + return nil +} + func (m *V1SwitchNic) validateBgpPortState(formats strfmt.Registry) error { if swag.IsZero(m.BgpPortState) { // not required return nil diff --git a/metal-api.json b/metal-api.json index 59ddfa3..80e3fe1 100644 --- a/metal-api.json +++ b/metal-api.json @@ -5426,6 +5426,14 @@ ], "type": "string" }, + "admin_status": { + "description": "the desired state of the nic", + "enum": [ + "DOWN", + "UP" + ], + "type": "string" + }, "bgp_port_state": { "$ref": "#/definitions/metal.SwitchBGPPortState", "description": "the current bgp port state" @@ -5453,6 +5461,7 @@ }, "required": [ "actual", + "admin_status", "identifier", "mac", "name" From e45c5077ebe104a7b5cc698d9d530ebb5e88f913 Mon Sep 17 00:00:00 2001 From: Ilja Rotar Date: Wed, 15 Jul 2026 11:16:42 +0200 Subject: [PATCH 2/2] update spec --- api/models/datastore_machine_search_query.go | 3 ++ api/models/datastore_switch_search_query.go | 3 ++ api/models/v1_firewall_find_request.go | 3 ++ api/models/v1_firewall_response.go | 17 ++++++ api/models/v1_machine_base.go | 17 ++++++ api/models/v1_machine_find_request.go | 3 ++ api/models/v1_machine_ip_m_i_response.go | 17 ++++++ api/models/v1_machine_issues_request.go | 3 ++ api/models/v1_machine_response.go | 17 ++++++ api/models/v1_switch_base.go | 3 ++ api/models/v1_switch_find_request.go | 3 ++ api/models/v1_switch_nic.go | 10 ++-- api/models/v1_switch_register_request.go | 3 ++ api/models/v1_switch_response.go | 3 ++ api/models/v1_switch_update_request.go | 3 ++ metal-api.json | 55 +++++++++++++++++++- 16 files changed, 156 insertions(+), 7 deletions(-) diff --git a/api/models/datastore_machine_search_query.go b/api/models/datastore_machine_search_query.go index 80e346b..3e10aef 100644 --- a/api/models/datastore_machine_search_query.go +++ b/api/models/datastore_machine_search_query.go @@ -131,6 +131,9 @@ type DatastoreMachineSearchQuery struct { // rackid Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + // roomid + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` + // sizeid Sizeid string `json:"sizeid,omitempty" yaml:"sizeid,omitempty"` diff --git a/api/models/datastore_switch_search_query.go b/api/models/datastore_switch_search_query.go index 6815d98..23b237e 100644 --- a/api/models/datastore_switch_search_query.go +++ b/api/models/datastore_switch_search_query.go @@ -34,6 +34,9 @@ type DatastoreSwitchSearchQuery struct { // rackid Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + + // roomid + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` } // Validate validates this datastore switch search query diff --git a/api/models/v1_firewall_find_request.go b/api/models/v1_firewall_find_request.go index 83e4b57..c72ec3c 100644 --- a/api/models/v1_firewall_find_request.go +++ b/api/models/v1_firewall_find_request.go @@ -131,6 +131,9 @@ type V1FirewallFindRequest struct { // rackid Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + // roomid + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` + // sizeid Sizeid string `json:"sizeid,omitempty" yaml:"sizeid,omitempty"` diff --git a/api/models/v1_firewall_response.go b/api/models/v1_firewall_response.go index c9c78e4..93fc0c8 100644 --- a/api/models/v1_firewall_response.go +++ b/api/models/v1_firewall_response.go @@ -70,6 +70,10 @@ type V1FirewallResponse struct { // Read Only: true Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + // the room assigned to this machine + // Read Only: true + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` + // the size of this machine // Read Only: true Size *V1SizeResponse `json:"size,omitempty" yaml:"size,omitempty"` @@ -393,6 +397,10 @@ func (m *V1FirewallResponse) ContextValidate(ctx context.Context, formats strfmt res = append(res, err) } + if err := m.contextValidateRoomid(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateSize(ctx, formats); err != nil { res = append(res, err) } @@ -544,6 +552,15 @@ func (m *V1FirewallResponse) contextValidateRackid(ctx context.Context, formats return nil } +func (m *V1FirewallResponse) contextValidateRoomid(ctx context.Context, formats strfmt.Registry) error { + + if err := validate.ReadOnly(ctx, "roomid", "body", string(m.Roomid)); err != nil { + return err + } + + return nil +} + func (m *V1FirewallResponse) contextValidateSize(ctx context.Context, formats strfmt.Registry) error { if m.Size != nil { diff --git a/api/models/v1_machine_base.go b/api/models/v1_machine_base.go index 78852b3..5ccef27 100644 --- a/api/models/v1_machine_base.go +++ b/api/models/v1_machine_base.go @@ -50,6 +50,10 @@ type V1MachineBase struct { // Read Only: true Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + // the room assigned to this machine + // Read Only: true + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` + // the size of this machine // Read Only: true Size *V1SizeResponse `json:"size,omitempty" yaml:"size,omitempty"` @@ -320,6 +324,10 @@ func (m *V1MachineBase) ContextValidate(ctx context.Context, formats strfmt.Regi res = append(res, err) } + if err := m.contextValidateRoomid(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateSize(ctx, formats); err != nil { res = append(res, err) } @@ -453,6 +461,15 @@ func (m *V1MachineBase) contextValidateRackid(ctx context.Context, formats strfm return nil } +func (m *V1MachineBase) contextValidateRoomid(ctx context.Context, formats strfmt.Registry) error { + + if err := validate.ReadOnly(ctx, "roomid", "body", string(m.Roomid)); err != nil { + return err + } + + return nil +} + func (m *V1MachineBase) contextValidateSize(ctx context.Context, formats strfmt.Registry) error { if m.Size != nil { diff --git a/api/models/v1_machine_find_request.go b/api/models/v1_machine_find_request.go index e80a407..f65ee5c 100644 --- a/api/models/v1_machine_find_request.go +++ b/api/models/v1_machine_find_request.go @@ -131,6 +131,9 @@ type V1MachineFindRequest struct { // rackid Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + // roomid + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` + // sizeid Sizeid string `json:"sizeid,omitempty" yaml:"sizeid,omitempty"` diff --git a/api/models/v1_machine_ip_m_i_response.go b/api/models/v1_machine_ip_m_i_response.go index ce981b6..db5e80d 100644 --- a/api/models/v1_machine_ip_m_i_response.go +++ b/api/models/v1_machine_ip_m_i_response.go @@ -74,6 +74,10 @@ type V1MachineIPMIResponse struct { // Read Only: true Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + // the room assigned to this machine + // Read Only: true + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` + // the size of this machine // Read Only: true Size *V1SizeResponse `json:"size,omitempty" yaml:"size,omitempty"` @@ -425,6 +429,10 @@ func (m *V1MachineIPMIResponse) ContextValidate(ctx context.Context, formats str res = append(res, err) } + if err := m.contextValidateRoomid(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateSize(ctx, formats); err != nil { res = append(res, err) } @@ -593,6 +601,15 @@ func (m *V1MachineIPMIResponse) contextValidateRackid(ctx context.Context, forma return nil } +func (m *V1MachineIPMIResponse) contextValidateRoomid(ctx context.Context, formats strfmt.Registry) error { + + if err := validate.ReadOnly(ctx, "roomid", "body", string(m.Roomid)); err != nil { + return err + } + + return nil +} + func (m *V1MachineIPMIResponse) contextValidateSize(ctx context.Context, formats strfmt.Registry) error { if m.Size != nil { diff --git a/api/models/v1_machine_issues_request.go b/api/models/v1_machine_issues_request.go index d1d985b..0f41874 100644 --- a/api/models/v1_machine_issues_request.go +++ b/api/models/v1_machine_issues_request.go @@ -143,6 +143,9 @@ type V1MachineIssuesRequest struct { // rackid Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + // roomid + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` + // filters issue for given severity // Required: true Severity *string `json:"severity" yaml:"severity"` diff --git a/api/models/v1_machine_response.go b/api/models/v1_machine_response.go index 306df99..48dab4a 100644 --- a/api/models/v1_machine_response.go +++ b/api/models/v1_machine_response.go @@ -70,6 +70,10 @@ type V1MachineResponse struct { // Read Only: true Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + // the room assigned to this machine + // Read Only: true + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` + // the size of this machine // Read Only: true Size *V1SizeResponse `json:"size,omitempty" yaml:"size,omitempty"` @@ -393,6 +397,10 @@ func (m *V1MachineResponse) ContextValidate(ctx context.Context, formats strfmt. res = append(res, err) } + if err := m.contextValidateRoomid(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateSize(ctx, formats); err != nil { res = append(res, err) } @@ -544,6 +552,15 @@ func (m *V1MachineResponse) contextValidateRackid(ctx context.Context, formats s return nil } +func (m *V1MachineResponse) contextValidateRoomid(ctx context.Context, formats strfmt.Registry) error { + + if err := validate.ReadOnly(ctx, "roomid", "body", string(m.Roomid)); err != nil { + return err + } + + return nil +} + func (m *V1MachineResponse) contextValidateSize(ctx context.Context, formats strfmt.Registry) error { if m.Size != nil { diff --git a/api/models/v1_switch_base.go b/api/models/v1_switch_base.go index c6d69fc..7b880f0 100644 --- a/api/models/v1_switch_base.go +++ b/api/models/v1_switch_base.go @@ -37,6 +37,9 @@ type V1SwitchBase struct { // the id of the rack in which this switch is located // Required: true RackID *string `json:"rack_id" yaml:"rack_id"` + + // the id of the room in which this switch is located + RoomID string `json:"room_id,omitempty" yaml:"room_id,omitempty"` } // Validate validates this v1 switch base diff --git a/api/models/v1_switch_find_request.go b/api/models/v1_switch_find_request.go index a5622aa..2bf237d 100644 --- a/api/models/v1_switch_find_request.go +++ b/api/models/v1_switch_find_request.go @@ -34,6 +34,9 @@ type V1SwitchFindRequest struct { // rackid Rackid string `json:"rackid,omitempty" yaml:"rackid,omitempty"` + + // roomid + Roomid string `json:"roomid,omitempty" yaml:"roomid,omitempty"` } // Validate validates this v1 switch find request diff --git a/api/models/v1_switch_nic.go b/api/models/v1_switch_nic.go index 888847e..9a3030f 100644 --- a/api/models/v1_switch_nic.go +++ b/api/models/v1_switch_nic.go @@ -26,9 +26,8 @@ type V1SwitchNic struct { Actual *string `json:"actual" yaml:"actual"` // the desired state of the nic - // Required: true // Enum: ["DOWN","UP"] - AdminStatus *string `json:"admin_status" yaml:"admin_status"` + AdminStatus string `json:"admin_status,omitempty" yaml:"admin_status,omitempty"` // the current bgp port state BgpPortState *MetalSwitchBGPPortState `json:"bgp_port_state,omitempty" yaml:"bgp_port_state,omitempty"` @@ -166,13 +165,12 @@ func (m *V1SwitchNic) validateAdminStatusEnum(path, location string, value strin } func (m *V1SwitchNic) validateAdminStatus(formats strfmt.Registry) error { - - if err := validate.Required("admin_status", "body", m.AdminStatus); err != nil { - return err + if swag.IsZero(m.AdminStatus) { // not required + return nil } // value enum - if err := m.validateAdminStatusEnum("admin_status", "body", *m.AdminStatus); err != nil { + if err := m.validateAdminStatusEnum("admin_status", "body", m.AdminStatus); err != nil { return err } diff --git a/api/models/v1_switch_register_request.go b/api/models/v1_switch_register_request.go index dddd493..3f83a9c 100644 --- a/api/models/v1_switch_register_request.go +++ b/api/models/v1_switch_register_request.go @@ -56,6 +56,9 @@ type V1SwitchRegisterRequest struct { // the id of the rack in which this switch is located // Required: true RackID *string `json:"rack_id" yaml:"rack_id"` + + // the id of the room in which this switch is located + RoomID string `json:"room_id,omitempty" yaml:"room_id,omitempty"` } // Validate validates this v1 switch register request diff --git a/api/models/v1_switch_response.go b/api/models/v1_switch_response.go index 09e1a2a..a2bef70 100644 --- a/api/models/v1_switch_response.go +++ b/api/models/v1_switch_response.go @@ -76,6 +76,9 @@ type V1SwitchResponse struct { // the id of the rack in which this switch is located // Required: true RackID *string `json:"rack_id" yaml:"rack_id"` + + // the id of the room in which this switch is located + RoomID string `json:"room_id,omitempty" yaml:"room_id,omitempty"` } // Validate validates this v1 switch response diff --git a/api/models/v1_switch_update_request.go b/api/models/v1_switch_update_request.go index ffc055e..066f51d 100644 --- a/api/models/v1_switch_update_request.go +++ b/api/models/v1_switch_update_request.go @@ -47,6 +47,9 @@ type V1SwitchUpdateRequest struct { // the id of the rack in which this switch is located // Required: true RackID *string `json:"rack_id" yaml:"rack_id"` + + // the id of the room in which this switch is located + RoomID string `json:"room_id,omitempty" yaml:"room_id,omitempty"` } // Validate validates this v1 switch update request diff --git a/metal-api.json b/metal-api.json index 80e3fe1..9c259b6 100644 --- a/metal-api.json +++ b/metal-api.json @@ -241,6 +241,9 @@ "rackid": { "type": "string" }, + "roomid": { + "type": "string" + }, "sizeid": { "type": "string" }, @@ -336,6 +339,9 @@ }, "rackid": { "type": "string" + }, + "roomid": { + "type": "string" } } }, @@ -1366,6 +1372,9 @@ "rackid": { "type": "string" }, + "roomid": { + "type": "string" + }, "sizeid": { "type": "string" }, @@ -1487,6 +1496,11 @@ "readOnly": true, "type": "string" }, + "roomid": { + "description": "the room assigned to this machine", + "readOnly": true, + "type": "string" + }, "size": { "$ref": "#/definitions/v1.SizeResponse", "description": "the size of this machine", @@ -2362,6 +2376,11 @@ "readOnly": true, "type": "string" }, + "roomid": { + "description": "the room assigned to this machine", + "readOnly": true, + "type": "string" + }, "size": { "$ref": "#/definitions/v1.SizeResponse", "description": "the size of this machine", @@ -2605,6 +2624,9 @@ "rackid": { "type": "string" }, + "roomid": { + "type": "string" + }, "sizeid": { "type": "string" }, @@ -2868,6 +2890,11 @@ "readOnly": true, "type": "string" }, + "roomid": { + "description": "the room assigned to this machine", + "readOnly": true, + "type": "string" + }, "size": { "$ref": "#/definitions/v1.SizeResponse", "description": "the size of this machine", @@ -3203,6 +3230,9 @@ "rackid": { "type": "string" }, + "roomid": { + "type": "string" + }, "severity": { "description": "filters issue for given severity", "type": "string" @@ -3480,6 +3510,11 @@ "readOnly": true, "type": "string" }, + "roomid": { + "description": "the room assigned to this machine", + "readOnly": true, + "type": "string" + }, "size": { "$ref": "#/definitions/v1.SizeResponse", "description": "the size of this machine", @@ -5356,6 +5391,10 @@ "rack_id": { "description": "the id of the rack in which this switch is located", "type": "string" + }, + "room_id": { + "description": "the id of the room in which this switch is located", + "type": "string" } }, "required": [ @@ -5396,6 +5435,9 @@ }, "rackid": { "type": "string" + }, + "roomid": { + "type": "string" } } }, @@ -5461,7 +5503,6 @@ }, "required": [ "actual", - "admin_status", "identifier", "mac", "name" @@ -5613,6 +5654,10 @@ "rack_id": { "description": "the id of the rack in which this switch is located", "type": "string" + }, + "room_id": { + "description": "the id of the room in which this switch is located", + "type": "string" } }, "required": [ @@ -5697,6 +5742,10 @@ "rack_id": { "description": "the id of the rack in which this switch is located", "type": "string" + }, + "room_id": { + "description": "the id of the room in which this switch is located", + "type": "string" } }, "required": [ @@ -5766,6 +5815,10 @@ "rack_id": { "description": "the id of the rack in which this switch is located", "type": "string" + }, + "room_id": { + "description": "the id of the room in which this switch is located", + "type": "string" } }, "required": [