client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package client provides a gRPC client for interacting with the RLA service. This package can be imported by external modules to communicate with RLA.

The client uses types from pkg/types, which can be imported independently for interface definitions and mocking without gRPC dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the gRPC client for interacting with the RLA service.

func New

func New(c Config) (*Client, error)

New creates a new client with the given configuration.

func (*Client) AddComponent

func (c *Client) AddComponent(
	ctx context.Context,
	comp *types.Component,
) (*types.Component, error)

AddComponent creates a single component under an existing rack.

func (*Client) AssociateRuleWithRack

func (c *Client) AssociateRuleWithRack(
	ctx context.Context,
	rackID uuid.UUID,
	ruleID uuid.UUID,
) error

AssociateRuleWithRack associates an operation rule with a specific rack.

func (*Client) AttachRacksToNVLDomain

func (c *Client) AttachRacksToNVLDomain(
	ctx context.Context,
	nvlDomainID types.Identifier,
	rackIDs []types.Identifier,
) error

AttachRacksToNVLDomain attaches racks to an NVL domain.

func (*Client) Close

func (c *Client) Close() error

Close closes the gRPC connection

func (*Client) CreateExpectedRack

func (c *Client) CreateExpectedRack(
	ctx context.Context,
	rack *types.Rack,
) (uuid.UUID, error)

CreateExpectedRack creates a new expected rack and returns its UUID.

func (*Client) CreateNVLDomain

func (c *Client) CreateNVLDomain(
	ctx context.Context,
	nvlDomain *types.NVLDomain,
) (uuid.UUID, error)

CreateNVLDomain creates a new NVL domain and returns its UUID.

func (*Client) CreateOperationRule

func (c *Client) CreateOperationRule(
	ctx context.Context,
	name string,
	description string,
	operationType types.OperationType,
	operationCode string,
	ruleDefinitionJSON string,
	isDefault bool,
) (uuid.UUID, error)

CreateOperationRule creates a new operation rule and returns its UUID.

func (*Client) DeleteComponent

func (c *Client) DeleteComponent(
	ctx context.Context,
	componentID uuid.UUID,
) error

DeleteComponent soft-deletes a component by UUID.

func (*Client) DeleteOperationRule

func (c *Client) DeleteOperationRule(
	ctx context.Context,
	ruleID uuid.UUID,
) error

DeleteOperationRule deletes an operation rule by its ID.

func (*Client) DetachRacksFromNVLDomain

func (c *Client) DetachRacksFromNVLDomain(
	ctx context.Context,
	rackIDs []types.Identifier,
) error

DetachRacksFromNVLDomain detaches racks from their NVL domain.

func (*Client) DisassociateRuleFromRack

func (c *Client) DisassociateRuleFromRack(
	ctx context.Context,
	rackID uuid.UUID,
	operationType types.OperationType,
	operationCode string,
) error

DisassociateRuleFromRack removes a rule association from a rack.

func (*Client) GetComponentInfoByID

func (c *Client) GetComponentInfoByID(
	ctx context.Context,
	id uuid.UUID,
	withRack bool,
) (*types.Component, *types.Rack, error)

GetComponentInfoByID retrieves component information by its UUID.

func (*Client) GetComponentInfoBySerial

func (c *Client) GetComponentInfoBySerial(
	ctx context.Context,
	manufacturer string,
	serial string,
	withRack bool,
) (*types.Component, *types.Rack, error)

GetComponentInfoBySerial retrieves component information by its manufacturer and serial number.

func (*Client) GetExpectedComponentsByComponentIDs

func (c *Client) GetExpectedComponentsByComponentIDs(
	ctx context.Context,
	componentIDs []string,
	componentType types.ComponentType,
) (*GetExpectedComponentsResult, error)

GetExpectedComponentsByComponentIDs retrieves expected components by external component IDs.

func (*Client) GetExpectedComponentsByRackIDs

func (c *Client) GetExpectedComponentsByRackIDs(
	ctx context.Context,
	rackIDs []uuid.UUID,
	componentType types.ComponentType,
) (*GetExpectedComponentsResult, error)

GetExpectedComponentsByRackIDs retrieves expected components from local database by rack IDs.

func (*Client) GetExpectedComponentsByRackNames

func (c *Client) GetExpectedComponentsByRackNames(
	ctx context.Context,
	rackNames []string,
	componentType types.ComponentType,
) (*GetExpectedComponentsResult, error)

GetExpectedComponentsByRackNames retrieves expected components from local database by rack names.

func (*Client) GetListOfNVLDomains

func (c *Client) GetListOfNVLDomains(
	ctx context.Context,
	info *types.StringQueryInfo,
	pagination *types.Pagination,
) ([]*types.NVLDomain, int32, error)

GetListOfNVLDomains retrieves a list of NVL domains matching the query.

func (*Client) GetListOfRacks

func (c *Client) GetListOfRacks(
	ctx context.Context,
	info *types.StringQueryInfo,
	pagination *types.Pagination,
	withComponents bool,
) ([]*types.Rack, int32, error)

GetListOfRacks retrieves a list of racks matching the query.

func (*Client) GetOperationRule

func (c *Client) GetOperationRule(
	ctx context.Context,
	ruleID uuid.UUID,
) (*types.OperationRule, error)

GetOperationRule retrieves an operation rule by its ID.

func (*Client) GetRackInfoByID

func (c *Client) GetRackInfoByID(
	ctx context.Context,
	id uuid.UUID,
	withComponents bool,
) (*types.Rack, error)

GetRackInfoByID retrieves rack information by its UUID.

func (*Client) GetRackInfoBySerial

func (c *Client) GetRackInfoBySerial(
	ctx context.Context,
	manufacturer string,
	serial string,
	withComponents bool,
) (*types.Rack, error)

GetRackInfoBySerial retrieves rack information by its manufacturer and serial number.

func (*Client) GetRackRuleAssociation

func (c *Client) GetRackRuleAssociation(
	ctx context.Context,
	rackID uuid.UUID,
	operationType types.OperationType,
	operationCode string,
) (uuid.UUID, error)

GetRackRuleAssociation retrieves the rule associated with a rack for a specific operation.

func (*Client) GetRacksForNVLDomain

func (c *Client) GetRacksForNVLDomain(
	ctx context.Context,
	nvlDomainID types.Identifier,
) ([]*types.Rack, error)

GetRacksForNVLDomain retrieves racks belonging to an NVL domain.

func (*Client) GetTasksByIDs

func (c *Client) GetTasksByIDs(
	ctx context.Context,
	taskIDs []uuid.UUID,
) ([]*types.Task, error)

GetTasksByIDs retrieves tasks by their IDs.

func (*Client) IngestRackByRackIDs

func (c *Client) IngestRackByRackIDs(
	ctx context.Context,
	rackIDs []uuid.UUID,
	description string,
) (*IngestRackResult, error)

IngestRackByRackIDs submits an ingestion task for the given rack IDs.

func (*Client) IngestRackByRackNames

func (c *Client) IngestRackByRackNames(
	ctx context.Context,
	rackNames []string,
	description string,
) (*IngestRackResult, error)

IngestRackByRackNames submits an ingestion task for the given rack names.

func (*Client) ListOperationRules

func (c *Client) ListOperationRules(
	ctx context.Context,
	operationType *types.OperationType,
	isDefault *bool,
	offset *int,
	limit *int,
) ([]*types.OperationRule, int, error)

ListOperationRules lists operation rules with optional filtering.

func (*Client) ListRackRuleAssociations

func (c *Client) ListRackRuleAssociations(
	ctx context.Context,
	rackID uuid.UUID,
) ([]*types.RackRuleAssociation, error)

ListRackRuleAssociations lists all rule associations for a specific rack.

func (*Client) ListTasks

func (c *Client) ListTasks(
	ctx context.Context,
	rackID *uuid.UUID,
	activeOnly bool,
	pagination *types.Pagination,
) (*ListTasksResult, error)

ListTasks lists tasks matching the query.

func (*Client) PatchComponent

func (c *Client) PatchComponent(
	ctx context.Context,
	componentID uuid.UUID,
	opts PatchComponentOpts,
) (*types.Component, error)

PatchComponent updates a single component's fields.

func (*Client) PowerControlByMachineIDs

func (c *Client) PowerControlByMachineIDs(
	ctx context.Context,
	machineIDs []string,
	op types.PowerControlOp,
) (*PowerControlResult, error)

PowerControlByMachineIDs performs power control on the given machine IDs.

func (*Client) PowerControlByRackIDs

func (c *Client) PowerControlByRackIDs(
	ctx context.Context,
	rackIDs []uuid.UUID,
	componentType types.ComponentType,
	op types.PowerControlOp,
) (*PowerControlResult, error)

PowerControlByRackIDs performs power control on components in the given rack IDs.

func (*Client) PowerControlByRackNames

func (c *Client) PowerControlByRackNames(
	ctx context.Context,
	rackNames []string,
	componentType types.ComponentType,
	op types.PowerControlOp,
) (*PowerControlResult, error)

PowerControlByRackNames performs power control on components in the given rack names.

func (*Client) SetRuleAsDefault

func (c *Client) SetRuleAsDefault(
	ctx context.Context,
	ruleID uuid.UUID,
) error

SetRuleAsDefault marks a rule as the default for its operation type and code.

func (*Client) UpdateOperationRule

func (c *Client) UpdateOperationRule(
	ctx context.Context,
	ruleID uuid.UUID,
	name *string,
	description *string,
	ruleDefinitionJSON *string,
) error

UpdateOperationRule updates an existing operation rule.

func (*Client) UpgradeFirmwareByMachineIDs

func (c *Client) UpgradeFirmwareByMachineIDs(
	ctx context.Context,
	machineIDs []string,
	startTime, endTime *time.Time,
) (*UpgradeFirmwareResult, error)

UpgradeFirmwareByMachineIDs upgrades firmware for the given machine IDs (external component IDs).

func (*Client) UpgradeFirmwareByRackIDs

func (c *Client) UpgradeFirmwareByRackIDs(
	ctx context.Context,
	rackIDs []uuid.UUID,
	componentType types.ComponentType,
	startTime, endTime *time.Time,
) (*UpgradeFirmwareResult, error)

UpgradeFirmwareByRackIDs upgrades firmware for components in the given rack IDs.

func (*Client) UpgradeFirmwareByRackNames

func (c *Client) UpgradeFirmwareByRackNames(
	ctx context.Context,
	rackNames []string,
	componentType types.ComponentType,
	startTime, endTime *time.Time,
) (*UpgradeFirmwareResult, error)

UpgradeFirmwareByRackNames upgrades firmware for components in the given rack names.

func (*Client) ValidateComponentsByComponentIDs

func (c *Client) ValidateComponentsByComponentIDs(
	ctx context.Context,
	componentIDs []string,
	componentType types.ComponentType,
) (*ValidateComponentsResult, error)

ValidateComponentsByComponentIDs validates expected vs actual components by external component IDs.

func (*Client) ValidateComponentsByRackIDs

func (c *Client) ValidateComponentsByRackIDs(
	ctx context.Context,
	rackIDs []uuid.UUID,
	componentType types.ComponentType,
) (*ValidateComponentsResult, error)

ValidateComponentsByRackIDs validates expected vs actual components by rack IDs.

func (*Client) ValidateComponentsByRackNames

func (c *Client) ValidateComponentsByRackNames(
	ctx context.Context,
	rackNames []string,
	componentType types.ComponentType,
) (*ValidateComponentsResult, error)

ValidateComponentsByRackNames validates expected vs actual components by rack names.

type Config

type Config struct {
	Host string
	Port int
}

Config represents the configuration needed to create a new RLA service gRPC client.

func (*Config) Target

func (c *Config) Target() string

Target builds the target string for connecting to RLA gRPC server.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the config fields are set correctly.

type GetExpectedComponentsResult

type GetExpectedComponentsResult struct {
	Components []*types.Component
	Total      int
}

GetExpectedComponentsResult contains the result of GetExpectedComponents operation.

type IngestRackResult

type IngestRackResult struct {
	TaskIDs []uuid.UUID
}

IngestRackResult represents the result of an IngestRack operation.

type ListTasksResult

type ListTasksResult struct {
	Tasks []*types.Task
	Total int
}

ListTasksResult represents the result of ListTasks call.

type PatchComponentOpts

type PatchComponentOpts struct {
	FirmwareVersion *string
	SlotID          *int32
	TrayIndex       *int32
	HostID          *int32
	Description     *string
	RackID          *uuid.UUID
}

PatchComponentOpts contains the optional fields for patching a component.

type PowerControlResult

type PowerControlResult struct {
	TaskIDs []uuid.UUID // Multiple task IDs (1 task per rack)
}

PowerControlResult represents the result of a power control operation.

type UpgradeFirmwareResult

type UpgradeFirmwareResult struct {
	TaskIDs []uuid.UUID // Multiple task IDs (1 task per rack)
}

UpgradeFirmwareResult represents the result of a firmware upgrade operation.

type ValidateComponentsResult

type ValidateComponentsResult struct {
	Diffs               []*types.ComponentDiff
	TotalDiffs          int
	OnlyInExpectedCount int
	OnlyInActualCount   int
	DriftCount          int
	MatchCount          int
}

ValidateComponentsResult represents the result of ValidateComponents call.

Jump to

Keyboard shortcuts

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