service

package
v0.0.0-...-8cbe82e Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: AGPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service provides the API for working with annotations.

func NewService

func NewService(st State) *Service

NewService returns a new service reference wrapping the given annotations state.

func (*Service) GetAnnotations

func (s *Service) GetAnnotations(ctx context.Context, id annotations.ID) (map[string]string, error)

GetAnnotations retrieves all the annotations associated with a given ID. If no annotations are found, an empty map is returned.

func (*Service) GetCharmAnnotations

func (s *Service) GetCharmAnnotations(ctx context.Context, id annotation.GetCharmArgs) (map[string]string, error)

GetCharmAnnotations retrieves all the annotations associated with a given charm argument. If no annotations are found, an empty map is returned.

func (*Service) SetAnnotations

func (s *Service) SetAnnotations(ctx context.Context, id annotations.ID, annotations map[string]string) error

SetAnnotations associates key/value annotation pairs with a given ID. If an annotation already exists for the given ID, then it will be updated with the given value.

func (*Service) SetCharmAnnotations

func (s *Service) SetCharmAnnotations(ctx context.Context, id annotation.GetCharmArgs, annotations map[string]string) error

SetCharmAnnotations associates key/value annotation pairs with a given charm argument. If an annotation already exists for the given ID, then it will be updated with the given value.

type State

type State interface {
	// GetAnnotations retrieves all the annotations associated with a given ID.
	// If no annotations are found, an empty map is returned.
	GetAnnotations(ctx context.Context, ID annotations.ID) (map[string]string, error)

	// GetCharmAnnotations retrieves all the annotations associated with a given
	// ID. If no annotations are found, an empty map is returned.
	GetCharmAnnotations(ctx context.Context, ID annotation.GetCharmArgs) (map[string]string, error)

	// SetAnnotations associates key/value annotation pairs with a given ID.
	// If an annotation already exists for the given ID, then it will be updated
	// with the given value. First all annotations are deleted, then the given
	// pairs are inserted, so unsetting an annotation is implicit.
	SetAnnotations(ctx context.Context, ID annotations.ID, annotations map[string]string) error

	// SetCharmAnnotations associates key/value annotation pairs with a given ID.
	// If an annotation already exists for the given ID, then it will be updated
	// with the given value. First all annotations are deleted, then the given
	// pairs are inserted, so unsetting an annotation is implicit.
	SetCharmAnnotations(ctx context.Context, ID annotation.GetCharmArgs, annotations map[string]string) error
}

State describes retrieval and persistence methods for annotations.

Jump to

Keyboard shortcuts

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