services

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package services, annotation specific

Package services, external connector specific

Package services, image definition specific

Package services, lab specific

Package services, node definition specific

Package services, smart annotation specific

Package services, system specific

Package services, system specific

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotationService

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

AnnotationService provides classic annotation operations.

func NewAnnotationService

func NewAnnotationService(apiClient *api.Client) *AnnotationService

NewAnnotationService creates a new annotation service.

func (*AnnotationService) Create

Create creates a new annotation in a lab.

func (*AnnotationService) Delete

func (s *AnnotationService) Delete(ctx context.Context, labID, annotationID models.UUID) error

Delete removes an annotation.

func (*AnnotationService) Get

func (s *AnnotationService) Get(ctx context.Context, labID, annotationID models.UUID) (models.Annotation, error)

Get returns a single annotation by ID.

func (*AnnotationService) List

List returns all annotations for a lab.

func (*AnnotationService) Update

func (s *AnnotationService) Update(ctx context.Context, labID, annotationID models.UUID, in models.AnnotationUpdate) (models.Annotation, error)

Update updates an existing annotation.

type AnnotationServiceInterface

type AnnotationServiceInterface interface {
	List(ctx context.Context, labID models.UUID) ([]models.Annotation, error)
	Create(ctx context.Context, labID models.UUID, in models.AnnotationCreate) (models.Annotation, error)
	Get(ctx context.Context, labID, annotationID models.UUID) (models.Annotation, error)
	Update(ctx context.Context, labID, annotationID models.UUID, in models.AnnotationUpdate) (models.Annotation, error)
	Delete(ctx context.Context, labID, annotationID models.UUID) error
}

AnnotationServiceInterface defines methods needed by other services/clients.

type ExtConnService

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

ExtConnService provides external connector-related operations

func NewExtConnService

func NewExtConnService(apiClient *api.Client) *ExtConnService

NewExtConnService creates a new external connector service

func (*ExtConnService) Get

func (s *ExtConnService) Get(ctx context.Context, extConnID models.UUID) (models.ExtConn, error)

Get returns the external connector specified by the ID given

func (*ExtConnService) List

func (s *ExtConnService) List(ctx context.Context) ([]*models.ExtConn, error)

List returns all external connectors on the system

type ExtConnServiceInterface

type ExtConnServiceInterface interface {
	Get(ctx context.Context, extConnID models.UUID) (models.ExtConn, error)
	List(ctx context.Context) ([]*models.ExtConn, error)
}

ExtConnServiceInterface defines methods needed by other services/clients.

type GroupService

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

GroupService provides group-related operations.

func NewGroupService

func NewGroupService(apiClient *api.Client) *GroupService

NewGroupService creates a new group service.

func (*GroupService) ByName

func (s *GroupService) ByName(ctx context.Context, name string) (models.Group, error)

ByName tries to get the group with the provided `name`.

func (*GroupService) Create

func (s *GroupService) Create(ctx context.Context, group models.Group) (result models.Group, err error)

Create creates a new group on the controller based on the data provided in the passed group parameter.

func (*GroupService) Delete

func (s *GroupService) Delete(ctx context.Context, id string) error

Delete removes the group identified by the `id` (a UUIDv4).

func (*GroupService) GetByID

func (s *GroupService) GetByID(ctx context.Context, id models.UUID) (group models.Group, err error)

GetByID retrieves the group with the provided `id` (a UUIDv4).

func (*GroupService) Groups

func (s *GroupService) Groups(ctx context.Context) (models.GroupList, error)

Groups retrieves the list of all groups which exist on the controller.

func (*GroupService) Update

func (s *GroupService) Update(ctx context.Context, group models.Group) (result models.Group, err error)

Update updates the given group which must exist.

type GroupServiceInterface

type GroupServiceInterface interface {
	GetByID(ctx context.Context, id models.UUID) (models.Group, error)
}

GroupServiceInterface defines methods needed by other services.

type ImageDefinitionService

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

ImageDefinitionService provides image definition-related operations

func NewImageDefinitionService

func NewImageDefinitionService(apiClient *api.Client) *ImageDefinitionService

NewImageDefinitionService creates a new image definition service

func (*ImageDefinitionService) ImageDefinitions

func (s *ImageDefinitionService) ImageDefinitions(ctx context.Context) ([]models.ImageDefinition, error)

ImageDefinitions returns a list of image definitions known to the controller.

type ImageDefinitionServiceInterface

type ImageDefinitionServiceInterface interface {
	ImageDefinitions(ctx context.Context) ([]models.ImageDefinition, error)
}

ImageDefinitionServiceInterface defines methods needed by other services/clients.

type InterfaceService

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

InterfaceService provides interface-related operations

func NewInterfaceService

func NewInterfaceService(apiClient *api.Client) *InterfaceService

NewInterfaceService creates a new lab service

func (*InterfaceService) Create

func (s *InterfaceService) Create(ctx context.Context, labID, nodeID models.UUID, slot int) (models.Interface, error)

Create creates an interface in the given lab and node. If the slot is >= 0, the request creates all unallocated slots up to and including that slot. Conversely, if the slot is < 0 (e.g. -1), the next free slot is used.

func (*InterfaceService) GetByID

func (s *InterfaceService) GetByID(ctx context.Context, labID, id models.UUID) (models.Interface, error)

GetByID returns the interface identified by its `ID` (iface.ID).

func (*InterfaceService) GetInterfacesForNode

func (s *InterfaceService) GetInterfacesForNode(ctx context.Context, labID, id models.UUID) (models.InterfaceList, error)

GetInterfacesForNode returns all interfaces for a specific node.

type InterfaceServiceInterface

type InterfaceServiceInterface interface {
	Create(ctx context.Context, labID, nodeID models.UUID, slot int) (models.Interface, error)
	GetByID(ctx context.Context, labID, id models.UUID) (models.Interface, error)
	GetInterfacesForNode(ctx context.Context, labID, id models.UUID) (models.InterfaceList, error)
}

InterfaceServiceInterface defines methods needed by other services

type LabService

type LabService struct {
	User      UserServiceInterface
	Link      LinkServiceInterface
	Interface InterfaceServiceInterface
	Node      NodeServiceInterface
	// contains filtered or unexported fields
}

LabService provides lab-related operations

func NewLabService

NewLabService creates a new lab service

func (*LabService) Create

Create creates a new lab on the controller. Only certain fields from the full Lab model are accepted during creation. Use GetByID() to retrieve the complete lab object after successful creation.

func (*LabService) Delete

func (s *LabService) Delete(ctx context.Context, id models.UUID) error

Delete deletes the lab identified by the `id` (a UUIDv4).

func (*LabService) GetByID

func (s *LabService) GetByID(ctx context.Context, id models.UUID, deep bool) (models.Lab, error)

GetByID retrieves a lab by ID

func (*LabService) GetByTitle

func (s *LabService) GetByTitle(ctx context.Context, title string, deep bool) (models.Lab, error)

GetByTitle returns the lab identified by its `title`.

func (*LabService) HasConverged

func (s *LabService) HasConverged(ctx context.Context, id models.UUID) (converged bool, err error)

HasConverged checks if all nodes in the lab have converged (are in BOOTED state)

func (*LabService) Import

func (s *LabService) Import(ctx context.Context, topology string) (models.Lab, error)

Import imports a lab from YAML topology

func (*LabService) Labs

func (s *LabService) Labs(ctx context.Context, showAll bool) (labs models.LabList, err error)

Labs returns a list of labs.

func (*LabService) LabsWithData

func (s *LabService) LabsWithData(ctx context.Context) ([]models.LabResponse, error)

LabsWithData retrieves labs with data using the /populate_lab_tiles endpoint

func (*LabService) Start

func (s *LabService) Start(ctx context.Context, id models.UUID) error

Start starts all nodes in a lab

func (*LabService) Stop

func (s *LabService) Stop(ctx context.Context, id models.UUID) error

Stop stops all nodes in a lab

func (*LabService) Update

func (s *LabService) Update(ctx context.Context, id models.UUID, data models.LabUpdateRequest) (lab models.Lab, err error)

Update updates a lab's metadata

func (*LabService) Wipe

func (s *LabService) Wipe(ctx context.Context, id models.UUID) error

Wipe wipes the lab identified by the `id` (a UUIDv4).

type LabServiceInterface

type LabServiceInterface interface {
	Labs(ctx context.Context, showAll bool) (models.LabList, error)
	LabsWithData(ctx context.Context) ([]models.LabResponse, error)
	Create(ctx context.Context, lab models.LabCreateRequest) (models.Lab, error)
	GetByID(ctx context.Context, id models.UUID, deep bool) (models.Lab, error)
	GetByTitle(ctx context.Context, title string, deep bool) (models.Lab, error)
	Update(ctx context.Context, labID models.UUID, lab models.LabUpdateRequest) (models.Lab, error)
	Delete(ctx context.Context, id models.UUID) error
	Import(ctx context.Context, topologyYAML string) (models.Lab, error)
	Start(ctx context.Context, labID models.UUID) error
	Stop(ctx context.Context, labID models.UUID) error
	Wipe(ctx context.Context, labID models.UUID) error
	HasConverged(ctx context.Context, id models.UUID) (bool, error)
}

LabServiceInterface defines methods needed by other services/clients.

type LinkService

type LinkService struct {
	Interface InterfaceServiceInterface
	Node      NodeServiceInterface
	// contains filtered or unexported fields
}

LinkService provides link-related operations

func NewLinkService

func NewLinkService(apiClient *api.Client) *LinkService

NewLinkService creates a new link service

func (*LinkService) Create

func (s *LinkService) Create(ctx context.Context, link models.Link) (models.Link, error)

Create creates a link based on the data passed in `link`. Required fields are the `LabID` and either a pair of interfaces `SrcID` / `DstID` or a pair of nodes `SrcNode` / `DstNode`. With nodes it's also possible to provide specific slots in `SrcSlot` / `DstSlot` where the link should be created. If one or both of the provided slots aren't available, then new interfaces will be created. If interface creation fails or the provided Interface IDs can't be found, the API returns an error, otherwise the returned Link variable has the updated link data. Node: -1 for a slot means: use next free slot. Specific slots run from 0 to the maximum slot number -1 per the node definition of the node type.

func (*LinkService) Delete

func (s *LinkService) Delete(ctx context.Context, labID, linkID models.UUID) error

Delete removes a link from a lab identified by the Lab ID and Link ID.

func (*LinkService) DeleteCondition

func (s *LinkService) DeleteCondition(ctx context.Context, labID, linkID models.UUID) error

DeleteCondition removes link conditioning configuration

func (*LinkService) GetByID

func (s *LinkService) GetByID(ctx context.Context, labID, linkID models.UUID) (models.Link, error)

GetByID returns the link data for the given `labID` and `linkID`.

func (*LinkService) GetCondition

func (s *LinkService) GetCondition(ctx context.Context, labID, linkID models.UUID) (models.ConditionResponse, error)

GetCondition retrieves the current link conditioning configuration

func (*LinkService) GetLinksForLab

func (s *LinkService) GetLinksForLab(ctx context.Context, labID models.UUID) ([]models.Link, error)

GetLinksForLab returns all links for a lab.

func (*LinkService) SetCondition

func (s *LinkService) SetCondition(ctx context.Context, labID, linkID models.UUID, config *models.LinkConditionConfiguration) (models.ConditionResponse, error)

SetCondition applies link conditioning configuration

type LinkServiceInterface

type LinkServiceInterface interface {
	GetLinksForLab(ctx context.Context, labID models.UUID) ([]models.Link, error)
	Delete(ctx context.Context, labID, linkID models.UUID) error
	GetCondition(ctx context.Context, labID, linkID models.UUID) (models.ConditionResponse, error)
	SetCondition(ctx context.Context, labID, linkID models.UUID, config *models.LinkConditionConfiguration) (models.ConditionResponse, error)
	DeleteCondition(ctx context.Context, labID, linkID models.UUID) error
}

LinkServiceInterface defines methods needed by other services

type NodeDefinitionService

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

NodeDefinitionService provides node definition-related operations

func NewNodeDefinitionService

func NewNodeDefinitionService(apiClient *api.Client) *NodeDefinitionService

NewNodeDefinitionService creates a new node definition service

func (*NodeDefinitionService) NodeDefinitions

NodeDefinitions returns the list of node definitions available on the CML controller. The key of the map is the definition type name (e.g. "alpine" or "ios"). The node def data structure matches the OpenAPI schema.

type NodeDefinitionServiceInterface

type NodeDefinitionServiceInterface interface {
	NodeDefinitions(ctx context.Context) (models.NodeDefinitionMap, error)
}

NodeDefinitionServiceInterface defines methods needed by other services/clients.

type NodeService

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

NodeService provides node-related operations

func NewNodeService

func NewNodeService(apiClient *api.Client, useNamedConfigs bool) *NodeService

NewNodeService creates a new node service

func (*NodeService) Create

func (s *NodeService) Create(ctx context.Context, node models.Node) (models.Node, error)

Create creates a new node on the controller based on the data provided in `node`. Label, node definition and image definition must be provided.

func (*NodeService) Delete

func (s *NodeService) Delete(ctx context.Context, labID, nodeID models.UUID) error

Delete deletes the node from the controller.

func (*NodeService) GetByID

func (s *NodeService) GetByID(ctx context.Context, labID, id models.UUID) (models.Node, error)

GetByID returns the node identified by its `ID` and `LabID` in the provided node.

func (*NodeService) GetNodesForLab

func (s *NodeService) GetNodesForLab(ctx context.Context, labID models.UUID) (models.NodeMap, error)

GetNodesForLab returns all nodes for a lab.

func (*NodeService) SetConfig

func (s *NodeService) SetConfig(ctx context.Context, node *models.Node, configuration string) error

SetConfig sets a configuration for the specified node. At least the `ID` of the node and the `labID` must be provided in `node`. The `node` instance will be updated with the current values for the node as provided by the controller.

func (*NodeService) SetExcludeConfigurations

func (s *NodeService) SetExcludeConfigurations(v *bool)

SetExcludeConfigurations forces exclude_configurations query behavior for node read operations (GET/LIST). If v is nil, the parameter is omitted.

func (*NodeService) SetNamedConfigs

func (s *NodeService) SetNamedConfigs(ctx context.Context, node *models.Node, configs []models.NodeConfig) error

SetNamedConfigs sets a list of named configurations for the specified node. At least the `ID` of the node and the `labID` must be provided in `node`.

func (*NodeService) Start

func (s *NodeService) Start(ctx context.Context, labID, nodeID models.UUID) error

Start starts the given node.

func (*NodeService) Stop

func (s *NodeService) Stop(ctx context.Context, labID, nodeID models.UUID) error

Stop stops the given node.

func (*NodeService) Update

func (s *NodeService) Update(ctx context.Context, node models.Node) (models.Node, error)

Update updates the node specified by data in `node` (e.g. ID and LabID) with the other data provided. It returns the updated node.

func (*NodeService) Wipe

func (s *NodeService) Wipe(ctx context.Context, labID, nodeID models.UUID) error

Wipe removes all runtime data from a node on the controller/compute. E.g. it will remove the actual VM and its associated disks.

type NodeServiceInterface

type NodeServiceInterface interface {
	GetNodesForLab(ctx context.Context, labID models.UUID) (models.NodeMap, error)
	GetByID(ctx context.Context, labID, id models.UUID) (models.Node, error)
}

NodeServiceInterface defines methods needed by other services

type SmartAnnotationService

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

SmartAnnotationService provides smart annotation operations.

func NewSmartAnnotationService

func NewSmartAnnotationService(apiClient *api.Client) *SmartAnnotationService

NewSmartAnnotationService creates a new smart annotation service.

func (*SmartAnnotationService) Get

Get returns a single smart annotation by ID.

func (*SmartAnnotationService) List

List returns all smart annotations for a lab.

func (*SmartAnnotationService) Update

Update updates an existing smart annotation.

type SmartAnnotationServiceInterface

type SmartAnnotationServiceInterface interface {
	List(ctx context.Context, labID models.UUID) ([]models.SmartAnnotation, error)
	Get(ctx context.Context, labID, id models.UUID) (models.SmartAnnotation, error)
	Update(ctx context.Context, labID, id models.UUID, in models.SmartAnnotationUpdate) (models.SmartAnnotation, error)
}

SmartAnnotationServiceInterface defines methods needed by other services/clients.

type SystemService

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

SystemService provides system-related operations

func NewSystemService

func NewSystemService(apiClient *api.Client) *SystemService

NewSystemService creates a new lab service

func (*SystemService) Ready

func (s *SystemService) Ready(ctx context.Context) error

Ready returns nil if the system is compatible and ready

func (*SystemService) UseNamedConfigs

func (s *SystemService) UseNamedConfigs()

UseNamedConfigs turns on the use of named configs (only with 2.7.0 and newer)

func (*SystemService) Version

func (s *SystemService) Version() string

Version returns the CML controller version

func (*SystemService) VersionCheck

func (s *SystemService) VersionCheck(ctx context.Context, constraintStr string) (bool, error)

VersionCheck checks if the client version satisfies the provided semantic version constraint.

type SystemServiceInterface

type SystemServiceInterface interface {
	Ready(ctx context.Context) error
	Version() string
	VersionCheck(ctx context.Context, constraintStr string) (bool, error)
	UseNamedConfigs()
}

SystemServiceInterface defines methods needed by other services/clients.

type UserService

type UserService struct {
	Group GroupServiceInterface
	// contains filtered or unexported fields
}

UserService provides user-related operations

func NewUserService

func NewUserService(apiClient *api.Client, group GroupServiceInterface) *UserService

NewUserService creates a new user service

func (*UserService) Create

Create creates a new user on the controller based on the data provided in the passed user parameter.

func (*UserService) Delete

func (s *UserService) Delete(ctx context.Context, id models.UUID) error

Delete removes the user identified by the `id` (a UUIDv4).

func (*UserService) GetByID

func (s *UserService) GetByID(ctx context.Context, id models.UUID) (user models.User, err error)

GetByID returns the user with the given `id`.

func (*UserService) GetByName

func (s *UserService) GetByName(ctx context.Context, name string) (models.User, error)

GetByName returns the user with the given username `name`.

func (*UserService) Groups deprecated

func (s *UserService) Groups(ctx context.Context, id models.UUID) (models.GroupList, error)

Groups retrieves the list of all groups the user belongs to.

Deprecated: newer CML schemas no longer document `GET /users/{user_id}/groups`. This method is kept as a compatibility surface for older backends and may return 404 on newer controllers.

func (*UserService) Update

Update updates the given user which must exist.

func (*UserService) Users

func (s *UserService) Users(ctx context.Context) (models.UserList, error)

Users retrieves the list of all users which exist on the controller.

type UserServiceInterface

type UserServiceInterface interface {
	GetByID(ctx context.Context, id models.UUID) (models.User, error)
}

UserServiceInterface defines methods needed by other services

Jump to

Keyboard shortcuts

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