api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: BSD-3-Clause Imports: 7 Imported by: 8 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearResources

func ClearResources()

ClearResources clears the resources for testing

Types

type Microgateway

type Microgateway struct {
	Name      string      `json:"name" jsonschema:"required"`
	Steps     []*Step     `json:"steps" jsonschema:"required,minItems=1"`
	Responses []*Response `json:"responses,omitempty"`
	Services  []*Service  `json:"services,omitempty" jsonschema:"uniqueItems=true"`
}

Microgateway defines a microgateway

func GetResource

func GetResource(name string) *Microgateway

GetResource gets the resource

func New

func New(name string) *Microgateway

New creates a new microgateway action

func (*Microgateway) AddResource

func (m *Microgateway) AddResource(app *api.App, inputSettings ...map[string]interface{}) (map[string]interface{}, error)

AddResource adds the microgateway resource to the app and returns the action settings

func (*Microgateway) NewResponse

func (m *Microgateway) NewResponse(isError bool) *Response

NewResponse adds a new response to the microgateway

func (*Microgateway) NewService

func (m *Microgateway) NewService(name string, act interface{}) *Service

NewService adds a new service to the microgateway

func (*Microgateway) NewStep

func (m *Microgateway) NewStep(service *Service) *Step

NewStep adds a new execution step to the microgateway

type Output

type Output struct {
	Code interface{} `json:"code,omitempty"`
	Data interface{} `json:"data" jsonschema:"additionalProperties"`
}

Output defines response output values back to a trigger event.

type Response

type Response struct {
	Condition string `json:"if,omitempty"`
	Error     bool   `json:"error" jsonschema:"required"`
	Output    Output `json:"output,omitempty" jsonschema:"required"`
}

Response defines response handling rules.

func (*Response) SetCode

func (r *Response) SetCode(code interface{})

SetCode sets the status code for the response

func (*Response) SetData

func (r *Response) SetData(data interface{})

SetData sets the return data for the response

func (*Response) SetIf

func (r *Response) SetIf(condition string)

SetIf sets the condition for the response

type Service

type Service struct {
	Name        string                 `json:"name" jsonschema:"required"`
	Ref         string                 `json:"ref" jsonschema:"required"`
	Description string                 `json:"description,omitempty"`
	Settings    map[string]interface{} `json:"settings,omitempty" jsonschema:"additionalProperties"`
	Handler     ServiceFunc            `json:"-"`
}

Service defines a functional target that may be invoked by a step in an execution flow.

func (*Service) AddSetting

func (s *Service) AddSetting(name string, value interface{})

AddSetting adds a setting to the service

func (*Service) SetDescription

func (s *Service) SetDescription(description string)

SetDescription sets the description of the service

type ServiceFunc

type ServiceFunc func(ctx activity.Context) (done bool, err error)

ServiceFunc is a function to be called for a service

type Step

type Step struct {
	Condition     string                 `json:"if,omitempty"`
	Service       string                 `json:"service" jsonschema:"required"`
	Input         map[string]interface{} `json:"input,omitempty" jsonschema:"additionalProperties"`
	HaltCondition string                 `json:"halt,omitempty"`
}

Step conditionally defines a step in a route's execution flow.

func (*Step) AddInput

func (s *Step) AddInput(name string, value interface{})

AddInput adds an input to the step

func (*Step) SetHalt

func (s *Step) SetHalt(condition string)

SetHalt sets the halting condition for the step

func (*Step) SetIf

func (s *Step) SetIf(condition string)

SetIf sets the execution condition of the step

Jump to

Keyboard shortcuts

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