client

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: AGPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backends

func Backends(id ...string) string

Backends creates a backend resource string

func Commands

func Commands(id ...string) string

Commands creates a new commands resource

func ErrRequestFailed

func ErrRequestFailed(res *http.Response) api.ServerError

ErrRequestFailed creates an APIError from the HTTP response.

func Frontends

func Frontends(id ...string) string

Frontends creates a frontend resource

func Meetings

func Meetings(id ...string) string

Meetings creates a meetings resource

func Resource

func Resource(res string, id []string) string

Resource creates a resource identifier

Types

type Client

type Client struct {
	Host        string
	AccessToken string

	*http.Client
}

Client implements the default client for v1

func New

func New(host, token string) *Client

New initializes the client

func (*Client) AgentBackendRetrieve

func (c *Client) AgentBackendRetrieve(
	ctx context.Context,
) (*store.BackendState, error)

AgentBackendRetrieve fetches the currently registered backend

func (*Client) AgentHeartbeatCreate

func (c *Client) AgentHeartbeatCreate(
	ctx context.Context,
) (*store.AgentHeartbeat, error)

AgentHeartbeatCreate creates a heartbeat for a backend

func (*Client) AgentRPC

func (c *Client) AgentRPC(
	ctx context.Context,
	req *api.RPCRequest,
) (api.RPCResult, error)

AgentRPC makes an rpc call

func (*Client) AuthorizeRequest

func (c *Client) AuthorizeRequest(req *http.Request) *http.Request

AuthorizeRequest will add a http Authorization header with the access token to the request

func (*Client) BackendCreate

func (c *Client) BackendCreate(
	ctx context.Context,
	backend *store.BackendState,
) (*store.BackendState, error)

BackendCreate creates a new backend on the server

func (*Client) BackendDelete

func (c *Client) BackendDelete(
	ctx context.Context,
	backend *store.BackendState,
	opts ...url.Values,
) (*store.BackendState, error)

BackendDelete removes a backend from the cluster

func (*Client) BackendMeetingsEnd

func (c *Client) BackendMeetingsEnd(
	ctx context.Context,
	backendID string,
) (*store.Command, error)

BackendMeetingsEnd ends all meetings on a given backend

func (*Client) BackendMeetingsList

func (c *Client) BackendMeetingsList(
	ctx context.Context,
	backendID string,
	query ...url.Values,
) ([]*store.MeetingState, error)

BackendMeetingsList retrieves all meetings for a given backend

func (*Client) BackendRetrieve

func (c *Client) BackendRetrieve(
	ctx context.Context,
	id string,
) (*store.BackendState, error)

BackendRetrieve retrieves a single backend by ID.

func (*Client) BackendUpdate

func (c *Client) BackendUpdate(
	ctx context.Context, backend *store.BackendState,
) (*store.BackendState, error)

BackendUpdate updates the backend

func (*Client) BackendUpdateRaw

func (c *Client) BackendUpdateRaw(
	ctx context.Context,
	id string,
	payload []byte,
) (*store.BackendState, error)

BackendUpdateRaw updates an existing backend identified by ID with a raw JSON payload.

func (*Client) BackendsList

func (c *Client) BackendsList(
	ctx context.Context,
	query ...url.Values,
) ([]*store.BackendState, error)

BackendsList retrievs a list of backends from the server

func (*Client) CommandCreate

func (c *Client) CommandCreate(
	ctx context.Context,
	cmd *store.Command,
) (*store.Command, error)

CommandCreate enqueues a command into the cluster's command queue.

func (*Client) CommandRetrieve

func (c *Client) CommandRetrieve(
	ctx context.Context,
	id string,
) (*store.Command, error)

CommandRetrieve gets a single command by ID. Usefull for state polling.

func (*Client) CtrlMigrate

func (c *Client) CtrlMigrate(ctx context.Context) (*schema.Status, error)

CtrlMigrate applies all pending migrations

func (*Client) FrontendCreate

func (c *Client) FrontendCreate(
	ctx context.Context, frontend *store.FrontendState,
) (*store.FrontendState, error)

FrontendCreate POSTs a new frontend to the server

func (*Client) FrontendDelete

func (c *Client) FrontendDelete(
	ctx context.Context,
	frontend *store.FrontendState,
) (*store.FrontendState, error)

FrontendDelete removes a frontend from the cluster.

func (*Client) FrontendRetrieve

func (c *Client) FrontendRetrieve(
	ctx context.Context,
	id string,
) (*store.FrontendState, error)

FrontendRetrieve retrieves a single frontend

func (*Client) FrontendUpdate

func (c *Client) FrontendUpdate(
	ctx context.Context,
	frontend *store.FrontendState,
) (*store.FrontendState, error)

FrontendUpdate PATCHes an already existing frontend.

func (*Client) FrontendUpdateRaw

func (c *Client) FrontendUpdateRaw(
	ctx context.Context,
	id string,
	payload []byte,
) (*store.FrontendState, error)

FrontendUpdateRaw PATCHes an already existing frontend identified by ID using raw payload.

func (*Client) FrontendsList

func (c *Client) FrontendsList(
	ctx context.Context,
	query ...url.Values,
) ([]*store.FrontendState, error)

FrontendsList retrievs a list of frontends

func (*Client) MeetingDelete

func (c *Client) MeetingDelete(
	ctx context.Context,
	id string,
) (*store.MeetingState, error)

MeetingDelete will remove a meeting from the store

func (*Client) MeetingRetrieve

func (c *Client) MeetingRetrieve(
	ctx context.Context,
	id string,
) (*store.MeetingState, error)

MeetingRetrieve will fetch a single meeting by ID

func (*Client) MeetingUpdate

func (c *Client) MeetingUpdate(
	ctx context.Context,
	meeting *store.MeetingState,
) (*store.MeetingState, error)

MeetingUpdate will invoke a patch for an entire meeting

func (*Client) MeetingUpdateRaw

func (c *Client) MeetingUpdateRaw(
	ctx context.Context,
	id string,
	payload []byte,
) (*store.MeetingState, error)

MeetingUpdateRaw will perform a PATCH on a meeting

func (*Client) MeetingsList

func (c *Client) MeetingsList(
	ctx context.Context,
	query ...url.Values,
) ([]*store.MeetingState, error)

MeetingsList retrieves all meetings. Warning: Some scope is required otherwise the request will fail.

func (*Client) Request

func (c *Client) Request(
	ctx context.Context,
	req *Request,
) (*Response, error)

Request creates a new request with context to an API url

func (*Client) Status

func (c *Client) Status(
	ctx context.Context,
) (*api.StatusResponse, error)

Status retrievs the API / server status

type Request

type Request struct {
	Method      string
	Resource    string
	Data        []byte
	Query       url.Values
	ContentType string
}

Request is an API request

func Create

func Create(resource string, data []byte) *Request

Create will make a POST request

func Destroy

func Destroy(resource string, opts ...url.Values) *Request

Destroy will make a DELETE request

func Fetch

func Fetch(resource string, query ...url.Values) *Request

Fetch will create a GET request with optional query params.

func Update

func Update(resource string, data []byte) *Request

Update will make a PATCH request

type Response

type Response http.Response

Response is a http resposne

func (*Response) JSON

func (res *Response) JSON(o interface{}) error

JSON reads the entire body as json

Jump to

Keyboard shortcuts

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