api

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KindPipe = "pipe"
	KindView = "view"
	KindRule = "rule"
)

Variables

This section is empty.

Functions

func MakeExchangeAction added in v1.4.0

func MakeExchangeAction(p nuggit.Point, pipe integrity.NameDigest) nuggit.Action

func MakePipeAction added in v1.4.0

func MakePipeAction(pipe integrity.NameDigest) nuggit.Action

func NewResourceSpec added in v1.3.0

func NewResourceSpec(kind Kind) (any, error)

func ValidateAction

func ValidateAction(action nuggit.Action, clientOnly bool) error

ValidateAction validates the action contents.

Use clientOnly for Pipes, and !clientOnly for Plans.

func ValidatePipe

func ValidatePipe(p *Pipe, clientOnly bool) error

func ValidatePoint

func ValidatePoint(p nuggit.Point) error

func ValidateRule added in v1.6.1

func ValidateRule(c nuggit.Rule) error

func ValidateScalar

func ValidateScalar(s nuggit.Scalar) error

func ValidateView added in v1.5.0

func ValidateView(v *nuggit.View) error

Types

type API

type API struct {
	*ViewsAPI
	*PipesAPI
	*TriggerAPI
	*ResourcesAPI
	*RulesAPI
}

func NewAPI

func NewAPI(viewStore ViewStore, pipeStore PipeStore, ruleStore RuleStore, planStore PlanStore, resultStore ResultStore, resourceStore ResourceStore, newTriggerPlanner func() TriggerPlanner) *API

type APIVersion added in v1.3.0

type APIVersion = string
const (
	V1 APIVersion = "v1"
)

type CloseTriggerRequest added in v1.5.0

type CloseTriggerRequest struct {
	Trigger string `json:"trigger,omitempty"`
}

type CloseTriggerResponse added in v1.5.0

type CloseTriggerResponse struct{}

type CreatePipeRequest

type CreatePipeRequest struct {
	Pipe *Pipe `json:"pipe,omitempty"`
}

type CreatePipeResponse

type CreatePipeResponse struct {
	Pipe *Ref `json:"pipe,omitempty"`
}

type CreatePipesBatchRequest

type CreatePipesBatchRequest struct {
	Pipes []*Pipe `json:"pipes,omitempty"`
}

type CreatePipesBatchResponse

type CreatePipesBatchResponse struct {
	Pipes []Ref `json:"pipes,omitempty"`
}

type CreateResourceRequest added in v1.8.0

type CreateResourceRequest struct {
	Resource *Resource `json:"resource,omitempty"`
}

type CreateResourceResponse added in v1.8.0

type CreateResourceResponse struct{}

type CreateRuleRequest added in v1.6.1

type CreateRuleRequest struct {
	Rule *nuggit.Rule `json:"rule,omitempty"`
}

type CreateRuleResponse added in v1.6.1

type CreateRuleResponse struct{}

type CreateViewRequest added in v1.5.0

type CreateViewRequest struct {
	View *nuggit.View `json:"view,omitempty"`
}

type CreateViewResponse added in v1.5.0

type CreateViewResponse struct {
	View *Ref `json:"view,omitempty"`
}

type DeleteRuleRequest added in v1.8.0

type DeleteRuleRequest struct {
	Rule *nuggit.Rule `json:"rule,omitempty"`
}

type DeleteRuleResponse added in v1.8.0

type DeleteRuleResponse struct{}

type ExchangeResultsRequest added in v1.1.0

type ExchangeResultsRequest struct {
	Trigger *TriggerEvent   `json:"trigger,omitempty"`
	Results []TriggerResult `json:"results,omitempty"`
}

type ExchangeResultsResponse added in v1.1.0

type ExchangeResultsResponse struct{}

type GetPipeRequest

type GetPipeRequest struct {
	Pipe string `json:"pipe,omitempty"`
}

type GetPipeResponse

type GetPipeResponse struct {
	Pipe *Pipe `json:"pipe,omitempty"`
}

type Kind

type Kind = string

type ListPipesRequest

type ListPipesRequest struct{}

type ListPipesResponse

type ListPipesResponse struct {
	Pipes []Ref `json:"pipes,omitempty"`
}

type OpenTriggerRequest added in v1.5.0

type OpenTriggerRequest struct {
	URL          string                 `json:"url,omitempty"`
	Implicit     bool                   `json:"implicit,omitempty"`
	IncludePipes []integrity.NameDigest `json:"include_views,omitempty"`
	ExcludePipes []integrity.NameDigest `json:"exclude_views,omitempty"`
}

type OpenTriggerResponse added in v1.5.0

type OpenTriggerResponse struct {
	Trigger *Ref          `json:"trigger,omitempty"`
	Plan    *trigger.Plan `json:"plan,omitempty"`
}

type Pipe

type Pipe struct {
	Name        string `json:"name,omitempty"`
	Digest      string `json:"digest,omitempty"`
	nuggit.Pipe `json:",omitempty"`
}

func (*Pipe) GetActions

func (p *Pipe) GetActions() []nuggit.Action

func (*Pipe) GetDigest added in v1.6.1

func (p *Pipe) GetDigest() string

func (*Pipe) GetName

func (p *Pipe) GetName() string

func (*Pipe) GetPipe added in v1.8.2

func (p *Pipe) GetPipe() nuggit.Pipe

func (*Pipe) GetPoint added in v1.1.0

func (p *Pipe) GetPoint() nuggit.Point

func (*Pipe) SetDigest added in v1.7.0

func (p *Pipe) SetDigest(digest string)

func (*Pipe) SetName added in v1.7.0

func (p *Pipe) SetName(name string)

type PipeStore

type PipeStore interface {
	Load(ctx context.Context, pipe integrity.NameDigest) (*Pipe, error)
	Store(context.Context, *Pipe) error
	StoreBatch(context.Context, []*Pipe) error
	ScanNames(context.Context) iter.Seq2[integrity.NameDigest, error]
	Scan(context.Context) iter.Seq2[*Pipe, error]
	ScanDependencies(ctx context.Context, pipe integrity.NameDigest) iter.Seq2[*Pipe, error]
}

type PipesAPI

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

func (*PipesAPI) CreatePipe

func (a *PipesAPI) CreatePipe(ctx context.Context, req *CreatePipeRequest) (*CreatePipeResponse, error)

func (*PipesAPI) CreatePipesBatch

func (*PipesAPI) GetPipe

func (a *PipesAPI) GetPipe(ctx context.Context, req *GetPipeRequest) (*GetPipeResponse, error)

func (*PipesAPI) Init

func (a *PipesAPI) Init(store PipeStore, rule RuleStore)

func (*PipesAPI) ListPipes

func (a *PipesAPI) ListPipes(ctx context.Context, _ *ListPipesRequest) (*ListPipesResponse, error)

type PlanStore added in v1.5.0

type PlanStore interface {
	Store(ctx context.Context, uuid string, plan *trigger.Plan) error
	Finish(ctx context.Context, uuid string) error
}

type Ref

type Ref struct {
	Name   string `json:"name,omitempty"`
	Digest string `json:"digest,omitempty"`
	ID     string `json:"id,omitempty"`
	URI    string `json:"uri,omitempty"`
}

func (*Ref) GetDigest added in v1.7.0

func (r *Ref) GetDigest() string

func (*Ref) GetID

func (r *Ref) GetID() string

func (*Ref) GetName added in v1.7.0

func (r *Ref) GetName() string

func (*Ref) GetURI

func (r *Ref) GetURI() string

type Resource

type Resource struct {
	APIVersion APIVersion        `json:"api_version,omitempty"`
	Kind       Kind              `json:"kind,omitempty"`
	Metadata   *ResourceMetadata `json:"metadata,omitempty"`
	Spec       any               `json:"spec,omitempty"`
}

func (*Resource) GetAPIVersion added in v1.3.0

func (r *Resource) GetAPIVersion() APIVersion

func (*Resource) GetDigest added in v1.7.0

func (r *Resource) GetDigest() string

func (*Resource) GetKind added in v1.3.0

func (r *Resource) GetKind() Kind

func (*Resource) GetMetadata added in v1.3.0

func (r *Resource) GetMetadata() *ResourceMetadata

func (*Resource) GetName added in v1.3.0

func (r *Resource) GetName() string

func (*Resource) GetPipe added in v1.3.0

func (r *Resource) GetPipe() *nuggit.Pipe

func (*Resource) GetRule added in v1.8.1

func (r *Resource) GetRule() *nuggit.Rule

func (*Resource) GetSpec added in v1.3.0

func (r *Resource) GetSpec() any

func (*Resource) GetView added in v1.5.0

func (r *Resource) GetView() *nuggit.View

func (*Resource) ReplaceSpec added in v1.5.0

func (r *Resource) ReplaceSpec(spec any)

func (*Resource) SetDigest added in v1.7.0

func (r *Resource) SetDigest(digest string)

func (*Resource) SetName added in v1.7.0

func (r *Resource) SetName(name string)

func (*Resource) UnmarshalJSON added in v1.3.0

func (r *Resource) UnmarshalJSON(data []byte) error

func (*Resource) UnmarshalYAML added in v1.3.0

func (r *Resource) UnmarshalYAML(value *yaml.Node) error

type ResourceMetadata

type ResourceMetadata struct {
	Name        string   `json:"name,omitempty"`
	Digest      string   `json:"digest,omitempty"` // TODO: Consider making this json:"-".
	UUID        string   `json:"uuid,omitempty"`
	Version     string   `json:"version,omitempty"`
	Description string   `json:"description,omitempty"`
	Labels      []string `json:"labels,omitempty"`
}

func (*ResourceMetadata) GetDescription added in v1.3.0

func (m *ResourceMetadata) GetDescription() string

func (*ResourceMetadata) GetDigest added in v1.7.0

func (m *ResourceMetadata) GetDigest() string

func (*ResourceMetadata) GetLabels added in v1.3.0

func (m *ResourceMetadata) GetLabels() []string

func (*ResourceMetadata) GetName added in v1.3.0

func (m *ResourceMetadata) GetName() string

func (*ResourceMetadata) GetUUID added in v1.8.0

func (m *ResourceMetadata) GetUUID() string

func (*ResourceMetadata) GetVersion added in v1.3.0

func (m *ResourceMetadata) GetVersion() string

func (*ResourceMetadata) SetDigest added in v1.7.0

func (m *ResourceMetadata) SetDigest(digest string)

func (*ResourceMetadata) SetName added in v1.7.0

func (m *ResourceMetadata) SetName(name string)

type ResourceStore added in v1.5.0

type ResourceStore interface {
	StorePipeResource(context.Context, *Resource, *Pipe) error
	StoreViewResource(ctx context.Context, r *Resource, viewUUID string) error
	StoreRuleResource(context.Context, *Resource, nuggit.Rule) error
}

type ResourcesAPI added in v1.5.0

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

func (*ResourcesAPI) CreateResource added in v1.8.0

func (*ResourcesAPI) Init added in v1.8.0

func (a *ResourcesAPI) Init(store ResourceStore, pipes *PipesAPI, views *ViewsAPI, rules *RulesAPI)

type ResultStore added in v1.2.0

type ResultStore interface {
	StoreResults(ctx context.Context, trigger *TriggerEvent, results []TriggerResult) error
}

type RuleStore added in v1.6.1

type RuleStore interface {
	StoreRule(ctx context.Context, rule nuggit.Rule) error
	DeleteRule(ctx context.Context, rule nuggit.Rule) error
	ScanMatched(ctx context.Context, u *url.URL) iter.Seq2[*Pipe, error]
}

type RulesAPI added in v1.8.0

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

func (*RulesAPI) CreateRule added in v1.8.0

func (a *RulesAPI) CreateRule(ctx context.Context, req *CreateRuleRequest) (*CreateRuleResponse, error)

func (*RulesAPI) DeleteRule added in v1.8.0

func (a *RulesAPI) DeleteRule(ctx context.Context, req *DeleteRuleRequest) (*DeleteRuleResponse, error)

func (*RulesAPI) Init added in v1.8.0

func (a *RulesAPI) Init(rules RuleStore)

type Runtime

type Runtime struct {
	Name             string   `json:"name,omitempty"`
	SupportedActions []string `json:"supported_actions,omitempty"`
}

func (*Runtime) GetName

func (r *Runtime) GetName() string

func (*Runtime) GetSupportedActions

func (r *Runtime) GetSupportedActions() []string

type TriggerAPI

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

func (*TriggerAPI) CloseTrigger added in v1.5.0

func (*TriggerAPI) ExchangeResults added in v1.1.0

func (*TriggerAPI) Init

func (a *TriggerAPI) Init(rules RuleStore, pipes PipeStore, planStore PlanStore, resultStore ResultStore, newPlanner func() TriggerPlanner)

func (*TriggerAPI) OpenTrigger added in v1.5.0

func (a *TriggerAPI) OpenTrigger(ctx context.Context, req *OpenTriggerRequest) (*OpenTriggerResponse, error)

type TriggerEvent added in v1.5.0

type TriggerEvent struct {
	Plan      string    `json:"plan,omitempty"`
	Implicit  bool      `json:"implicit,omitempty"`
	URL       string    `json:"url,omitempty"`
	Timestamp time.Time `json:"timestamp,omitempty"`
}

func (*TriggerEvent) GetImplicit added in v1.5.0

func (e *TriggerEvent) GetImplicit() bool

func (*TriggerEvent) GetPlan added in v1.5.0

func (e *TriggerEvent) GetPlan() string

func (*TriggerEvent) GetTimestamp added in v1.5.0

func (e *TriggerEvent) GetTimestamp() time.Time

func (*TriggerEvent) GetURL added in v1.5.0

func (e *TriggerEvent) GetURL() string

type TriggerPlanner

type TriggerPlanner interface {
	AddReferencedPipe(name, digest string, pipe nuggit.Pipe)
	AddPipe(name, digest string, pipe nuggit.Pipe) error
	Build() *trigger.Plan
}

type TriggerResult

type TriggerResult struct {
	Pipe   string        `json:"pipe,omitempty"`
	Scalar nuggit.Scalar `json:"scalar,omitempty"`
	Result any           `json:"result,omitempty"`
}

TODO: Add Point to this struct.

func (*TriggerResult) GetPipe added in v1.5.0

func (r *TriggerResult) GetPipe() string

func (*TriggerResult) GetResult added in v1.5.0

func (r *TriggerResult) GetResult() any

type ViewStore added in v1.5.0

type ViewStore interface {
	Store(ctx context.Context, uuid string, view nuggit.View) error
}

type ViewsAPI added in v1.5.0

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

func (*ViewsAPI) CreateView added in v1.5.0

func (a *ViewsAPI) CreateView(ctx context.Context, req *CreateViewRequest) (*CreateViewResponse, error)

func (*ViewsAPI) Init added in v1.5.0

func (a *ViewsAPI) Init(store ViewStore, pipes PipeStore)

Jump to

Keyboard shortcuts

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