Documentation ¶
Index ¶
- Constants
- Variables
- func GetClientVersion(req *http.Request) *semver.Version
- type APIError
- type AuthnRequest
- type AuthnResponse
- type BaseGetRequest
- type BaseGetResponse
- type BaseListRequest
- type BaseListResponse
- type BasePostRequest
- type BasePostResponse
- type BasePutRequest
- type BasePutResponse
- type BaseRequest
- type BaseResponse
- type GetAgentConfigResponse
- type GetAgentNodeRequest
- type GetAgentNodeResponse
- type GetJobRequest
- type GetJobResponse
- type GetLogsRequest
- type GetNodeRequest
- type GetNodeResponse
- type GetRequest
- type GetResponse
- type GetVersionResponse
- type HTTPCredential
- type HTTPRequest
- type IsAliveResponse
- type ListAuthnMethodsRequest
- type ListAuthnMethodsResponse
- type ListJobExecutionsRequest
- type ListJobExecutionsResponse
- type ListJobHistoryRequest
- type ListJobHistoryResponse
- type ListJobResultsRequest
- type ListJobResultsResponse
- type ListJobsRequest
- type ListJobsResponse
- type ListNodesRequest
- type ListNodesResponse
- type ListRequest
- type ListResponse
- type NodeAction
- type PostRequest
- type PostResponse
- type PutJobRequest
- type PutJobResponse
- type PutNodeRequest
- type PutNodeResponse
- type PutRequest
- type PutResponse
- type Request
- type Response
- type StopJobRequest
- type StopJobResponse
Constants ¶
const ( // AllNamespacesNamespace is a sentinel Namespace value to indicate that api should search for // jobs and allocations in all the namespaces the requester can access. AllNamespacesNamespace = "*" // HTTPHeaderClientID is the header used to pass the client ID to the server. HTTPHeaderClientID = "X-Bacalhau-Client-ID" // HTTPHeaderJobID is the header used to pass the job ID to the server. HTTPHeaderJobID = "X-Bacalhau-Job-ID" // HTTPHeaderAppID is the header used to pass the application ID to the server. HTTPHeaderAppID = "X-Bacalhau-App-ID" // HTTPHeaderBacalhauGitVersion is the header used to pass the agent version, eg v1.2.3 HTTPHeaderBacalhauGitVersion = "X-Bacalhau-Git-Version" // HTTPHeaderBacalhauGitCommit is the header used to pass the agent git commit HTTPHeaderBacalhauGitCommit = "X-Bacalhau-Git-Commit" // HTTPHeaderBacalhauBuildDate is the header used to pass the agent build date in UTC HTTPHeaderBacalhauBuildDate = "X-Bacalhau-Build-Date" // HTTPHeaderBacalhauBuildOS is the header used to pass the agent operating system HTTPHeaderBacalhauBuildOS = "X-Bacalhau-Build-OS" // HTTPHeaderBacalhauArch is the header used to pass the agent architecture HTTPHeaderBacalhauArch = "X-Bacalhau-Arch" HTTPHeaderBacalhauInstallationID = "X-Bacalhau-InstallationID" HTTPHeaderBacalhauInstanceID = "X-Bacalhau-InstanceID" )
Variables ¶
var ErrInvalidToken = errors.New("invalid token")
Functions ¶
func GetClientVersion ¶ added in v1.4.0
GetClientVersion extracts the client version from the `X-Bacalhau-Git-Version` header in the request. If the header is present and the version string can be parsed, it returns the parsed version. If the header is missing or the version string cannot be parsed, it returns version.Unknown.
Types ¶
type APIError ¶ added in v1.5.0
type APIError struct { // httpstatuscode is the http status code associated with this error. // it should correspond to standard http status codes (e.g., 400, 404, 500). HTTPStatusCode int `json:"Status"` // message is a short, human-readable description of the error. // it should be concise and provide a clear indication of what went wrong. Message string `json:"Message"` // RequestID is the request ID of the request that caused the error. RequestID string `json:"RequestID"` // Code is the error code of the error. Code string `json:"Code"` // Component is the component that caused the error. Component string `json:"Component"` // Hint is a string providing additional context or suggestions related to the error. Hint string `json:"Hint,omitempty"` // Details is a map of string key-value pairs providing additional error context. Details map[string]string `json:"Details,omitempty"` }
APIError represents a standardized error response for the api.
it encapsulates:
- an http status code
- a human-readable error message
purpose:
- primarily used to send synchronous errors from the orchestrator endpoint
- provides a structured json error response to http clients
usage:
- when the cli interacts with an orchestrator node via an http client: 1. the http client receives this structured json error 2. the human-readable message is output to stdout 3. the http status code allows for programmatic handling of different error types
benefits:
- ensures consistent error formatting across the api
- facilitates both user-friendly error messages and machine-readable error codes
func FromBacError ¶ added in v1.5.0
FromBacError converts a bacerror.Error to an APIError
func GenerateAPIErrorFromHTTPResponse ¶ added in v1.5.1
Parse HTTP Response to APIError
func NewAPIError ¶ added in v1.5.0
NewAPIError creates a new APIError with the given HTTP status code and message.
func NewUnauthorizedError ¶ added in v1.5.0
NewUnauthorizedError creates an APIError for Unauthorized (401) errors.
func (*APIError) Error ¶ added in v1.5.0
Error implements the error interface, allowing APIError to be used as a standard Go error.
func (*APIError) ToBacError ¶ added in v1.5.0
ToBacError converts an APIError to a bacerror.Error
type AuthnRequest ¶ added in v1.2.1
type AuthnRequest struct { BaseRequest Name string MethodData []byte }
type AuthnResponse ¶ added in v1.2.1
type AuthnResponse struct { BaseResponse Authentication authn.Authentication }
type BaseGetRequest ¶
type BaseGetRequest struct {
BaseRequest
}
BaseGetRequest is the base request used for all get requests
type BaseGetResponse ¶
type BaseGetResponse struct {
BaseResponse `json:",omitempty,inline" yaml:",omitempty,inline"`
}
type BaseListRequest ¶
type BaseListRequest struct { BaseGetRequest Limit uint32 `query:"limit"` NextToken string `query:"next_token"` OrderBy string `query:"order_by"` Reverse bool `query:"reverse"` }
BaseListRequest is the base request used for all list requests
func (*BaseListRequest) ToHTTPRequest ¶
func (o *BaseListRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type BaseListResponse ¶
type BaseListResponse struct { BaseGetResponse `json:",omitempty,inline" yaml:",omitempty,inline"` NextToken string `json:"NextToken"` }
func (*BaseListResponse) GetNextToken ¶
func (o *BaseListResponse) GetNextToken() string
type BasePostRequest ¶ added in v1.3.0
type BasePostRequest struct { BaseRequest IdempotencyToken string `query:"idempotency_token"` }
BasePostRequest is the base request used for all POST requests
func (*BasePostRequest) ToHTTPRequest ¶ added in v1.3.0
func (o *BasePostRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type BasePostResponse ¶ added in v1.3.0
type BasePostResponse struct {
BaseResponse `json:",omitempty,inline" yaml:",omitempty,inline"`
}
type BasePutRequest ¶
type BasePutRequest struct { BaseRequest IdempotencyToken string `query:"idempotency_token"` }
BasePutRequest is the base request used for all put requests
func (*BasePutRequest) ToHTTPRequest ¶
func (o *BasePutRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type BasePutResponse ¶
type BasePutResponse struct {
BaseResponse `json:",omitempty,inline" yaml:",omitempty,inline"`
}
type BaseRequest ¶
type BaseRequest struct { Namespace string `query:"namespace"` Headers map[string]string `query:"-" json:"-"` Credential *HTTPCredential `header:"Authorization"` }
BaseRequest is the base request used for all requests
func (*BaseRequest) SetCredential ¶ added in v1.2.2
func (o *BaseRequest) SetCredential(cred *HTTPCredential)
func (*BaseRequest) ToHTTPRequest ¶
func (o *BaseRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type BaseResponse ¶
type BaseResponse struct{}
func (*BaseResponse) Normalize ¶
func (o *BaseResponse) Normalize()
Normalize normalizes the response
type GetAgentConfigResponse ¶ added in v1.5.2
type GetAgentConfigResponse struct { BaseGetResponse Config types.Bacalhau `json:"config"` }
type GetAgentNodeRequest ¶
type GetAgentNodeRequest struct {
BaseGetRequest
}
GetAgentNodeRequest is the request to get the agent node.
type GetAgentNodeResponse ¶
type GetAgentNodeResponse struct { BaseGetResponse *models.NodeInfo }
type GetJobRequest ¶
type GetJobRequest struct { BaseGetRequest JobID string Include string `query:"include" validate:"omitempty,oneof=history executions"` Limit uint32 `query:"limit"` }
func (*GetJobRequest) ToHTTPRequest ¶ added in v1.2.2
func (o *GetJobRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type GetJobResponse ¶
type GetJobResponse struct { BaseGetResponse Job *models.Job `json:"Job"` History *ListJobHistoryResponse `json:"History,omitempty"` Executions *ListJobExecutionsResponse `json:"Executions,omitempty"` }
func (*GetJobResponse) Normalize ¶
func (r *GetJobResponse) Normalize()
Normalize is used to canonicalize fields in the GetJobResponse.
type GetLogsRequest ¶ added in v1.2.2
type GetLogsRequest struct { BaseGetRequest JobID string `query:"-"` ExecutionID string `query:"execution_id" validate:"omitempty"` Tail bool `query:"tail"` Follow bool `query:"follow"` }
func (*GetLogsRequest) ToHTTPRequest ¶ added in v1.2.2
func (o *GetLogsRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type GetNodeRequest ¶
type GetNodeRequest struct { BaseGetRequest NodeID string }
type GetNodeResponse ¶
type GetNodeResponse struct { BaseGetResponse Node *models.NodeState `json:"Node"` }
type GetRequest ¶
type GetRequest interface { Request }
type GetResponse ¶
type GetResponse interface { Response }
type GetVersionResponse ¶
type GetVersionResponse struct { BaseGetResponse *models.BuildVersionInfo }
GetVersionResponse is the response to the Version request.
type HTTPCredential ¶ added in v1.2.1
type HTTPCredential struct { // An HTTP authorization scheme, such as one registered with IANA // https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml Scheme string // For authorization schemes that only provide a single value, such as // Basic, the single string value providing the credential Value string // For authorization schemes that provide multiple values, a map of names to // values providing the credential Params map[string]string }
func (HTTPCredential) String ¶ added in v1.2.1
func (cred HTTPCredential) String() string
type HTTPRequest ¶
type HTTPRequest struct { Params url.Values Body io.Reader BodyObj interface{} Ctx context.Context Header http.Header }
HTTPRequest is used to help build up a request
func NewHTTPRequest ¶
func NewHTTPRequest() *HTTPRequest
NewHTTPRequest is used to create a new request
type IsAliveResponse ¶
type IsAliveResponse struct { BaseGetResponse `json:",omitempty,inline" yaml:",omitempty,inline"` Status string `json:"Status"` }
IsAliveResponse is the response to the IsAlive request.
func (*IsAliveResponse) IsReady ¶
func (r *IsAliveResponse) IsReady() bool
type ListAuthnMethodsRequest ¶ added in v1.2.1
type ListAuthnMethodsRequest struct {
BaseListRequest
}
type ListAuthnMethodsResponse ¶ added in v1.2.1
type ListAuthnMethodsResponse struct { BaseListResponse Methods map[string]authn.Requirement }
type ListJobExecutionsRequest ¶
type ListJobExecutionsRequest struct { BaseListRequest JobID string `query:"-"` }
type ListJobExecutionsResponse ¶
type ListJobExecutionsResponse struct { BaseListResponse Items []*models.Execution `json:"Items"` }
type ListJobHistoryRequest ¶
type ListJobHistoryRequest struct { BaseListRequest JobID string `query:"-"` Since int64 `query:"since" validate:"min=0"` EventType string `query:"event_type" validate:"omitempty,oneof=all job execution"` ExecutionID string `query:"execution_id" validate:"omitempty"` }
func (*ListJobHistoryRequest) ToHTTPRequest ¶ added in v1.1.0
func (o *ListJobHistoryRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type ListJobHistoryResponse ¶
type ListJobHistoryResponse struct { BaseListResponse Items []*models.JobHistory `json:"Items"` }
type ListJobResultsRequest ¶
type ListJobResultsRequest struct { BaseListRequest JobID string `query:"-"` }
type ListJobResultsResponse ¶
type ListJobResultsResponse struct { BaseListResponse Items []*models.SpecConfig `json:"Items"` }
type ListJobsRequest ¶
type ListJobsRequest struct { BaseListRequest Labels []labels.Requirement `query:"-"` // don't auto bind as it requires special handling }
func (*ListJobsRequest) ToHTTPRequest ¶ added in v1.1.0
func (o *ListJobsRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type ListJobsResponse ¶
type ListJobsResponse struct { BaseListResponse Items []*models.Job `json:"Items"` }
func (*ListJobsResponse) Normalize ¶
func (r *ListJobsResponse) Normalize()
Normalize is used to canonicalize fields in the ListJobsResponse.
type ListNodesRequest ¶
type ListNodesRequest struct { BaseListRequest Labels []labels.Requirement `query:"-"` // don't auto bind as it requires special handling FilterByApproval string `query:"filter-approval"` FilterByStatus string `query:"filter-status"` }
func (*ListNodesRequest) ToHTTPRequest ¶
func (o *ListNodesRequest) ToHTTPRequest() *HTTPRequest
ToHTTPRequest is used to convert the request to an HTTP request
type ListNodesResponse ¶
type ListNodesResponse struct { BaseListResponse Nodes []*models.NodeState `json:"Nodes"` }
type ListRequest ¶
type ListRequest interface { GetRequest }
type ListResponse ¶
type ListResponse interface { GetResponse // GetNextToken is the token used to indicate where to start paging // for queries that support paginated lists. To resume paging from // this point, pass this token in the next request GetNextToken() string }
type NodeAction ¶ added in v1.3.0
type NodeAction string
const ( NodeActionApprove NodeAction = "approve" NodeActionReject NodeAction = "reject" NodeActionDelete NodeAction = "delete" )
func (NodeAction) Description ¶ added in v1.3.0
func (n NodeAction) Description() string
func (NodeAction) IsValid ¶ added in v1.3.0
func (n NodeAction) IsValid() bool
type PostRequest ¶ added in v1.3.0
type PostRequest interface { Request }
type PostResponse ¶ added in v1.3.0
type PostResponse interface { Response }
type PutJobRequest ¶
type PutJobRequest struct { BasePutRequest Job *models.Job `json:"Job"` }
func (*PutJobRequest) Normalize ¶
func (r *PutJobRequest) Normalize()
Normalize is used to canonicalize fields in the PutJobRequest.
func (*PutJobRequest) Validate ¶
func (r *PutJobRequest) Validate() error
Validate is used to validate fields in the PutJobRequest.
type PutJobResponse ¶
type PutJobResponse struct { BasePutResponse JobID string `json:"JobID"` EvaluationID string `json:"EvaluationID"` Warnings []string `json:"Warnings"` }
type PutNodeRequest ¶ added in v1.3.0
type PutNodeRequest struct { BasePutRequest Action string `json:"Action"` Message string `json:"Message"` NodeID string `json:"NodeID"` }
type PutNodeResponse ¶ added in v1.3.0
type PutNodeResponse struct { BasePutResponse Success bool `json:"Success"` Error string `json:"Error,omitempty"` }
type PutRequest ¶
type PutRequest interface { Request }
type PutResponse ¶
type PutResponse interface { Response }
type Request ¶
type Request interface { // SetCredential is used to set the authorization token for the request SetCredential(*HTTPCredential) // ToHTTPRequest is used to convert the request to an HTTP request ToHTTPRequest() *HTTPRequest }
type StopJobRequest ¶
type StopJobRequest struct { BasePutRequest JobID string `json:"-"` Reason string `json:"reason"` }
type StopJobResponse ¶
type StopJobResponse struct { BasePutResponse EvaluationID string `json:"EvaluationID"` }