epcmd

package
v1.155.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package epcmd is manage_script's endpoint binding commands (#2171): endpoint_set, endpoint_list, endpoint_enable and endpoint_disable, beside the schedule commands. internal/platform/scriptlayer resolves the script a command names, as it does for every command, and hands it here with who is asking; the input fields and their schema are spliced into manage_script's own.

Index

Constants

View Source
const (
	CmdSet     = "endpoint_set"
	CmdList    = "endpoint_list"
	CmdEnable  = "endpoint_enable"
	CmdDisable = "endpoint_disable"
	// CmdFormPreview opens a preview of a form for its owner (#2494).
	CmdFormPreview = "form_preview"
)

The commands.

Variables

Commands is every endpoint command, in the order the schema lists them.

View Source
var ErrStore = errors.New("the endpoint store failed")

ErrStore marks a command that failed because a store could not be read or written, which is the platform's failure rather than the caller's.

Functions

func Properties

func Properties() map[string]any

Properties is the schema fragment manage_script splices in for the fields of Input.

func Writes

func Writes(cmd string) bool

Writes reports whether cmd changes a binding, which a script run may not do: a run that could bind a script would be able to publish a route.

Types

type Approvals added in v1.153.2

type Approvals interface {
	Approved(ctx context.Context, scriptID, purpose string) int
	RecordSelfApproval(ctx context.Context, actor approval.Actor, sc *script.Script, version int) error
}

Approvals is the part of the Approvals queue (internal/approval) a binding reads: the version approved for form_public, and an administrator's approval of the version they serve.

type FormSources added in v1.152.0

type FormSources interface {
	Ensure(ctx context.Context, req epsource.SourceRequest) (epsource.SourceResult, error)
	Find(ctx context.Context, scriptID string) (epsource.SourceResult, bool, error)
	ConnectionChoices() []string
}

FormSources makes the webhook source a form stores its submissions in (epcollect.Maker).

type Handler

type Handler struct {
	Store epbinding.Store
	// CheckUsable reports why a binding cannot name a bot check: none has
	// the name, or it cannot be issued here (internal/botcheck).
	CheckUsable func(ctx context.Context, name string) error
	// BaseURL is the deployment's public address, empty when it has none.
	BaseURL string
	// ScriptName names a script a listing found by id; nil leaves names out.
	ScriptName func(ctx context.Context, scriptID string) string
	// Approvals says which version of a form is approved to be served to
	// callers with no session (#2494); nil refuses making a form public.
	Approvals Approvals
	// Previews opens a form's preview (#2494); nil refuses form_preview.
	Previews *eppreview.Previews
	// PageAllowed reports why a script's endpoint cannot be a browser page
	// (#2517); nil refuses every page.
	PageAllowed func(ctx context.Context, scriptID string) error
	// contains filtered or unexported fields
}

Handler carries the commands out.

func (*Handler) Bound

func (h *Handler) Bound(ctx context.Context, scriptID string) string

Bound names the endpoint a script is bound to, "" when it is bound to none or the binding cannot be read: the save gate's question (#2171).

func (*Handler) Run

func (h *Handler) Run(ctx context.Context, req Request) (map[string]any, error)

Run carries out req and returns the result manage_script answers with. An error is the caller's to read.

func (*Handler) SetForms added in v1.152.0

func (h *Handler) SetForms(f FormSources)

SetForms is what makes a form's source from here on: the webhook sources, which are assembled after the endpoint commands.

type Input

type Input struct {
	Endpoint        string   `json:"endpoint,omitempty"`
	Methods         []string `json:"methods,omitempty"`
	Path            *string  `json:"path,omitempty"`
	AuthMode        string   `json:"auth_mode,omitempty"`
	Callers         []string `json:"callers,omitempty"`
	BotCheck        string   `json:"bot_check,omitempty"`
	CheckedMethods  []string `json:"checked_methods,omitempty"`
	MaxMemoryBytes  int64    `json:"max_memory_bytes,omitempty"`
	MaxBodyBytes    int      `json:"max_body_bytes,omitempty"`
	AllowedOrigins  []string `json:"allowed_origins,omitempty"`
	RateLimit       int      `json:"rate_limit,omitempty"`
	CallerRateLimit int      `json:"caller_rate_limit,omitempty"`
	// ResponseMode and PageCDNs make the endpoint a browser page (#2517).
	ResponseMode string   `json:"response_mode,omitempty"`
	PageCDNs     []string `json:"page_cdns,omitempty"`
	// Connection and DecryptPersonas are a form's (#2178, #2179): the Trino
	// connection its source's table is created on, and the personas a script
	// run may decrypt its sensitive fields as (nil keeps them).
	Connection      string   `json:"connection,omitempty"`
	DecryptPersonas []string `json:"decrypt_personas,omitempty"`
	// PreviewVersion is the saved version form_preview renders, 0 for the
	// latest (#2494).
	PreviewVersion int `json:"preview_version,omitempty"`
}

Input is the part of manage_script's input the endpoint commands read. endpoint_set also reads manage_script's timeout_seconds.

type Request

type Request struct {
	Command string
	Input   Input
	// TimeoutSeconds is manage_script's timeout_seconds.
	TimeoutSeconds int
	// Script is the script the command names, nil for a listing that names
	// none.
	Script *script.Script
	// Visible scopes a listing that names no script to the scripts the caller
	// may see; nil for an administrator, whose listing is every binding.
	Visible map[string]*script.Script
	Admin   bool
	Actor   string
	// Limit is how many bindings a listing returns, bounded by the store.
	Limit int
	// Opener is who opens a form_preview, with the identity its drafts run
	// as; Source is the unsaved source it renders, empty for a saved
	// version (#2494).
	Opener eppreview.Opener
	Source string
}

Request is one endpoint command.

Jump to

Keyboard shortcuts

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