Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)
- type Base
- func (*Base) Descriptor() ([]byte, []int)deprecated
- func (x *Base) GetCreateAt() int64
- func (x *Base) GetDescribeHash() string
- func (x *Base) GetDescribeHashChanged() bool
- func (x *Base) GetDomain() string
- func (x *Base) GetEnv() string
- func (x *Base) GetId() string
- func (x *Base) GetNamespace() string
- func (x *Base) GetRegion() string
- func (x *Base) GetResourceHash() string
- func (x *Base) GetResourceHashChanged() bool
- func (x *Base) GetResourceType() Type
- func (x *Base) GetSecretId() string
- func (x *Base) GetSharedPolicy() *SharedPolicy
- func (x *Base) GetSyncAt() int64
- func (x *Base) GetUsageMode() UsageMode
- func (x *Base) GetVendor() Vendor
- func (x *Base) GetZone() string
- func (*Base) ProtoMessage()
- func (x *Base) ProtoReflect() protoreflect.Message
- func (x *Base) Reset()
- func (x *Base) String() string
- type Information
- func (r *Information) AddTag(t *Tag)
- func (*Information) Descriptor() ([]byte, []int)deprecated
- func (x *Information) GetCategory() string
- func (x *Information) GetDescription() string
- func (x *Information) GetExpireAt() int64
- func (x *Information) GetName() string
- func (x *Information) GetPayType() string
- func (x *Information) GetPrivateIp() []string
- func (x *Information) GetPublicIp() []string
- func (x *Information) GetStatus() string
- func (x *Information) GetSyncAccount() string
- func (x *Information) GetTags() []*Tag
- func (x *Information) GetType() string
- func (x *Information) GetUpdateAt() int64
- func (i *Information) Hash() string
- func (i *Information) LoadPrivateIPString(s string)
- func (i *Information) LoadPublicIPString(s string)
- func (i *Information) PrivateIPToString() string
- func (*Information) ProtoMessage()
- func (x *Information) ProtoReflect() protoreflect.Message
- func (i *Information) PublicIPToString() string
- func (x *Information) Reset()
- func (x *Information) String() string
- type Operator
- type QueryTagRequest
- type ReleasePlan
- func (*ReleasePlan) Descriptor() ([]byte, []int)deprecated
- func (x *ReleasePlan) GetDestoryAt() int64
- func (x *ReleasePlan) GetExecAt() int64
- func (x *ReleasePlan) GetImmediately() bool
- func (x *ReleasePlan) GetNoticeBeforeDays() int64
- func (x *ReleasePlan) GetPlanAt() int64
- func (x *ReleasePlan) GetReason() string
- func (*ReleasePlan) ProtoMessage()
- func (x *ReleasePlan) ProtoReflect() protoreflect.Message
- func (x *ReleasePlan) Reset()
- func (x *ReleasePlan) String() string
- type Resource
- func (*Resource) Descriptor() ([]byte, []int)deprecated
- func (x *Resource) GetBase() *Base
- func (x *Resource) GetInformation() *Information
- func (x *Resource) GetReleasePlan() *ReleasePlan
- func (*Resource) ProtoMessage()
- func (x *Resource) ProtoReflect() protoreflect.Message
- func (x *Resource) Reset()
- func (x *Resource) String() string
- type ResourceSet
- func (s *ResourceSet) Add(item *Resource)
- func (*ResourceSet) Descriptor() ([]byte, []int)deprecated
- func (x *ResourceSet) GetItems() []*Resource
- func (x *ResourceSet) GetTotal() int64
- func (*ResourceSet) ProtoMessage()
- func (x *ResourceSet) ProtoReflect() protoreflect.Message
- func (x *ResourceSet) Reset()
- func (s *ResourceSet) ResourceIds() (ids []string)
- func (x *ResourceSet) String() string
- func (s *ResourceSet) UpdateTag(tags []*Tag)
- type SearchRequest
- func (req *SearchRequest) AddTag(t ...*TagSelector)
- func (*SearchRequest) Descriptor() ([]byte, []int)deprecated
- func (x *SearchRequest) GetDomain() string
- func (x *SearchRequest) GetEnv() string
- func (x *SearchRequest) GetExactMatch() bool
- func (x *SearchRequest) GetKeywords() string
- func (x *SearchRequest) GetNamespace() string
- func (x *SearchRequest) GetPage() *request.PageRequest
- func (x *SearchRequest) GetStatus() string
- func (x *SearchRequest) GetSyncAccount() string
- func (x *SearchRequest) GetTags() []*TagSelector
- func (x *SearchRequest) GetType() Type
- func (x *SearchRequest) GetUsageMode() UsageMode
- func (x *SearchRequest) GetVendor() Vendor
- func (x *SearchRequest) GetWithTags() bool
- func (r *SearchRequest) HasTag() bool
- func (*SearchRequest) ProtoMessage()
- func (x *SearchRequest) ProtoReflect() protoreflect.Message
- func (x *SearchRequest) Reset()
- func (x *SearchRequest) String() string
- type ServiceClient
- type ServiceServer
- type SharedPolicy
- func (*SharedPolicy) Descriptor() ([]byte, []int)deprecated
- func (x *SharedPolicy) GetTagKey() string
- func (x *SharedPolicy) GetTagValues() []string
- func (*SharedPolicy) ProtoMessage()
- func (x *SharedPolicy) ProtoReflect() protoreflect.Message
- func (x *SharedPolicy) Reset()
- func (x *SharedPolicy) String() string
- type Tag
- func (*Tag) Descriptor() ([]byte, []int)deprecated
- func (x *Tag) GetDescribe() string
- func (x *Tag) GetHidden() bool
- func (x *Tag) GetIsCost() bool
- func (x *Tag) GetKey() string
- func (x *Tag) GetMeta() map[string]string
- func (x *Tag) GetResourceId() string
- func (x *Tag) GetType() TagType
- func (x *Tag) GetValue() string
- func (x *Tag) GetWeight() int64
- func (*Tag) ProtoMessage()
- func (x *Tag) ProtoReflect() protoreflect.Message
- func (x *Tag) Reset()
- func (x *Tag) String() string
- type TagSelector
- func (*TagSelector) Descriptor() ([]byte, []int)deprecated
- func (x *TagSelector) GetKey() string
- func (x *TagSelector) GetOperator() string
- func (x *TagSelector) GetValues() []string
- func (*TagSelector) ProtoMessage()
- func (x *TagSelector) ProtoReflect() protoreflect.Message
- func (s *TagSelector) Relationship() string
- func (x *TagSelector) Reset()
- func (x *TagSelector) String() string
- type TagSet
- type TagType
- func (TagType) Descriptor() protoreflect.EnumDescriptor
- func (x TagType) Enum() *TagType
- func (TagType) EnumDescriptor() ([]byte, []int)deprecated
- func (t TagType) Equal(target TagType) bool
- func (t TagType) IsIn(targets ...TagType) bool
- func (t TagType) MarshalJSON() ([]byte, error)
- func (x TagType) Number() protoreflect.EnumNumber
- func (x TagType) String() string
- func (TagType) Type() protoreflect.EnumType
- func (t *TagType) UnmarshalJSON(b []byte) error
- type Type
- func (Type) Descriptor() protoreflect.EnumDescriptor
- func (x Type) Enum() *Type
- func (Type) EnumDescriptor() ([]byte, []int)deprecated
- func (t Type) Equal(target Type) bool
- func (t Type) IsIn(targets ...Type) bool
- func (t Type) MarshalJSON() ([]byte, error)
- func (x Type) Number() protoreflect.EnumNumber
- func (x Type) String() string
- func (Type) Type() protoreflect.EnumType
- func (t *Type) UnmarshalJSON(b []byte) error
- type UnimplementedServiceServer
- type UnsafeServiceServer
- type UpdateAction
- func (UpdateAction) Descriptor() protoreflect.EnumDescriptor
- func (x UpdateAction) Enum() *UpdateAction
- func (UpdateAction) EnumDescriptor() ([]byte, []int)deprecated
- func (t UpdateAction) Equal(target UpdateAction) bool
- func (t UpdateAction) IsIn(targets ...UpdateAction) bool
- func (t UpdateAction) MarshalJSON() ([]byte, error)
- func (x UpdateAction) Number() protoreflect.EnumNumber
- func (x UpdateAction) String() string
- func (UpdateAction) Type() protoreflect.EnumType
- func (t *UpdateAction) UnmarshalJSON(b []byte) error
- type UpdateTagRequest
- func (*UpdateTagRequest) Descriptor() ([]byte, []int)deprecated
- func (x *UpdateTagRequest) GetAction() UpdateAction
- func (x *UpdateTagRequest) GetId() string
- func (x *UpdateTagRequest) GetTags() []*Tag
- func (*UpdateTagRequest) ProtoMessage()
- func (x *UpdateTagRequest) ProtoReflect() protoreflect.Message
- func (x *UpdateTagRequest) Reset()
- func (x *UpdateTagRequest) String() string
- type UsageMode
- func (UsageMode) Descriptor() protoreflect.EnumDescriptor
- func (x UsageMode) Enum() *UsageMode
- func (UsageMode) EnumDescriptor() ([]byte, []int)deprecated
- func (t UsageMode) Equal(target UsageMode) bool
- func (t UsageMode) IsIn(targets ...UsageMode) bool
- func (t UsageMode) MarshalJSON() ([]byte, error)
- func (x UsageMode) Number() protoreflect.EnumNumber
- func (x UsageMode) String() string
- func (UsageMode) Type() protoreflect.EnumType
- func (t *UsageMode) UnmarshalJSON(b []byte) error
- type Vendor
- func (Vendor) Descriptor() protoreflect.EnumDescriptor
- func (x Vendor) Enum() *Vendor
- func (Vendor) EnumDescriptor() ([]byte, []int)deprecated
- func (t Vendor) Equal(target Vendor) bool
- func (t Vendor) IsIn(targets ...Vendor) bool
- func (t Vendor) MarshalJSON() ([]byte, error)
- func (x Vendor) Number() protoreflect.EnumNumber
- func (x Vendor) String() string
- func (Vendor) Type() protoreflect.EnumType
- func (t *Vendor) UnmarshalJSON(b []byte) error
Constants ¶
const ( // SQL 比较操作 = Operator_EQUAL = "=" // SQL 比较操作 != Operator_NOT_EQUAL = "!=" // SQL 比较操作 LIKE Operator_LIKE_EQUAL = "=~" // SQL 比较操作 NOT LIKE Operator_NOT_LIKE_EQUAL = "!~" )
const (
AppName = "resource"
)
Variables ¶
var ( UpdateAction_name = map[int32]string{ 0: "ADD", 1: "REMOVE", } UpdateAction_value = map[string]int32{ "ADD": 0, "REMOVE": 1, } )
Enum value maps for UpdateAction.
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.
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.
var ( UsageMode_name = map[int32]string{ 0: "SHARED", 1: "MONOPOLY", } UsageMode_value = map[string]int32{ "SHARED": 0, "MONOPOLY": 1, } )
Enum value maps for UsageMode.
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.
var File_apps_resource_pb_resource_proto protoreflect.FileDescriptor
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、云商内唯一ID ,可以通过厂商+1d做到唯一
// @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"`
// 地域 //如果这种变动大的字段可以做一个api专门处理变动的资源
// @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) GetCreateAt ¶
func (*Base) GetDescribeHash ¶
func (*Base) GetDescribeHashChanged ¶
func (*Base) GetNamespace ¶
func (*Base) GetResourceHash ¶
func (*Base) GetResourceHashChanged ¶
func (*Base) GetResourceType ¶
func (*Base) GetSecretId ¶
func (*Base) GetSharedPolicy ¶
func (x *Base) GetSharedPolicy() *SharedPolicy
func (*Base) GetUsageMode ¶
func (*Base) ProtoMessage ¶
func (*Base) ProtoMessage()
func (*Base) ProtoReflect ¶
func (x *Base) ProtoReflect() protoreflect.Message
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(1c1g),根据云商的概念
// @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) 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) LoadPrivateIPString ¶
func (i *Information) LoadPrivateIPString(s string)
从数据库取得数据需要进行格式化 独立绑定一个方法单独处理这个逻辑
func (*Information) LoadPublicIPString ¶
func (i *Information) LoadPublicIPString(s string)
func (*Information) PrivateIPToString ¶
func (i *Information) PrivateIPToString() string
ip地址的转换逻辑 数组转为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
定义四种表达式,用于匹配values的场景2 使用符号搜索 tag的比较操作符号类比promethus做的 官网找到四种操作符号 把四种符号映射为sql语句
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
}
请求tag的参数
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 ReleasePlan ¶
type ReleasePlan struct {
// 释放原因
// @gotags: json:"reason"
Reason string `protobuf:"bytes,1,opt,name=reason,proto3" json:"reason"`
// 是否立即释放
// @gotags: json:"immediately"
Immediately bool `protobuf:"varint,2,opt,name=immediately,proto3" json:"immediately"`
// 计划时间
// @gotags: json:"plan_at"
PlanAt int64 `protobuf:"varint,3,opt,name=plan_at,json=planAt,proto3" json:"plan_at"`
// 执行时间
// @gotags: json:"exec_at"
ExecAt int64 `protobuf:"varint,4,opt,name=exec_at,json=execAt,proto3" json:"exec_at"`
// 释放前 提前几天通知, 过期后 云商会自动释放的也需要提前通知
// @gotags: json:"notice_before_days"
NoticeBeforeDays int64 `protobuf:"varint,5,opt,name=notice_before_days,json=noticeBeforeDays,proto3" json:"notice_before_days"`
// 资源释放后, 什么时候销毁该数据
// @gotags: json:"destory_at"
DestoryAt int64 `protobuf:"varint,6,opt,name=destory_at,json=destoryAt,proto3" json:"destory_at"`
// contains filtered or unexported fields
}
资源释放计划
func (*ReleasePlan) Descriptor
deprecated
func (*ReleasePlan) Descriptor() ([]byte, []int)
Deprecated: Use ReleasePlan.ProtoReflect.Descriptor instead.
func (*ReleasePlan) GetDestoryAt ¶
func (x *ReleasePlan) GetDestoryAt() int64
func (*ReleasePlan) GetExecAt ¶
func (x *ReleasePlan) GetExecAt() int64
func (*ReleasePlan) GetImmediately ¶
func (x *ReleasePlan) GetImmediately() bool
func (*ReleasePlan) GetNoticeBeforeDays ¶
func (x *ReleasePlan) GetNoticeBeforeDays() int64
func (*ReleasePlan) GetPlanAt ¶
func (x *ReleasePlan) GetPlanAt() int64
func (*ReleasePlan) GetReason ¶
func (x *ReleasePlan) GetReason() string
func (*ReleasePlan) ProtoMessage ¶
func (*ReleasePlan) ProtoMessage()
func (*ReleasePlan) ProtoReflect ¶
func (x *ReleasePlan) ProtoReflect() protoreflect.Message
func (*ReleasePlan) Reset ¶
func (x *ReleasePlan) Reset()
func (*ReleasePlan) String ¶
func (x *ReleasePlan) 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"`
//资源释放计划
//@gotags: json:"release_plan"
ReleasePlan *ReleasePlan `protobuf:"bytes,3,opt,name=release_plan,json=releasePlan,proto3" json:"release_plan"`
// contains filtered or unexported fields
}
资源的描述信息
func NewDefaultResource ¶
func NewDefaultResource() *Resource
func (*Resource) Descriptor
deprecated
func (*Resource) GetInformation ¶
func (x *Resource) GetInformation() *Information
func (*Resource) GetReleasePlan ¶
func (x *Resource) GetReleasePlan() *ReleasePlan
func (*Resource) ProtoMessage ¶
func (*Resource) ProtoMessage()
func (*Resource) ProtoReflect ¶
func (x *Resource) ProtoReflect() protoreflect.Message
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) 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)
ResourceIds 方法 把item里面的所有id取出,放到ids []string 数组里面去返回 把属性里面的id取出来转换为string的一个操作 循环到append到一个数组里面
func (*ResourceSet) String ¶
func (x *ResourceSet) String() string
func (*ResourceSet) UpdateTag ¶
func (s *ResourceSet) UpdateTag(tags []*Tag)
UpdateTag 是一个循环 先循环所有的tag 把tag里面的 ResourceId 跟我们的列表里面的item里面的id相等 我们就把这个tag添加到information里面Tag 字段里面 所以我们的information 需要添加一个addtag的功能
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"`
// 资源类型,opentional 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.0.1.1 10.10.1.1xxx
// @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)
AddTag 添加tag 逻辑 扔到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
HasTag 扩展SearchRequest 给他一个方法HasTag,让他返回一个当前的查询参数到底有没有带着tag来做一个查询 判断下长度是不是大于0,如果大于0就可以做过滤,如果等于0就没有tag
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"`
// @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=0xxx111
// @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
// 资源的具体金额,费用是100,被多个业务方共同使用,出业务成本,面临这个成本如何分摊的问题
// 为了让分摊更加的灵活,添加了标签的权重,更加权重的值做具体的分摊比例计算,比如a:1(1/4),b2(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
Meta map[string]string `` /* 140-byte string literal not displayed */
// contains filtered or unexported fields
}
func NewDefaultTag ¶
func NewDefaultTag() *Tag
NewDefaultTag 方法 默认给予的tag 是TagType_USER 用户自定义标签, 允许用户修改
func NewThirdTag ¶
func (*Tag) Descriptor
deprecated
func (*Tag) GetDescribe ¶
func (*Tag) GetResourceId ¶
func (*Tag) ProtoMessage ¶
func (*Tag) ProtoMessage()
func (*Tag) ProtoReflect ¶
func (x *Tag) ProtoReflect() protoreflect.Message
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
}
标签选择器 通过key value 进行匹配,匹配key,app-atrr1,app-attr2 以下两个标签共同组成一套业务逻辑,需要过滤 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
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
}
返回的tag列表
func (*TagSet) Descriptor
deprecated
func (*TagSet) ProtoMessage ¶
func (*TagSet) ProtoMessage()
func (*TagSet) ProtoReflect ¶
func (x *TagSet) ProtoReflect() protoreflect.Message
type TagType ¶
type TagType int32
func ParseTagTypeFromString ¶
ParseTagTypeFromString Parse TagType from string
func (TagType) Descriptor ¶
func (TagType) Descriptor() protoreflect.EnumDescriptor
func (TagType) EnumDescriptor
deprecated
func (TagType) Number ¶
func (x TagType) Number() protoreflect.EnumNumber
func (TagType) Type ¶
func (TagType) Type() protoreflect.EnumType
type Type ¶
type Type int32
定义资源的类型
func ParseTypeFromString ¶
ParseTypeFromString Parse Type from string
func (Type) Descriptor ¶
func (Type) Descriptor() protoreflect.EnumDescriptor
func (Type) EnumDescriptor
deprecated
func (Type) Number ¶
func (x Type) Number() protoreflect.EnumNumber
func (Type) Type ¶
func (Type) Type() protoreflect.EnumType
type UnimplementedServiceServer ¶
type UnimplementedServiceServer struct {
}
UnimplementedServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedServiceServer) QueryTag ¶
func (UnimplementedServiceServer) QueryTag(context.Context, *QueryTagRequest) (*TagSet, error)
func (UnimplementedServiceServer) Search ¶
func (UnimplementedServiceServer) Search(context.Context, *SearchRequest) (*ResourceSet, error)
func (UnimplementedServiceServer) UpdateTag ¶
func (UnimplementedServiceServer) UpdateTag(context.Context, *UpdateTagRequest) (*Resource, error)
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) Descriptor() protoreflect.EnumDescriptor
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) MarshalJSON ¶
func (t UpdateAction) MarshalJSON() ([]byte, error)
MarshalJSON todo
func (UpdateAction) Number ¶
func (x UpdateAction) Number() protoreflect.EnumNumber
func (UpdateAction) String ¶
func (x UpdateAction) String() string
func (UpdateAction) Type ¶
func (UpdateAction) Type() protoreflect.EnumType
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
使用方式,同一个资源可能会被多个业务方使用,或者多个人共享使用 对这种使用方式做一个标记
func ParseUsageModeFromString ¶
ParseUsageModeFromString Parse UsageMode from string
func (UsageMode) Descriptor ¶
func (UsageMode) Descriptor() protoreflect.EnumDescriptor
func (UsageMode) EnumDescriptor
deprecated
func (UsageMode) Number ¶
func (x UsageMode) Number() protoreflect.EnumNumber
func (UsageMode) Type ¶
func (UsageMode) Type() protoreflect.EnumType
func (*UsageMode) UnmarshalJSON ¶
UnmarshalJSON todo
type Vendor ¶
type Vendor int32
定义厂商,使用枚举定义
func ParseVendorFromString ¶
ParseVendorFromString Parse Vendor from string
func (Vendor) Descriptor ¶
func (Vendor) Descriptor() protoreflect.EnumDescriptor
func (Vendor) EnumDescriptor
deprecated
func (Vendor) Number ¶
func (x Vendor) Number() protoreflect.EnumNumber
func (Vendor) Type ¶
func (Vendor) Type() protoreflect.EnumType