client

package
v0.0.7 Latest Latest
Warning

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

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

Documentation

Overview

Package client provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.

Index

Constants

View Source
const (
	TaskTypeSnapshotRestore    = "snapshot-restore"
	TaskTypeDiscoverPeers      = "discover-peers"
	TaskTypeConfigPatch        = "config-patch"
	TaskTypeMarkReady          = "mark-ready"
	TaskTypeConfigureGenesis   = "configure-genesis"
	TaskTypeConfigureStateSync = "configure-state-sync"
	TaskTypeSnapshotUpload     = "snapshot-upload"
)
View Source
const DefaultPort int32 = 7777

Variables

View Source
var ErrBusy = errors.New("sidecar: task already running")

ErrBusy is returned when the sidecar rejects a task because another non-scheduled task is already running (HTTP 409).

View Source
var ErrNotFound = errors.New("sidecar: task not found")

ErrNotFound is returned when the requested task does not exist (HTTP 404).

Functions

func NewDeleteTaskRequest

func NewDeleteTaskRequest(server string, id openapi_types.UUID) (*http.Request, error)

NewDeleteTaskRequest generates requests for DeleteTask

func NewGetStatusRequest

func NewGetStatusRequest(server string) (*http.Request, error)

NewGetStatusRequest generates requests for GetStatus

func NewGetTaskRequest

func NewGetTaskRequest(server string, id openapi_types.UUID) (*http.Request, error)

NewGetTaskRequest generates requests for GetTask

func NewHealthzRequest

func NewHealthzRequest(server string) (*http.Request, error)

NewHealthzRequest generates requests for Healthz

func NewListTasksRequest

func NewListTasksRequest(server string) (*http.Request, error)

NewListTasksRequest generates requests for ListTasks

func NewSubmitTaskRequest

func NewSubmitTaskRequest(server string, body SubmitTaskJSONRequestBody) (*http.Request, error)

NewSubmitTaskRequest calls the generic SubmitTask builder with application/json body

func NewSubmitTaskRequestWithBody

func NewSubmitTaskRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewSubmitTaskRequestWithBody generates requests for SubmitTask with any type of body

Types

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) DeleteTask

func (c *Client) DeleteTask(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) Healthz

func (c *Client) Healthz(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ListTasks

func (c *Client) ListTasks(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) SubmitTask

func (c *Client) SubmitTask(ctx context.Context, body SubmitTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) SubmitTaskWithBody

func (c *Client) SubmitTaskWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// Healthz request
	Healthz(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetStatus request
	GetStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListTasks request
	ListTasks(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// SubmitTaskWithBody request with any body
	SubmitTaskWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	SubmitTask(ctx context.Context, body SubmitTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// DeleteTask request
	DeleteTask(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetTask request
	GetTask(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

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

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) DeleteTaskWithResponse

func (c *ClientWithResponses) DeleteTaskWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTaskResponse, error)

DeleteTaskWithResponse request returning *DeleteTaskResponse

func (*ClientWithResponses) GetStatusWithResponse

func (c *ClientWithResponses) GetStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetStatusResponse, error)

GetStatusWithResponse request returning *GetStatusResponse

func (*ClientWithResponses) GetTaskWithResponse

func (c *ClientWithResponses) GetTaskWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTaskResponse, error)

GetTaskWithResponse request returning *GetTaskResponse

func (*ClientWithResponses) HealthzWithResponse

func (c *ClientWithResponses) HealthzWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthzResponse, error)

HealthzWithResponse request returning *HealthzResponse

func (*ClientWithResponses) ListTasksWithResponse

func (c *ClientWithResponses) ListTasksWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListTasksResponse, error)

ListTasksWithResponse request returning *ListTasksResponse

func (*ClientWithResponses) SubmitTaskWithBodyWithResponse

func (c *ClientWithResponses) SubmitTaskWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SubmitTaskResponse, error)

SubmitTaskWithBodyWithResponse request with arbitrary body returning *SubmitTaskResponse

func (*ClientWithResponses) SubmitTaskWithResponse

func (c *ClientWithResponses) SubmitTaskWithResponse(ctx context.Context, body SubmitTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*SubmitTaskResponse, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// HealthzWithResponse request
	HealthzWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthzResponse, error)

	// GetStatusWithResponse request
	GetStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetStatusResponse, error)

	// ListTasksWithResponse request
	ListTasksWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListTasksResponse, error)

	// SubmitTaskWithBodyWithResponse request with any body
	SubmitTaskWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SubmitTaskResponse, error)

	SubmitTaskWithResponse(ctx context.Context, body SubmitTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*SubmitTaskResponse, error)

	// DeleteTaskWithResponse request
	DeleteTaskWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTaskResponse, error)

	// GetTaskWithResponse request
	GetTaskWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTaskResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type ConfigPatchTask

type ConfigPatchTask struct {
	Files map[string]map[string]any
}

ConfigPatchTask applies generic TOML merge-patches to seid config files. Files maps a filename (e.g. "config.toml", "app.toml") to a nested patch that will be recursively merged into the existing file.

func (ConfigPatchTask) TaskType

func (t ConfigPatchTask) TaskType() string

func (ConfigPatchTask) ToTaskRequest

func (t ConfigPatchTask) ToTaskRequest() TaskRequest

func (ConfigPatchTask) Validate

func (t ConfigPatchTask) Validate() error

type ConfigureGenesisTask

type ConfigureGenesisTask struct {
	URI    string
	Region string
}

ConfigureGenesisTask downloads genesis.json from an S3 URI.

func ConfigureGenesisTaskFromParams

func ConfigureGenesisTaskFromParams(params map[string]interface{}) ConfigureGenesisTask

ConfigureGenesisTaskFromParams reconstructs a ConfigureGenesisTask from a generic params map.

func (ConfigureGenesisTask) TaskType

func (t ConfigureGenesisTask) TaskType() string

func (ConfigureGenesisTask) ToTaskRequest

func (t ConfigureGenesisTask) ToTaskRequest() TaskRequest

func (ConfigureGenesisTask) Validate

func (t ConfigureGenesisTask) Validate() error

type ConfigureStateSyncTask

type ConfigureStateSyncTask struct{}

ConfigureStateSyncTask discovers a trust point and configures state sync. No parameters are required; configuration is derived from the peers file.

func (ConfigureStateSyncTask) TaskType

func (t ConfigureStateSyncTask) TaskType() string

func (ConfigureStateSyncTask) ToTaskRequest

func (t ConfigureStateSyncTask) ToTaskRequest() TaskRequest

func (ConfigureStateSyncTask) Validate

func (t ConfigureStateSyncTask) Validate() error

type DeleteTaskResponse

type DeleteTaskResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON404      *ErrorResponse
}

func ParseDeleteTaskResponse

func ParseDeleteTaskResponse(rsp *http.Response) (*DeleteTaskResponse, error)

ParseDeleteTaskResponse parses an HTTP response from a DeleteTaskWithResponse call

func (DeleteTaskResponse) Status

func (r DeleteTaskResponse) Status() string

Status returns HTTPResponse.Status

func (DeleteTaskResponse) StatusCode

func (r DeleteTaskResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type DiscoverPeersTask

type DiscoverPeersTask struct {
	Sources []PeerSource
}

DiscoverPeersTask resolves peers from one or more sources.

func DiscoverPeersTaskFromParams

func DiscoverPeersTaskFromParams(params map[string]interface{}) (DiscoverPeersTask, error)

DiscoverPeersTaskFromParams reconstructs a DiscoverPeersTask from a generic params map.

func (DiscoverPeersTask) TaskType

func (t DiscoverPeersTask) TaskType() string

func (DiscoverPeersTask) ToTaskRequest

func (t DiscoverPeersTask) ToTaskRequest() TaskRequest

func (DiscoverPeersTask) Validate

func (t DiscoverPeersTask) Validate() error

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse defines model for ErrorResponse.

type GetStatusResponse

type GetStatusResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *StatusResponse
}

func ParseGetStatusResponse

func ParseGetStatusResponse(rsp *http.Response) (*GetStatusResponse, error)

ParseGetStatusResponse parses an HTTP response from a GetStatusWithResponse call

func (GetStatusResponse) Status

func (r GetStatusResponse) Status() string

Status returns HTTPResponse.Status

func (GetStatusResponse) StatusCode

func (r GetStatusResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetTaskResponse

type GetTaskResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *TaskResult
	JSON404      *ErrorResponse
}

func ParseGetTaskResponse

func ParseGetTaskResponse(rsp *http.Response) (*GetTaskResponse, error)

ParseGetTaskResponse parses an HTTP response from a GetTaskWithResponse call

func (GetTaskResponse) Status

func (r GetTaskResponse) Status() string

Status returns HTTPResponse.Status

func (GetTaskResponse) StatusCode

func (r GetTaskResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HealthzResponse

type HealthzResponse struct {
	Body         []byte
	HTTPResponse *http.Response
}

func ParseHealthzResponse

func ParseHealthzResponse(rsp *http.Response) (*HealthzResponse, error)

ParseHealthzResponse parses an HTTP response from a HealthzWithResponse call

func (HealthzResponse) Status

func (r HealthzResponse) Status() string

Status returns HTTPResponse.Status

func (HealthzResponse) StatusCode

func (r HealthzResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type ListTasksResponse

type ListTasksResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *[]TaskResult
}

func ParseListTasksResponse

func ParseListTasksResponse(rsp *http.Response) (*ListTasksResponse, error)

ParseListTasksResponse parses an HTTP response from a ListTasksWithResponse call

func (ListTasksResponse) Status

func (r ListTasksResponse) Status() string

Status returns HTTPResponse.Status

func (ListTasksResponse) StatusCode

func (r ListTasksResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type MarkReadyTask

type MarkReadyTask struct{}

MarkReadyTask signals that bootstrap is complete.

func (MarkReadyTask) TaskType

func (t MarkReadyTask) TaskType() string

func (MarkReadyTask) ToTaskRequest

func (t MarkReadyTask) ToTaskRequest() TaskRequest

func (MarkReadyTask) Validate

func (t MarkReadyTask) Validate() error

type Option

type Option func(*sidecarOpts)

Option configures optional SidecarClient parameters.

func WithHTTPDoer

func WithHTTPDoer(doer HttpRequestDoer) Option

WithHTTPDoer overrides the underlying HTTP transport.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the HTTP client timeout. Defaults to 10s.

type PeerSource

type PeerSource struct {
	Type      PeerSourceType
	Region    string
	Tags      map[string]string
	Addresses []string
}

PeerSource is a single peer discovery source.

type PeerSourceType

type PeerSourceType string

PeerSourceType identifies the peer discovery mechanism.

const (
	PeerSourceEC2Tags PeerSourceType = "ec2Tags"
	PeerSourceStatic  PeerSourceType = "static"
)

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type Schedule

type Schedule struct {
	// BlockHeight Reserved for future block-height-based scheduling.
	BlockHeight *int64 `json:"blockHeight,omitempty"`

	// Cron Cron expression for recurring execution.
	Cron *string `json:"cron,omitempty"`
}

Schedule Defines when a task should recur. Currently only cron is supported; blockHeight is reserved for future use.

type SidecarClient

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

SidecarClient wraps the generated ClientWithResponses with a simpler, error-oriented API.

func NewSidecarClient

func NewSidecarClient(baseURL string, opts ...Option) (*SidecarClient, error)

NewSidecarClient creates a client from an explicit base URL.

func NewSidecarClientFromPodDNS

func NewSidecarClientFromPodDNS(name, namespace string, port int32, opts ...Option) (*SidecarClient, error)

NewSidecarClientFromPodDNS builds a client targeting the sidecar via Kubernetes headless-service DNS:

http://{name}-0.{name}.{namespace}.svc.cluster.local:{port}

func (*SidecarClient) DeleteTask

func (c *SidecarClient) DeleteTask(ctx context.Context, id uuid.UUID) error

DeleteTask removes a task result or cancels a scheduled task.

func (*SidecarClient) GetTask

func (c *SidecarClient) GetTask(ctx context.Context, id uuid.UUID) (*TaskResult, error)

GetTask retrieves a single task result by ID.

func (*SidecarClient) Healthz

func (c *SidecarClient) Healthz(ctx context.Context) (bool, error)

Healthz checks whether the sidecar is healthy. Returns (true, nil) for 200, (false, nil) for 503, and (false, error) for network failures or unexpected status codes.

func (*SidecarClient) ListTasks

func (c *SidecarClient) ListTasks(ctx context.Context) ([]TaskResult, error)

ListTasks returns recent task results and active scheduled tasks.

func (*SidecarClient) Status

func (c *SidecarClient) Status(ctx context.Context) (*StatusResponse, error)

Status queries the sidecar's current lifecycle state.

func (*SidecarClient) SubmitRawTask

func (c *SidecarClient) SubmitRawTask(ctx context.Context, task TaskRequest) (uuid.UUID, error)

SubmitRawTask sends a pre-built TaskRequest without validation. Use SubmitTask for the typed, validated path.

func (*SidecarClient) SubmitTask

func (c *SidecarClient) SubmitTask(ctx context.Context, task TaskBuilder) (uuid.UUID, error)

SubmitTask validates and sends a typed task to the sidecar. Returns the assigned task UUID on success, ErrBusy on 409, and a descriptive error otherwise.

type SnapshotRestoreTask

type SnapshotRestoreTask struct {
	Bucket  string
	Prefix  string
	Region  string
	ChainID string
}

SnapshotRestoreTask downloads and extracts a snapshot archive from S3.

func SnapshotRestoreTaskFromParams

func SnapshotRestoreTaskFromParams(params map[string]interface{}) SnapshotRestoreTask

SnapshotRestoreTaskFromParams reconstructs a SnapshotRestoreTask from a generic params map. Useful for round-trip testing.

func (SnapshotRestoreTask) TaskType

func (t SnapshotRestoreTask) TaskType() string

func (SnapshotRestoreTask) ToTaskRequest

func (t SnapshotRestoreTask) ToTaskRequest() TaskRequest

func (SnapshotRestoreTask) Validate

func (t SnapshotRestoreTask) Validate() error

type SnapshotUploadTask

type SnapshotUploadTask struct {
	Bucket string
	Prefix string
	Region string
}

SnapshotUploadTask archives and streams a local snapshot to S3.

func SnapshotUploadTaskFromParams

func SnapshotUploadTaskFromParams(params map[string]interface{}) SnapshotUploadTask

SnapshotUploadTaskFromParams reconstructs a SnapshotUploadTask from a generic params map.

func (SnapshotUploadTask) TaskType

func (t SnapshotUploadTask) TaskType() string

func (SnapshotUploadTask) ToTaskRequest

func (t SnapshotUploadTask) ToTaskRequest() TaskRequest

func (SnapshotUploadTask) Validate

func (t SnapshotUploadTask) Validate() error

type StatusResponse

type StatusResponse struct {
	Status StatusResponseStatus `json:"status"`
}

StatusResponse defines model for StatusResponse.

type StatusResponseStatus

type StatusResponseStatus string

StatusResponseStatus defines model for StatusResponse.Status.

const (
	Initializing StatusResponseStatus = "Initializing"
	Ready        StatusResponseStatus = "Ready"
	Running      StatusResponseStatus = "Running"
)

Defines values for StatusResponseStatus.

type SubmitTaskJSONRequestBody

type SubmitTaskJSONRequestBody = TaskRequest

SubmitTaskJSONRequestBody defines body for SubmitTask for application/json ContentType.

type SubmitTaskResponse

type SubmitTaskResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON201      *TaskSubmitResponse
	JSON202      *TaskSubmitResponse
	JSON400      *ErrorResponse
	JSON409      *ErrorResponse
}

func ParseSubmitTaskResponse

func ParseSubmitTaskResponse(rsp *http.Response) (*SubmitTaskResponse, error)

ParseSubmitTaskResponse parses an HTTP response from a SubmitTaskWithResponse call

func (SubmitTaskResponse) Status

func (r SubmitTaskResponse) Status() string

Status returns HTTPResponse.Status

func (SubmitTaskResponse) StatusCode

func (r SubmitTaskResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type TaskBuilder

type TaskBuilder interface {
	TaskType() string
	Validate() error
	ToTaskRequest() TaskRequest
}

TaskBuilder is implemented by every typed task struct. It converts a strongly-typed task description into the generic TaskRequest wire format and validates required fields before submission.

type TaskRequest

type TaskRequest struct {
	Params *map[string]interface{} `json:"params,omitempty"`

	// Schedule Defines when a task should recur. Currently only cron is supported; blockHeight is reserved for future use.
	Schedule *Schedule `json:"schedule,omitempty"`

	// Type Task type identifier.
	Type string `json:"type"`
}

TaskRequest defines model for TaskRequest.

type TaskResult

type TaskResult struct {
	CompletedAt *time.Time `json:"completedAt,omitempty"`

	// Error Error message if the task failed.
	Error     *string                 `json:"error,omitempty"`
	Id        openapi_types.UUID      `json:"id"`
	NextRunAt *time.Time              `json:"nextRunAt,omitempty"`
	Params    *map[string]interface{} `json:"params,omitempty"`

	// Schedule Defines when a task should recur. Currently only cron is supported; blockHeight is reserved for future use.
	Schedule    *Schedule `json:"schedule,omitempty"`
	SubmittedAt time.Time `json:"submittedAt"`

	// Type Task type that was executed.
	Type string `json:"type"`
}

TaskResult defines model for TaskResult.

type TaskSubmitResponse

type TaskSubmitResponse struct {
	// Id The assigned task UUID.
	Id openapi_types.UUID `json:"id"`
}

TaskSubmitResponse defines model for TaskSubmitResponse.

Jump to

Keyboard shortcuts

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