models

package
v0.0.0-...-8f5bff0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 17 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ALBEvent

type ALBEvent struct {
	ListenerARN string            `yaml:"listenerArn"`
	Priority    int               `yaml:",omitempty"`
	Conditions  map[string]string `yaml:",omitempty"`
}

ALBEvent ...

type AlexaEvent

type AlexaEvent struct {
	AppID   string `yaml:"appId"`
	Enabled bool   `yaml:",omitempty"`
}

AlexaEvent ...

type Attribute

type Attribute struct {
	Name    string      `json:"name"`
	Ident   flect.Ident `json:"ident"`
	GoType  string      `json:"go_type"`
	AwsType string      `json:"aws_type"`
}

Attribute represents a resource model's attribute

func (Attribute) String

func (a Attribute) String(isKey bool) string

String returns the string representation of an attribute

type AttributeDef

type AttributeDef struct {
	AttributeName string `yaml:"AttributeName"`
	AttributeType string `yaml:"AttributeType"`
}

AttributeDef ...

type AttributeDefinition

type AttributeDefinition struct {
	Ident   flect.Ident `json:"ident"`
	AwsType string      `json:"aws_type"`
}

AttributeDefinition represents the definition of a resource's attribute

type Authorizer

type Authorizer struct {
	ARN                          string
	Name                         string `yaml:",omitempty"`
	ResultTTL                    int    `yaml:"resultTtlInSeconds,omitempty"`
	IdentitySource               string `yaml:"identitySource,omitempty"`
	IdentityValidationExpression string `yaml:"identityValidationExpression,omitempty"`
	Type                         string `yaml:",omitempty"`
}

Authorizer ...

type CognitoEvent

type CognitoEvent struct {
	Pool     string
	Trigger  string
	Existing bool
}

CognitoEvent ...

type DQLConfig

type DQLConfig struct {
	ProjectName string
	ProjectPath string
	Region      string
	Schemas     map[string]*Schema
	Resources   map[string]*Resource
}

DQLConfig ...

func ReadDQLConfig

func ReadDQLConfig() (*DQLConfig, error)

ReadDQLConfig ...

func (*DQLConfig) AddSchema

func (c *DQLConfig) AddSchema(schemaName, path string) error

AddSchema adds a new instance of Schema to the Config

func (DQLConfig) CreateResourceTables

func (c DQLConfig) CreateResourceTables(overwrite bool) error

CreateResourceTables creates the tables in the local DynamoDB named by the given mode

func (DQLConfig) MakeBuild

func (c DQLConfig) MakeBuild(test bool)

MakeBuild renders the Makefile and builds the binaries

func (DQLConfig) MakeDebug

func (c DQLConfig) MakeDebug()

MakeDebug renders the Makefile and builds the debug binaries

func (DQLConfig) ReadServerlessConfig

func (c DQLConfig) ReadServerlessConfig() (*ServerlessConfig, error)

ReadServerlessConfig reads the ServerlessConfig from serverless.yml in the resource or function group directory. If a serverless.yml file does not exist, a new default ServerlessConfig is returned

func (*DQLConfig) Remove

func (c *DQLConfig) Remove(name string) error

Remove removes the schema/ function from the Config

func (DQLConfig) RemoveFiles

func (c DQLConfig) RemoveFiles(name string) error

RemoveFiles ...

func (*DQLConfig) RemoveResource

func (c *DQLConfig) RemoveResource(resourceName string, deleteTable bool) error

RemoveResource removes a given resource from the DQLConfig and ServerlessConfig

func (DQLConfig) RemoveResourceFiles

func (c DQLConfig) RemoveResourceFiles(schemaName, resourceName string) error

RemoveResourceFiles ...

func (DQLConfig) Write

func (c DQLConfig) Write() error

Write write the DQLConfig to dql.config.json in the project path

type DeploymentBucket

type DeploymentBucket struct {
	Name string
	SSE  string            `yaml:"serverSideEncryption,omitempty"`
	Tags map[string]string `yaml:",omitempty"`
}

DeploymentBucket ...

type Events

type Events struct {
	HTTP            *HTTPEvent      `yaml:"http,omitempty"`
	WebSocket       *WebSocketEvent `yaml:"websocket,omitempty"`
	S3              *S3Event        `yaml:"s3,omitempty"`
	Schedule        *ScheduleEvent  `yaml:"schedule,omitempty"`
	SNS             *SNSEvent       `yaml:"sns,omitempty"`
	SQS             *SQSEvent       `yaml:"sqs,omitempty"`
	Stream          *StreamEvent    `yaml:"stream,omitempty"`
	AlexaSkill      *AlexaEvent     `yaml:"alexaSkill,omitempty"`
	AlexaSmartHome  *AlexaEvent     `yaml:"alexaSmartHome,omitempty"`
	IOT             *IOTEvent       `yaml:"iot,omitempty"`
	CognitoUserPool *CognitoEvent   `yaml:"cognitoUserPool,omitempty"`
	ALB             *ALBEvent       `yaml:"alb,omitempty"`
}

Events ...

type FnEnvironment

type FnEnvironment struct {
	Variables map[string]string `yaml:"Variables,omitempty"`
}

FnEnvironment ...

type GlobalConfig

type GlobalConfig struct {
	Function SAMFnProp `yaml:"Function"`
}

GlobalConfig ...

type GlobalIndex

type GlobalIndex struct {
	IndexName             string                 `yaml:"IndexName"`
	KeySchema             []KeySchema            `yaml:"KeySchema"`
	Projection            Projection             `yaml:"Projection"`
	ProvisionedThroughput *ProvisionedThroughput `yaml:"ProvisionedTroughput,omitempty"`
}

GlobalIndex ...

type HTTPEvent

type HTTPEvent struct {
	Path       string
	Method     string
	CORS       bool        `yaml:",omitempty"`
	Private    bool        `yaml:",omitempty"`
	Authorizer *Authorizer `yaml:",omitempty"`
	Scopes     []string    `yaml:",omitempty"`
}

HTTPEvent ...

type IOTEvent

type IOTEvent struct {
	Name        string `yaml:",omitempty"`
	Description string `yaml:",omitempty"`
	Enabled     bool   `yaml:",omitempty"`
	SQL         string `yaml:"sql,omitempty"`
	SQLVersion  string `yaml:"sqlVersion,omitempty"`
}

IOTEvent ...

type KeySchema

type KeySchema struct {
	AttributeName string `yaml:"AttributeName"`
	KeyType       string `yaml:"KeyType"`
}

KeySchema ...

type Layer

type Layer struct {
	Path               string
	Name               string   `yaml:",omitempty"`
	Description        string   `yaml:",omitempty"`
	CompatibleRuntimes []string `yaml:"compatibleRuntimes,omitempty"`
	License            string   `yaml:"licenseInfo,omitempty"`
	AllowedAccounts    []string `yaml:"allowedAccounts,omitempty"`
	Retain             bool     `yaml:",omitempty"`
}

Layer ...

type LocalIndex

type LocalIndex struct {
	IndexName  string      `yaml:"IndexName"`
	KeySchema  []KeySchema `yaml:"KeySchema"`
	Projection Projection  `yaml:"Projection"`
}

LocalIndex ...

type LogConfig

type LogConfig struct {
	RESTAPI   bool `yaml:"restApi,omitempty"`
	WebSocket bool `yaml:"websocket,omitempty"`
}

LogConfig ...

type Model

type Model struct {
	Name          string               `json:"name"`
	Type          string               `json:"type"`
	Ident         flect.Ident          `json:"ident"`
	Attributes    map[string]Attribute `json:"attributes"`
	Nested        []*Model             `json:"nested"`
	Imports       []string             `json:"imports"`
	KeySchema     map[string]string    `json:"key_schema"`
	GeneratedID   bool                 `json:"generated_id"`
	CompositeKey  bool                 `json:"composite_key"`
	BillingMode   string               `json:"billing_mode"`
	CapacityUnits map[string]int64     `json:"capacity_units"`
}

Model represents a resource model object

func New

func New(name string, slice bool, attributes string, options map[string]interface{}) (*Model, error)

New returns a new model object

func (Model) GetConfig

func (m Model) GetConfig() (*DQLConfig, error)

GetConfig returns the updated DQLConfig with the information from this Model

func (*Model) GetImports

func (m *Model) GetImports() []string

GetImports recursively iterates through all import slices and adds the import to the root model

func (Model) String

func (m Model) String() string

String prints a representation of a model

func (Model) Write

func (m Model) Write(path string) error

Write write the Model definition to the modelName.json

type Package

type Package struct {
	Excludes     []string `yaml:"exclude,omitempty"`
	Includes     []string `yaml:"include,omitempty"`
	Individually bool     `yaml:",omitempty"`
}

Package ...

type Projection

type Projection struct {
	NonKeyAttributes []string `yaml:"NonKeyAttributes,omitempty"`
	ProjectionType   string   `yaml:"ProjectionType,omitempty"`
}

Projection ...

type Properties

type Properties struct {
	// Properties for Resources
	AttributeDefinitions   []AttributeDef         `yaml:"AttributeDefinitions,omitempty"`
	KeySchema              []KeySchema            `yaml:"KeySchema,omitempty"`
	ProvisionedThroughput  *ProvisionedThroughput `yaml:"ProvisionedThroughput,omitempty"`
	BillingMode            string                 `yaml:"BillingMode,omitempty"`
	TableName              string                 `yaml:"TableName,omitempty"`
	LocalSecondaryIndexes  []LocalIndex           `yaml:"LocalSecondaryIndexes,omitempty"`
	GlobalSecondaryIndexes []GlobalIndex          `yaml:"GlobalSecondaryIndexes,omitempty"`
	TTLSpecification       TTLSpecification       `yaml:"TimeToLiveSpecification,omitempty"`

	//Properties for Authorizer
	Name           string    `yaml:"Name,omitempty"`
	IdentitySource string    `yaml:"IdentitySource,omitempty"`
	RestAPIID      Reference `yaml:"RestApiId,omitempty"`
	Type           string    `yaml:"Type,omitempty"`
	ProviderARNs   []string  `yaml:"ProviderARNs,omitempty"`
}

Properties ...

type Provider

type Provider struct {
	Name                string
	Runtime             string
	Region              string
	Stage               string
	StackName           string `yaml:"stackName,omitempty"`
	APIName             string `yaml:"apiName,omitempty"`
	Profile             string `yaml:",omitempty"`
	MemSize             string `yaml:"memorySize,omitempty"`
	ReservedConcurrency int    `yaml:"reservedConcurrency,omitempty"`
	Timeout             int    `yaml:"timeout,omitempty"`

	DeyploymentBucket DeploymentBucket  `yaml:"deploymendBucket,omitempty"`
	DeploymentPrefix  string            `yaml:"deploymentPrefix,omitempty"`
	Environments      map[string]string `yaml:"environment,omitempty"`
	RoleStatements    []RoleStatement   `yaml:"iamRoleStatements,omitempty"`
	EndpointType      string            `yaml:"endpointType,omitempty"`
	NotificationARNs  []string          `yaml:"notificationArns,omitempty"`
	Tags              map[string]string `yaml:",omitempty"`
	Tracing           TracingConfig     `yaml:",omitempty"`
	Logs              LogConfig         `yaml:",omitempty"`
	// contains filtered or unexported fields
}

Provider ...

type ProvisionedThroughput

type ProvisionedThroughput struct {
	ReadCapacityUnits  int64 `yaml:"ReadCapacityUnits"`
	WriteCapacityUnits int64 `yaml:"WriteCapacityUnits"`
}

ProvisionedThroughput ...

type Reference

type Reference struct {
	Ref string `yaml:"Ref"`
}

Reference ...

type Resource

type Resource struct {
	Ident      flect.Ident
	Attributes map[string]AttributeDefinition
}

Resource ...

type ResourceDefinition

type ResourceDefinition struct {
	DependsOn      []string   `yaml:"DependsOn,omitempty"`
	Type           string     `yaml:"Type"`
	DeletionPolicy string     `yaml:"DeletionPolicy,omitempty"`
	Properties     Properties `yaml:"Properties"`
}

ResourceDefinition ...

type Resources

type Resources struct {
	Resources map[string]*ResourceDefinition `yaml:"Resources"`
}

Resources ...

type RoleStatement

type RoleStatement struct {
	Effect   string   `yaml:"Effect"`
	Actions  []string `yaml:"Action"`
	Resource string   `yaml:"Resource"`
}

RoleStatement ...

type S3Event

type S3Event struct {
	Bucket string
	Event  string
	Rules  map[string]string `yaml:",omitempty"`
}

S3Event ...

type SAMEvent

type SAMEvent struct {
	Type       string  `yaml:"Type"`
	Properties SAMProp `yaml:"Properties"`
}

SAMEvent ...

type SAMFnProp

type SAMFnProp struct {
	Runtime     string              `yaml:"Runtime,omitempty"`
	Handler     string              `yaml:"Handler,omitempty"`
	CodeURI     string              `yaml:"CodeUri,omitempty"`
	Events      map[string]SAMEvent `yaml:"Events,omitempty"`
	Environment FnEnvironment       `yaml:"Environment,omitempty"`
}

SAMFnProp ...

type SAMFunction

type SAMFunction struct {
	Type       string    `yaml:"Type"`
	Properties SAMFnProp `yaml:"Properties"`
}

SAMFunction ...

type SAMProp

type SAMProp struct {
	Path   string `yaml:"Path"`
	Method string `yaml:"Method"`
}

SAMProp ...

type SNSEvent

type SNSEvent struct {
	TopicName   string `yaml:"topicName"`
	DisplayName string `yaml:"displayName,omitempty"`
}

SNSEvent ...

type SQSEvent

type SQSEvent struct {
	ARN       string `yaml:"arn"`
	BatchSize int    `yaml:"batchSize,omitempty"`
}

SQSEvent ...

type ScheduleEvent

type ScheduleEvent struct {
	Name        string
	Description string `yaml:",omitempty"`
	Rate        string
	Enabled     bool   `yaml:",omitempty"`
	InputPath   string `yaml:"inputPath,omitempty"`
}

ScheduleEvent ...

type Schema

type Schema struct {
	Name string
	Path string
}

Schema ...

type ServerlessConfig

type ServerlessConfig struct {
	ProjectPath string `yaml:"-"`
	Service     Service
	Provider    Provider
	Package     Package
	Functions   map[string]*ServerlessFunction `yaml:",omitempty"`
	Layers      map[string]Layer               `yaml:",omitempty"`
	Resources   Resources                      `yaml:",omitempty"`
}

ServerlessConfig ...

func (*ServerlessConfig) AddAuth

func (s *ServerlessConfig) AddAuth(excludes string)

AddAuth adds Authorization to the ServerlessConfig

func (*ServerlessConfig) AddFunction

func (s *ServerlessConfig) AddFunction(name, path, method string) *ServerlessConfig

AddFunction adds a Function with given name, path and method to the ServerlessConfig

func (*ServerlessConfig) AddPoolEnv

func (s *ServerlessConfig) AddPoolEnv(ms ServerlessConfig, rName, pool string) error

AddPoolEnv adds the given cognito user pool arn as environment in .env

func (*ServerlessConfig) AddSchema

func (s *ServerlessConfig) AddSchema(schemaName, path string) *ServerlessConfig

AddSchema adds the Schema to the ServerlessConfig

func (*ServerlessConfig) RemoveAuth

func (s *ServerlessConfig) RemoveAuth()

RemoveAuth removes Authorization from the ServerlessConfig

func (*ServerlessConfig) RemoveFunction

func (s *ServerlessConfig) RemoveFunction(n string) *ServerlessConfig

RemoveFunction removes a function from the ServerlessConfig

func (*ServerlessConfig) SetResourceWithModel

func (s *ServerlessConfig) SetResourceWithModel(c *DQLConfig, m *Model)

SetResourceWithModel sets a Resource to the ServerlessConfig

func (*ServerlessConfig) Write

func (s *ServerlessConfig) Write() error

Write writes the ServerlessConfig to serverless.yml

type ServerlessFunction

type ServerlessFunction struct {
	Handler             string
	Package             Package           `yaml:",omitempty"`
	Name                string            `yaml:",omitempty"`
	Description         string            `yaml:",omitempty"`
	MemorySize          int               `yaml:",omitempty"`
	ReservedConcurrency int               `yaml:"reservedConcurrency,omitempty"`
	RunTime             string            `yaml:"runtime,omitempty"`
	Timeout             int               `yaml:",omitempty"`
	AWSKMSKeyARN        string            `yaml:"awsKmsKeyArn,omitempty"`
	Environments        map[string]string `yaml:"environment,omitempty"`
	Tags                map[string]string `yaml:",omitempty"`
	Layers              []string          `yaml:",omitempty"`
	Events              []Events
}

ServerlessFunction ...

type Service

type Service struct {
	Name         string
	AWSKMSKeyARN string `yaml:"awsKmsKeyArn,omitempty"`
}

Service ...

type StreamEvent

type StreamEvent struct {
	ARN              string `yaml:"arn"`
	BatchSize        int    `yaml:"batchSize,omitempty"`
	StartingPosition string `yaml:"startingPosition,omitempty"`
	Enabled          bool   `yaml:",omitempty"`
}

StreamEvent ...

type TTLSpecification

type TTLSpecification struct {
	AttributeName string `yaml:"AttributeName"`
	Enabled       bool   `yaml:"Enabled"`
}

TTLSpecification ...

type TemplateConfig

type TemplateConfig struct {
	ProjectPath string                 `yaml:"-"`
	Transform   string                 `yaml:"Transform"`
	Globals     GlobalConfig           `yaml:"Globals"`
	Resources   map[string]SAMFunction `yaml:"Resources"`
}

TemplateConfig ...

func NewTemplate

func NewTemplate(c *DQLConfig) (*TemplateConfig, error)

NewTemplate returns a new TemplateConfig

func (*TemplateConfig) Write

func (t *TemplateConfig) Write() error

Write writes the TemplateConfig to template.yml

type TracingConfig

type TracingConfig struct {
	APIGateway bool `yaml:"apiGateway,omitempty"`
	Lambda     bool `yaml:",omitempty"`
}

TracingConfig ...

type WebSocketEvent

type WebSocketEvent struct {
	Route      string
	Authorizer *Authorizer `yaml:",omitempty"`
}

WebSocketEvent ...

Jump to

Keyboard shortcuts

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