resource

package
v0.0.0-...-eccb811 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: MIT Imports: 14 Imported by: 0

README

资源通用信息管理

Documentation

Index

Constants

View Source
const (
	// SQL 比较操作  =
	Operator_EQUAL = "="
	// SQL 比较操作  !=
	Operator_NOT_EQUAL = "!="
	// SQL 比较操作  LIKE
	Operator_LIKE_EQUAL = "=~"
	// SQL 比较操作  NOT LIKE
	Operator_NOT_LIKE_EQUAL = "!~"
)
View Source
const (
	AppName = "resource"
)

Variables

View Source
var (
	UpdateAction_name = map[int32]string{
		0: "ADD",
		1: "REMOVE",
	}
	UpdateAction_value = map[string]int32{
		"ADD":    0,
		"REMOVE": 1,
	}
)

Enum value maps for UpdateAction.

View Source
var (
	Vendor_name = map[int32]string{
		0: "ALIYUN",
		1: "TENCENT",
		2: "HUAWEI",
		3: "VSPHERE",
		4: "AMAZON",
	}
	Vendor_value = map[string]int32{
		"ALIYUN":  0,
		"TENCENT": 1,
		"HUAWEI":  2,
		"VSPHERE": 3,
		"AMAZON":  4,
	}
)

Enum value maps for Vendor.

View Source
var (
	Type_name = map[int32]string{
		0:  "HOST",
		1:  "RDS",
		99: "BILL",
	}
	Type_value = map[string]int32{
		"HOST": 0,
		"RDS":  1,
		"BILL": 99,
	}
)

Enum value maps for Type.

View Source
var (
	UsageMode_name = map[int32]string{
		0: "SHARED",
		1: "MONOPOLY",
	}
	UsageMode_value = map[string]int32{
		"SHARED":   0,
		"MONOPOLY": 1,
	}
)

Enum value maps for UsageMode.

View Source
var (
	TagType_name = map[int32]string{
		0: "USER",
		1: "THIRD",
		2: "SYSTEM",
	}
	TagType_value = map[string]int32{
		"USER":   0,
		"THIRD":  1,
		"SYSTEM": 2,
	}
)

Enum value maps for TagType.

View Source
var File_apps_resource_pb_resource_proto protoreflect.FileDescriptor
View Source
var Service_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "course.cmdb.resource.Service",
	HandlerType: (*ServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Search",
			Handler:    _Service_Search_Handler,
		},
		{
			MethodName: "QueryTag",
			Handler:    _Service_QueryTag_Handler,
		},
		{
			MethodName: "UpdateTag",
			Handler:    _Service_UpdateTag_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/resource/pb/resource.proto",
}

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

Functions

func RegisterServiceServer

func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)

Types

type Base

type Base struct {

	// 全局唯一Id, 直接使用个云商自己的Id, 云商内部唯一
	// @gotags: json:"id" validate:"required"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" validate:"required"`
	// 同步时间, 什么时候被录入该系统
	// @gotags: json:"sync_at"
	SyncAt int64 `protobuf:"varint,2,opt,name=sync_at,json=syncAt,proto3" json:"sync_at"`
	// 用于同步的凭证ID, 需要凭证才能读取或操作云商的资源
	// @gotags: json:"secret_id"
	SecretId string `protobuf:"bytes,3,opt,name=secret_id,json=secretId,proto3" json:"secret_id"`
	// 厂商
	// @gotags: json:"vendor"
	Vendor Vendor `protobuf:"varint,4,opt,name=vendor,proto3,enum=course.cmdb.resource.Vendor" json:"vendor"`
	// 资源类型
	// @gotags: json:"resource_type"
	ResourceType Type `protobuf:"varint,5,opt,name=resource_type,json=resourceType,proto3,enum=course.cmdb.resource.Type" json:"resource_type"`
	// 地域
	// @gotags: json:"region"
	Region string `protobuf:"bytes,6,opt,name=region,proto3" json:"region"`
	// 区域
	// @gotags: json:"zone"
	Zone string `protobuf:"bytes,7,opt,name=zone,proto3" json:"zone"`
	// 创建时间, 生产时间
	// @gotags: json:"create_at"
	CreateAt int64 `protobuf:"varint,8,opt,name=create_at,json=createAt,proto3" json:"create_at"`
	// 基础数据Hash, 通用属性Hash, 有比对是否需要被更新, 提升效率
	// @gotags: json:"resource_hash"
	ResourceHash string `protobuf:"bytes,10,opt,name=resource_hash,json=resourceHash,proto3" json:"resource_hash"`
	// 描述数据Hash, 资源特有属性, 就是其他的模型表, 比如主机, GPU
	// @gotags: json:"describe_hash"
	DescribeHash string `protobuf:"bytes,11,opt,name=describe_hash,json=describeHash,proto3" json:"describe_hash"`
	// Resource信息是否有变化
	// @gotags: json:"resource_hash_changed,omitempty"
	ResourceHashChanged bool `protobuf:"varint,12,opt,name=resource_hash_changed,json=resourceHashChanged,proto3" json:"resource_hash_changed,omitempty"`
	// Describe信息释放有变化
	// @gotags: json:"describe_hash_changed,omitempty"
	DescribeHashChanged bool `protobuf:"varint,13,opt,name=describe_hash_changed,json=describeHashChanged,proto3" json:"describe_hash_changed,omitempty"`
	// 资源所属空间, 所欲那个项目
	// @gotags: json:"namespace"
	Namespace string `protobuf:"bytes,14,opt,name=namespace,proto3" json:"namespace"`
	// 资源所属环境
	// @gotags: json:"env"
	Env string `protobuf:"bytes,15,opt,name=env,proto3" json:"env"`
	// 使用方式(可选)
	// @gotags: json:"usage_mode"
	UsageMode UsageMode `protobuf:"varint,16,opt,name=usage_mode,json=usageMode,proto3,enum=course.cmdb.resource.UsageMode" json:"usage_mode"`
	// 共享策略, 当一个资源被多个应用共享时, 可以指定允许的应用
	// @gotags: json:"shared_policy"
	SharedPolicy *SharedPolicy `protobuf:"bytes,17,opt,name=shared_policy,json=sharedPolicy,proto3" json:"shared_policy"`
	// 资源所属域, 一个组织或者一个公司, 做多租户模型
	// @gotags: json:"domain"
	Domain string `protobuf:"bytes,18,opt,name=domain,proto3" json:"domain"`
	// contains filtered or unexported fields
}

func (*Base) Descriptor deprecated

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

Deprecated: Use Base.ProtoReflect.Descriptor instead.

func (*Base) GetCreateAt

func (x *Base) GetCreateAt() int64

func (*Base) GetDescribeHash

func (x *Base) GetDescribeHash() string

func (*Base) GetDescribeHashChanged

func (x *Base) GetDescribeHashChanged() bool

func (*Base) GetDomain

func (x *Base) GetDomain() string

func (*Base) GetEnv

func (x *Base) GetEnv() string

func (*Base) GetId

func (x *Base) GetId() string

func (*Base) GetNamespace

func (x *Base) GetNamespace() string

func (*Base) GetRegion

func (x *Base) GetRegion() string

func (*Base) GetResourceHash

func (x *Base) GetResourceHash() string

func (*Base) GetResourceHashChanged

func (x *Base) GetResourceHashChanged() bool

func (*Base) GetResourceType

func (x *Base) GetResourceType() Type

func (*Base) GetSecretId

func (x *Base) GetSecretId() string

func (*Base) GetSharedPolicy

func (x *Base) GetSharedPolicy() *SharedPolicy

func (*Base) GetSyncAt

func (x *Base) GetSyncAt() int64

func (*Base) GetUsageMode

func (x *Base) GetUsageMode() UsageMode

func (*Base) GetVendor

func (x *Base) GetVendor() Vendor

func (*Base) GetZone

func (x *Base) GetZone() string

func (*Base) ProtoMessage

func (*Base) ProtoMessage()

func (*Base) ProtoReflect

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

func (*Base) Reset

func (x *Base) Reset()

func (*Base) String

func (x *Base) String() string

type Information

type Information struct {

	// 过期时间
	// @gotags: json:"expire_at"
	ExpireAt int64 `protobuf:"varint,1,opt,name=expire_at,json=expireAt,proto3" json:"expire_at"`
	// 种类, 计算型, 内存型
	// @gotags: json:"category"
	Category string `protobuf:"bytes,2,opt,name=category,proto3" json:"category"`
	// 规格, small(1u1g), 根据云商的概念
	// @gotags: json:"type"
	Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type"`
	// 资源名称
	// @gotags: json:"name"
	Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name"`
	// 资源描述
	// @gotags: json:"description"
	Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description"`
	// 服务商中的状态, 需要统一多个云商的状态
	// @gotags: json:"status"
	Status string `protobuf:"bytes,6,opt,name=status,proto3" json:"status"`
	// 资源标签, key=value 一个表情
	// @gotags: json:"tags"
	Tags []*Tag `protobuf:"bytes,7,rep,name=tags,proto3" json:"tags"`
	// 更新时间
	// @gotags: json:"update_at"
	UpdateAt int64 `protobuf:"varint,8,opt,name=update_at,json=updateAt,proto3" json:"update_at"`
	// 资源所属的账号
	// @gotags: json:"sync_account"
	SyncAccount string `protobuf:"bytes,9,opt,name=sync_account,json=syncAccount,proto3" json:"sync_account"`
	// 公网IP, 或者域名
	// @gotags: json:"public_ip"
	PublicIp []string `protobuf:"bytes,10,rep,name=public_ip,json=publicIp,proto3" json:"public_ip"`
	// 内网IP, 或者域名
	// @gotags: json:"private_ip"
	PrivateIp []string `protobuf:"bytes,11,rep,name=private_ip,json=privateIp,proto3" json:"private_ip"`
	// 实例付费方式, 按量, 包年包月, 买断(自己针对IDC)
	// @gotags: json:"pay_type"
	PayType string `protobuf:"bytes,12,opt,name=pay_type,json=payType,proto3" json:"pay_type"`
	// contains filtered or unexported fields
}

通过属性, 可能变化, 用于快速解索资源

func (*Information) AddTag

func (r *Information) AddTag(t *Tag)

func (*Information) Descriptor deprecated

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

Deprecated: Use Information.ProtoReflect.Descriptor instead.

func (*Information) GetCategory

func (x *Information) GetCategory() string

func (*Information) GetDescription

func (x *Information) GetDescription() string

func (*Information) GetExpireAt

func (x *Information) GetExpireAt() int64

func (*Information) GetName

func (x *Information) GetName() string

func (*Information) GetPayType

func (x *Information) GetPayType() string

func (*Information) GetPrivateIp

func (x *Information) GetPrivateIp() []string

func (*Information) GetPublicIp

func (x *Information) GetPublicIp() []string

func (*Information) GetStatus

func (x *Information) GetStatus() string

func (*Information) GetSyncAccount

func (x *Information) GetSyncAccount() string

func (*Information) GetTags

func (x *Information) GetTags() []*Tag

func (*Information) GetType

func (x *Information) GetType() string

func (*Information) GetUpdateAt

func (x *Information) GetUpdateAt() int64

func (*Information) Hash

func (i *Information) Hash() string

func (*Information) LoadPrivateIPString

func (i *Information) LoadPrivateIPString(s string)

func (*Information) LoadPublicIPString

func (i *Information) LoadPublicIPString(s string)

func (*Information) PrivateIPToString

func (i *Information) PrivateIPToString() string

func (*Information) ProtoMessage

func (*Information) ProtoMessage()

func (*Information) ProtoReflect

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

func (*Information) PublicIPToString

func (i *Information) PublicIPToString() string

func (*Information) Reset

func (x *Information) Reset()

func (*Information) String

func (x *Information) String() string

type Operator

type Operator string

Tag的比较操作符, 内比promethues 的Tag比较操作, 官网也能找到该4种操作符号

type QueryTagRequest

type QueryTagRequest struct {

	// 资源id
	// @gotags: json:"resource_ids"
	ResourceIds []string `protobuf:"bytes,1,rep,name=resource_ids,json=resourceIds,proto3" json:"resource_ids"`
	// contains filtered or unexported fields
}

func (*QueryTagRequest) Descriptor deprecated

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

Deprecated: Use QueryTagRequest.ProtoReflect.Descriptor instead.

func (*QueryTagRequest) GetResourceIds

func (x *QueryTagRequest) GetResourceIds() []string

func (*QueryTagRequest) ProtoMessage

func (*QueryTagRequest) ProtoMessage()

func (*QueryTagRequest) ProtoReflect

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

func (*QueryTagRequest) Reset

func (x *QueryTagRequest) Reset()

func (*QueryTagRequest) String

func (x *QueryTagRequest) String() string

type Resource

type Resource struct {

	// 资源元数据信息, 固有属性, 比如云商
	// @gotags: json:"base"
	Base *Base `protobuf:"bytes,1,opt,name=base,proto3" json:"base"`
	// 资源信息, 通用信息, 允许变化, 比如IP
	// @gotags: json:"information"
	Information *Information `protobuf:"bytes,2,opt,name=information,proto3" json:"information"`
	// contains filtered or unexported fields
}

就是用于资源的快速解索

func NewDefaultResource

func NewDefaultResource() *Resource

func (*Resource) Descriptor deprecated

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

Deprecated: Use Resource.ProtoReflect.Descriptor instead.

func (*Resource) GetBase

func (x *Resource) GetBase() *Base

func (*Resource) GetInformation

func (x *Resource) GetInformation() *Information

func (*Resource) ProtoMessage

func (*Resource) ProtoMessage()

func (*Resource) ProtoReflect

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

func (*Resource) Reset

func (x *Resource) Reset()

func (*Resource) String

func (x *Resource) String() string

type ResourceSet

type ResourceSet struct {

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

func NewResourceSet

func NewResourceSet() *ResourceSet

func (*ResourceSet) Add

func (s *ResourceSet) Add(item *Resource)

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) ResourceIds

func (s *ResourceSet) ResourceIds() (ids []string)

func (*ResourceSet) String

func (x *ResourceSet) String() string

func (*ResourceSet) UpdateTag

func (s *ResourceSet) UpdateTag(tags []*Tag)

type SearchRequest

type SearchRequest struct {

	// 分页参数
	// @gotags: json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	// 资源所属域
	// @gotags: json:"domain"
	Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain"`
	// 资源所属空间
	// @gotags: json:"namespace"
	Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace"`
	// 资源所属环境
	// @gotags: json:"env"
	Env string `protobuf:"bytes,4,opt,name=env,proto3" json:"env"`
	// 使用方式
	// @gotags: json:"usage_mode"
	UsageMode *UsageMode `protobuf:"varint,5,opt,name=usage_mode,json=usageMode,proto3,enum=course.cmdb.resource.UsageMode,oneof" json:"usage_mode"`
	// 厂商
	// @gotags: json:"vendor"
	Vendor *Vendor `protobuf:"varint,6,opt,name=vendor,proto3,enum=course.cmdb.resource.Vendor,oneof" json:"vendor"`
	// 同步的账号
	// @gotags: json:"sync_account"
	SyncAccount string `protobuf:"bytes,7,opt,name=sync_account,json=syncAccount,proto3" json:"sync_account"`
	// 资源类型, optional protoc编译过后--> 指针类型, 意思允许为空指针
	// @gotags: json:"type"
	Type *Type `protobuf:"varint,8,opt,name=type,proto3,enum=course.cmdb.resource.Type,oneof" json:"type"`
	// 服务商中的状态
	// @gotags: json:"status"
	Status string `protobuf:"bytes,9,opt,name=status,proto3" json:"status"`
	// 资源标签
	// @gotags: json:"tags"
	Tags []*TagSelector `protobuf:"bytes,10,rep,name=tags,proto3" json:"tags"`
	// 是否返回资源的标签, 如果标签很多,你有不想要, 可以控制返回该资源的标签?
	// 提升性能,  避免以下不必要数据的传输
	// @gotags: json:"with_tags"
	WithTags bool `protobuf:"varint,11,opt,name=with_tags,json=withTags,proto3" json:"with_tags"`
	// 关键字参数
	// @gotags: json:"keywords"
	Keywords string `protobuf:"bytes,14,opt,name=keywords,proto3" json:"keywords"`
	// 是否精确匹配, 比如你要匹配IP, 10,10.1.1   10.10.1.1xx
	// @gotags: json:"exact_match"
	ExactMatch bool `protobuf:"varint,15,opt,name=exact_match,json=exactMatch,proto3" json:"exact_match"`
	// contains filtered or unexported fields
}

func NewSearchRequestFromHTTP

func NewSearchRequestFromHTTP(r *http.Request) (*SearchRequest, error)

keywords=xx&domain=xx&tag=app=~app1,app2,app3

func (*SearchRequest) AddTag

func (req *SearchRequest) AddTag(t ...*TagSelector)

func (*SearchRequest) Descriptor deprecated

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

Deprecated: Use SearchRequest.ProtoReflect.Descriptor instead.

func (*SearchRequest) GetDomain

func (x *SearchRequest) GetDomain() string

func (*SearchRequest) GetEnv

func (x *SearchRequest) GetEnv() string

func (*SearchRequest) GetExactMatch

func (x *SearchRequest) GetExactMatch() bool

func (*SearchRequest) GetKeywords

func (x *SearchRequest) GetKeywords() string

func (*SearchRequest) GetNamespace

func (x *SearchRequest) GetNamespace() string

func (*SearchRequest) GetPage

func (x *SearchRequest) GetPage() *request.PageRequest

func (*SearchRequest) GetStatus

func (x *SearchRequest) GetStatus() string

func (*SearchRequest) GetSyncAccount

func (x *SearchRequest) GetSyncAccount() string

func (*SearchRequest) GetTags

func (x *SearchRequest) GetTags() []*TagSelector

func (*SearchRequest) GetType

func (x *SearchRequest) GetType() Type

func (*SearchRequest) GetUsageMode

func (x *SearchRequest) GetUsageMode() UsageMode

func (*SearchRequest) GetVendor

func (x *SearchRequest) GetVendor() Vendor

func (*SearchRequest) GetWithTags

func (x *SearchRequest) GetWithTags() bool

func (*SearchRequest) HasTag

func (r *SearchRequest) HasTag() bool

func (*SearchRequest) ProtoMessage

func (*SearchRequest) ProtoMessage()

func (*SearchRequest) ProtoReflect

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

func (*SearchRequest) Reset

func (x *SearchRequest) Reset()

func (*SearchRequest) String

func (x *SearchRequest) String() string

type ServiceClient

type ServiceClient interface {
	Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (*ResourceSet, error)
	QueryTag(ctx context.Context, in *QueryTagRequest, opts ...grpc.CallOption) (*TagSet, error)
	UpdateTag(ctx context.Context, in *UpdateTagRequest, opts ...grpc.CallOption) (*Resource, error)
}

ServiceClient is the client API for Service 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 NewServiceClient

func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient

type ServiceServer

type ServiceServer interface {
	Search(context.Context, *SearchRequest) (*ResourceSet, error)
	QueryTag(context.Context, *QueryTagRequest) (*TagSet, error)
	UpdateTag(context.Context, *UpdateTagRequest) (*Resource, error)
	// contains filtered or unexported methods
}

ServiceServer is the server API for Service service. All implementations must embed UnimplementedServiceServer for forward compatibility

type SharedPolicy

type SharedPolicy struct {

	// 分享的维度, 多个应用,多个使用者
	// @gotags: json:"tag_key"
	TagKey string `protobuf:"bytes,1,opt,name=tag_key,json=tagKey,proto3" json:"tag_key"`
	// 分享给哪些值, app1,app2,app3,   user1,user2,user3
	// @gotags: json:"tag_values"
	TagValues []string `protobuf:"bytes,2,rep,name=tag_values,json=tagValues,proto3" json:"tag_values"`
	// contains filtered or unexported fields
}

共享策略

func (*SharedPolicy) Descriptor deprecated

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

Deprecated: Use SharedPolicy.ProtoReflect.Descriptor instead.

func (*SharedPolicy) GetTagKey

func (x *SharedPolicy) GetTagKey() string

func (*SharedPolicy) GetTagValues

func (x *SharedPolicy) GetTagValues() []string

func (*SharedPolicy) ProtoMessage

func (*SharedPolicy) ProtoMessage()

func (*SharedPolicy) ProtoReflect

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

func (*SharedPolicy) Reset

func (x *SharedPolicy) Reset()

func (*SharedPolicy) String

func (x *SharedPolicy) String() string

type Tag

type Tag struct {

	// 标签属于的资源, 通过resource_id来进行关联, 根据数据库设计有关系
	// @gotags: json:"resource_id"
	ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id"`
	// 标签的类型
	// @gotags: json:"type"
	Type TagType `protobuf:"varint,2,opt,name=type,proto3,enum=course.cmdb.resource.TagType" json:"type"`
	// 标签的Key
	// @gotags: json:"key" validate:"lte=255,required"
	Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key" validate:"lte=255,required"`
	// 标签的值, 可读性不好, appid=0xxx0111
	// @gotags: json:"value" validate:"lte=255,required"
	Value string `protobuf:"bytes,4,opt,name=value,proto3" json:"value" validate:"lte=255,required"`
	// 标签的值的描述, 通常用于展示, 财务系统a
	// @gotags: json:"describe"
	Describe string `protobuf:"bytes,5,opt,name=describe,proto3" json:"describe"`
	// 标签权重, 针对同一个key, 多个value场景, 默认值1
	// 有一个资源A, 费用100, 被多个业务方共同使用, 出业务成本, 面临这个成本如何分摊的问题?
	// 为了让分摊更加灵活, 添加标签的权重, 更加权重的值做具体分摊比例计算, 比如 a:1(1/4), b:2(2/4), c:1(1/4)
	// 默认公平分摊, 默认就是1, 更加自由使用量俩进行分摊, 外部系统(监控系统) 通过使用计算出权重, 设置过来
	// @gotags: json:"weight"
	Weight int64 `protobuf:"varint,6,opt,name=weight,proto3" json:"weight"`
	// 标签是否纳入成本统计, 比如监控标签就不需要纳入到成本统计
	// @gotags: json:"is_cost"
	IsCost bool `protobuf:"varint,7,opt,name=is_cost,json=isCost,proto3" json:"is_cost"`
	// 标签是否隐藏, 用于控制是否在前端展示
	// @gotags: json:"hidden"
	Hidden bool `protobuf:"varint,8,opt,name=hidden,proto3" json:"hidden"`
	// 标签meta信息, 比如前端需要设置标签的颜色
	// @gotags: json:"meta"
	Meta map[string]string `` /* 140-byte string literal not displayed */
	// contains filtered or unexported fields
}

func NewDefaultTag

func NewDefaultTag() *Tag

func NewThirdTag

func NewThirdTag(key, value string) *Tag

func (*Tag) Descriptor deprecated

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

Deprecated: Use Tag.ProtoReflect.Descriptor instead.

func (*Tag) GetDescribe

func (x *Tag) GetDescribe() string

func (*Tag) GetHidden

func (x *Tag) GetHidden() bool

func (*Tag) GetIsCost

func (x *Tag) GetIsCost() bool

func (*Tag) GetKey

func (x *Tag) GetKey() string

func (*Tag) GetMeta

func (x *Tag) GetMeta() map[string]string

func (*Tag) GetResourceId

func (x *Tag) GetResourceId() string

func (*Tag) GetType

func (x *Tag) GetType() TagType

func (*Tag) GetValue

func (x *Tag) GetValue() string

func (*Tag) GetWeight

func (x *Tag) GetWeight() int64

func (*Tag) ProtoMessage

func (*Tag) ProtoMessage()

func (*Tag) ProtoReflect

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

func (*Tag) Reset

func (x *Tag) Reset()

func (*Tag) String

func (x *Tag) String() string

type TagSelector

type TagSelector struct {

	// 匹配的key, 支持LIKE匹配
	// @gotags: json:"key"
	Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key"`
	// 匹配符
	// @gotags: json:"operator"
	Operator string `protobuf:"bytes,2,opt,name=operator,proto3" json:"operator"`
	// 匹配的值, 支持多个值匹配
	// @gotags: json:"values"
	Values []string `protobuf:"bytes,3,rep,name=values,proto3" json:"values"`
	// contains filtered or unexported fields
}

Tag选择器, 通过key value进行匹配, app-atrr1, app-atrr2 以下连个标签共同组成一套业务逻辑, 需要过滤: promethues.io 开头的标签 promethues.io/port = "xxxx" promethues.io/metric_path = "xxxx"

func NewTagsFromString

func NewTagsFromString(tagStr string) (tags []*TagSelector, err error)

key1=v1,v2,v3&key2=~v1,v2,v3

func ParExpr

func ParExpr(str string) (*TagSelector, error)

func (*TagSelector) Descriptor deprecated

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

Deprecated: Use TagSelector.ProtoReflect.Descriptor instead.

func (*TagSelector) GetKey

func (x *TagSelector) GetKey() string

func (*TagSelector) GetOperator

func (x *TagSelector) GetOperator() string

func (*TagSelector) GetValues

func (x *TagSelector) GetValues() []string

func (*TagSelector) ProtoMessage

func (*TagSelector) ProtoMessage()

func (*TagSelector) ProtoReflect

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

func (*TagSelector) RelationShip

func (s *TagSelector) RelationShip() string

多个值比较的关系说明:

app=~app1,app2  你不能说 app1和app2是 AND关系, 一定是OR关系    是一种白名单策略(包含策略)
app!~app3,app4  tag_key=app tag_value NOT LIKE (app3,app4), 是一种黑名单策略(排除策略)

func (*TagSelector) Reset

func (x *TagSelector) Reset()

func (*TagSelector) String

func (x *TagSelector) String() string

type TagSet

type TagSet struct {

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

func (*TagSet) Descriptor deprecated

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

Deprecated: Use TagSet.ProtoReflect.Descriptor instead.

func (*TagSet) GetItems

func (x *TagSet) GetItems() []*Tag

func (*TagSet) GetTotal

func (x *TagSet) GetTotal() int64

func (*TagSet) ProtoMessage

func (*TagSet) ProtoMessage()

func (*TagSet) ProtoReflect

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

func (*TagSet) Reset

func (x *TagSet) Reset()

func (*TagSet) String

func (x *TagSet) String() string

type TagType

type TagType int32
const (
	// 用户自定义标签, 允许用户修改
	TagType_USER TagType = 0
	// 第三方定义的标签, 比如云商同步过来的标签, 不允许通过本系统修改, 如果有修改,去第三方系统修改
	TagType_THIRD TagType = 1
	// 内部系统使用标签, 禁止用户修改, 表示被其他系统引用, 比如应用关联标签, app=app1
	TagType_SYSTEM TagType = 2
)

func ParseTagTypeFromString

func ParseTagTypeFromString(str string) (TagType, error)

ParseTagTypeFromString Parse TagType from string

func (TagType) Descriptor

func (TagType) Descriptor() protoreflect.EnumDescriptor

func (TagType) Enum

func (x TagType) Enum() *TagType

func (TagType) EnumDescriptor deprecated

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

Deprecated: Use TagType.Descriptor instead.

func (TagType) Equal

func (t TagType) Equal(target TagType) bool

Equal type compare

func (TagType) IsIn

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

IsIn todo

func (TagType) MarshalJSON

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

MarshalJSON todo

func (TagType) Number

func (x TagType) Number() protoreflect.EnumNumber

func (TagType) String

func (x TagType) String() string

func (TagType) Type

func (TagType) Type() protoreflect.EnumType

func (*TagType) UnmarshalJSON

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

UnmarshalJSON todo

type Type

type Type int32
const (
	Type_HOST Type = 0
	Type_RDS  Type = 1
	// ... 其他的资源
	Type_BILL Type = 99
)

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 UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedServiceServer) QueryTag

func (UnimplementedServiceServer) Search

func (UnimplementedServiceServer) UpdateTag

type UnsafeServiceServer

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

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

type UpdateAction

type UpdateAction int32
const (
	// 添加
	UpdateAction_ADD UpdateAction = 0
	// 移除
	UpdateAction_REMOVE UpdateAction = 1
)

func ParseUpdateActionFromString

func ParseUpdateActionFromString(str string) (UpdateAction, error)

ParseUpdateActionFromString Parse UpdateAction from string

func (UpdateAction) Descriptor

func (UpdateAction) Enum

func (x UpdateAction) Enum() *UpdateAction

func (UpdateAction) EnumDescriptor deprecated

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

Deprecated: Use UpdateAction.Descriptor instead.

func (UpdateAction) Equal

func (t UpdateAction) Equal(target UpdateAction) bool

Equal type compare

func (UpdateAction) IsIn

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

IsIn todo

func (UpdateAction) MarshalJSON

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

MarshalJSON todo

func (UpdateAction) Number

func (UpdateAction) String

func (x UpdateAction) String() string

func (UpdateAction) Type

func (*UpdateAction) UnmarshalJSON

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

UnmarshalJSON todo

type UpdateTagRequest

type UpdateTagRequest struct {

	// 资源id, 你要修改那个资源的标签
	// @gotags: json:"id" validate:"required"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" validate:"required"`
	// 资源id
	// @gotags: json:"action"
	Action UpdateAction `protobuf:"varint,2,opt,name=action,proto3,enum=course.cmdb.resource.UpdateAction" json:"action"`
	// 需要修改的资源标签
	// @gotags: json:"tags" validate:"required"
	Tags []*Tag `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags" validate:"required"`
	// contains filtered or unexported fields
}

func (*UpdateTagRequest) Descriptor deprecated

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

Deprecated: Use UpdateTagRequest.ProtoReflect.Descriptor instead.

func (*UpdateTagRequest) GetAction

func (x *UpdateTagRequest) GetAction() UpdateAction

func (*UpdateTagRequest) GetId

func (x *UpdateTagRequest) GetId() string

func (*UpdateTagRequest) GetTags

func (x *UpdateTagRequest) GetTags() []*Tag

func (*UpdateTagRequest) ProtoMessage

func (*UpdateTagRequest) ProtoMessage()

func (*UpdateTagRequest) ProtoReflect

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

func (*UpdateTagRequest) Reset

func (x *UpdateTagRequest) Reset()

func (*UpdateTagRequest) String

func (x *UpdateTagRequest) String() string

type UsageMode

type UsageMode int32

使用方式

const (
	// 共享使用
	UsageMode_SHARED UsageMode = 0
	// 独占使用
	UsageMode_MONOPOLY UsageMode = 1
)

func ParseUsageModeFromString

func ParseUsageModeFromString(str string) (UsageMode, error)

ParseUsageModeFromString Parse UsageMode from string

func (UsageMode) Descriptor

func (UsageMode) Descriptor() protoreflect.EnumDescriptor

func (UsageMode) Enum

func (x UsageMode) Enum() *UsageMode

func (UsageMode) EnumDescriptor deprecated

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

Deprecated: Use UsageMode.Descriptor instead.

func (UsageMode) Equal

func (t UsageMode) Equal(target UsageMode) bool

Equal type compare

func (UsageMode) IsIn

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

IsIn todo

func (UsageMode) MarshalJSON

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

MarshalJSON todo

func (UsageMode) Number

func (x UsageMode) Number() protoreflect.EnumNumber

func (UsageMode) String

func (x UsageMode) String() string

func (UsageMode) Type

func (*UsageMode) UnmarshalJSON

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

UnmarshalJSON todo

type Vendor

type Vendor int32
const (
	Vendor_ALIYUN  Vendor = 0
	Vendor_TENCENT Vendor = 1
	Vendor_HUAWEI  Vendor = 2
	Vendor_VSPHERE Vendor = 3
	Vendor_AMAZON  Vendor = 4
)

func ParseVendorFromString

func ParseVendorFromString(str string) (Vendor, error)

ParseVendorFromString Parse Vendor from string

func (Vendor) Descriptor

func (Vendor) Descriptor() protoreflect.EnumDescriptor

func (Vendor) Enum

func (x Vendor) Enum() *Vendor

func (Vendor) EnumDescriptor deprecated

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

Deprecated: Use Vendor.Descriptor instead.

func (Vendor) Equal

func (t Vendor) Equal(target Vendor) bool

Equal type compare

func (Vendor) IsIn

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

IsIn todo

func (Vendor) MarshalJSON

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

MarshalJSON todo

func (Vendor) Number

func (x Vendor) Number() protoreflect.EnumNumber

func (Vendor) String

func (x Vendor) String() string

func (Vendor) Type

func (Vendor) Type() protoreflect.EnumType

func (*Vendor) UnmarshalJSON

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

UnmarshalJSON todo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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