configs

package
v0.0.0-...-f2f1368 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Fields []struct {
		Label            string    `json:"label"`
		Key              string    `json:"key"`
		Tip              string    `json:"tip"`
		IsRequired       bool      `mapstructure:"is_required" json:"is_required"`
		IsAdministrative bool      `mapstructure:"is_administrative" json:"is_administrative"`
		InputKind        InputKind `mapstructure:"input_kind" json:"input_kind"`
		DefaultValue     string    `mapstructure:"default_value" json:"default_value"`
		Dropdown         Dropdown  `json:"dropdown"`
	} `json:"fields"`
	API Endpoint `json:"api"`
}

APIKey holds the necessary information for getting authorisation via api keys.

type Action

type Action struct {
	Key        string     `json:"key"`
	Label      string     `json:"label"`
	Tip        string     `json:"tip"`
	ActionKind ActionKind `json:"action_kind"`
	Fields     []Field    `json:"field"`
	API        Endpoint   `json:"api"`
}

Action specifies an action operation.

type ActionKind

type ActionKind string

ActionKind is the type of action.

const (
	ActionKindAction ActionKind = "Action"
	ActionKindSearch ActionKind = "Search"
)

...

type AppConfig

type AppConfig struct {
	Model    *models.App
	Version  uint       `json:"version"`
	Kind     ConfigKind `json:"kind"`
	Metadata struct {
		Name          string   `json:"name"`
		PublicID      UUID     `mapstructure:"public_id" json:"public_id"`
		Version       string   `json:"version"`
		Description   string   `json:"description"`
		Category      string   `json:"category"`
		Tags          []string `json:"tags"`
		AvatarID      UUID     `mapstructure:"avatar_id" json:"avatar_id"`
		HomepageURL   string   `json:"homepage_url"`
		ResourceNouns []string `json:"resource_nouns"`
		Authors       []Author `json:"authors"`
	} `json:"metadata"`
	Auths struct {
		OAuth2s []OAuth2 `json:"oauth2s"`
		APIKeys []APIKey `json:"api_keys"`
	} `json:"auths"`
	Operations struct {
		Triggers []Trigger `json:"triggers"`
		Actions  []Action  `json:"actions"`
	} `json:"operations"`
}

AppConfig holds the information about an app which can be used in tasks.

type AppCredentialsConfig

type AppCredentialsConfig struct {
	Model    *auth.AppCredentials
	Version  uint       `json:"version"`
	Kind     ConfigKind `json:"kind"`
	Metadata struct {
		AppName string   `mapstructure:"app_name" json:"app_name"`
		AppID   UUID     `mapstructure:"app_id" json:"app_id"`
		Authors []Author `json:"authors"`
	} `json:"metadata"`
	Auths struct {
		OAuth2s []struct {
			Fields map[string][]string `json:"fields"`
			Envs   struct {
				ClientID     string `mapstructure:"client_id" json:"client_id"`
				ClientSecret string `mapstructure:"client_secret" json:"client_secret"`
				RedirectURI  string `mapstructure:"redirect_uri" json:"redirect_uri"`
			} `json:"envs"`
		} `json:"oauth2s"`
		APIKeys []struct {
			Fields map[string][]string `json:"fields"`
			Envs   struct {
				APIKey string `mapstructure:"api_key" json:"api_key"`
			} `json:"envs"`
		} `json:"api_keys"`
	} `json:"auths"`
}

AppCredentialsConfig contains app-specific information for establishing auth.

type AuthKind

type AuthKind string

AuthKind is the type of authorisation an App supports.

const (
	AuthKindOAuth2 AuthKind = "OAuth2"
)

...

type Author

type Author struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

Author describes the author of a config file.

type ConfigFormat

type ConfigFormat string

ConfigFormat is the different config format supported by Sageflow.

const (
	YAML ConfigFormat = "YAML"
	JSON ConfigFormat = "JSON"
	TOML ConfigFormat = "TOML"
)

...

func ToConfigFormat

func ToConfigFormat(format string) (ConfigFormat, error)

ToConfigFormat convert a string to ConfigFormat.

func (*ConfigFormat) String

func (format *ConfigFormat) String() string

type ConfigKind

type ConfigKind string

ConfigKind represents the kind of config file.

const (
	App            ConfigKind = "App"
	Workflow       ConfigKind = "Workflow"
	Sageflow       ConfigKind = "Sageflow"
	Appcredentials ConfigKind = "AppCredentials"
)

...

type Dropdown struct {
	Kind           DropdownKind `json:"kind"`
	AllowsMultiple bool         `mapstructure:"allows_multiple" json:"allows_multiple"`
	AllowsCustom   bool         `mapstructure:"allows_custom" json:"allows_custom"`
	Options        []string     `json:"options"`
}

Dropdown specifies dropdown information.

type DropdownKind string

DropdownKind is the type of dropdown.

const (
	Static  DropdownKind = "Static"
	Dynamic DropdownKind = "Dynamic"
)

...

type Endpoint

type Endpoint struct {
	Code     string `json:"code"`
	Language string `json:"language"`
	Form     struct {
		Method  string            `json:"method"`
		URL     string            `json:"url"`
		Headers map[string]string `json:"headers"`
		Params  map[string]string `json:"params"`
		Body    map[string]string `json:"body"`
	} `json:"form"`
}

Endpoint specifies how a resource is resoved, fetched, updated, etc.

type ExecutionContext

type ExecutionContext string

ExecutionContext refers to how the engine is going to run each task.

const (
	Protected ExecutionContext = "Protected" // Sandboxed code execution
	Bare      ExecutionContext = "Bare"      // Non-sandboxed code execution
)

...

type Field

type Field struct {
	Key              string    `json:"key"`
	Label            string    `json:"label"`
	Tip              string    `json:"tip"`
	IsRequired       bool      `mapstructure:"is_required" json:"is_required"`
	IsWriteOp        bool      `mapstructure:"is_write_op" json:"is_write_op"`
	IsIdentification bool      `mapstructure:"is_identification" json:"is_identification"`
	ResourceNoun     string    `json:"resource_noun"`
	InputKind        InputKind `mapstructure:"input_kind" json:"input_kind"`
	Dropdown         Dropdown  `json:"dropdown"`
}

Field describes an input field.

type InputKind

type InputKind string

InputKind is the type of user input.

const (
	Email  InputKind = "Email"
	Select InputKind = "Select"
)

...

type OAuth2

type OAuth2 struct {
	Label                      string   `json:"label"`
	Scopes                     []string `json:"scopes"`
	ShouldRefreshAutomatically bool     `mapstructure:"should_refresh_automatically" json:"should_refresh_automatically"`
	Fields                     []struct {
		Label            string    `json:"label"`
		Key              string    `json:"key"`
		Tip              string    `json:"tip"`
		IsRequired       bool      `mapstructure:"is_required" json:"is_required"`
		IsAdministrative bool      `mapstructure:"is_administrative" json:"is_administrative"`
		InputKind        InputKind `mapstructure:"input_kind" json:"input_kind"`
		DefaultValue     string    `mapstructure:"default_value" json:"default_value"`
		Dropdown         Dropdown  `json:"dropdown"`
	} `json:"fields"`
	APIs struct {
		AuthorisationRequest Endpoint `mapstructure:"authorisation_request" json:"authorisation_request"`
		AccessTokenRequest   Endpoint `mapstructure:"access_token_request" json:"access_token_request"`
		RefreshTokenRequest  Endpoint `mapstructure:"refresh_token_request" json:"refresh_token_request"`
	} `json:"apis"`
}

OAuth2 holds the necessary information for getting authorisation via OAuth2.

type Poll

type Poll struct {
	Endpoint `json:"endpoint"`
	AuthKind AuthKind `json:"auth_kind"`
}

Poll describes how a trigger polls data.

type RestHook

type RestHook struct {
	AuthKind   AuthKind `json:"auth_kind"`
	Operations struct {
		Subscribe   Endpoint `json:"subscribe"`
		Unsubscribe Endpoint `json:"unsubscribe"`
		List        Endpoint `json:"list"`
	} `json:"operations"`
}

RestHook describes a webhook trigger API.

type SageflowConfig

type SageflowConfig struct {
	Version  uint       `json:"version"`
	Kind     ConfigKind `json:"kind"`
	Metadata struct {
		Authors []Author `json:"authors"`
	} `json:"metdata"`
	Execution struct {
		UseSubprocess bool `mapstructure:"use_subprocess" json:"use_subprocess"`
	} `json:"execution"`
	Services struct {
		TLS   struct{} `json:"tls"`
		Types struct {
			API struct {
				Port int `json:"port"`
			} `json:"api"`
			Engine struct {
				Port int `json:"port"`
			} `json:"engine"`
			Auth struct {
				Port int `json:"port"`
			} `json:"auth"`
		} `json:"types"`
	} `json:"services"`
	SecretsManager struct {
		// contains filtered or unexported fields
	} `mapstructure:"secrets_manager" json:"secrets_manager"`
}

SageflowConfig holds Sageflow configurations. Sec: Secrets shouldn't be stored in this file.

func LoadSageflowConfig

func LoadSageflowConfig() (SageflowConfig, error)

LoadSageflowConfig loads a sageflow config from file

func NewSageflowConfig

func NewSageflowConfig(sageflowString string, format ConfigFormat) (SageflowConfig, error)

NewSageflowConfig creates a SageflowConfig from string. Supports JSON, TOML and YAML string format.

type Step

type Step struct {
	Kind             StepKind            `json:"kind"`
	Name             string              `json:"name"`
	Index            uint                `json:"index"`
	Dependencies     []uint              `json:"dependencies"`
	Position         []uint              `json:"position"`
	AppName          string              `mapstructure:"app_name" json:"app_name"`
	ExecutionContext ExecutionContext    `mapstructure:"execution_context" json:"execution_context"`
	AppID            UUID                `mapstructure:"app_id" json:"app_id"`
	AccountID        UUID                `mapstructure:"account_id" json:"account_id"`
	Fields           map[string][]string `json:"fields"`
}

Step is an executable step in a workflow.

type StepKind

type StepKind string

StepKind is the type of task.

const (
	StepKindTrigger StepKind = "Trigger"
	StepKindAction  StepKind = "Action"
)

...

type Trigger

type Trigger struct {
	Key    string  `json:"key"`
	Label  string  `json:"label"`
	Tip    string  `json:"tip"`
	Fields []Field `json:"field"`
	APIs   struct {
		Polls     []Poll     `json:"polls"`
		RestHooks []RestHook `json:"resthook"`
	} `json:"apis"`
}

Trigger specifies a trigger operation.

type UUID

type UUID uuid.UUID

UUID aliases gofrs/UUID type to allow custom unmarhsalling.

type WorkflowConfig

type WorkflowConfig struct {
	Version  uint       `json:"version"`
	Kind     ConfigKind `json:"kind"`
	Metadata struct {
		Name              string             `json:"name"`
		Description       string             `json:"description"`
		ExecutionContexts []ExecutionContext `mapstructure:"execution_contexts" json:"execution_contexts"`
		Authors           []Author           `json:"authors"`
	} `json:"metadata"`
	Steps []Step `json:"steps"`
}

WorkflowConfig represents a runnable workflow.

func NewWorkflowConfig

func NewWorkflowConfig(workflowString string, format ConfigFormat) (WorkflowConfig, error)

NewWorkflowConfig creates a WorkflowConfig from string. Supports JSON, TOML and YAML string format.

Jump to

Keyboard shortcuts

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