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 ¶
- Variables
- func MetricsHandler() http.Handler
- type API
- func (a *API) AddBookmark(ctx context.Context, req *protobuf.AddBookmarkRequest) (*protobuf.AddBookmarkResponse, error)
- func (a *API) CreateInfoPage(ctx context.Context, req *protobuf.CreateInfoPageRequest) (*protobuf.InfoPage, error)
- func (a *API) CreateUser(ctx context.Context, req *protobuf.CreateUserRequest) (*protobuf.UserSummary, error)
- func (a *API) DeleteBookmark(ctx context.Context, req *protobuf.DeleteBookmarkRequest) (*emptypb.Empty, error)
- func (a *API) DeleteInfoPage(ctx context.Context, req *protobuf.DeleteInfoPageRequest) (*emptypb.Empty, error)
- func (a *API) DeleteRunner(ctx context.Context, req *protobuf.DeleteRunnerRequest) (*emptypb.Empty, error)
- func (a *API) DeleteUser(ctx context.Context, req *protobuf.DeleteUserRequest) (*emptypb.Empty, error)
- func (a *API) ExportPersonalData(ctx context.Context, req *emptypb.Empty) (*protobuf.ExportPersonalDataResponse, error)
- func (a *API) GetBookmarks(ctx context.Context, req *protobuf.GetBookmarksRequest) (*protobuf.GetBookmarksResponse, error)
- func (a *API) GetCourseBySlug(ctx context.Context, req *protobuf.GetCourseBySlugRequest) (*protobuf.GetCourseBySlugResponse, error)
- func (a *API) GetFrontendConfig(ctx context.Context, req *emptypb.Empty) (*protobuf.GetFrontendConfigResponse, error)
- func (a *API) GetInfoPage(ctx context.Context, req *protobuf.GetInfoPageRequest) (*protobuf.GetInfoPageResponse, error)
- func (a *API) GetLiveCourses(ctx context.Context, req *emptypb.Empty) (*protobuf.GetLiveCoursesResponse, error)
- func (a *API) GetLoginOptions(ctx context.Context, req *emptypb.Empty) (*protobuf.GetLoginOptionsResponse, error)
- func (a *API) GetNotifications(ctx context.Context, req *emptypb.Empty) (*protobuf.GetNotificationsResponse, error)
- func (a *API) GetPinForCourse(ctx context.Context, req *protobuf.GetPinForCourseRequest) (*protobuf.GetPinForCourseResponse, error)
- func (a *API) GetPinnedCourses(ctx context.Context, req *emptypb.Empty) (*protobuf.GetPinnedCoursesResponse, error)
- func (a *API) GetProgressBatch(ctx context.Context, req *protobuf.GetProgressBatchRequest) (*protobuf.GetProgressBatchResponse, error)
- func (a *API) GetPublicCourses(ctx context.Context, req *protobuf.GetPublicCoursesRequest) (*protobuf.GetPublicCoursesResponse, error)
- func (a *API) GetSemesters(ctx context.Context, req *emptypb.Empty) (*protobuf.GetSemestersResponse, error)
- func (a *API) GetServerNotifications(ctx context.Context, req *emptypb.Empty) (*protobuf.GetServerNotificationsResponse, error)
- func (a *API) GetStream(ctx context.Context, req *protobuf.GetStreamRequest) (*protobuf.CourseStream, error)
- func (a *API) GetStreamPlaylist(ctx context.Context, req *protobuf.GetStreamPlaylistRequest) (*protobuf.GetStreamPlaylistResponse, error)
- func (a *API) GetSubtitles(ctx context.Context, req *protobuf.GetSubtitlesRequest) (*httpbody.HttpBody, error)
- func (a *API) GetThumbs(ctx context.Context, req *protobuf.GetThumbsRequest) (*httpbody.HttpBody, error)
- func (a *API) GetUser(ctx context.Context, req *emptypb.Empty) (*protobuf.GetUserResponse, error)
- func (a *API) GetUserCourses(ctx context.Context, req *protobuf.GetUserCoursesRequest) (*protobuf.GetUserCoursesResponse, error)
- func (a *API) GetVideoSections(ctx context.Context, req *protobuf.GetVideoSectionsRequest) (*protobuf.GetVideoSectionsResponse, error)
- func (a *API) HealthCheck(ctx context.Context, req *emptypb.Empty) (*protobuf.HealthCheckResponse, error)
- func (a *API) ListInfoPages(ctx context.Context, req *emptypb.Empty) (*protobuf.ListInfoPagesResponse, error)
- func (a *API) ListInfoPagesAdmin(ctx context.Context, req *emptypb.Empty) (*protobuf.ListInfoPagesAdminResponse, error)
- func (a *API) ListRunners(ctx context.Context, req *emptypb.Empty) (*protobuf.ListRunnersResponse, error)
- func (a *API) ListStaff(ctx context.Context, req *emptypb.Empty) (*protobuf.ListUsersResponse, error)
- func (a *API) PinCourse(ctx context.Context, req *protobuf.PinCourseRequest) (*protobuf.PinCourseResponse, error)
- func (a *API) Proxy() func(c *gin.Context)
- func (a *API) ResetPassword(ctx context.Context, req *protobuf.ResetPasswordRequest) (*protobuf.ResetPasswordResponse, error)
- func (a *API) Run(lis net.Listener) error
- func (a *API) SearchUsers(ctx context.Context, req *protobuf.SearchUsersRequest) (*protobuf.ListUsersResponse, error)
- func (a *API) UpdateBookmark(ctx context.Context, req *protobuf.UpdateBookmarkRequest) (*protobuf.UpdateBookmarkResponse, error)
- func (a *API) UpdateInfoPage(ctx context.Context, req *protobuf.UpdateInfoPageRequest) (*protobuf.InfoPage, error)
- func (a *API) UpdateProgress(ctx context.Context, req *protobuf.UpdateProgressRequest) (*protobuf.StreamProgress, error)
- func (a *API) UpdateUserRole(ctx context.Context, req *protobuf.UpdateUserRoleRequest) (*protobuf.UserSummary, error)
- func (a *API) UpdateUserSettings(ctx context.Context, req *protobuf.UpdateUserSettingsRequest) (*protobuf.UpdateUserSettingsResponse, error)
- type CourseRequest
- type StreamRequest
Constants ¶
This section is empty.
Variables ¶
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
MetricsHandler serves the Prometheus exposition format for everything registered on the default registry, the gRPC server metrics included.
Types ¶
type API ¶
type API struct {
protobuf.UnimplementedMetaServiceServer
protobuf.UnimplementedUserServiceServer
protobuf.UnimplementedCourseServiceServer
protobuf.UnimplementedStreamServiceServer
protobuf.UnimplementedAdminServiceServer
// contains filtered or unexported fields
}
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 (*API) AddBookmark ¶
func (a *API) AddBookmark(ctx context.Context, req *protobuf.AddBookmarkRequest) (*protobuf.AddBookmarkResponse, error)
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) 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) 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) 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) GetBookmarks ¶
func (a *API) GetBookmarks(ctx context.Context, req *protobuf.GetBookmarksRequest) (*protobuf.GetBookmarksResponse, error)
GetBookmarks retrieves bookmarks by stream ID.
func (*API) GetCourseBySlug ¶
func (a *API) GetCourseBySlug(ctx context.Context, req *protobuf.GetCourseBySlugRequest) (*protobuf.GetCourseBySlugResponse, error)
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
func (a *API) GetInfoPage(ctx context.Context, req *protobuf.GetInfoPageRequest) (*protobuf.GetInfoPageResponse, error)
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) GetNotifications ¶
func (a *API) GetNotifications(ctx context.Context, req *emptypb.Empty) (*protobuf.GetNotificationsResponse, error)
GetNotifications retrieves notifications for the current user.
func (*API) GetPinForCourse ¶
func (a *API) GetPinForCourse(ctx context.Context, req *protobuf.GetPinForCourseRequest) (*protobuf.GetPinForCourseResponse, error)
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 ¶
func (a *API) GetProgressBatch(ctx context.Context, req *protobuf.GetProgressBatchRequest) (*protobuf.GetProgressBatchResponse, error)
GetProgressBatch returns a batch of watch progresses for a list of streams for the current user
func (*API) GetPublicCourses ¶
func (a *API) GetPublicCourses(ctx context.Context, req *protobuf.GetPublicCoursesRequest) (*protobuf.GetPublicCoursesResponse, error)
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 ¶
func (a *API) GetStreamPlaylist(ctx context.Context, req *protobuf.GetStreamPlaylistRequest) (*protobuf.GetStreamPlaylistResponse, error)
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 ¶
GetUser retrieves the current user based on the context. It returns a GetUserResponse or an error if one occurs.
func (*API) GetUserCourses ¶
func (a *API) GetUserCourses(ctx context.Context, req *protobuf.GetUserCoursesRequest) (*protobuf.GetUserCoursesResponse, error)
GetUserCourses retrieves the courses for a user for a given semester.
func (*API) GetVideoSections ¶
func (a *API) GetVideoSections(ctx context.Context, req *protobuf.GetVideoSectionsRequest) (*protobuf.GetVideoSectionsResponse, error)
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) 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) PinCourse ¶
func (a *API) PinCourse(ctx context.Context, req *protobuf.PinCourseRequest) (*protobuf.PinCourseResponse, error)
PinCourse pins or unpins a course for the user.
func (*API) ResetPassword ¶
func (a *API) ResetPassword(ctx context.Context, req *protobuf.ResetPasswordRequest) (*protobuf.ResetPasswordResponse, error)
ResetPassword resets the password for the user with the given username.
func (*API) SearchUsers ¶ added in v1.8.0
func (a *API) SearchUsers(ctx context.Context, req *protobuf.SearchUsersRequest) (*protobuf.ListUsersResponse, error)
SearchUsers searches every account, with contact details masked.
func (*API) UpdateBookmark ¶
func (a *API) UpdateBookmark(ctx context.Context, req *protobuf.UpdateBookmarkRequest) (*protobuf.UpdateBookmarkResponse, error)
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 ¶
func (a *API) UpdateUserSettings(ctx context.Context, req *protobuf.UpdateUserSettingsRequest) (*protobuf.UpdateUserSettingsResponse, error)
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
}