Documentation
¶
Overview ¶
Package rest provides methods and functions to communicate with the MarbleRun Coordinator using its REST API.
Index ¶
Constants ¶
const ( ManifestEndpoint = "manifest" UpdateEndpoint = "update" UpdateCancelEndpoint = "update-cancel" UpdateStatusEndpoint = "update-manifest" QuoteEndpoint = "quote" RecoverEndpoint = "recover" SecretEndpoint = "secrets" StatusEndpoint = "status" SignQuoteEndpoint = "sign-quote" V2API = "/api/v2/" ContentJSON = "application/json" ContentPlain = "text/plain" )
Endpoints of the MarbleRun Coordinator REST API.
Variables ¶
This section is empty.
Functions ¶
func IsNotAllowedErr ¶
IsNotAllowedErr checks if the error is a RequestFailedError with HTTP status code 405 (Method Not Allowed).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a REST client for the MarbleRun Coordinator.
func NewClient ¶
func NewClient(host string, rootCert *x509.Certificate, clientCert *tls.Certificate) (*Client, error)
NewClient creates and returns an http client using the given certificate of the server. An optional clientCert can be used to enable client authentication.
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, path string, body io.Reader, queryParameters ...string) ([]byte, error)
Get sends a GET request to the Coordinator under the specified path. If body is non nil, it is sent as the request body. Query parameters can be provided as a list of strings, where each pair of strings is a key-value pair. On success, the data field of the JSON response is returned.
type RequestFailedError ¶
type RequestFailedError struct {
HTTPStatusCode int
Status string
Message string
Data []byte
// contains filtered or unexported fields
}
RequestFailedError is returned when an HTTP request to the Coordinator fails. It contains the HTTP status code, as well as the JSend status, message and data fields.
func (*RequestFailedError) Error ¶
func (e *RequestFailedError) Error() string
Error returns the error message.