api

package
v0.0.0-...-9758eb9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const APIUrl = "https://api.border0.com/api/v1"

Variables

View Source
var APIImpl = (*Border0API)(nil)
View Source
var ErrNotFound = errors.New("resource not found")
View Source
var ErrUnauthorized = errors.New("invalid token, please login")

Functions

func APIURL

func APIURL() string

Types

type API

type API interface {
	GetOrganizationInfo(ctx context.Context) (*models.Organization, error)
	GetSockets(ctx context.Context) ([]models.Socket, error)
	GetSocket(ctx context.Context, socketID string) (*models.Socket, error)
	GetTunnel(ctx context.Context, socketID string, tunnelID string) (*models.Tunnel, error)
	CreateTunnel(ctx context.Context, socketID string) (*models.Tunnel, error)
	CreateSocket(ctx context.Context, socket *models.Socket) (*models.Socket, error)
	UpdateSocket(ctx context.Context, socketID string, socket models.Socket) error
	DeleteSocket(ctx context.Context, socketID string) error
	Login(email, password string) (*models.LoginResponse, error)
	GetPolicyByName(ctx context.Context, name string) (*models.Policy, error)
	AttachPolicies(ctx context.Context, socketID string, policyUUIDs []string) ([]string, error)
	DetachPolicies(ctx context.Context, socketID string, policyUUIDs []string) ([]string, error)
	GetPoliciesBySocketID(socketID string) ([]models.Policy, error)
	StartRefreshAccessTokenJob(ctx context.Context)
	GetAccessToken() string
	SignSSHKey(ctx context.Context, socketID string, key []byte) (string, string, error)
	GetUserID() (string, error)
	Evaluate(ctx context.Context, socket *models.Socket, clientIP, userEmail, sessionKey string) (allowedActions []any, info map[string][]string, err error)
	UpdateSession(update models.SessionUpdate) error
	SignSshOrgCertificate(ctx context.Context, socketID, sessionID, userEmail string, ticket, publicKey []byte) ([]byte, error)
	UploadRecording(content []byte, socketID, sessionKey, recordingID string) error
	ServerOrgCertificate(ctx context.Context, name string, csr []byte) ([]byte, error)
}

type APIOption

type APIOption func(*Border0API)

func WithCredentials

func WithCredentials(creds *models.Credentials) APIOption

func WithVersion

func WithVersion(version string) APIOption

type Border0API

type Border0API struct {
	Credentials *models.Credentials
	Version     string
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(opts ...APIOption) *Border0API

func (*Border0API) AttachPolicies

func (a *Border0API) AttachPolicies(ctx context.Context, socketID string, policyUUIDs []string) ([]string, error)

func (*Border0API) CreateConnector

func (a *Border0API) CreateConnector(
	ctx context.Context,
	name string,
	description string,
	enableBuiltInSshService bool,
	builtInSshServiceConfig *service.BuiltInSshServiceConfiguration,
) (*models.Connector, error)

CreateConnector creates a new border0 connector (v2)

func (*Border0API) CreateConnectorToken

func (a *Border0API) CreateConnectorToken(ctx context.Context, connectorId string, name string, expiresAt *time.Time) (*models.ConnectorToken, error)

CreateConnectorToken creates a new border0 connector token

func (*Border0API) CreateConnectorWithInstallToken

func (a *Border0API) CreateConnectorWithInstallToken(
	ctx context.Context,
	name string,
	installToken string,
) (*models.ConnectorWithInstallTokenResponse, error)

CreateConnectorWithInstallToken is a connector v2 method, it creates a new border0 connector and connector token from an install token (invite code)

func (*Border0API) CreatePlugin

func (a *Border0API) CreatePlugin(
	ctx context.Context,
	connectorId string,
	enabled bool,
	pluginType string,
	pluginConfiguration *connector.PluginConfiguration,
) (*models.ConnectorPlugin, error)

CreatePlugin creates a new connector plugin.

func (*Border0API) CreateSocket

func (a *Border0API) CreateSocket(ctx context.Context, socket *models.Socket) (*models.Socket, error)

func (*Border0API) CreateToken

func (a *Border0API) CreateToken(ctx context.Context, name string, role string, expiresAt *time.Time) (*models.Token, error)

CreateToken creates a new border0 admin token (api key)

func (*Border0API) CreateTunnel

func (a *Border0API) CreateTunnel(ctx context.Context, socketID string) (*models.Tunnel, error)

func (*Border0API) DeleteSocket

func (a *Border0API) DeleteSocket(ctx context.Context, socketID string) error

func (*Border0API) DetachPolicies

func (a *Border0API) DetachPolicies(ctx context.Context, socketID string, policyUUIDs []string) ([]string, error)

func (*Border0API) Evaluate

func (a *Border0API) Evaluate(ctx context.Context, socket *models.Socket, clientIP, userEmail, sessionKey string) (allowedActions []any, info map[string][]string, err error)

func (*Border0API) GetAccessToken

func (a *Border0API) GetAccessToken() string

func (*Border0API) GetDefaultPluginConfiguration

func (a *Border0API) GetDefaultPluginConfiguration(ctx context.Context, pluginType string) (*connector.PluginConfiguration, error)

GetDefaultPluginConfiguration returns the default configuration for a given plugin type.

func (*Border0API) GetOrganizationInfo

func (a *Border0API) GetOrganizationInfo(ctx context.Context) (*models.Organization, error)

func (*Border0API) GetPoliciesBySocketID

func (a *Border0API) GetPoliciesBySocketID(socketID string) ([]models.Policy, error)

func (*Border0API) GetPolicyByName

func (a *Border0API) GetPolicyByName(ctx context.Context, name string) (*models.Policy, error)

func (*Border0API) GetSocket

func (a *Border0API) GetSocket(ctx context.Context, socketID string) (*models.Socket, error)

func (*Border0API) GetSockets

func (a *Border0API) GetSockets(ctx context.Context) ([]models.Socket, error)

func (*Border0API) GetTunnel

func (a *Border0API) GetTunnel(ctx context.Context, socketID string, tunnelID string) (*models.Tunnel, error)

func (*Border0API) GetUserID

func (a *Border0API) GetUserID() (string, error)

func (*Border0API) ListConnectors

func (a *Border0API) ListConnectors(ctx context.Context) ([]models.Connector, error)

ListConnectors lists an organization's connectors (v2)

func (*Border0API) Login

func (a *Border0API) Login(email, password string) (*models.LoginResponse, error)

func (*Border0API) RefreshAccessToken

func (a *Border0API) RefreshAccessToken() (*models.Credentials, error)

func (*Border0API) Request

func (a *Border0API) Request(method string, url string, target interface{}, data interface{}, requireAccessToken bool) error

func (*Border0API) RequestAny

func (a *Border0API) RequestAny(method string, url string, target interface{}, body *bytes.Buffer, contentType string, requireAccessToken bool) error

func (*Border0API) ServerOrgCertificate

func (a *Border0API) ServerOrgCertificate(ctx context.Context, name string, csr []byte) ([]byte, error)

func (*Border0API) SignSSHKey

func (a *Border0API) SignSSHKey(ctx context.Context, socketID string, key []byte) (string, string, error)

func (*Border0API) SignSshOrgCertificate

func (a *Border0API) SignSshOrgCertificate(ctx context.Context, socketID, sessionID, userEmail string, ticket, publicKey []byte) ([]byte, error)

func (*Border0API) StartRefreshAccessTokenJob

func (a *Border0API) StartRefreshAccessTokenJob(ctx context.Context)

func (*Border0API) UpdateSession

func (a *Border0API) UpdateSession(update models.SessionUpdate) (err error)

func (*Border0API) UpdateSocket

func (a *Border0API) UpdateSocket(ctx context.Context, socketID string, socket models.Socket) error

func (*Border0API) UploadRecording

func (a *Border0API) UploadRecording(content []byte, socketID, sessionKey, recordingID string) error

func (*Border0API) Whoami

func (a *Border0API) Whoami(ctx context.Context) (map[string]any, error)

func (*Border0API) With

func (a *Border0API) With(opt APIOption) *Border0API

type ErrorMessage

type ErrorMessage struct {
	ErrorMessage string `json:"error_message,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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