Documentation ¶
Index ¶
- func ExponentialBackoff(min, max time.Duration, attempt int) time.Duration
- func NotFound(err error) bool
- type APIClient
- func (api *APIClient) CreateSocket(ctx context.Context, in *Socket) (out *Socket, err error)
- func (api *APIClient) DeleteSocket(ctx context.Context, idOrName string) (err error)
- func (api *APIClient) SignSocketKey(ctx context.Context, idOrName string, in *SocketKeyToSign) (out *SignedSocketKey, err error)
- func (api *APIClient) Socket(ctx context.Context, idOrName string) (out *Socket, err error)
- func (api *APIClient) Sockets(ctx context.Context) (out []Socket, err error)
- func (api *APIClient) TokenClaims() (jwt.MapClaims, error)
- func (api *APIClient) UpdateSocket(ctx context.Context, idOrName string, in *Socket) (out *Socket, err error)
- type Backoff
- type Error
- type HTTPClient
- type HTTPRequester
- type Option
- type Requester
- type SignedSocketKey
- type Socket
- type SocketConnectorData
- type SocketKeyToSign
- type SocketService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExponentialBackoff ¶
ExponentialBackoff is a Backoff function which will backoff exponentially between the given minimum and maximum durations. The attempt number is used as the exponent base, so the first attempt will backoff by the minimum duration, the second attempt will backoff by twice the minimum duration, the third attempt will backoff by four times the minimum duration, and so on. The maximum duration is used as a cap, so the backoff will never exceed the maximum duration.
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient is the client for the Border0 API.
func (*APIClient) CreateSocket ¶
CreateSocket creates a new socket in your organization. Socket name must be unique within your organization, otherwise, an error will be returned. Socket type is required and must be one of the following: "http", "ssh", "tls" or "database".
func (*APIClient) DeleteSocket ¶ added in v0.1.22
DeleteSocket deletes a socket in your organization. If the socket does not exist, no error will be returned.
func (*APIClient) SignSocketKey ¶
func (api *APIClient) SignSocketKey(ctx context.Context, idOrName string, in *SocketKeyToSign) (out *SignedSocketKey, err error)
SignSocketKey generates a signed SSH certificate for a socket. The SSH public key must be in OpenSSH format. The SSH certificate will be valid for 5 minutes. The host key is the public key Border0 server. It can be used to verify the SSH certificate.
func (*APIClient) Socket ¶
Socket fetches a socket by socket UUID or name. Socket UUID is globally unique and socket name is unique within an organization.
func (*APIClient) TokenClaims ¶
TokenClaims returns the claims of the JWT token.
type Backoff ¶
Backoff is a callback function which will be called by APIClient when performing retries. It is passed the minimum and maximum durations to backoff between, as well as the attempt number (starting at zero)
type Error ¶
type Error struct { Code int `json:"status_code"` Message string `json:"error_message"` Fallback string `json:"message"` }
Error is an error returned by the API server.
func APIErrorFrom ¶
APIErrorFrom creates an Error from an HTTP response.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is a wrapper around http.Client that handles authentication, request/response encoding/decoding, and error handling.
func (*HTTPClient) Close ¶
func (h *HTTPClient) Close()
Close closes idle connections in the underlying HTTP client.
type HTTPRequester ¶
type HTTPRequester interface { Request(ctx context.Context, method, path string, input, output any) (int, error) Close() }
HTTPRequester is an interface for HTTPClient.
type Option ¶
type Option func(*APIClient)
Option is a function that can be passed to NewAPIClient to configure it.
func WithAuthToken ¶
WithAuthToken sets the auth token for Border0 api calls.
func WithBackoff ¶
WithBackoff sets the backoff function that's used to calculate the wait time between retries of failed api calls.
func WithBaseURL ¶
WithBaseURL sets the base url for Border0 api calls.
func WithRetryMax ¶
WithRetryMax sets the maximum number of retries of failed api calls.
func WithRetryWaitMax ¶
WithRetryWaitMax sets the maximum wait time between retries of failed api calls.
func WithRetryWaitMin ¶
WithRetryWaitMin sets the minimum wait time between retries of failed api calls.
func WithTimeout ¶
WithTimeout sets the timeout for the underlying http client.
type Requester ¶
type Requester interface { TokenClaims() (jwt.MapClaims, error) SocketService }
Requester is the interface for the Border0 API client.
type SignedSocketKey ¶
type SignedSocketKey struct { SignedSSHCert string `json:"signed_ssh_cert"` HostKey string `json:"host_key"` }
SignedSocketKey represents a signed SSH certificate and the host key.
type Socket ¶
type Socket struct { Name string `json:"name"` SocketID string `json:"socket_id"` SocketType string `json:"socket_type"` Description string `json:"description,omitempty"` UpstreamType string `json:"upstream_type,omitempty"` UpstreamHTTPHostname string `json:"upstream_http_hostname,omitempty"` Tags map[string]string `json:"tags,omitempty"` RecordingEnabled bool `json:"recording_enabled"` ConnectorAuthenticationEnabled bool `json:"connector_authentication_enabled"` ConnectorData *SocketConnectorData `json:"connector_data,omitempty"` }
Socket represents a socket in Border0 API.
type SocketConnectorData ¶ added in v0.1.22
type SocketConnectorData struct { ConnectorID string `json:"connector_id,omitempty"` Config *types.ConnectorServiceUpstreamConfig `json:"config,omitempty"` }
type SocketKeyToSign ¶
type SocketKeyToSign struct {
SSHPublicKey string `json:"ssh_public_key"`
}
SocketKeyToSign represents a SSH public key to sign.
type SocketService ¶
type SocketService interface { Socket(ctx context.Context, idOrName string) (out *Socket, err error) Sockets(ctx context.Context) (out []Socket, err error) CreateSocket(ctx context.Context, in *Socket) (out *Socket, err error) UpdateSocket(ctx context.Context, idOrName string, in *Socket) (out *Socket, err error) DeleteSocket(ctx context.Context, idOrName string) (err error) SignSocketKey(ctx context.Context, idOrName string, in *SocketKeyToSign) (out *SignedSocketKey, err error) }
SocketService is an interface for API client methods that interact with Border0 API to manage sockets.