host

package
v0.0.0-...-d5aecf8 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObjectPatch

func ObjectPatch(old, new interface{}) error

patch JSON {a: 1, b: 2}, {b:20} ===> {a:1, b:20}

Types

type Base

type Base struct {
	Id           string `json:"id"`            // 全局唯一Id
	SyncAt       int64  `json:"sync_at"`       // 同步时间
	Vendor       Vendor `json:"vendor"`        // 厂商
	Region       string `json:"region"`        // 地域
	Zone         string `json:"zone"`          // 区域
	CreateAt     int64  `json:"create_at"`     // 创建时间
	InstanceId   string `json:"instance_id"`   // 实例ID
	ResourceHash string `json:"resource_hash"` // 基础数据Hash
	DescribeHash string `json:"describe_hash"` // 描述数据Hash
}

type DeleteHostRequest

type DeleteHostRequest struct {
	Id string `json:"id" validate:"required"`
}

func NewDeleteHostRequestWithID

func NewDeleteHostRequestWithID(id string) *DeleteHostRequest

type Describe

type Describe struct {
	ResourceId              string `json:"resource_id"`                // 关联Resource
	CPU                     int    `json:"cpu"`                        // 核数
	Memory                  int    `json:"memory"`                     // 内存
	GPUAmount               int    `json:"gpu_amount"`                 // GPU数量
	GPUSpec                 string `json:"gpu_spec"`                   // GPU类型
	OSType                  string `json:"os_type"`                    // 操作系统类型,分为Windows和Linux
	OSName                  string `json:"os_name"`                    // 操作系统名称
	SerialNumber            string `json:"serial_number"`              // 序列号
	ImageID                 string `json:"image_id"`                   // 镜像ID
	InternetMaxBandwidthOut int    `json:"internet_max_bandwidth_out"` // 公网出带宽最大值,单位为 Mbps
	InternetMaxBandwidthIn  int    `json:"internet_max_bandwidth_in"`  // 公网入带宽最大值,单位为 Mbps
	KeyPairName             string `json:"key_pair_name,omitempty"`    // 秘钥对名称
	SecurityGroups          string `json:"security_groups"`            // 安全组  采用逗号分隔
}

type DescribeHostRequest

type DescribeHostRequest struct {
	Id string `json:"id" validate:"required"`
}

func NewDescribeHostRequestWithID

func NewDescribeHostRequestWithID(id string) *DescribeHostRequest

type Host

type Host struct {
	*Base
	*Resource
	*Describe
}

func NewDefaultHost

func NewDefaultHost() *Host

func (*Host) GenHash

func (h *Host) GenHash() error

func (*Host) Patch

func (h *Host) Patch(req *UpdateHostData) error

func (*Host) Put

func (h *Host) Put(req *UpdateHostData)

type HostSet

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

func NewHostSet

func NewHostSet() *HostSet

func (*HostSet) Add

func (s *HostSet) Add(item *Host)

type QueryHostRequest

type QueryHostRequest struct {
	PageSize   uint64 `json:"page_size,omitempty"`
	PageNumber uint64 `json:"page_number,omitempty"`
	Keywords   string `json:"keywords"`
}

func NewQueryHostRequestFromHTTP

func NewQueryHostRequestFromHTTP(r *http.Request) *QueryHostRequest

func (*QueryHostRequest) OffSet

func (req *QueryHostRequest) OffSet() int64

type Resource

type Resource struct {
	ExpireAt    int64             `json:"expire_at"`   // 过期时间
	Category    string            `json:"category"`    // 种类
	Type        string            `json:"type"`        // 规格
	Name        string            `json:"name"`        // 名称
	Description string            `json:"description"` // 描述
	Status      string            `json:"status"`      // 服务商中的状态
	Tags        map[string]string `json:"tags"`        // 标签
	UpdateAt    int64             `json:"update_at"`   // 更新时间
	SyncAccount string            `json:"sync_accout"` // 同步的账号
	PublicIP    string            `json:"public_ip"`   // 公网IP
	PrivateIP   string            `json:"private_ip"`  // 内网IP
	PayType     string            `json:"pay_type"`    // 实例付费方式
}

type Service

type Service interface {
	SaveHost(context.Context, *Host) (*Host, error)
	QueryHost(context.Context, *QueryHostRequest) (*HostSet, error)
	UpdateHost(context.Context, *UpdateHostRequest) (*Host, error)
	DescribeHost(context.Context, *DescribeHostRequest) (*Host, error)
	DeleteHost(context.Context, *DeleteHostRequest) (*Host, error)
}

type UpdateHostData

type UpdateHostData struct {
	*Resource
	*Describe
}

type UpdateHostRequest

type UpdateHostRequest struct {
	Id             string          `json:"id" validate:"required"`
	UpdateMode     UpdateMode      `json:"update_mode"`
	UpdateHostData *UpdateHostData `json:"data" validate:"required"`
}

func NewUpdateHostRequest

func NewUpdateHostRequest(id string) *UpdateHostRequest

func (*UpdateHostRequest) Validate

func (req *UpdateHostRequest) Validate() error

type UpdateMode

type UpdateMode int
const (
	PUT UpdateMode = iota
	PATCH
)

type Vendor

type Vendor int
const (
	PrivateIDC Vendor = 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