Back to

Package handlers

Latest Go to latest

The latest major version is .

Published: Sep 19, 2020 | License: BSD-3-Clause | Module:


type Email

type Email struct {
	Subject string
	Body    string

Email defines the data needed to send out on call emails.

type JSONMember

type JSONMember struct {
	TZString string

JSONMember adds a TZString field to the rotang.Member structure. This is needed due to time.Location not having an encoding to JSON.

type MemberInfo

type MemberInfo struct {
	Member JSONMember
	Shifts []RotaShift

MemberInfo is used by the shift-member element to get relevant member information.

type Modifier

type Modifier struct {
	Name    string
	Checked bool

Modifier is used to send the Modifiers state to the shift generator element.

type OnCallerRequest

type OnCallerRequest struct {
	Name string
	At   time.Time

OnCallerRequest is the format used by the `rota-oncall` element for requests.

type OnCallers

type OnCallers struct {
	Name  string
	Shift rotang.ShiftEntry

OnCallers is the struct used with the `rota-oncall` element.

type Options

type Options struct {
	ProjectID          func(context.Context) string
	ProdENV            string
	Calendar           rotang.Calenderer
	LegacyCalendar     rotang.Calenderer
	Generators         *algo.Generators
	MailSender         rotang.MailSender
	MailAddress        string
	MissingEmail       Email
	DeclinedEventEmail Email
	BackupCred         func(*router.Context) (*http.Client, error)
	AuthGroup          string

	MemberStore func(context.Context) rotang.MemberStorer
	ConfigStore func(context.Context) rotang.ConfigStorer
	ShiftStore  func(context.Context) rotang.ShiftStorer

Options contains the options used by the handlers.

type RotaShift

type RotaShift struct {
	Name    string
	Entries []rotang.ShiftEntry

RotaShift contains a rota name and relevant shift information for the shift-member element.

type RotaShifts

type RotaShifts struct {
	Rota        string
	SplitShifts []SplitShifts

RotaShifts mirrors the `shiftcurrent-element` RotaShifts structure.

type SplitShifts

type SplitShifts struct {
	Name    string
	Members []string
	Shifts  []rotang.ShiftEntry

SplitShifts mirrors the `shiftcurrent-element` SplitShifts structure.

type State

type State struct {
	// contains filtered or unexported fields

State holds shared state between handlers.

func New

func New(opt *Options) (*State, error)

New creates a new handlers State container.

func (*State) CreateExternal

func (h *State) CreateExternal(ctx context.Context, req *apb.CreateExternalRequest) (*apb.CreateExternalResponse, error)

CreateExternal creates a new External rotation.

func (*State) DeleteExternal

func (h *State) DeleteExternal(ctx context.Context, req *apb.DeleteExternalRequest) (*apb.DeleteExternalResponse, error)

DeleteExternal deletes an external rotation.

func (*State) HandleCalTest

func (h *State) HandleCalTest(ctx *router.Context)

HandleCalTest tests calendar access.

func (*State) HandleDeleteRota

func (h *State) HandleDeleteRota(ctx *router.Context)

HandleDeleteRota handles deletion of a rotation configuration

func (*State) HandleEmailTest

func (h *State) HandleEmailTest(ctx *router.Context)

HandleEmailTest lists the members rotations.

func (*State) HandleEmailTestJSON

func (h *State) HandleEmailTestJSON(ctx *router.Context)

HandleEmailTestJSON runs the email test and returns the result as json.

func (*State) HandleEmailTestSend

func (h *State) HandleEmailTestSend(ctx *router.Context)

HandleEmailTestSend tries to send an email to the caller.

func (*State) HandleEnableDisable

func (h *State) HandleEnableDisable(ctx *router.Context)

HandleEnableDisable enables/disables rotation configurations.

func (*State) HandleGenerate

func (h *State) HandleGenerate(ctx *router.Context)

HandleGenerate generates rota schedules. Used by the `shiftgenerate-element`

func (*State) HandleIndex

func (h *State) HandleIndex(ctx *router.Context)

HandleIndex is the handler used for requests to '/'.

func (*State) HandleLegacy

func (h *State) HandleLegacy(ctx *router.Context)

HandleLegacy serves the /legacy endpoint.

func (*State) HandleList

func (h *State) HandleList(ctx *router.Context)

HandleList lists all rotations in store.

func (*State) HandleManageRota

func (h *State) HandleManageRota(ctx *router.Context)

HandleManageRota handles the rota management interface.

func (*State) HandleManageShifts

func (h *State) HandleManageShifts(ctx *router.Context)

HandleManageShifts presents the shift management page.

func (*State) HandleMember

func (h *State) HandleMember(ctx *router.Context)

HandleMember handles shift-member.

func (*State) HandleOncall

func (h *State) HandleOncall(ctx *router.Context)

HandleOncall handles the current oncall page.

func (*State) HandleOncallJSON

func (h *State) HandleOncallJSON(ctx *router.Context)

HandleOncallJSON returns a JSON representation of oncallers. Primarily used by the `rota-oncall` element.

func (*State) HandleRotaCreate

func (h *State) HandleRotaCreate(ctx *router.Context)

HandleRotaCreate handles creation of new rotations.

func (*State) HandleRotaModify

func (h *State) HandleRotaModify(ctx *router.Context)

HandleRotaModify is used to modify or copy rotation configurations.

func (*State) HandleRotaSwitch

func (h *State) HandleRotaSwitch(ctx *router.Context)

HandleRotaSwitch handles the rotation switch page.

func (*State) HandleRotaSwitchList

func (h *State) HandleRotaSwitchList(ctx *router.Context)

HandleRotaSwitchList lists rotations not yest switched over.

func (*State) HandleShiftGenerate

func (h *State) HandleShiftGenerate(ctx *router.Context)

HandleShiftGenerate saves generated shifts.

func (*State) HandleShiftImportJSON

func (h *State) HandleShiftImportJSON(ctx *router.Context)

HandleShiftImportJSON imort shifts from legacy calendar.

func (*State) HandleShiftSwap

func (h *State) HandleShiftSwap(ctx *router.Context)

HandleShiftSwap is used by the rota-shift-swap element for swapping shifts.

func (*State) HandleShiftUpdate

func (h *State) HandleShiftUpdate(ctx *router.Context)

HandleShiftUpdate handles shift updates.

func (*State) HandleUpload

func (h *State) HandleUpload(ctx *router.Context)

HandleUpload handles legacy JSON configurations.

func (*State) IsLocal

func (h *State) IsLocal() bool

IsLocal is true if the service is running in the local dev environment.

func (*State) IsProduction

func (h *State) IsProduction() bool

IsProduction is true if the service is running in production.

func (*State) IsStaging

func (h *State) IsStaging() bool

IsStaging is true if the service is running in staging.

func (*State) JobBackup

func (h *State) JobBackup(ctx *router.Context)

JobBackup handles scheduled backups of the datastore.

func (*State) JobEmail

func (h *State) JobEmail(ctx *router.Context)

JobEmail sends emails to upcoming oncallers. The rotang.Email `DaysBeforeNotify` number is used to set when the mail is going to be sent. Setting DaysBeforeNotify == 0 disables sending Emails for that rotation.

func (*State) JobEventUpdate

func (h *State) JobEventUpdate(ctx *router.Context)

JobEventUpdate reads calendar Events and updates shifts accordingly.

func (*State) JobExternal

func (h *State) JobExternal(ctx *router.Context)

JobExternal updates the external rotations shifts.

func (*State) JobLegacy

func (h *State) JobLegacy(ctx *router.Context)

JobLegacy updates the information served by the /legacy endpoint. This Job periodically updates the information and saves it to memcache.

func (*State) JobSchedule

func (h *State) JobSchedule(ctx *router.Context)

JobSchedule schedules new shifts for enabled rotas.

func (*State) ListRotations

func (h *State) ListRotations(ctx context.Context, _ *apb.ListRotationsRequest) (*apb.ListRotationsResponse, error)

ListRotations returns a list of all rotations known to RotaNG.

func (*State) MakeAllMembersOwners

func (h *State) MakeAllMembersOwners(ctx context.Context, req *apb.MakeAllMembersOwnersRequest) (*apb.MakeAllMembersOwnersResponse, error)

MakeAllMembersOwners sets all rotation members as owners.

func (*State) MigrationInfo

func (h *State) MigrationInfo(ctx context.Context, req *apb.MigrationInfoRequest) (*apb.MigrationInfoResponse, error)

MigrationInfo returns information used for migrating a rotation to G3 oncall.

func (*State) Oncall

func (h *State) Oncall(ctx context.Context, req *apb.OncallRequest) (*apb.OncallResponse, error)

Oncall returns the current oncaller for the specified shift.

func (*State) RotationMembers

func (h *State) RotationMembers(ctx context.Context, req *apb.RotationMembersRequest) (*apb.RotationMembersResponse, error)

RotationMembers return information for all members of a rotation.

func (*State) Shifts

func (h *State) Shifts(ctx context.Context, req *apb.ShiftsRequest) (*apb.ShiftsResponse, error)

Shifts returns a list of shift for the specified rotation and period.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier