api

package
v0.0.0-...-4ceb61e Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var APIImpl = (*MysocketAPI)(nil)
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrUnauthorized = errors.New("unauthorized")

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)

	GetAccessToken() string
}

type APIOption

type APIOption func(*MysocketAPI)

func WithAccessToken

func WithAccessToken(accessToken string) APIOption

func WithVersion

func WithVersion(version string) APIOption

type ErrorMessage

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

type MysocketAPI

type MysocketAPI struct {
	AccessToken string
	Version     string
}

func NewAPI

func NewAPI(opts ...APIOption) *MysocketAPI

func (*MysocketAPI) AttachPolicies

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

func (*MysocketAPI) CreateSocket

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

func (*MysocketAPI) CreateTunnel

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

func (*MysocketAPI) DeleteSocket

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

func (*MysocketAPI) DetachPolicies

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

func (*MysocketAPI) GetAccessToken

func (a *MysocketAPI) GetAccessToken() string

func (*MysocketAPI) GetOrganizationInfo

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

func (*MysocketAPI) GetPoliciesBySocketID

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

func (*MysocketAPI) GetPolicyByName

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

func (*MysocketAPI) GetSocket

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

func (*MysocketAPI) GetSockets

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

func (*MysocketAPI) GetTunnel

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

func (*MysocketAPI) Login

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

func (*MysocketAPI) Request

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

func (*MysocketAPI) UpdateSocket

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

func (*MysocketAPI) With

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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