client

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyResponse = errors.New("empty response")
	ErrSourceGone    = errors.New("source is gone")
	ErrUnauthorized  = errors.New("agent is not authorized")
)

Functions

func NewFromConfig

func NewFromConfig(config *baseclient.Config) (*client.ClientWithResponses, error)

NewFromConfig returns a new FlightCtl API client from the given config.

Types

type Config

type Config = baseclient.Config

func NewDefault

func NewDefault() *Config

type Interceptor

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

func NewInterceptor

func NewInterceptor(client Planner) *Interceptor

func (*Interceptor) GetStatus

func (i *Interceptor) GetStatus() common.AgentStatus

func (*Interceptor) UpdateAgentStatus

func (i *Interceptor) UpdateAgentStatus(ctx context.Context, id uuid.UUID, params api.AgentStatusUpdate) error

UpdateAgentStatus updates the agent status.

func (*Interceptor) UpdateSourceStatus

func (i *Interceptor) UpdateSourceStatus(ctx context.Context, id uuid.UUID, params api.SourceStatusUpdate) error

type Planner

type Planner interface {
	UpdateSourceStatus(ctx context.Context, id uuid.UUID, params api.SourceStatusUpdate) error
	// UpdateAgentStatus updates the agent status.
	UpdateAgentStatus(ctx context.Context, id uuid.UUID, params api.AgentStatusUpdate) error
}

Planner is the client interface for migration planning.

func NewPlanner

func NewPlanner(client *client.ClientWithResponses) Planner

type PlannerMock

type PlannerMock struct {
	// UpdateAgentStatusFunc mocks the UpdateAgentStatus method.
	UpdateAgentStatusFunc func(ctx context.Context, id uuid.UUID, params api.AgentStatusUpdate) error

	// UpdateSourceStatusFunc mocks the UpdateSourceStatus method.
	UpdateSourceStatusFunc func(ctx context.Context, id uuid.UUID, params api.SourceStatusUpdate) error
	// contains filtered or unexported fields
}

PlannerMock is a mock implementation of Planner.

func TestSomethingThatUsesPlanner(t *testing.T) {

	// make and configure a mocked Planner
	mockedPlanner := &PlannerMock{
		UpdateAgentStatusFunc: func(ctx context.Context, id uuid.UUID, params api.AgentStatusUpdate) error {
			panic("mock out the UpdateAgentStatus method")
		},
		UpdateSourceStatusFunc: func(ctx context.Context, id uuid.UUID, params api.SourceStatusUpdate) error {
			panic("mock out the UpdateSourceStatus method")
		},
	}

	// use mockedPlanner in code that requires Planner
	// and then make assertions.

}

func (*PlannerMock) UpdateAgentStatus

func (mock *PlannerMock) UpdateAgentStatus(ctx context.Context, id uuid.UUID, params api.AgentStatusUpdate) error

UpdateAgentStatus calls UpdateAgentStatusFunc.

func (*PlannerMock) UpdateAgentStatusCalls

func (mock *PlannerMock) UpdateAgentStatusCalls() []struct {
	Ctx    context.Context
	ID     uuid.UUID
	Params api.AgentStatusUpdate
}

UpdateAgentStatusCalls gets all the calls that were made to UpdateAgentStatus. Check the length with:

len(mockedPlanner.UpdateAgentStatusCalls())

func (*PlannerMock) UpdateSourceStatus

func (mock *PlannerMock) UpdateSourceStatus(ctx context.Context, id uuid.UUID, params api.SourceStatusUpdate) error

UpdateSourceStatus calls UpdateSourceStatusFunc.

func (*PlannerMock) UpdateSourceStatusCalls

func (mock *PlannerMock) UpdateSourceStatusCalls() []struct {
	Ctx    context.Context
	ID     uuid.UUID
	Params api.SourceStatusUpdate
}

UpdateSourceStatusCalls gets all the calls that were made to UpdateSourceStatus. Check the length with:

len(mockedPlanner.UpdateSourceStatusCalls())

type Service

type Service = baseclient.Service

Jump to

Keyboard shortcuts

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