apiv2

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 47 Imported by: 0

Documentation

Overview

Package apiv2 provides API endpoints for the application.

Package apiv2 provides API endpoints for the application.

Package apiv2 provides API endpoints for the application.

Package apiv2 provides API endpoints for the application.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCredentials = errors.New("no credentials presented")

ErrNoCredentials means nothing was presented to authenticate with, as opposed to something presented and rejected. On endpoints serving anonymous callers the first answers normally and the second is an expired token that needs a 401 to refresh.

Functions

func MetricsHandler added in v1.7.10

func MetricsHandler() http.Handler

MetricsHandler serves the Prometheus exposition format for everything registered on the default registry, the gRPC server metrics included.

Types

type API

API is the grpc server for the v2 api. It implements all four services, which are split for grouping rather than to be deployed apart: one process, one gateway mux, one set of interceptors.

func New

func New(db *gorm.DB) *API

New creates a new API and assigns the given db and a logger

func (*API) AddBookmark

AddBookmark adds a new bookmark.

func (*API) CreateInfoPage added in v1.8.0

func (a *API) CreateInfoPage(ctx context.Context, req *protobuf.CreateInfoPageRequest) (*protobuf.InfoPage, error)

CreateInfoPage creates a page reachable at /{slug} immediately, without a redeploy.

func (*API) CreateIntegration added in v1.8.1

func (*API) CreateUser added in v1.8.0

func (a *API) CreateUser(ctx context.Context, req *protobuf.CreateUserRequest) (*protobuf.UserSummary, error)

CreateUser creates a lecturer account and emails an invitation to set a password.

func (*API) DeleteBookmark

func (a *API) DeleteBookmark(ctx context.Context, req *protobuf.DeleteBookmarkRequest) (*emptypb.Empty, error)

DeleteBookmark deletes a bookmark.

func (*API) DeleteInfoPage added in v1.8.0

func (a *API) DeleteInfoPage(ctx context.Context, req *protobuf.DeleteInfoPageRequest) (*emptypb.Empty, error)

DeleteInfoPage deletes an info page; its route stops resolving immediately.

func (*API) DeleteMaintenanceEmailFailure added in v1.8.1

func (a *API) DeleteMaintenanceEmailFailure(ctx context.Context, req *protobuf.DeleteMaintenanceEmailFailureRequest) (*emptypb.Empty, error)

DeleteMaintenanceEmailFailure dismisses a failed email. It is not retried afterwards.

func (*API) DeleteMaintenanceTranscodingFailure added in v1.8.1

func (a *API) DeleteMaintenanceTranscodingFailure(ctx context.Context, req *protobuf.DeleteMaintenanceTranscodingFailureRequest) (*emptypb.Empty, error)

DeleteMaintenanceTranscodingFailure dismisses a recorded failure. It does not retry the transcode; a stream stuck this way is fixed the way it always has been.

func (*API) DeleteRunner added in v1.8.0

func (a *API) DeleteRunner(ctx context.Context, req *protobuf.DeleteRunnerRequest) (*emptypb.Empty, error)

DeleteRunner removes a runner's registration. Not a way to stop one: a runner still running re-registers on its next heartbeat.

func (*API) DeleteUser added in v1.8.0

func (a *API) DeleteUser(ctx context.Context, req *protobuf.DeleteUserRequest) (*emptypb.Empty, error)

DeleteUser deletes an account.

func (*API) DeleteWorker added in v1.8.1

func (a *API) DeleteWorker(ctx context.Context, req *protobuf.DeleteWorkerRequest) (*emptypb.Empty, error)

DeleteWorker removes a worker's registration. Not a way to stop one: a worker still running re-registers on its next heartbeat.

func (*API) ExportPersonalData

func (a *API) ExportPersonalData(ctx context.Context, req *emptypb.Empty) (*protobuf.ExportPersonalDataResponse, error)

ExportPersonalData exports the personal data of the current user.

func (*API) GenerateMaintenanceThumbnails added in v1.8.1

func (a *API) GenerateMaintenanceThumbnails(ctx context.Context, req *emptypb.Empty) (*protobuf.MaintenanceThumbnailStatus, error)

GenerateMaintenanceThumbnails starts a background job that requests a fresh thumbnail for every VoD file. A run already in progress is left alone: the old page disabled its button while running, but nothing stops two admins opening the page at once, so the handler itself has to be the guard.

func (*API) GetBookmarks

GetBookmarks retrieves bookmarks by stream ID.

func (*API) GetCourseBySlug

GetCourseBySlug retrieves a course by its slug, year, and term.

func (*API) GetFrontendConfig added in v1.7.10

func (a *API) GetFrontendConfig(ctx context.Context, req *emptypb.Empty) (*protobuf.GetFrontendConfigResponse, error)

GetFrontendConfig returns what the frontend needs to render its shell: branding, version and footer links. Public, because the shell renders before anyone signs in. Nothing in it is per-user.

func (*API) GetInfoPage added in v1.8.0

GetInfoPage returns an info page as HTML, rendered and sanitised here so that bluemonday stays the only thing deciding what may appear in the document.

func (*API) GetLiveCourses

func (a *API) GetLiveCourses(ctx context.Context, req *emptypb.Empty) (*protobuf.GetLiveCoursesResponse, error)

GetLiveCourses retrieves the currently live courses and their streams.

func (*API) GetLoginOptions added in v1.7.10

func (a *API) GetLoginOptions(ctx context.Context, req *emptypb.Empty) (*protobuf.GetLoginOptionsResponse, error)

GetLoginOptions reports which login methods this deployment offers, so that a client can render the right controls before anyone has authenticated.

func (*API) GetMaintenanceThumbnailStatus added in v1.8.1

func (a *API) GetMaintenanceThumbnailStatus(ctx context.Context, req *emptypb.Empty) (*protobuf.MaintenanceThumbnailStatus, error)

GetMaintenanceThumbnailStatus reports the state of the background regeneration job, for the page to poll instead of blocking on a request that can run for a long time.

func (*API) GetNotifications

func (a *API) GetNotifications(ctx context.Context, req *emptypb.Empty) (*protobuf.GetNotificationsResponse, error)

GetNotifications retrieves notifications for the current user.

func (*API) GetPinForCourse

GetPinForCourse checks if the user has pinned the course.

func (*API) GetPinnedCourses

func (a *API) GetPinnedCourses(ctx context.Context, req *emptypb.Empty) (*protobuf.GetPinnedCoursesResponse, error)

GetPinnedCourses retrieves the pinned courses for a user.

func (*API) GetProgressBatch

GetProgressBatch returns a batch of watch progresses for a list of streams for the current user

func (*API) GetPublicCourses

GetPublicCourses retrieves the public courses for a given semester.

func (*API) GetSemesters

func (a *API) GetSemesters(ctx context.Context, req *emptypb.Empty) (*protobuf.GetSemestersResponse, error)

GetSemesters retrieves all available semesters and the current semester.

func (*API) GetServerNotifications

func (a *API) GetServerNotifications(ctx context.Context, req *emptypb.Empty) (*protobuf.GetServerNotificationsResponse, error)

GetServerNotifications retrieves current server notifications.

func (*API) GetStream

func (a *API) GetStream(ctx context.Context, req *protobuf.GetStreamRequest) (*protobuf.CourseStream, error)

GetStream returns a stream by its ID including the course and lecture hall

func (*API) GetStreamPlaylist

GetStreamPlaylist returns the playlist for a stream

func (*API) GetSubtitles

func (a *API) GetSubtitles(ctx context.Context, req *protobuf.GetSubtitlesRequest) (*httpbody.HttpBody, error)

GetSubtitles returns the subtitles for a stream in a specific language

func (*API) GetThumbs

func (a *API) GetThumbs(ctx context.Context, req *protobuf.GetThumbsRequest) (*httpbody.HttpBody, error)

GetThumbs returns the thumbnails for a stream

func (*API) GetUser

func (a *API) GetUser(ctx context.Context, req *emptypb.Empty) (*protobuf.GetUserResponse, error)

GetUser retrieves the current user based on the context. It returns a GetUserResponse or an error if one occurs.

func (*API) GetUserCourses

GetUserCourses retrieves the courses for a user for a given semester.

func (*API) GetVideoSections

GetVideoSections returns a list of video sections for a stream

func (*API) HealthCheck

func (a *API) HealthCheck(ctx context.Context, req *emptypb.Empty) (*protobuf.HealthCheckResponse, error)

HealthCheck returns ok

func (*API) ListInfoPages added in v1.8.0

func (a *API) ListInfoPages(ctx context.Context, req *emptypb.Empty) (*protobuf.ListInfoPagesResponse, error)

ListInfoPages lists every info page's slug and title, without its content: enough for a client to know a page exists before asking getInfoPage for it.

func (*API) ListInfoPagesAdmin added in v1.8.0

func (a *API) ListInfoPagesAdmin(ctx context.Context, req *emptypb.Empty) (*protobuf.ListInfoPagesAdminResponse, error)

ListInfoPagesAdmin lists every info page with its raw content, for editing.

func (*API) ListIntegrations added in v1.8.1

func (a *API) ListIntegrations(ctx context.Context, req *emptypb.Empty) (*protobuf.ListIntegrationsResponse, error)

func (*API) ListMaintenanceCronJobs added in v1.8.1

func (a *API) ListMaintenanceCronJobs(ctx context.Context, req *emptypb.Empty) (*protobuf.ListMaintenanceCronJobsResponse, error)

ListMaintenanceCronJobs lists the jobs the scheduler knows by name, for the page to offer as choices before triggering one manually.

func (*API) ListMaintenanceEmailFailures added in v1.8.1

func (a *API) ListMaintenanceEmailFailures(ctx context.Context, req *emptypb.Empty) (*protobuf.ListMaintenanceEmailFailuresResponse, error)

ListMaintenanceEmailFailures lists every email that has exhausted its retries or is still failing, so an administrator can see why and dismiss the ones that are stale.

func (*API) ListMaintenanceTranscodingFailures added in v1.8.1

func (a *API) ListMaintenanceTranscodingFailures(ctx context.Context, req *emptypb.Empty) (*protobuf.ListMaintenanceTranscodingFailuresResponse, error)

ListMaintenanceTranscodingFailures lists every recorded transcoding failure.

func (*API) ListRunners added in v1.8.0

func (a *API) ListRunners(ctx context.Context, req *emptypb.Empty) (*protobuf.ListRunnersResponse, error)

ListRunners returns every registered runner. Both endpoints here are gated on PermAdministerServer by their policy in services.go.

func (*API) ListStaff added in v1.8.0

func (a *API) ListStaff(ctx context.Context, req *emptypb.Empty) (*protobuf.ListUsersResponse, error)

ListStaff returns the administrators and lecturers, with contact details unmasked.

That SearchUsers masks and this does not is inherited from the page they replace, and kept deliberately: what an administrator may see is a policy decision, not a port.

func (*API) ListWorkers added in v1.8.1

func (a *API) ListWorkers(ctx context.Context, req *emptypb.Empty) (*protobuf.ListWorkersResponse, error)

ListWorkers returns every registered worker, plus the token a new worker authenticates its registration with. Both endpoints here are gated on PermAdministerServer by their policy in services.go.

func (*API) PinCourse

PinCourse pins or unpins a course for the user.

func (*API) Proxy

func (a *API) Proxy() func(c *gin.Context)

Proxy returns a gin handler that proxies requests to the grpc gateway server

func (*API) ResetPassword

ResetPassword resets the password for the user with the given username.

func (*API) RevokeIntegrationKey added in v1.8.1

func (a *API) RevokeIntegrationKey(ctx context.Context, req *protobuf.RevokeIntegrationKeyRequest) (*emptypb.Empty, error)

func (*API) RotateIntegrationKey added in v1.8.1

func (*API) Run

func (a *API) Run(lis net.Listener) error

Run starts the grpc server on port 12544 and the grpc gateway on ::8081/api/v2

func (*API) RunMaintenanceCronJob added in v1.8.1

func (a *API) RunMaintenanceCronJob(ctx context.Context, req *protobuf.RunMaintenanceCronJobRequest) (*emptypb.Empty, error)

RunMaintenanceCronJob executes a registered job immediately. Unlike the v1 route, which silently ignored a name it did not recognize, this refuses one — the page only ever offers names from ListMaintenanceCronJobs, so a mismatch means the scheduler changed underneath an open tab, and the caller should be told rather than shown a false success.

func (*API) SearchUsers added in v1.8.0

SearchUsers searches every account, with contact details masked.

func (*API) UpdateBookmark

UpdateBookmark updates an existing bookmark.

func (*API) UpdateInfoPage added in v1.8.0

func (a *API) UpdateInfoPage(ctx context.Context, req *protobuf.UpdateInfoPageRequest) (*protobuf.InfoPage, error)

UpdateInfoPage replaces an info page's slug, title and content.

func (*API) UpdateProgress

func (a *API) UpdateProgress(ctx context.Context, req *protobuf.UpdateProgressRequest) (*protobuf.StreamProgress, error)

UpdateProgress updates the watch progress for a stream

func (*API) UpdateUserRole added in v1.8.0

func (a *API) UpdateUserRole(ctx context.Context, req *protobuf.UpdateUserRoleRequest) (*protobuf.UserSummary, error)

UpdateUserRole sets an account's role.

func (*API) UpdateUserSettings

UpdateUserSettings updates the profile settings for the current user.

type CourseRequest added in v1.8.0

type CourseRequest interface {
	GetCourseId() uint32
}

CourseRequest is the request of an RPC that acts on one course.

type StreamRequest

type StreamRequest interface {
	GetStreamId() uint32
}

Jump to

Keyboard shortcuts

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