tag

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTagValue

func ParseTagValue(templateURN string, fieldID uint,
	dataType, tagValue string, options []string) (interface{}, error,
)

Types

type DuplicateError

type DuplicateError struct {
	AssetID     string
	TemplateURN string
}

func (DuplicateError) Error

func (e DuplicateError) Error() string

type DuplicateTemplateError

type DuplicateTemplateError struct {
	URN string
}

func (DuplicateTemplateError) Error

func (e DuplicateTemplateError) Error() string

type Field

type Field struct {
	ID          uint      `json:"id"`
	URN         string    `json:"urn" validate:"required"`
	DisplayName string    `json:"display_name" validate:"required"`
	Description string    `json:"description" validate:"required"`
	DataType    string    `json:"data_type" validate:"oneof=string double boolean enumerated datetime"`
	Options     []string  `json:"options"`
	Required    bool      `json:"required"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

Field is a field for a single template

type NotFoundError

type NotFoundError struct {
	AssetID  string
	Template string
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Service

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

Service is a type that manages business process

func NewService

func NewService(repository TagRepository, templateService *TemplateService) *Service

NewService initializes service tag

func (*Service) CreateTag

func (s *Service) CreateTag(ctx context.Context, tag *Tag) error

Create handles business process for create

func (*Service) DeleteTag

func (s *Service) DeleteTag(ctx context.Context, assetID, templateURN string) error

DeleteTag handles business process to delete a tag

func (*Service) FindTagByAssetIDAndTemplateURN

func (s *Service) FindTagByAssetIDAndTemplateURN(ctx context.Context, assetID, templateURN string) (Tag, error)

FindByAssetAndTemplate handles business process to get tags by its asset id and template id

func (*Service) GetTagsByAssetID

func (s *Service) GetTagsByAssetID(ctx context.Context, assetID string) ([]Tag, error)

GetTagsByAssetID handles business process to get tags by its asset id

func (*Service) UpdateTag

func (s *Service) UpdateTag(ctx context.Context, tag *Tag) error

Update handles business process for update

func (*Service) Validate

func (s *Service) Validate(tag *Tag) error

Validate validates domain tag based on business requirement

type Tag

type Tag struct {
	AssetID             string     `json:"asset_id" validate:"required"`
	TemplateURN         string     `json:"template_urn" validate:"required"`
	TagValues           []TagValue `json:"tag_values" validate:"required,min=1,dive"`
	TemplateDisplayName string     `json:"template_display_name"`
	TemplateDescription string     `json:"template_description"`
}

Tag is the tag to be managed

type TagRepository

type TagRepository interface {
	Create(ctx context.Context, tag *Tag) error
	Read(ctx context.Context, filter Tag) ([]Tag, error)
	Update(ctx context.Context, tag *Tag) error
	Delete(ctx context.Context, filter Tag) error
}

TagRepository is a contract to communicate with the primary store

type TagTemplateRepository

type TagTemplateRepository interface {
	Create(ctx context.Context, template *Template) error
	Read(ctx context.Context, templateURN string) ([]Template, error)
	ReadAll(ctx context.Context) ([]Template, error)
	Update(ctx context.Context, templateURN string, template *Template) error
	Delete(ctx context.Context, templateURN string) error
}

TagTemplateRepository is a contract to communicate with the primary store

type TagValue

type TagValue struct {
	FieldID          uint        `json:"field_id" validate:"required"`
	FieldValue       interface{} `json:"field_value" validate:"required"`
	FieldURN         string      `json:"field_urn"`
	FieldDisplayName string      `json:"field_display_name"`
	FieldDescription string      `json:"field_description"`
	FieldDataType    string      `json:"field_data_type"`
	FieldOptions     []string    `json:"field_options"`
	FieldRequired    bool        `json:"field_required"`
	CreatedAt        time.Time   `json:"created_at"`
	UpdatedAt        time.Time   `json:"updated_at"`
}

TagValue is one of the value for a tag

type Template

type Template struct {
	URN         string    `json:"urn" validate:"required"`
	DisplayName string    `json:"display_name" validate:"required"`
	Description string    `json:"description" validate:"required"`
	Fields      []Field   `json:"fields" validate:"required,min=1,dive"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

Template is a template of a tag for a resource

type TemplateNotFoundError

type TemplateNotFoundError struct {
	URN string
}

func (TemplateNotFoundError) Error

func (e TemplateNotFoundError) Error() string

type TemplateService

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

Service is a type of service that manages business process

func NewTemplateService

func NewTemplateService(r TagTemplateRepository) *TemplateService

NewTemplateService initializes service template service

func (*TemplateService) CreateTemplate

func (s *TemplateService) CreateTemplate(ctx context.Context, template *Template) error

Create handles create business operation for template

func (*TemplateService) DeleteTemplate

func (s *TemplateService) DeleteTemplate(ctx context.Context, urn string) error

DeleteTemplate handles request to delete template by urn

func (*TemplateService) GetTemplate

func (s *TemplateService) GetTemplate(ctx context.Context, urn string) (Template, error)

GetTemplate handles request to get template by urn

func (*TemplateService) GetTemplates

func (s *TemplateService) GetTemplates(ctx context.Context, templateURN string) ([]Template, error)

GetTemplates handles read business operation for template

func (*TemplateService) UpdateTemplate

func (s *TemplateService) UpdateTemplate(ctx context.Context, templateURN string, template *Template) error

UpdateTemplate handles update business operation for template

func (*TemplateService) Validate

func (s *TemplateService) Validate(template Template) error

Validate validates domain template based on the business rule

type ValidationError

type ValidationError struct {
	Err error
}

func (ValidationError) Error

func (e ValidationError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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