resource

package
v0.0.0-...-f4276bb Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 14 Imported by: 0

README

资源管理

Documentation

Index

Constants

View Source
const (
	Rpc_CreateResource_FullMethodName = "/go11.devcloud_mini.cmdb.resource.Rpc/CreateResource"
	Rpc_QueryResource_FullMethodName  = "/go11.devcloud_mini.cmdb.resource.Rpc/QueryResource"
)
View Source
const (
	AppName = "resource"
)

Variables

View Source
var (
	TYPE_name = map[int32]string{
		0: "UNKONW",
		1: "HOST",
		2: "RDS",
	}
	TYPE_value = map[string]int32{
		"UNKONW": 0,
		"HOST":   1,
		"RDS":    2,
	}
)

Enum value maps for TYPE.

View Source
var (
	PROVIDER_name = map[int32]string{
		0: "TENCENT",
		1: "VMWARE",
		2: "OPENSTACK",
		3: "IDC",
	}
	PROVIDER_value = map[string]int32{
		"TENCENT":   0,
		"VMWARE":    1,
		"OPENSTACK": 2,
		"IDC":       3,
	}
)

Enum value maps for PROVIDER.

View Source
var File_cmdb_apps_resource_pb_model_proto protoreflect.FileDescriptor
View Source
var File_cmdb_apps_resource_pb_rpc_proto protoreflect.FileDescriptor
View Source
var Rpc_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "go11.devcloud_mini.cmdb.resource.Rpc",
	HandlerType: (*RpcServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateResource",
			Handler:    _Rpc_CreateResource_Handler,
		},
		{
			MethodName: "QueryResource",
			Handler:    _Rpc_QueryResource_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "cmdb/apps/resource/pb/rpc.proto",
}

Rpc_ServiceDesc is the grpc.ServiceDesc for Rpc service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterRpcServer

func RegisterRpcServer(s grpc.ServiceRegistrar, srv RpcServer)

Types

type PROVIDER

type PROVIDER int32
const (
	// 腾讯云
	PROVIDER_TENCENT PROVIDER = 0
	// 腾讯云
	PROVIDER_VMWARE    PROVIDER = 1
	PROVIDER_OPENSTACK PROVIDER = 2
	// 托管机房
	PROVIDER_IDC PROVIDER = 3
)

func ParsePROVIDERFromString

func ParsePROVIDERFromString(str string) (PROVIDER, error)

ParsePROVIDERFromString Parse PROVIDER from string

func (PROVIDER) Descriptor

func (PROVIDER) Descriptor() protoreflect.EnumDescriptor

func (PROVIDER) Enum

func (x PROVIDER) Enum() *PROVIDER

func (PROVIDER) EnumDescriptor deprecated

func (PROVIDER) EnumDescriptor() ([]byte, []int)

Deprecated: Use PROVIDER.Descriptor instead.

func (PROVIDER) Equal

func (t PROVIDER) Equal(target PROVIDER) bool

Equal type compare

func (PROVIDER) IsIn

func (t PROVIDER) IsIn(targets ...PROVIDER) bool

IsIn todo

func (PROVIDER) MarshalJSON

func (t PROVIDER) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (PROVIDER) Number

func (x PROVIDER) Number() protoreflect.EnumNumber

func (PROVIDER) String

func (x PROVIDER) String() string

func (PROVIDER) Type

func (*PROVIDER) UnmarshalJSON

func (t *PROVIDER) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type QueryResourceRequest

type QueryResourceRequest struct {
	// contains filtered or unexported fields
}

func NewQueryResourceRequest

func NewQueryResourceRequest() *QueryResourceRequest

func (*QueryResourceRequest) Descriptor deprecated

func (*QueryResourceRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryResourceRequest.ProtoReflect.Descriptor instead.

func (*QueryResourceRequest) ProtoMessage

func (*QueryResourceRequest) ProtoMessage()

func (*QueryResourceRequest) ProtoReflect

func (x *QueryResourceRequest) ProtoReflect() protoreflect.Message

func (*QueryResourceRequest) Reset

func (x *QueryResourceRequest) Reset()

func (*QueryResourceRequest) String

func (x *QueryResourceRequest) String() string

type Resource

type Resource struct {

	// 元数据信息
	// @gotags: json:"meta" bson:",inline"
	Meta *resource.Meta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta" bson:",inline"`
	// 资源的定义
	// @gotags: json:"spec" bson:",inline"
	Spec *Spec `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec" bson:",inline"`
	// contains filtered or unexported fields
}

func NewResource

func NewResource() *Resource

func (*Resource) Descriptor deprecated

func (*Resource) Descriptor() ([]byte, []int)

Deprecated: Use Resource.ProtoReflect.Descriptor instead.

func (*Resource) GetMeta

func (x *Resource) GetMeta() *resource.Meta

func (*Resource) GetSpec

func (x *Resource) GetSpec() *Spec

func (*Resource) MakeDefault

func (r *Resource) MakeDefault()

func (*Resource) ProtoMessage

func (*Resource) ProtoMessage()

func (*Resource) ProtoReflect

func (x *Resource) ProtoReflect() protoreflect.Message

func (*Resource) Reset

func (x *Resource) Reset()

func (*Resource) ShortDesc

func (r *Resource) ShortDesc() string

资源概述

func (*Resource) String

func (x *Resource) String() string

type ResourceSet

type ResourceSet struct {

	// 总数
	// @gotags: json:"total" bson:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total" bson:"total"`
	// 清单
	// @gotags: json:"items" bson:"items"
	Items []*Resource `protobuf:"bytes,2,rep,name=items,proto3" json:"items" bson:"items"`
	// contains filtered or unexported fields
}

func (*ResourceSet) Descriptor deprecated

func (*ResourceSet) Descriptor() ([]byte, []int)

Deprecated: Use ResourceSet.ProtoReflect.Descriptor instead.

func (*ResourceSet) GetItems

func (x *ResourceSet) GetItems() []*Resource

func (*ResourceSet) GetTotal

func (x *ResourceSet) GetTotal() int64

func (*ResourceSet) ProtoMessage

func (*ResourceSet) ProtoMessage()

func (*ResourceSet) ProtoReflect

func (x *ResourceSet) ProtoReflect() protoreflect.Message

func (*ResourceSet) Reset

func (x *ResourceSet) Reset()

func (*ResourceSet) String

func (x *ResourceSet) String() string

type RpcClient

type RpcClient interface {
	// 创建资源
	CreateResource(ctx context.Context, in *Resource, opts ...grpc.CallOption) (*Resource, error)
	// 查询资源
	QueryResource(ctx context.Context, in *QueryResourceRequest, opts ...grpc.CallOption) (*ResourceSet, error)
}

RpcClient is the client API for Rpc service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewRpcClient

func NewRpcClient(cc grpc.ClientConnInterface) RpcClient

type RpcServer

type RpcServer interface {
	// 创建资源
	CreateResource(context.Context, *Resource) (*Resource, error)
	// 查询资源
	QueryResource(context.Context, *QueryResourceRequest) (*ResourceSet, error)
	// contains filtered or unexported methods
}

RpcServer is the server API for Rpc service. All implementations must embed UnimplementedRpcServer for forward compatibility

type Service

type Service interface {
	RpcServer
}

type Spec

type Spec struct {

	// 通用属性
	// 资源名称
	// @gotags: json:"name" bson:"name"
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name" bson:"name"`
	// 资源规格
	// @gotags: json:"type" bson:"type"
	Type TYPE `protobuf:"varint,8,opt,name=type,proto3,enum=go11.devcloud_mini.cmdb.resource.TYPE" json:"type" bson:"type"`
	// 资源规格, io,xxx
	// @gotags: json:"class" bson:"class"
	Class string `protobuf:"bytes,7,opt,name=class,proto3" json:"class" bson:"class"`
	// 资源关联的secret id, 方便我们直接使用 资源关联的secret来进行管理
	// @gotags: json:"secret_id" bson:"secret_id"
	SecretId string `protobuf:"bytes,2,opt,name=secret_id,json=secretId,proto3" json:"secret_id" bson:"secret_id"`
	// 资源属于哪个账号, 用于做账号过滤
	// @gotags: json:"account" bson:"account"
	Account string `protobuf:"bytes,3,opt,name=account,proto3" json:"account" bson:"account"`
	// 资源属于哪个云商<过滤条件>
	// @gotags: json:"provider" bson:"provider"
	Provider PROVIDER `protobuf:"varint,4,opt,name=provider,proto3,enum=go11.devcloud_mini.cmdb.resource.PROVIDER" json:"provider" bson:"provider"`
	// 资源属于哪个地域
	// @gotags: json:"region" bson:"region"
	Region string `protobuf:"bytes,5,opt,name=region,proto3" json:"region" bson:"region"`
	// 资源属于哪个可用区
	// @gotags: json:"zone" bson:"zone"
	Zone string `protobuf:"bytes,6,opt,name=zone,proto3" json:"zone" bson:"zone"`
	// 资源属于哪个可用区
	// @gotags: json:"status" bson:"status"
	Status string `protobuf:"bytes,9,opt,name=status,proto3" json:"status" bson:"status"`
	// 针对运维 IT 来说的特殊属性
	// 网络
	// 资源内网地址
	// @gotags: json:"private_address" bson:"private_address"
	PrivateAddress []string `protobuf:"bytes,10,rep,name=private_address,json=privateAddress,proto3" json:"private_address" bson:"private_address"`
	// 资源公网地址
	// @gotags: json:"public_address" bson:"public_address"
	PublicAddress []string `protobuf:"bytes,11,rep,name=public_address,json=publicAddress,proto3" json:"public_address" bson:"public_address"`
	// 计算
	// 资源cpu
	// @gotags: json:"cpu" bson:"cpu"
	Cpu int32 `protobuf:"varint,12,opt,name=cpu,proto3" json:"cpu" bson:"cpu"`
	// 资源内存, 单位为M
	// @gotags: json:"memory" bson:"memory"
	Memory int64 `protobuf:"varint,13,opt,name=memory,proto3" json:"memory" bson:"memory"`
	// 存储, 单位G
	// 资源存储
	// @gotags: json:"storage" bson:"storage"
	Storage int64 `protobuf:"varint,14,opt,name=storage,proto3" json:"storage" bson:"storage"`
	// 资源的其他属性, ECS: storage
	// @gotags: json:"extra" bson:"extra"
	Extra map[string]string `` /* 155-byte string literal not displayed */
	// contains filtered or unexported fields
}

资源通用属性, 非通用属性直接定义一个map来表示

func NewSpec

func NewSpec() *Spec

func (*Spec) Descriptor deprecated

func (*Spec) Descriptor() ([]byte, []int)

Deprecated: Use Spec.ProtoReflect.Descriptor instead.

func (*Spec) GetAccount

func (x *Spec) GetAccount() string

func (*Spec) GetClass

func (x *Spec) GetClass() string

func (*Spec) GetCpu

func (x *Spec) GetCpu() int32

func (*Spec) GetExtra

func (x *Spec) GetExtra() map[string]string

func (*Spec) GetMemory

func (x *Spec) GetMemory() int64

func (*Spec) GetName

func (x *Spec) GetName() string

func (*Spec) GetPrivateAddress

func (x *Spec) GetPrivateAddress() []string

func (*Spec) GetProvider

func (x *Spec) GetProvider() PROVIDER

func (*Spec) GetPublicAddress

func (x *Spec) GetPublicAddress() []string

func (*Spec) GetRegion

func (x *Spec) GetRegion() string

func (*Spec) GetSecretId

func (x *Spec) GetSecretId() string

func (*Spec) GetStatus

func (x *Spec) GetStatus() string

func (*Spec) GetStorage

func (x *Spec) GetStorage() int64

func (*Spec) GetType

func (x *Spec) GetType() TYPE

func (*Spec) GetZone

func (x *Spec) GetZone() string

func (*Spec) ProtoMessage

func (*Spec) ProtoMessage()

func (*Spec) ProtoReflect

func (x *Spec) ProtoReflect() protoreflect.Message

func (*Spec) Reset

func (x *Spec) Reset()

func (*Spec) String

func (x *Spec) String() string

type TYPE

type TYPE int32

资源的类型

const (
	// 未知资源
	TYPE_UNKONW TYPE = 0
	// 主机, 服务器
	TYPE_HOST TYPE = 1
	// 关系新数据库
	TYPE_RDS TYPE = 2
)

func ParseTYPEFromString

func ParseTYPEFromString(str string) (TYPE, error)

ParseTYPEFromString Parse TYPE from string

func (TYPE) Descriptor

func (TYPE) Descriptor() protoreflect.EnumDescriptor

func (TYPE) Enum

func (x TYPE) Enum() *TYPE

func (TYPE) EnumDescriptor deprecated

func (TYPE) EnumDescriptor() ([]byte, []int)

Deprecated: Use TYPE.Descriptor instead.

func (TYPE) Equal

func (t TYPE) Equal(target TYPE) bool

Equal type compare

func (TYPE) IsIn

func (t TYPE) IsIn(targets ...TYPE) bool

IsIn todo

func (TYPE) MarshalJSON

func (t TYPE) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (TYPE) Number

func (x TYPE) Number() protoreflect.EnumNumber

func (TYPE) String

func (x TYPE) String() string

func (TYPE) Type

func (TYPE) Type() protoreflect.EnumType

func (*TYPE) UnmarshalJSON

func (t *TYPE) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type UnimplementedRpcServer

type UnimplementedRpcServer struct {
}

UnimplementedRpcServer must be embedded to have forward compatible implementations.

func (UnimplementedRpcServer) CreateResource

func (UnimplementedRpcServer) QueryResource

type UnsafeRpcServer

type UnsafeRpcServer interface {
	// contains filtered or unexported methods
}

UnsafeRpcServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RpcServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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