switchs

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PortDisable

func PortDisable(ctx *dcimsdk.Context, portId uint) (resp dcimsdk.CreateUpdateResp, err error)

PortDisable 禁用

func PortEnable

func PortEnable(ctx *dcimsdk.Context, portId uint) (resp dcimsdk.CreateUpdateResp, err error)

PortEnable 启用

func PortMacLock

func PortMacLock(ctx *dcimsdk.Context, request *MacLockReq) (resp dcimsdk.CreateUpdateResp, err error)

PortMacLock 加锁交换机mac地址绑定 https://www.eolink.com/share/inside/XIPzIs/api/1389879/detail/5756321

func PortMacUnLock

func PortMacUnLock(ctx *dcimsdk.Context, request *MacUnLockReq) (resp dcimsdk.CreateUpdateResp, err error)

PortMacUnLock 解锁交换机mac地址绑定 https://www.eolink.com/share/inside/XIPzIs/api/1389879/detail/5756312

func PortUpdateMac

func PortUpdateMac(ctx *dcimsdk.Context, request *PortUpdateMacReq) (resp dcimsdk.CreateUpdateResp, err error)

Types

type CreateReq

type CreateReq struct {
	Name            string          `json:"name"`             // 名称
	SnmpSupport     uint            `json:"snmp_support"`     // 控制snmp
	ControlSupport  uint            `json:"control_support"`  // 手动控制
	ControlProtocol string          `json:"control_protocol"` // 手动控制协议
	Device          string          `json:"device"`           // 驱动
	Type            string          `json:"type"`             // 类型
	CabinetId       uint            `json:"cabinet_id"`       // 机柜id
	Remark          string          `json:"remark"`           // 备注
	MainIpv4Address MainIpv4Address `json:"main_ipv4address"`
}

func (*CreateReq) Body

func (r *CreateReq) Body() (body any)

func (*CreateReq) Method

func (r *CreateReq) Method() (method string)

func (*CreateReq) Url

func (r *CreateReq) Url() (url string)

func (*CreateReq) Values

func (r *CreateReq) Values() (values url.Values)

type DeleteReq

type DeleteReq struct {
	Id uint `json:"-"`
}

func (*DeleteReq) Body

func (r *DeleteReq) Body() (body any)

func (*DeleteReq) Method

func (r *DeleteReq) Method() (method string)

func (*DeleteReq) Url

func (r *DeleteReq) Url() (url string)

func (*DeleteReq) Values

func (r *DeleteReq) Values() (values url.Values)

type DetailReq

type DetailReq struct {
	Id uint `url:"id" json:"id"`
}

func (*DetailReq) Body

func (r *DetailReq) Body() (body any)

func (*DetailReq) Method

func (r *DetailReq) Method() (method string)

func (*DetailReq) Url

func (r *DetailReq) Url() (url string)

func (*DetailReq) Values

func (r *DetailReq) Values() (values url.Values)

type DetailResp

type DetailResp struct {
	Success bool   `json:"success"`
	Error   string `json:"error"`
	Switch  struct {
		Id                    int    `json:"id"`
		Name                  string `json:"name"`            // 名称
		Device                string `json:"device"`          // 驱动
		DatacenterId          int    `json:"datacenter_id"`   // 机房id
		CabinetId             int    `json:"cabinet_id"`      // 机柜id
		Type                  string `json:"type"`            // 类型
		NetworkLayer          int    `json:"network_layer"`   // 网络层
		SwitchModelId         any    `json:"switch_model_id"` // 交换机型号id
		Lib                   string `json:"lib"`
		Model                 string `json:"model"`
		SnmpSupport           int    `json:"snmp_support"` // snmp控制
		SnmpVersion           string `json:"snmp_version"` // snmp版本
		SnmpStatus            int    `json:"snmp_status"`  // snmp状态
		Remark                string `json:"remark"`       // 备注
		IsLock                int    `json:"is_lock"`      // 锁定
		Capacity              int    `json:"capacity"`
		TotalPortsCount       int    `json:"total_ports_count"`       // 端口总数
		IdlePortsCount        int    `json:"idle_ports_count"`        // 空闲端口总数
		MalfunctionPortsCount int    `json:"malfunction_ports_count"` // 故障端口数
		IpAddress             struct {
			Id      int    `json:"id"`      // ip地址主键id
			Address string `json:"address"` // ip地址
		} `json:"ip_address"`
		Cabinet struct {
			Id   int    `json:"id"`
			Name string `json:"name"` // 机柜名称
		} `json:"cabinet"` // 机柜信息
		MainIpv4Address struct {
			Id      int    `json:"id"`
			Address string `json:"address"` // ip地址
		} `json:"main_ipv4address"` // 主ip地址

		SnmpCredential struct {
			Community string `json:"community"` // 社区
		} `json:"snmp_credential"` // snmp凭证
		ControlSupport    int    `json:"control_support"`  // 手动控制
		ControlProtocol   string `json:"control_protocol"` // 手动控制协议
		ControlCredential struct {
			Username string `json:"username"` // 用户名
			Password string `json:"password"` // 密码
			Port     string `json:"port"`     // 端口
		} `json:"control_credential"` // 手动控制凭证
		AutoControlProtocol   string `json:"auto_control_protocol"` // 自动控制协议
		AutoControlCredential struct {
			Username string `json:"username"` // 用户名
			Password string `json:"password"` // 密码
			Port     string `json:"port"`     // 端口
		} `json:"auto_control_credential"` // 自动控制凭证
		CreatedAt string `json:"created_at"`
		UpdatedAt string `json:"updated_at"`
		Block     struct {
			Id   int    `json:"id"`   // ip段主键id
			Type string `json:"type"` // 类型
		} `json:"block"` // ip段信息
		Address []struct {
			AddressString string `json:"address_string"` // ip地址
			BlockId       int    `json:"block_id"`       // ip段id
			Type          string `json:"type"`           // 类型
			Id            int    `json:"id"`             // ip地址id TODO address_id
		} `json:"address"` // ip地址信息
		Intranets  []any  `json:"intranets"`  // 内网信息
		Brand      string `json:"brand"`      // 品牌
		ModelValue string `json:"modelValue"` // 型号
		ChassisMac []any  `json:"chassisMac"` // 底盘mac
		// ip地址信息
		SwitchModel any `json:"switch_model"` // 交换机型号
	} `json:"switch"` // 交换机信息
}

func Detail

func Detail(ctx *dcimsdk.Context, request *DetailReq) (resp DetailResp, err error)

Detail 获取交换机详情 https://www.eolink.com/share/inside/XIPzIs/api/1389879/detail/5753939

type ListReq

type ListReq struct {
	Page     uint `url:"page"`
	PageSize uint `url:"page_size"`
}

func (*ListReq) Body

func (r *ListReq) Body() (body any)

func (*ListReq) Method

func (r *ListReq) Method() (method string)

func (*ListReq) Url

func (r *ListReq) Url() (url string)

func (*ListReq) Values

func (r *ListReq) Values() (values url.Values)

type ListResp

type ListResp struct {
	Success bool     `json:"success"`
	Error   string   `json:"error"`
	Switchs []Switch `json:"switchs"`
	Total   int      `json:"total"`
}

func List

func List(ctx *dcimsdk.Context, request *ListReq) (resp ListResp, err error)

List 获取交换机列表 https://www.eolink.com/share/inside/XIPzIs/api/1389879/detail/5750682

func (ListResp) Err

func (r ListResp) Err() (err error)

func (ListResp) Ok

func (r ListResp) Ok() (ok bool)

type MacLockReq

type MacLockReq struct{ PortId uint }

func (*MacLockReq) Body

func (r *MacLockReq) Body() (body any)

func (*MacLockReq) Method

func (r *MacLockReq) Method() (method string)

func (*MacLockReq) Url

func (r *MacLockReq) Url() (url string)

func (*MacLockReq) Values

func (r *MacLockReq) Values() (values url.Values)

type MacUnLockReq

type MacUnLockReq struct{ PortId uint }

func (*MacUnLockReq) Body

func (r *MacUnLockReq) Body() (body any)

func (*MacUnLockReq) Method

func (r *MacUnLockReq) Method() (method string)

func (*MacUnLockReq) Url

func (r *MacUnLockReq) Url() (url string)

func (*MacUnLockReq) Values

func (r *MacUnLockReq) Values() (values url.Values)

type MainIpv4Address

type MainIpv4Address struct {
	Id uint `json:"id"`
}

type Port

type Port struct {
	Id                uint   `json:"id"`
	SwitchId          uint   `json:"switch_id"`        // 交换机id
	PortName          string `json:"port_name"`        // 端口名称
	PortType          string `json:"port_type"`        // 端口类型
	PortRemark        string `json:"port_remark"`      // 端口备注
	Type              string `json:"type"`             // 类型
	Disconnected      int    `json:"disconnected"`     // 断线状态
	Disabled          bool   `json:"disabled"`         // 禁用状态:false启用;true禁用
	VlanType          string `json:"vlan_type"`        // VLAN类型
	Speed             any    `json:"speed"`            // 链路速率
	Mtu               any    `json:"mtu"`              // MTU
	BindMac           int    `json:"bind_mac"`         // 绑定mac状态
	BindArp           int    `json:"bind_arp"`         // 绑定arp状态
	UpPort            uint   `json:"up_port"`          // 上行端口
	DownPort          uint   `json:"down_port"`        // 下载端口
	MacAddress        string `json:"mac_address"`      // mac地址
	PhysMacAddress    any    `json:"phys_mac_address"` // 物理mac地址
	MacReachTime      any    `json:"mac_reach_time"`   // mac延伸时间
	Remarks           string `json:"remarks"`          // 备注
	CreatedAt         string `json:"created_at"`
	UpdatedAt         string `json:"updated_at"`
	MacAddressesCount int    `json:"mac_addresses_count"` // mac地址数量
	Device            struct {
		Id     uint   `json:"id"`      // 交换机id
		Name   string `json:"name"`    // 交换机名称
		Type   string `json:"type"`    // 交换机端口类型
		MainIp string `json:"main_ip"` // 交换机ip地址
	} `json:"device"` // 驱动
}

type PortDetailReq

type PortDetailReq struct {
	PortId int `url:"port_id" json:"-"`
}

func (*PortDetailReq) Body

func (r *PortDetailReq) Body() (body any)

func (*PortDetailReq) Method

func (r *PortDetailReq) Method() (method string)

func (*PortDetailReq) Url

func (r *PortDetailReq) Url() (url string)

func (*PortDetailReq) Values

func (r *PortDetailReq) Values() (values url.Values)

type PortDetailResp

type PortDetailResp struct {
	Success  bool   `json:"success"`
	Error    string `json:"error"`
	PortInfo struct {
		Id             uint     `json:"id"`           // 端口id
		SwitchId       uint     `json:"switch_id"`    // 交换机id
		PortIndex      string   `json:"port_index"`   // 端口序号
		PortName       string   `json:"port_name"`    // 端口名
		PortType       string   `json:"port_type"`    // 端口类型
		PortRemark     string   `json:"port_remark"`  // 端口备注
		Type           string   `json:"type"`         // 类型
		Relid          uint     `json:"relid"`        // 关联Id
		Disconnected   uint     `json:"disconnected"` // 断开连接
		Disabled       bool     `json:"disabled"`     // 禁用
		VlanType       string   `json:"vlan_type"`    // vlan类型
		Speed          any      `json:"speed"`        // 速度
		Mtu            any      `json:"mtu"`
		BindMac        int      `json:"bind_mac"` // 绑定mac
		BindArp        int      `json:"bind_arp"` // 绑定arp
		BindAcl        int      `json:"bind_acl"`
		UpPort         int      `json:"up_port"`          // 上行端口
		DownPort       int      `json:"down_port"`        // 下载端口
		MacAddress     string   `json:"mac_address"`      // mac地址
		PhysMacAddress any      `json:"phys_mac_address"` // 物理mac地址
		MacReachTime   any      `json:"mac_reach_time"`   // mac延伸时间
		Remarks        string   `json:"remarks"`          // 备注
		FilePath       string   `json:"file_path"`        // 文件路径
		CreatedAt      any      `json:"created_at"`
		UpdatedAt      any      `json:"updated_at"`
		Vlans          []string `json:"vlans"` // vlan
	} `json:"portinfo"` // 端口信息
}

func PortDetail

func PortDetail(ctx *dcimsdk.Context, request *PortDetailReq) (resp PortDetailResp, err error)

PortDetail 获取端口详情 https://www.eolink.com/share/inside/XIPzIs/api/1389879/detail/5752250

type PortListReq

type PortListReq struct{ SwitchId uint }

func (*PortListReq) Body

func (r *PortListReq) Body() (body any)

func (*PortListReq) Method

func (r *PortListReq) Method() (method string)

func (*PortListReq) Url

func (r *PortListReq) Url() (url string)

func (*PortListReq) Values

func (r *PortListReq) Values() (values url.Values)

type PortListResp

type PortListResp struct {
	Success string `json:"success"`
	Error   string `json:"error"` //  错误信息(错误信息,当success===false时才会存在)
	Ports   []Port `json:"ports"` // 端口列表
}

func PortList

func PortList(ctx *dcimsdk.Context, request *PortListReq) (resp PortListResp, err error)

PortList 获取交换机端口列表 https://www.eolink.com/share/inside/XIPzIs/api/1389879/detail/5754666

func (PortListResp) Err

func (r PortListResp) Err() (err error)

func (PortListResp) Ok

func (r PortListResp) Ok() (ok bool)

type PortUpdateMacReq

type PortUpdateMacReq struct {
	PortId uint   `json:"-"`
	Mac    string `json:"mac"`
}

func (*PortUpdateMacReq) Body

func (r *PortUpdateMacReq) Body() (body any)

func (*PortUpdateMacReq) Method

func (r *PortUpdateMacReq) Method() (method string)

func (*PortUpdateMacReq) Url

func (r *PortUpdateMacReq) Url() (url string)

func (*PortUpdateMacReq) Values

func (r *PortUpdateMacReq) Values() (values url.Values)

type PortUpdateStatusReq

type PortUpdateStatusReq struct {
	PortId uint `json:"-"`      // 交换机端口Id
	Enable bool `json:"enable"` // false:禁用;true:启用
}

func (*PortUpdateStatusReq) Body

func (r *PortUpdateStatusReq) Body() (body any)

func (*PortUpdateStatusReq) Method

func (r *PortUpdateStatusReq) Method() (method string)

func (*PortUpdateStatusReq) Url

func (r *PortUpdateStatusReq) Url() (url string)

func (*PortUpdateStatusReq) Values

func (r *PortUpdateStatusReq) Values() (values url.Values)

type Switch

type Switch struct {
	Id                    uint   `json:"id"`
	Name                  string `json:"name"`
	Device                string `json:"device"`
	DatacenterId          uint   `json:"datacenter_id"`
	CabinetId             uint   `json:"cabinet_id"`
	Type                  string `json:"type"`
	NetworkLayer          int    `json:"network_layer"`
	SwitchModelId         any    `json:"switch_model_id"`
	Lib                   string `json:"lib"`
	Model                 string `json:"model"`
	SnmpVersion           string `json:"snmp_version"`
	SnmpStatus            int    `json:"snmp_status"`
	Remark                string `json:"remark"`
	Capacity              int    `json:"capacity"`
	IsLock                int    `json:"is_lock"`
	RoutingSupport        int    `json:"routing_support"`
	SnmpPort              int    `json:"snmp_port"`
	PrivilegedPassword    any    `json:"privileged_password"`
	TotalPortsCount       int    `json:"total_ports_count"`
	IdlePortsCount        int    `json:"idle_ports_count"`
	MalfunctionPortsCount int    `json:"malfunction_ports_count"`
	UsingPortsCount       int    `json:"using_ports_count"`
	SwitchModelName       string `json:"switch_model_name"`
	ChassisMac            []any  `json:"chassisMac"`
	IpAddress             struct {
		Id             uint   `json:"id"`
		BlockId        uint   `json:"block_id"`
		Address        string `json:"address"`
		AddressString  string `json:"address_string"`
		Ipv4BlockType  string `json:"ipv4_block_type"`
		Ipv4BlockLabel string `json:"ipv4_block_label"`
	} `json:"ip_address"`
	Datacenter struct {
		Id                 int    `json:"id"`
		Name               string `json:"name"`
		Voltage            int    `json:"voltage"`
		SwitchPorts        []any  `json:"switch_ports"`
		ArpOs              int    `json:"arp_os"`
		ReinstallLimit     int    `json:"reinstall_limit"`
		HardwareCheckLimit int    `json:"hardware_check_limit"`
		SerialNumberRuleId any    `json:"serial_number_rule_id"`
		CreatedAt          int    `json:"created_at"`
		UpdatedAt          int    `json:"updated_at"`
	} `json:"datacenter"`
	Cabinet struct {
		Id     int    `json:"id"`
		Name   string `json:"name"`
		IsLock int    `json:"is_lock"`
	} `json:"cabinet"`
	MainIpv4Address struct {
		Id             int    `json:"id"`
		BlockId        int    `json:"block_id"`
		Address        string `json:"address"`
		AddressString  string `json:"address_string"`
		Ipv4BlockType  string `json:"ipv4_block_type"`
		Ipv4BlockLabel string `json:"ipv4_block_label"`
	} `json:"main_ipv4address"`
}

type UpdateReq

type UpdateReq struct {
	Id uint `json:"-"`

	Name            string          `json:"name"`             // 名称
	SnmpSupport     uint            `json:"snmp_support"`     // 控制snmp
	ControlSupport  uint            `json:"control_support"`  // 手动控制
	ControlProtocol string          `json:"control_protocol"` // 手动控制协议
	Device          string          `json:"device"`           // 驱动
	Type            string          `json:"type"`             // 类型
	CabinetId       uint            `json:"cabinet_id"`       // 机柜id
	Remark          string          `json:"remark"`           // 备注
	MainIpv4Address MainIpv4Address `json:"main_ipv4address"`
}

func (*UpdateReq) Body

func (r *UpdateReq) Body() (body any)

func (*UpdateReq) Method

func (r *UpdateReq) Method() (method string)

func (*UpdateReq) Url

func (r *UpdateReq) Url() (url string)

func (*UpdateReq) Values

func (r *UpdateReq) Values() (values url.Values)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL