代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/telegraf 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package influxdb
import (
"context"
)
// ErrLabelNotFound is the error for a missing Label.
const ErrLabelNotFound = "label not found"
const (
OpFindLabels = "FindLabels"
OpFindLabelByID = "FindLabelByID"
OpFindLabelMapping = "FindLabelMapping"
OpCreateLabel = "CreateLabel"
OpCreateLabelMapping = "CreateLabelMapping"
OpUpdateLabel = "UpdateLabel"
OpDeleteLabel = "DeleteLabel"
OpDeleteLabelMapping = "DeleteLabelMapping"
)
// errors on label
var (
// ErrLabelNameisEmpty is error when org name is empty
ErrLabelNameisEmpty = &Error{
Code: EInvalid,
Msg: "label name is empty",
}
// ErrLabelExistsOnResource is used when attempting to add a label to a resource
// when that label already exists on the resource
ErrLabelExistsOnResource = &Error{
Code: EConflict,
Msg: "Cannot add label, label already exists on resource",
}
)
// LabelService represents a service for managing resource labels
type LabelService interface {
// FindLabelByID a single label by ID.
FindLabelByID(ctx context.Context, id ID) (*Label, error)
// FindLabels returns a list of labels that match a filter
FindLabels(ctx context.Context, filter LabelFilter, opt ...FindOptions) ([]*Label, error)
// FindResourceLabels returns a list of labels that belong to a resource
FindResourceLabels(ctx context.Context, filter LabelMappingFilter) ([]*Label, error)
// CreateLabel creates a new label
CreateLabel(ctx context.Context, l *Label) error
// CreateLabelMapping maps a resource to an existing label
CreateLabelMapping(ctx context.Context, m *LabelMapping) error
// UpdateLabel updates a label with a changeset.
UpdateLabel(ctx context.Context, id ID, upd LabelUpdate) (*Label, error)
// DeleteLabel deletes a label
DeleteLabel(ctx context.Context, id ID) error
// DeleteLabelMapping deletes a label mapping
DeleteLabelMapping(ctx context.Context, m *LabelMapping) error
}
// Label is a tag set on a resource, typically used for filtering on a UI.
type Label struct {
ID ID `json:"id,omitempty"`
OrgID ID `json:"orgID,omitempty"`
Name string `json:"name"`
Properties map[string]string `json:"properties,omitempty"`
}
// Validate returns an error if the label is invalid.
func (l *Label) Validate() error {
if l.Name == "" {
return &Error{
Code: EInvalid,
Msg: "label name is required",
}
}
if !l.OrgID.Valid() {
return &Error{
Code: EInvalid,
Msg: "orgID is required",
}
}
return nil
}
// LabelMapping is used to map resource to its labels.
// It should not be shared directly over the HTTP API.
type LabelMapping struct {
LabelID ID `json:"labelID"`
ResourceID ID `json:"resourceID,omitempty"`
ResourceType `json:"resourceType"`
}
// Validate returns an error if the mapping is invalid.
func (l *LabelMapping) Validate() error {
if !l.LabelID.Valid() {
return &Error{
Code: EInvalid,
Msg: "label id is required",
}
}
if !l.ResourceID.Valid() {
return &Error{
Code: EInvalid,
Msg: "resource id is required",
}
}
if err := l.ResourceType.Valid(); err != nil {
return &Error{
Code: EInvalid,
Err: err,
}
}
return nil
}
// LabelUpdate represents a changeset for a label.
// Only the properties specified are updated.
type LabelUpdate struct {
Name string `json:"name,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
}
// LabelFilter represents a set of filters that restrict the returned results.
type LabelFilter struct {
Name string
OrgID *ID
}
// LabelMappingFilter represents a set of filters that restrict the returned results.
type LabelMappingFilter struct {
ResourceID ID
ResourceType
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。