client

package
v1.12.5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

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 can perform queries against the Conditions Orchestrator API service.

func (*Client) ConditionQuery

func (c *Client) ConditionQuery(ctx context.Context, serverID uuid.UUID) (*v1types.ServerResponse, error)

func (*Client) ConditionStatusUpdate

func (c *Client) ConditionStatusUpdate(ctx context.Context, conditionKind rctypes.Kind, serverID, conditionID uuid.UUID, statusValue *rctypes.StatusValue, onlyUpdateTimestamp bool) (*v1types.ServerResponse, error)

func (*Client) ConditionTaskPublish

func (c *Client) ConditionTaskPublish(ctx context.Context, conditionKind rctypes.Kind, serverID, conditionID uuid.UUID, task *rctypes.Task[any, any], onlyUpdateTimestamp bool) (*v1types.ServerResponse, error)

func (*Client) ConditionTaskQuery

func (c *Client) ConditionTaskQuery(ctx context.Context, conditionKind rctypes.Kind, serverID uuid.UUID) (*v1types.ServerResponse, error)

type Error

type Error struct {
	Cause string
}

Error holds the cause of a client error and implements the Error interface.

func (Error) Error

func (c Error) Error() string

Error returned for a client side problem.

type HTTPRequestDoer

type HTTPRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type MockHTTPRequestDoer

type MockHTTPRequestDoer struct {
	mock.Mock
}

MockHTTPRequestDoer is an autogenerated mock type for the HTTPRequestDoer type

func NewMockHTTPRequestDoer

func NewMockHTTPRequestDoer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockHTTPRequestDoer

NewMockHTTPRequestDoer creates a new instance of MockHTTPRequestDoer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHTTPRequestDoer) Do

Do provides a mock function with given fields: req

func (*MockHTTPRequestDoer) EXPECT

type MockHTTPRequestDoer_Do_Call

type MockHTTPRequestDoer_Do_Call struct {
	*mock.Call
}

MockHTTPRequestDoer_Do_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Do'

func (*MockHTTPRequestDoer_Do_Call) Return

func (*MockHTTPRequestDoer_Do_Call) Run

func (*MockHTTPRequestDoer_Do_Call) RunAndReturn

type MockHTTPRequestDoer_Expecter

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

func (*MockHTTPRequestDoer_Expecter) Do

Do is a helper method to define mock.On call

  • req *http.Request

type MockQueryor

type MockQueryor struct {
	mock.Mock
}

MockQueryor is an autogenerated mock type for the Queryor type

func NewMockQueryor

func NewMockQueryor(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockQueryor

NewMockQueryor creates a new instance of MockQueryor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockQueryor) ConditionQuery

func (_m *MockQueryor) ConditionQuery(ctx context.Context, serverID uuid.UUID) (*types.ServerResponse, error)

ConditionQuery provides a mock function with given fields: ctx, serverID

func (*MockQueryor) ConditionStatusUpdate

func (_m *MockQueryor) ConditionStatusUpdate(ctx context.Context, conditionKind condition.Kind, serverID uuid.UUID, conditionID uuid.UUID, statusValue *condition.StatusValue, onlyUpdateTimestamp bool) (*types.ServerResponse, error)

ConditionStatusUpdate provides a mock function with given fields: ctx, conditionKind, serverID, conditionID, statusValue, onlyUpdateTimestamp

func (*MockQueryor) ConditionTaskPublish

func (_m *MockQueryor) ConditionTaskPublish(ctx context.Context, conditionKind condition.Kind, serverID uuid.UUID, conditionID uuid.UUID, task *condition.Task[interface{}, interface{}], onlyUpdateTimestamp bool) (*types.ServerResponse, error)

ConditionTaskPublish provides a mock function with given fields: ctx, conditionKind, serverID, conditionID, task, onlyUpdateTimestamp

func (*MockQueryor) ConditionTaskQuery

func (_m *MockQueryor) ConditionTaskQuery(ctx context.Context, conditionKind condition.Kind, serverID uuid.UUID) (*types.ServerResponse, error)

ConditionTaskQuery provides a mock function with given fields: ctx, conditionKind, serverID

func (*MockQueryor) EXPECT

func (_m *MockQueryor) EXPECT() *MockQueryor_Expecter

type MockQueryor_ConditionQuery_Call

type MockQueryor_ConditionQuery_Call struct {
	*mock.Call
}

MockQueryor_ConditionQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConditionQuery'

func (*MockQueryor_ConditionQuery_Call) Return

func (*MockQueryor_ConditionQuery_Call) Run

func (*MockQueryor_ConditionQuery_Call) RunAndReturn

type MockQueryor_ConditionStatusUpdate_Call

type MockQueryor_ConditionStatusUpdate_Call struct {
	*mock.Call
}

MockQueryor_ConditionStatusUpdate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConditionStatusUpdate'

func (*MockQueryor_ConditionStatusUpdate_Call) Return

func (*MockQueryor_ConditionStatusUpdate_Call) Run

func (_c *MockQueryor_ConditionStatusUpdate_Call) Run(run func(ctx context.Context, conditionKind condition.Kind, serverID uuid.UUID, conditionID uuid.UUID, statusValue *condition.StatusValue, onlyUpdateTimestamp bool)) *MockQueryor_ConditionStatusUpdate_Call

type MockQueryor_ConditionTaskPublish_Call

type MockQueryor_ConditionTaskPublish_Call struct {
	*mock.Call
}

MockQueryor_ConditionTaskPublish_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConditionTaskPublish'

func (*MockQueryor_ConditionTaskPublish_Call) Return

func (*MockQueryor_ConditionTaskPublish_Call) Run

func (_c *MockQueryor_ConditionTaskPublish_Call) Run(run func(ctx context.Context, conditionKind condition.Kind, serverID uuid.UUID, conditionID uuid.UUID, task *condition.Task[interface{}, interface{}], onlyUpdateTimestamp bool)) *MockQueryor_ConditionTaskPublish_Call

func (*MockQueryor_ConditionTaskPublish_Call) RunAndReturn

type MockQueryor_ConditionTaskQuery_Call

type MockQueryor_ConditionTaskQuery_Call struct {
	*mock.Call
}

MockQueryor_ConditionTaskQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConditionTaskQuery'

func (*MockQueryor_ConditionTaskQuery_Call) Return

func (*MockQueryor_ConditionTaskQuery_Call) Run

func (*MockQueryor_ConditionTaskQuery_Call) RunAndReturn

type MockQueryor_Expecter

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

func (*MockQueryor_Expecter) ConditionQuery

func (_e *MockQueryor_Expecter) ConditionQuery(ctx interface{}, serverID interface{}) *MockQueryor_ConditionQuery_Call

ConditionQuery is a helper method to define mock.On call

  • ctx context.Context
  • serverID uuid.UUID

func (*MockQueryor_Expecter) ConditionStatusUpdate

func (_e *MockQueryor_Expecter) ConditionStatusUpdate(ctx interface{}, conditionKind interface{}, serverID interface{}, conditionID interface{}, statusValue interface{}, onlyUpdateTimestamp interface{}) *MockQueryor_ConditionStatusUpdate_Call

ConditionStatusUpdate is a helper method to define mock.On call

  • ctx context.Context
  • conditionKind condition.Kind
  • serverID uuid.UUID
  • conditionID uuid.UUID
  • statusValue *condition.StatusValue
  • onlyUpdateTimestamp bool

func (*MockQueryor_Expecter) ConditionTaskPublish

func (_e *MockQueryor_Expecter) ConditionTaskPublish(ctx interface{}, conditionKind interface{}, serverID interface{}, conditionID interface{}, task interface{}, onlyUpdateTimestamp interface{}) *MockQueryor_ConditionTaskPublish_Call

ConditionTaskPublish is a helper method to define mock.On call

  • ctx context.Context
  • conditionKind condition.Kind
  • serverID uuid.UUID
  • conditionID uuid.UUID
  • task *condition.Task[interface{},interface{}]
  • onlyUpdateTimestamp bool

func (*MockQueryor_Expecter) ConditionTaskQuery

func (_e *MockQueryor_Expecter) ConditionTaskQuery(ctx interface{}, conditionKind interface{}, serverID interface{}) *MockQueryor_ConditionTaskQuery_Call

ConditionTaskQuery is a helper method to define mock.On call

  • ctx context.Context
  • conditionKind condition.Kind
  • serverID uuid.UUID

type Option

type Option func(*Client) error

Option allows setting custom parameters during construction

func WithAuthToken

func WithAuthToken(authToken string) Option

WithAuthToken sets the client auth token.

func WithHTTPClient

func WithHTTPClient(doer HTTPRequestDoer) Option

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

type Queryor

type Queryor interface {
	// Retrieve the current in-complete condition for the serverID
	// The returned condition is in either the Active or Pending states.
	ConditionQuery(ctx context.Context, serverID uuid.UUID) (*v1types.ServerResponse, error)
	// Update a Condition status
	ConditionStatusUpdate(ctx context.Context, conditionKind rctypes.Kind, serverID, conditionID uuid.UUID, statusValue *rctypes.StatusValue, onlyUpdateTimestamp bool) (*v1types.ServerResponse, error)
	// Publish Task
	ConditionTaskPublish(ctx context.Context, conditionKind rctypes.Kind, serverID, conditionID uuid.UUID, task *rctypes.Task[any, any], onlyUpdateTimestamp bool) (*v1types.ServerResponse, error)
	// Query task
	ConditionTaskQuery(ctx context.Context, conditionKind rctypes.Kind, serverID uuid.UUID) (*v1types.ServerResponse, error)
}

The Queryor interface enables

func NewClient

func NewClient(serverAddress string, opts ...Option) (Queryor, error)

Creates a new Client, with reasonable defaults

type RequestError

type RequestError struct {
	Message    string `json:"message"`
	StatusCode int    `json:"statusCode"`
}

RequestError is returned when the client gets an error while performing a request.

func (RequestError) Error

func (e RequestError) Error() string

Error returns the RequestError in string format

Jump to

Keyboard shortcuts

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