api

package
v1.30.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricChartPeriod          = 10
	MetricRollingAveragePeriod = 10
)
View Source
const SettingsKey = "global_settings"

Variables

View Source
var GraphiqlPage []byte
View Source
var SchemaFile string

Functions

func CanStartTrialLicense

func CanStartTrialLicense(userID string, pluginAPI *pluginapi.Client) error

func HandleErrorWithCode

func HandleErrorWithCode(logger bot.Logger, w http.ResponseWriter, code int, publicErrorMsg string, internalErr error)

HandleErrorWithCode logs the internal error and sends the public facing error message as JSON in a response with the provided code.

func MattermostAuthorizationRequired

func MattermostAuthorizationRequired(next http.Handler) http.Handler

MattermostAuthorizationRequired checks if request is authorized.

func ReturnJSON

func ReturnJSON(w http.ResponseWriter, pointerToObject interface{}, httpStatus int)

ReturnJSON writes the given pointerToObject as json with the provided httpStatus

Types

type ActionsHandler added in v1.26.0

type ActionsHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

func NewActionsHandler added in v1.26.0

func NewActionsHandler(router *mux.Router, log bot.Logger, channelActionsService app.ChannelActionService, pluginAPI *pluginapi.Client, permissions *app.PermissionsService) *ActionsHandler

type BotHandler

type BotHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

func NewBotHandler

func NewBotHandler(router *mux.Router, api *pluginapi.Client, poster bot.Poster, logger bot.Logger,
	config config.Service, playbookRunService app.PlaybookRunService, userInfoStore app.UserInfoStore) *BotHandler

type CategoryHandler added in v1.31.0

type CategoryHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

func NewCategoryHandler added in v1.31.0

func NewCategoryHandler(router *mux.Router, api *pluginapi.Client, logger bot.Logger, categoryService app.CategoryService, playbookService app.PlaybookService, playbookRunService app.PlaybookRunService) *CategoryHandler

type ChecklistItemResolver added in v1.28.0

type ChecklistItemResolver struct {
	app.ChecklistItem
}

func (*ChecklistItemResolver) AssigneeModified added in v1.28.0

func (r *ChecklistItemResolver) AssigneeModified() float64

func (*ChecklistItemResolver) CommandLastRun added in v1.28.0

func (r *ChecklistItemResolver) CommandLastRun() float64

func (*ChecklistItemResolver) DueDate added in v1.28.0

func (r *ChecklistItemResolver) DueDate() float64

func (*ChecklistItemResolver) StateModified added in v1.28.0

func (r *ChecklistItemResolver) StateModified() float64

type ChecklistResolver added in v1.28.0

type ChecklistResolver struct {
	app.Checklist
}

func (*ChecklistResolver) Items added in v1.28.0

type Context added in v1.28.0

type Context struct {
	// contains filtered or unexported fields
}

type ErrorHandler

type ErrorHandler struct {
	// contains filtered or unexported fields
}

func (*ErrorHandler) HandleError

func (h *ErrorHandler) HandleError(w http.ResponseWriter, internalErr error)

HandleError logs the internal error and sends a generic error as JSON in a 500 response.

func (*ErrorHandler) HandleErrorWithCode

func (h *ErrorHandler) HandleErrorWithCode(w http.ResponseWriter, code int, publicErrorMsg string, internalErr error)

HandleErrorWithCode logs the internal error and sends the public facing error message as JSON in a response with the provided code.

func (*ErrorHandler) PermissionsCheck

func (h *ErrorHandler) PermissionsCheck(w http.ResponseWriter, checkOutput error) bool

PermissionsCheck handles the output of a permisions check Automatically does the proper error handling. Returns true if the check passed and false on failure. Correct use is: if !h.PermissionsCheck(w, check) { return }

type GraphQLHandler added in v1.28.0

type GraphQLHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

func NewGraphQLHandler added in v1.28.0

func NewGraphQLHandler(
	router *mux.Router,
	playbookService app.PlaybookService,
	categoryService app.CategoryService,
	api *pluginapi.Client,
	log bot.Logger,
	configService config.Service,
	permissions *app.PermissionsService,
	playbookStore app.PlaybookStore,
	licenceChecker app.LicenseChecker,
) *GraphQLHandler

type Handler

type Handler struct {
	*ErrorHandler

	APIRouter *mux.Router
	// contains filtered or unexported fields
}

Handler Root API handler.

func NewHandler

func NewHandler(pluginAPI *pluginapi.Client, config config.Service, log bot.Logger) *Handler

NewHandler constructs a new handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MetricConfigResolver added in v1.28.0

type MetricConfigResolver struct {
	app.PlaybookMetricConfig
}

func (*MetricConfigResolver) Target added in v1.28.0

func (r *MetricConfigResolver) Target() *int32

type PlaybookHandler

type PlaybookHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

PlaybookHandler is the API handler.

func NewPlaybookHandler

func NewPlaybookHandler(router *mux.Router, playbookService app.PlaybookService, api *pluginapi.Client, log bot.Logger, configService config.Service, permissions *app.PermissionsService) *PlaybookHandler

NewPlaybookHandler returns a new playbook api handler

type PlaybookResolver added in v1.28.0

type PlaybookResolver struct {
	app.Playbook
	IsFavorite bool
}

func (*PlaybookResolver) Checklists added in v1.28.0

func (r *PlaybookResolver) Checklists() []*ChecklistResolver

func (*PlaybookResolver) DeleteAt added in v1.28.0

func (r *PlaybookResolver) DeleteAt() float64

func (*PlaybookResolver) Metrics added in v1.28.0

func (r *PlaybookResolver) Metrics() []*MetricConfigResolver

func (*PlaybookResolver) ReminderTimerDefaultSeconds added in v1.28.0

func (r *PlaybookResolver) ReminderTimerDefaultSeconds() float64

func (*PlaybookResolver) RetrospectiveReminderIntervalSeconds added in v1.28.0

func (r *PlaybookResolver) RetrospectiveReminderIntervalSeconds() float64

type PlaybookRunHandler

type PlaybookRunHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

PlaybookRunHandler is the API handler.

func NewPlaybookRunHandler

func NewPlaybookRunHandler(
	router *mux.Router,
	playbookRunService app.PlaybookRunService,
	playbookService app.PlaybookService,
	permissions *app.PermissionsService,
	licenseChecker app.LicenseChecker,
	api *pluginapi.Client,
	poster bot.Poster,
	log bot.Logger,
	configService config.Service,
) *PlaybookRunHandler

NewPlaybookRunHandler Creates a new Plugin API handler.

type PlaybookSiteStats added in v1.28.0

type PlaybookSiteStats struct {
	TotalPlaybooks    int `json:"total_playbooks"`
	TotalPlaybookRuns int `json:"total_playbook_runs"`
}

type PlaybookStats

type PlaybookStats struct {
	RunsInProgress                int        `json:"runs_in_progress"`
	ParticipantsActive            int        `json:"participants_active"`
	RunsFinishedPrev30Days        int        `json:"runs_finished_prev_30_days"`
	RunsFinishedPercentageChange  int        `json:"runs_finished_percentage_change"`
	RunsStartedPerWeek            []int      `json:"runs_started_per_week"`
	RunsStartedPerWeekTimes       [][]int64  `json:"runs_started_per_week_times"`
	ActiveRunsPerDay              []int      `json:"active_runs_per_day"`
	ActiveRunsPerDayTimes         [][]int64  `json:"active_runs_per_day_times"`
	ActiveParticipantsPerDay      []int      `json:"active_participants_per_day"`
	ActiveParticipantsPerDayTimes [][]int64  `json:"active_participants_per_day_times"`
	MetricOverallAverage          []null.Int `json:"metric_overall_average"`
	MetricRollingAverage          []null.Int `json:"metric_rolling_average"`
	MetricRollingAverageChange    []null.Int `json:"metric_rolling_average_change"`
	MetricValueRange              [][]int64  `json:"metric_value_range"`
	MetricRollingValues           [][]int64  `json:"metric_rolling_values"`
	LastXRunNames                 []string   `json:"last_x_run_names"`
}

type RootResolver added in v1.28.0

type RootResolver struct{}

func (*RootResolver) AddMetric added in v1.28.0

func (r *RootResolver) AddMetric(ctx context.Context, args struct {
	PlaybookID  string
	Title       string
	Description string
	Type        string
	Target      *float64
}) (string, error)

func (*RootResolver) DeleteMetric added in v1.28.0

func (r *RootResolver) DeleteMetric(ctx context.Context, args struct {
	ID string
}) (string, error)

func (*RootResolver) Playbook added in v1.28.0

func (r *RootResolver) Playbook(ctx context.Context, args struct {
	ID string
}) (*PlaybookResolver, error)

func (*RootResolver) UpdateMetric added in v1.28.0

func (r *RootResolver) UpdateMetric(ctx context.Context, args struct {
	ID          string
	Title       *string
	Description *string
	Target      *float64
}) (string, error)

func (*RootResolver) UpdatePlaybook added in v1.28.0

func (r *RootResolver) UpdatePlaybook(ctx context.Context, args struct {
	ID      string
	Updates struct {
		Title                                *string
		Description                          *string
		Public                               *bool
		CreatePublicPlaybookRun              *bool
		ReminderMessageTemplate              *string
		ReminderTimerDefaultSeconds          *float64
		StatusUpdateEnabled                  *bool
		InvitedUserIDs                       *[]string
		InvitedGroupIDs                      *[]string
		InviteUsersEnabled                   *bool
		DefaultOwnerID                       *string
		DefaultOwnerEnabled                  *bool
		BroadcastChannelIDs                  *[]string
		BroadcastEnabled                     *bool
		WebhookOnCreationURLs                *[]string
		WebhookOnCreationEnabled             *bool
		MessageOnJoin                        *string
		MessageOnJoinEnabled                 *bool
		RetrospectiveReminderIntervalSeconds *float64
		RetrospectiveTemplate                *string
		RetrospectiveEnabled                 *bool
		WebhookOnStatusUpdateURLs            *[]string
		WebhookOnStatusUpdateEnabled         *bool
		SignalAnyKeywords                    *[]string
		SignalAnyKeywordsEnabled             *bool
		CategorizeChannelEnabled             *bool
		CategoryName                         *string
		RunSummaryTemplateEnabled            *bool
		RunSummaryTemplate                   *string
		ChannelNameTemplate                  *string
		Checklists                           *[]UpdateChecklist
		IsFavorite                           *bool
	}
}) (string, error)

type SettingsHandler

type SettingsHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

SettingsHandler is the API handler.

func NewSettingsHandler

func NewSettingsHandler(router *mux.Router, api *pluginapi.Client, log bot.Logger, configService config.Service) *SettingsHandler

NewSettingsHandler returns a new settings api handler

type SignalHandler

type SignalHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

func NewSignalHandler

func NewSignalHandler(router *mux.Router, api *pluginapi.Client, logger bot.Logger, playbookRunService app.PlaybookRunService, playbookService app.PlaybookService, keywordsThreadIgnorer app.KeywordsThreadIgnorer) *SignalHandler

type StatsHandler

type StatsHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

func NewStatsHandler

func NewStatsHandler(router *mux.Router, api *pluginapi.Client, log bot.Logger, statsStore *sqlstore.StatsStore, playbookService app.PlaybookService, permissions *app.PermissionsService, licenseChecker app.LicenseChecker) *StatsHandler

type TelemetryHandler

type TelemetryHandler struct {
	*ErrorHandler
	// contains filtered or unexported fields
}

TelemetryHandler is the API handler.

func NewTelemetryHandler

func NewTelemetryHandler(
	router *mux.Router,
	playbookRunService app.PlaybookRunService,
	api *pluginapi.Client,
	log bot.Logger,
	playbookRunTelemetry app.PlaybookRunTelemetry,
	playbookService app.PlaybookService,
	playbookTelemetry app.PlaybookTelemetry,
	botTelemetry bot.Telemetry,
	permissions *app.PermissionsService,
) *TelemetryHandler

NewTelemetryHandler Creates a new Plugin API handler.

type TrackerPayload

type TrackerPayload struct {
	Action string `json:"action"`
}

type UpdateChecklist added in v1.28.0

type UpdateChecklist struct {
	Title string                `json:"title"`
	Items []UpdateChecklistItem `json:"items"`
}

type UpdateChecklistItem added in v1.28.0

type UpdateChecklistItem struct {
	Title            string  `json:"title"`
	State            string  `json:"state"`
	StateModified    float64 `json:"state_modified"`
	AssigneeID       string  `json:"assignee_id"`
	AssigneeModified float64 `json:"assignee_modified"`
	Command          string  `json:"command"`
	CommandLastRun   float64 `json:"command_last_run"`
	Description      string  `json:"description"`
	LastSkipped      float64 `json:"delete_at"`
	DueDate          float64 `json:"due_date"`
}

Jump to

Keyboard shortcuts

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