host

package
v0.0.0-...-5f20023 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteHostRequest

type DeleteHostRequest struct{}

type Describe

type Describe struct {
	ResourceId   string `json:"resource_id" `               //关联的资源ID
	CPU          int    `json:"cpu" validate:"required"`    //CPU核数
	Memory       int    `json:"memory" validate:"required"` //内存大小
	GPUAmount    int    `json:"gpu_amount"`                 //GPU数量
	GPUSpec      string `json:"gpu_spec"`                   //GPU规格
	OSType       string `json:"os_type"`                    //操作系统类型
	OSName       string `json:"os_name"`
	SerialNumber string `json:"serial_number"` //序列号
}

type Host

type Host struct {
	*Resource //公共部分

	*Describe //独有部分
}

func NewHost

func NewHost() *Host

func (*Host) InjectDefault

func (h *Host) InjectDefault()

func (*Host) Validate

func (h *Host) Validate() error

校验数据合法性

type Hostset

type Hostset struct {
	Items []*Host `json:"items"`
	Total int     `json:"total"`
}

方便扩展,避免修改接口

type QueryHostRequest

type QueryHostRequest struct{}

type Resource

type Resource struct {
	Id          string `json:"id" validate:"required"`
	Vender      Vender `json:"vender" `
	Region      string `json:"region" validate:"required"`
	CreateAt    int    `json:"create_at"`
	ExpireAt    int    `json:"expire_at"`
	Type        string `json:"type" validate:"required"`
	Name        string `json:"name" validate:"required"`
	Description string `json:"description"`
	Status      string `json:"status"`
	UpdateAt    int    `json:"update_at"`
	SyncAt      int    `json:"sync_at"`
	Account     string `json:"account"`
	PublicIP    string `json:"public_ip"`
	PrivateIP   string `json:"private_ip"`
}

type Service

type Service interface {

	//创建主机
	CreateHost(context.Context, *Host) (*Host, error)
	//查询主机列表(列表不展示详细信息)
	QueryHost(context.Context, *QueryHostRequest) (*Hostset, error)
	//查询主机详情
	DescribeHost(context.Context, *QueryHostRequest) (*Host, error)
	//删除主机,比如前端需要打印删除对象的详细信息
	DeleteHost(context.Context, *UpdateHostRequest) (*Host, error)
	//更新主机
	UpdateHost(context.Context, *DeleteHostRequest) error
}

type UpdateHostRequest

type UpdateHostRequest struct {
	//只允许更新私有部分
	*Describe
}

type Vender

type Vender int
const (
	PrivateIDC Vender = iota
	Tencent
	AliYun
	HuaWei
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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