Documentation ¶
Index ¶
- Constants
- Variables
- func BackendFromAgentRef(ctx context.Context, api *API, tx pgx.Tx) (*store.BackendState, error)
- func BackendFromQuery(ctx context.Context, api *API, tx pgx.Tx) (*store.BackendState, error)
- func ContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func Endpoint(handler ResourceHandler) echo.HandlerFunc
- func ErrorHandler(next echo.HandlerFunc) echo.HandlerFunc
- func ErrorInvalidCredentials(c echo.Context) error
- func ErrorValidationFailed(c echo.Context, err store.ValidationError) error
- func HTMLError(c echo.Context, status int, title, message string) error
- func Init(e *echo.Echo) error
- func InternalMeetingID(id string) string
- func MeetingFromRequest(ctx context.Context, api *API, tx pgx.Tx) (*store.MeetingState, error)
- func NewAPIEndpointsSchema() map[string]oa.Path
- func NewAPIResponses() map[string]oa.Response
- func NewAPISchemas() map[string]oa.Schema
- func NewAPISecuritySchemes() map[string]oa.SecurityScheme
- func NewAPISpec() *oa.Spec
- func NewAgentAPISchema() map[string]oa.Path
- func NewBackendsAPISchema() map[string]oa.Path
- func NewCommandsAPISchema() map[string]oa.Path
- func NewCtrlEndpointsSchema() map[string]oa.Path
- func NewErrorSchema() oa.Schema
- func NewFrontendsAPISchema() map[string]oa.Path
- func NewMeetingsAPISchema() map[string]oa.Path
- func NewMetaEndpointsSchema() map[string]oa.Path
- func NewNotFoundErrorSchema() oa.Schema
- func NewRPCRequestSchema() oa.Schema
- func NewRPCResponseSchema() oa.Schema
- func NewRecordingsImportAPISchema() map[string]oa.Path
- func NewServerErrorSchema() oa.Schema
- func NewValidationErrorSchema() oa.Schema
- type API
- type AgentResourceClient
- type BackendResourceClient
- type Client
- type CommandResourceClient
- type FrontendResourceClient
- type MeetingAddAttendeeRequest
- type MeetingRemoveAttendeeRequest
- type MeetingResourceClient
- type MeetingSetRunningRequest
- type MeetingStateResetRequest
- type RPCHandler
- func (rpc *RPCHandler) MeetingAddAttendee(ctx context.Context, req *MeetingAddAttendeeRequest) (RPCResult, error)
- func (rpc *RPCHandler) MeetingRemoveAttendee(ctx context.Context, req *MeetingRemoveAttendeeRequest) (RPCResult, error)
- func (rpc *RPCHandler) MeetingSetRunning(ctx context.Context, req *MeetingSetRunningRequest) (RPCResult, error)
- func (rpc *RPCHandler) MeetingStateReset(ctx context.Context, req *MeetingStateResetRequest) (RPCResult, error)
- type RPCPayload
- type RPCRequest
- func NewRPCRequest(action string, params interface{}) *RPCRequest
- func RPCMeetingAddAttendee(params *MeetingAddAttendeeRequest) *RPCRequest
- func RPCMeetingRemoveAttendee(params *MeetingRemoveAttendeeRequest) *RPCRequest
- func RPCMeetingSetRunning(params *MeetingSetRunningRequest) *RPCRequest
- func RPCMeetingStateReset(params *MeetingStateResetRequest) *RPCRequest
- type RPCResponse
- type RPCResult
- type Resource
- type ResourceHandler
- type ResourceMiddleware
- type ServerError
- type StatusResponse
Constants ¶
const ( RPCStatusOK = "ok" RPCStatusError = "error" )
RPC status
const ( ActionMeetingStateReset = "meeting_state_reset" ActionMeetingSetRunning = "meeting_set_running" ActionMeetingAddAttendee = "meeting_add_attendee" ActionMeetingRemoveAttendee = "meeting_remove_attendee" )
Actions
const (
CookieKeyProtected = "_b3s_protected"
)
Cookies
const (
// PrefixInternalID indicates that the ID is an 'internal' ID.
PrefixInternalID = "internal:"
)
Variables ¶
var ( ErrInvalidAction = errors.New("the requsted RPC action is unknown") ErrInvalidBackend = errors.New("backend not associated with meeting") )
Errors
var ErrCommandNotAllowed = store.ValidationError{ "action": []string{"this action is not allowed"}, }
ErrCommandNotAllowed is a validation error
var ErrNotFound = errors.New("the resource could not be found (404)")
ErrNotFound is the error when a response is a 404
var ( ErrRequestBodyRequired = echo.NewHTTPError( http.StatusBadRequest, "the request must contain content of a metadata.xml") )
Errors
var ( // ReMatchRecordID will match the recordID in an URL with // the pattern /.../<hash>-<number>/.. ReMatchRecordID = regexp.MustCompile(`\/([a-f0-9]+-\d+)`) )
Regular Expressions
var ResourceAgentBackend = &Resource{ List: RequireScope( auth.ScopeNode, )(apiAgentBackendShow), }
ResourceAgentBackend is the resource for retrieving the currently with the agent associated backend
var ResourceAgentHeartbeat = &Resource{ Create: RequireScope( auth.ScopeNode, )(apiAgentHeartbeatCreate), }
ResourceAgentHeartbeat is the resource for receiving an agent heartbeat
var ResourceAgentRPC = &Resource{ Create: RequireScope( auth.ScopeNode, )(func(ctx context.Context, api *API) error { rpc := &RPCRequest{} if err := api.Bind(rpc); err != nil { return api.JSON(http.StatusBadRequest, RPCError(err)) } tx, err := api.Conn.Begin(ctx) if err != nil { return err } defer tx.Rollback(ctx) backend, err := BackendFromAgentRef(ctx, api, tx) if err != nil { return err } if backend == nil { return echo.ErrForbidden } tx.Rollback(ctx) res := rpc.Dispatch(ctx, &RPCHandler{ AgentRef: api.Ref, Backend: backend, Conn: api.Conn, }) return api.JSON(http.StatusOK, res) }), }
ResourceAgentRPC is the API resource for creating RPC requests
var ResourceBackends = &Resource{ List: RequireScope( auth.ScopeAdmin, )(apiBackendsList), Create: RequireScope( auth.ScopeAdmin, auth.ScopeNode, )(apiBackendCreate), Show: RequireScope( auth.ScopeAdmin, auth.ScopeNode, )(apiBackendShow), Update: RequireScope( auth.ScopeAdmin, auth.ScopeNode, )(apiBackendUpdate), Destroy: RequireScope( auth.ScopeAdmin, )(apiBackendDestroy), }
ResourceBackends is a restful group for backend endpoints
var ResourceCommands = &Resource{ List: RequireScope( auth.ScopeAdmin, )(apiCommandList), Show: RequireScope( auth.ScopeAdmin, )(apiCommandShow), Create: RequireScope( auth.ScopeAdmin, )(apiCommandCreate), }
ResourceCommands bundles read and create operations for manipulating the command queue.
var ResourceCtlMigrate = &Resource{ Create: RequireScope( auth.ScopeAdmin, )(apiCtlMigrate), }
ResourceCtlMigrate is a restful group for applying migrations
var ResourceFrontends = &Resource{ List: RequireScope( auth.ScopeAdmin, auth.ScopeUser, )(apiFrontendsList), Create: RequireScope( auth.ScopeAdmin, )(apiFrontendCreate), Show: RequireScope( auth.ScopeAdmin, auth.ScopeUser, )(apiFrontendShow), Update: RequireScope( auth.ScopeAdmin, auth.ScopeUser, )(apiFrontendUpdate), Destroy: RequireScope( auth.ScopeAdmin, )(apiFrontendDestroy), }
ResourceFrontends is a restful group for frontend endpoints
var ResourceMeetings = &Resource{ List: RequireScope( auth.ScopeAdmin, )(apiMeetingsList), Show: RequireScope( auth.ScopeAdmin, auth.ScopeNode, )(apiMeetingShow), Update: RequireScope( auth.ScopeAdmin, auth.ScopeNode, )(apiMeetingUpdate), Destroy: RequireScope( auth.ScopeAdmin, auth.ScopeNode, )(apiMeetingDestroy), }
ResourceMeetings is a restful group for meetings
var ResourceRecordingsImport = &Resource{ Create: RequireScope( auth.ScopeAdmin, auth.ScopeNode, )(apiRecordingsImport), }
ResourceRecordingsImport is the recordings import api resource
Functions ¶
func BackendFromAgentRef ¶
BackendFromAgentRef resolves the backend attached to the current node agent.
func BackendFromQuery ¶
BackendFromQuery resolves the backend, either identified by ID or by hostname. The hostname must be an exact match.
func ContextMiddleware ¶
func ContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc
ContextMiddleware initializes the context with auth information and a database connection.
func Endpoint ¶
func Endpoint(handler ResourceHandler) echo.HandlerFunc
Endpoint wrapps a handler function and provides the request context and sets the correct APIContext type.
func ErrorHandler ¶
func ErrorHandler(next echo.HandlerFunc) echo.HandlerFunc
ErrorHandler intercepts well known errors and renders a response.
func ErrorInvalidCredentials ¶
func ErrorInvalidCredentials(c echo.Context) error
ErrorInvalidCredentials will create an API response for an unauthorized request
func ErrorValidationFailed ¶
func ErrorValidationFailed(c echo.Context, err store.ValidationError) error
ErrorValidationFailed creates an API response when validating a resource failed.
func Init ¶
func Init(e *echo.Echo) error
Init sets up a group with authentication for a restful management interface.
func InternalMeetingID ¶
InternalMeetingID returns the internal id for accessing via the API.
func MeetingFromRequest ¶
MeetingFromRequest resolves the current meeting
func NewAPIEndpointsSchema ¶
NewAPIEndpointsSchema combines all the endpoints schemas
func NewAPIResponses ¶
NewAPIResponses creates all default (error) responses
func NewAPISchemas ¶
NewAPISchemas creates the schemas we use in the API
func NewAPISecuritySchemes ¶
func NewAPISecuritySchemes() map[string]oa.SecurityScheme
NewAPISecuritySchemes creates the default security schemes
func NewAgentAPISchema ¶
NewAgentAPISchema creates the API schema for the node agent
func NewBackendsAPISchema ¶
NewBackendsAPISchema generates the schema for backend related endpoint.
func NewCommandsAPISchema ¶
NewCommandsAPISchema create the endpoint schema for commands
func NewCtrlEndpointsSchema ¶
NewCtrlEndpointsSchema creates the api ctrl endpoints
func NewFrontendsAPISchema ¶
NewFrontendsAPISchema generates the endpoints for the frontend
func NewMeetingsAPISchema ¶
NewMeetingsAPISchema create the endpoint schema for meetings
func NewMetaEndpointsSchema ¶
NewMetaEndpointsSchema creates the api meta endpoints
func NewNotFoundErrorSchema ¶
NewNotFoundErrorSchema creates a not found error object schema
func NewRPCRequestSchema ¶
NewRPCRequestSchema creates the RPCRequest schema
func NewRPCResponseSchema ¶
NewRPCResponseSchema creates the RPC response schema
func NewRecordingsImportAPISchema ¶
NewRecordingsImportAPISchema creates the api schema for accepting a BBB recodrings metadata document
func NewServerErrorSchema ¶
NewServerErrorSchema creates a fallback error schema with only contains the error message.
func NewValidationErrorSchema ¶
NewValidationErrorSchema creates the validation error schema
Types ¶
type API ¶
type API struct { // Authorization Scopes []string Ref string // Database Conn *pgxpool.Conn echo.Context }
API extends the context and provides methods for handling the current user.
type AgentResourceClient ¶
type AgentResourceClient interface { AgentHeartbeatCreate( ctx context.Context, ) (*store.AgentHeartbeat, error) AgentBackendRetrieve( ctx context.Context, ) (*store.BackendState, error) AgentRPC( ctx context.Context, req *RPCRequest, ) (RPCResult, error) }
AgentResourceClient defines node agent specific methods.
type BackendResourceClient ¶
type BackendResourceClient interface { BackendsList( ctx context.Context, query ...url.Values, ) ([]*store.BackendState, error) BackendRetrieve( ctx context.Context, id string, ) (*store.BackendState, error) BackendCreate( ctx context.Context, backend *store.BackendState, ) (*store.BackendState, error) BackendUpdate( ctx context.Context, backend *store.BackendState, ) (*store.BackendState, error) BackendUpdateRaw( ctx context.Context, id string, payload []byte, ) (*store.BackendState, error) BackendDelete( ctx context.Context, backend *store.BackendState, opts ...url.Values, ) (*store.BackendState, error) }
BackendResourceClient defines methods for using the backends api resource
type Client ¶
type Client interface { Status(ctx context.Context) (*StatusResponse, error) FrontendResourceClient BackendResourceClient MeetingResourceClient CommandResourceClient AgentResourceClient }
Client is an interface to the api API.
type CommandResourceClient ¶
type CommandResourceClient interface { BackendMeetingsEnd( ctx context.Context, backendID string, ) (*store.Command, error) CommandCreate( ctx context.Context, cmd *store.Command, ) (*store.Command, error) CommandRetrieve( ctx context.Context, id string, ) (*store.Command, error) // Control commands CtrlMigrate( ctx context.Context, ) (*schema.Status, error) }
CommandResourceClient defines methods for creating and polling commands
type FrontendResourceClient ¶
type FrontendResourceClient interface { FrontendsList( ctx context.Context, query ...url.Values, ) ([]*store.FrontendState, error) FrontendRetrieve( ctx context.Context, id string, ) (*store.FrontendState, error) FrontendCreate( ctx context.Context, frontend *store.FrontendState, ) (*store.FrontendState, error) FrontendUpdate( ctx context.Context, frontend *store.FrontendState, ) (*store.FrontendState, error) FrontendUpdateRaw( ctx context.Context, id string, payload []byte, ) (*store.FrontendState, error) FrontendDelete( ctx context.Context, frontend *store.FrontendState, ) (*store.FrontendState, error) }
FrontendResourceClient defines methods for using the frontends resource of the api
type MeetingAddAttendeeRequest ¶
type MeetingAddAttendeeRequest struct { InternalMeetingID string `json:"internal_meeting_id"` Attendee *bbb.Attendee `json:"attendee"` }
MeetingAddAttendeeRequest will add an attedee to the attendees list of a meeting
type MeetingRemoveAttendeeRequest ¶
type MeetingRemoveAttendeeRequest struct { InternalMeetingID string `json:"internal_meeting_id"` InternalUserID string `json:"internal_user_id"` }
MeetingRemoveAttendeeRequest will remove an attendee from a meeting identified by the internal user id
type MeetingResourceClient ¶
type MeetingResourceClient interface { BackendMeetingsList( ctx context.Context, backendID string, query ...url.Values, ) ([]*store.MeetingState, error) MeetingsList( ctx context.Context, query ...url.Values, ) ([]*store.MeetingState, error) MeetingRetrieve( ctx context.Context, id string, ) (*store.MeetingState, error) MeetingUpdateRaw( ctx context.Context, id string, payload []byte, ) (*store.MeetingState, error) MeetingUpdate( ctx context.Context, meeting *store.MeetingState, ) (*store.MeetingState, error) MeetingDelete( ctx context.Context, id string, ) (*store.MeetingState, error) }
MeetingResourceClient defines methods for accessing the meetings api resource
type MeetingSetRunningRequest ¶
type MeetingSetRunningRequest struct { InternalMeetingID string `json:"internal_meeting_id"` Running bool `json:"running"` }
MeetingSetRunningRequest contains a meetingID
type MeetingStateResetRequest ¶
type MeetingStateResetRequest struct {
InternalMeetingID string `json:"internal_meeting_id"`
}
MeetingStateResetRequest contains a meetingID
type RPCHandler ¶
type RPCHandler struct { AgentRef string Backend *store.BackendState Conn *pgxpool.Conn }
RPCHandler contains a database connection
func (*RPCHandler) MeetingAddAttendee ¶
func (rpc *RPCHandler) MeetingAddAttendee( ctx context.Context, req *MeetingAddAttendeeRequest, ) (RPCResult, error)
MeetingAddAttendee insers an attendee into the list
func (*RPCHandler) MeetingRemoveAttendee ¶
func (rpc *RPCHandler) MeetingRemoveAttendee( ctx context.Context, req *MeetingRemoveAttendeeRequest, ) (RPCResult, error)
MeetingRemoveAttendee removes an attendee from the list
func (*RPCHandler) MeetingSetRunning ¶
func (rpc *RPCHandler) MeetingSetRunning( ctx context.Context, req *MeetingSetRunningRequest, ) (RPCResult, error)
MeetingSetRunning sets the meeting is running flag for a meeting. The meeting will be awaited.
func (*RPCHandler) MeetingStateReset ¶
func (rpc *RPCHandler) MeetingStateReset( ctx context.Context, req *MeetingStateResetRequest, ) (RPCResult, error)
MeetingStateReset clears the attendees list and sets the running flag to false
type RPCPayload ¶
type RPCPayload json.RawMessage
RPCPayload is a json raw message which then can be decoded into the actual request
type RPCRequest ¶
type RPCRequest struct { Action string `json:"action"` Payload RPCPayload `json:"payload"` }
RPCRequest is an incomming request with an action and a payload.
func NewRPCRequest ¶
func NewRPCRequest( action string, params interface{}, ) *RPCRequest
NewRPCRequest creates a new RPC request
func RPCMeetingAddAttendee ¶
func RPCMeetingAddAttendee(params *MeetingAddAttendeeRequest) *RPCRequest
RPCMeetingAddAttendee creates a new add attendee request
func RPCMeetingRemoveAttendee ¶
func RPCMeetingRemoveAttendee(params *MeetingRemoveAttendeeRequest) *RPCRequest
RPCMeetingRemoveAttendee creates a remove attendee request
func RPCMeetingSetRunning ¶
func RPCMeetingSetRunning(params *MeetingSetRunningRequest) *RPCRequest
RPCMeetingSetRunning creates a set running request
func RPCMeetingStateReset ¶
func RPCMeetingStateReset(params *MeetingStateResetRequest) *RPCRequest
RPCMeetingStateReset creates an meeting state reset request
func (*RPCRequest) Dispatch ¶
func (rpc *RPCRequest) Dispatch( ctx context.Context, handler *RPCHandler, ) *RPCResponse
Dispatch will invoke the RPC handlers with the decoded request payload.
type RPCResponse ¶
RPCResponse is the result of an RPC request
func RPCSuccess ¶
func RPCSuccess(result RPCResult) *RPCResponse
RPCSuccess is a successful RPC response
type Resource ¶
type Resource struct { List ResourceHandler Show ResourceHandler Create ResourceHandler Update ResourceHandler Destroy ResourceHandler }
Resource is a restful handler group
type ResourceHandler ¶
ResourceHandler is a handler function for API endpoints
type ResourceMiddleware ¶
type ResourceMiddleware func(next ResourceHandler) ResourceHandler
ResourceMiddleware is a function returning a HandlerFunction
func RequireScope ¶
func RequireScope(scopes ...string) ResourceMiddleware
RequireScope creates a middleware to ensure the presence of at least one required scope.
type ServerError ¶
type ServerError map[string]interface{}
ServerError will contain the decoded json body when the response status was not OK or Accepted
func (ServerError) Error ¶
func (err ServerError) Error() string
Error implements the error interface
type StatusResponse ¶
type StatusResponse struct { Version string `json:"version" doc:"The current b3scale server version."` Build string `json:"build" doc:"Build identifier of the server."` API string `json:"api" doc:"The API version." example:"v1"` AccountRef string `json:"account_ref" doc:"The currently authenticated subject."` IsAdmin bool `json:"is_admin" doc:"True if the subject has admin privileges."` Database *schema.Status `json:"database" doc:"Status of the database" api:"SchemaStatus"` }
StatusResponse returns information about the API implementation and the current user.