label

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseManager

type BaseManager struct{}

BaseManager is the default implementation of the Manager interface.

func (*BaseManager) Exists

func (bm *BaseManager) Exists(labelID int64) (*models.Label, error)

Exists is the implementation of same method in Manager interface.

func (*BaseManager) GetLabelsOfResource

func (bm *BaseManager) GetLabelsOfResource(resourceType string, resourceIDOrName interface{}) ([]*models.Label, error)

GetLabelsOfResource is the implementation of same method in Manager interface.

func (*BaseManager) MarkLabelToResource

func (bm *BaseManager) MarkLabelToResource(label *models.ResourceLabel) (int64, error)

MarkLabelToResource is the implementation of same method in Manager interface.

func (*BaseManager) RemoveLabelFromResource

func (bm *BaseManager) RemoveLabelFromResource(resourceType string, resourceIDOrName interface{}, labelID int64) error

RemoveLabelFromResource is the implementation of same method in Manager interface.

func (*BaseManager) Validate

func (bm *BaseManager) Validate(labelID int64, projectID int64) (*models.Label, error)

Validate is the implementation of same method in Manager interface.

type ErrLabelBadRequest

type ErrLabelBadRequest struct {
	Message string
}

ErrLabelBadRequest defines the error of bad request to the resource.

func NewErrLabelBadRequest

func NewErrLabelBadRequest(message string) *ErrLabelBadRequest

NewErrLabelBadRequest builds an error with ErrLabelBadRequest type.

func (*ErrLabelBadRequest) Error

func (br *ErrLabelBadRequest) Error() string

Error returns the error message of ErrLabelBadRequest.

type ErrLabelBase

type ErrLabelBase struct {
	LabelID          int64
	ResourceType     string
	ResourceIDOrName interface{}
}

ErrLabelBase contains the basic required info for building the final errors.

type ErrLabelConflict

type ErrLabelConflict struct {
	ErrLabelBase
}

ErrLabelConflict defines the error of label conflicts on the resource.

func NewErrLabelConflict

func NewErrLabelConflict(labelID int64, resourceType string, resourceIDOrName interface{}) *ErrLabelConflict

NewErrLabelConflict builds an error with NewErrLabelConflict type.

func (*ErrLabelConflict) Error

func (cl *ErrLabelConflict) Error() string

Error returns the error message of ErrLabelConflict.

type ErrLabelNotFound

type ErrLabelNotFound struct {
	ErrLabelBase
}

ErrLabelNotFound defines the error of not found label on the resource or the specified label is not found.

func NewErrLabelNotFound

func NewErrLabelNotFound(labelID int64, resourceType string, resourceIDOrName interface{}) *ErrLabelNotFound

NewErrLabelNotFound builds an error with ErrLabelNotFound type

func (*ErrLabelNotFound) Error

func (nf *ErrLabelNotFound) Error() string

Error returns the error message of ErrLabelNotFound.

type Manager

type Manager interface {
	// Mark label to the resource.
	//
	// If succeed, the relationship ID will be returned.
	// Otherwise, an non-nil error will be returned.
	MarkLabelToResource(label *models.ResourceLabel) (int64, error)

	// Remove the label from the resource.
	// Resource type and ID(/name) should be provided to identify the relationship.
	//
	// An non-nil error will be got if meet any issues or nil error returned.
	RemoveLabelFromResource(resourceType string, resourceIDOrName interface{}, labelID int64) error

	// Get labels for the specified resource.
	// Resource is identified by the resource type and ID(/name).
	//
	// If succeed, a label list is returned.
	// Otherwise, a non-nil error will be returned.
	GetLabelsOfResource(resourceType string, resourceIDOrName interface{}) ([]*models.Label, error)

	// Check the existence of the specified label.
	//
	// If label existing, a non-nil label object is returned and nil error is set.
	// A non-nil error will be set if any issues met while checking or label is not found.
	Exists(labelID int64) (*models.Label, error)

	// Validate if the scope of the input label is correct.
	// If the scope is project level, the projectID is required then.
	//
	// If everything is ok, an validated label reference will be returned.
	// Otherwise, a non-nil error is returned.
	Validate(labelID int64, projectID int64) (*models.Label, error)
}

Manager defines the related operations for label management

Jump to

Keyboard shortcuts

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