config

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Global = Config{}

Global is the object that contains your configuration

Functions

This section is empty.

Types

type ComposedData

type ComposedData struct {
	Data     string `yaml:"Data,omitempty"`
	Operator string `yaml:"Operator,omitempty"`
}

ComposedData is a struct representing an AttributeValue. You will use this struct to inform parameters of an key.

Example:

  • let's consider that you have a PK and a SK, and your PK needs to be exactly, but your SK is a number and needs to be better than 5

In this case you will indicate: > Keys:

	email:
  		Operator: "="
	id:
  		Operator: "="

You don't need to inform the data, because the client will get then of your request.

type Config

type Config struct {
	TemplateFormatVersion string    `yaml:"TemplateFormatVersion"`
	Description           string    `yaml:"Description"`
	Resources             Resources `yaml:"Resources"`
}

func (*Config) FromFile added in v0.1.8

func (c *Config) FromFile(path string) error

carega as configuracoes do arquivo de configuração

func (*Config) Load

func (config *Config) Load(data []byte) error

Load is the function responsible for unmarshaling the configuration YAML file into an object that can be used by the DynamoDBClient.

func (*Config) Set

func (config *Config) Set() error

Set is the function that can be used to load the content of a Config struct into the Global variable.

type Database

type Database struct {
	TableName      string                  `yaml:"TableName"`
	Keys           map[string]ComposedData `yaml:"Keys"`
	Filter         string                  `yaml:"Filter,omitempty"`
	FilterValues   map[string]string       `yaml:"FilterValues,omitempty"`
	ProjectionCols []string                `yaml:"ProjectionCols,omitempty"`
}

Database is a struct representing the necessary DynamoDB information required to perform actions on your table. To use a DynamoDBClient, it's necessary to specify a 'TableName' and the 'Keys' to be used. If you want to apply filtering to a query, you can specify the 'Filter' and 'FilterValues' attributes. When using the 'Filter', use '#name_of_the_column' to specify the column name and ':name_of_the_column' to represent the value to be filtered. In 'FilterValues', provide the actual value to be filtered.

In the following example, we have a query on the 'users' table, specifying keys 'email' and 'product' that should be equal to the values indicated in the request. Additionally, the query will only retrieve items where the 'age' is greater than 18.

Example: > Database:

		TableName: users
		Keys:
  		email:
    			Operator: "="
  		id:
    			Operator: "="
		Filter: "#age > :age"
		FilterValues:
  		age: "18"
		ProjectionCols:
		- email
		- username
		- age

type DynamoAttributes added in v0.1.8

type DynamoAttributes struct {
	Key                map[string]*dynamodb.AttributeValue
	KeyAttributeValues map[string]*dynamodb.AttributeValue
	KeyAttributeNames  map[string]*string
	AttributeNames     map[string]*string
	AttributeValues    map[string]*dynamodb.AttributeValue
	KeyCondition       string
	UpdateExpression   string
}

type KeyCondition

type KeyCondition struct {
	ExpressionAttributeNames  map[string]*string                `json:"expressionAttributeNames,omitempty"`
	ExpressionAttributeValues map[string]*dynamo.AttributeValue `json:"expressionAttributeValues,omitempty"`
	PrimaryKeys               map[string]*dynamo.AttributeValue `json:"primaryKeys,omitempty"`
	Condition                 string                            `json:"condition,omitempty"`
}

KeyCondition is a struct used in the client to organize the parameters of the query.

type Properties added in v0.1.8

type Properties struct {
	// ApiGateway Receiver
	AllowedMethods []string          `yaml:"AllowedMethods"`
	AllowedPath    map[string]string `yaml:"AllowedPath"`

	// DynamoDB Connector
	TableName     string                 `yaml:"TableName"`
	Keys          map[string]string      `yaml:"Keys"`
	Filter        []string               `yaml:"Filters"`
	FilterValues  map[string]interface{} `yaml:"FilterValues"`
	OutputColumns []string               `yaml:"OutputColumns"`
}

type Request

type Request struct {
	AllowedMethods []string          `yaml:"AllowedMethods"`
	HTTPMethod     string            `yaml:"HttpMethod,omitempty"`
	Parameters     map[string]string `yaml:"Parameters,omitempty"`
}

Request is a struct representing the configuration of an HTTP request. This struct defines the HTTP methods allowed to be processed by the client, the method received in the request, and all the query parameters provided.

Example: > Request:

AllowedMethods:
- GET
- POST
- PUT

type ResourceItem added in v0.1.8

type ResourceItem struct {
	ObjectPathSchema string `yaml:"ObjectPathSchema"`
	ResourceType     string `yaml:"ResourceType"`

	Properties Properties `yaml:"Properties"`
}

func (*ResourceItem) EncodeJSON added in v0.1.8

func (res *ResourceItem) EncodeJSON(data map[string]interface{}) (interface{}, error)

func (*ResourceItem) GetAllAttributeNames added in v0.1.8

func (res *ResourceItem) GetAllAttributeNames(data interface{}) (map[string]*string, error)

Returns the names of all attributes

func (*ResourceItem) GetAllAttributeValues added in v0.1.8

func (res *ResourceItem) GetAllAttributeValues(data interface{}) (map[string]*dynamodb.AttributeValue, error)

Returns the values of all attributes

func (*ResourceItem) GetAttributeNames added in v0.1.8

func (res *ResourceItem) GetAttributeNames(data interface{}) (map[string]*string, error)

Returns the names of all attributes, except those who make up the primary key

func (*ResourceItem) GetAttributeValues added in v0.1.8

func (res *ResourceItem) GetAttributeValues(data interface{}) (map[string]*dynamodb.AttributeValue, error)

Returns the values of all attributes except those that make up the primary key

func (*ResourceItem) GetKeyAttributeNames added in v0.1.8

func (res *ResourceItem) GetKeyAttributeNames(data interface{}) (map[string]*string, error)

func (*ResourceItem) GetKeyAttributeValues added in v0.1.8

func (res *ResourceItem) GetKeyAttributeValues(data interface{}) (map[string]*dynamodb.AttributeValue, error)

func (*ResourceItem) GetKeyConditions added in v0.1.8

func (res *ResourceItem) GetKeyConditions(data interface{}) (string, error)

func (*ResourceItem) GetPrimaryKeyAttributeValue added in v0.1.8

func (res *ResourceItem) GetPrimaryKeyAttributeValue(data interface{}) (map[string]*dynamodb.AttributeValue, error)

Recovers the primary key from the table

func (*ResourceItem) GetUpdateExpression added in v0.1.8

func (res *ResourceItem) GetUpdateExpression(data interface{}) (string, error)

func (*ResourceItem) MarshalMap added in v0.1.8

func (res *ResourceItem) MarshalMap(data map[string]interface{}) (map[string]*dynamodb.AttributeValue, error)

Estrutura dados para criação de registro

func (*ResourceItem) UnmarshalSchema added in v0.1.8

func (res *ResourceItem) UnmarshalSchema() (map[string]interface{}, error)

Pega o schema do arquivo json

func (*ResourceItem) Validate added in v0.1.8

func (res *ResourceItem) Validate(data map[string]interface{}) bool

Valida formato do json de acordo com o schema

type Resources

type Resources struct {
	Receiver  ResourceItem `yaml:"Receiver"`
	Connector ResourceItem `yaml:"Connector"`
}

type Resourcess added in v0.1.8

type Resourcess struct {
	Request  Request  `yaml:"Request"`
	Database Database `yaml:"Database,omitempty"`
	Response Response `yaml:"Response,omitempty"`
}

Resources is a struct used as an attribute of the Config to group information about request, database, and response configurations.

type Response

type Response struct {
	DataStruct string `yaml:"DataStruct,omitempty"`
}

Response is a struct representing the configuration of the response. This struct specifies the data structure of the response in a JSON-based format.

Example: > Response:

DataStruct: '[{"username": "", "age": ""}]'

Jump to

Keyboard shortcuts

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