attr

package
v0.0.0-...-1eb86f4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package attr provides utilities for converting between go and DynamoDB attribute values.

Only types that are required are supported. Conversion from cty types can cover a larger range of types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBool

func FromBool(b bool) dynamodb.AttributeValue

FromBool creates a boolean attribute.

func FromCtyPath

func FromCtyPath(path cty.Path) dynamodb.AttributeValue

FromCtyPath encodes a cty path to an attribute.

func FromCtyValue

func FromCtyValue(v cty.Value) dynamodb.AttributeValue

FromCtyValue encodes a value from the cty type system to a DynamoDB attribute.

In case the value contains nested objects such as objects, they are nested into the returned attribute.

Unknown, dynamic and capsule values are not supported.

func FromExpression

func FromExpression(expression resource.Expression) dynamodb.AttributeValue

FromExpression encodes a graph expression into an attribute.

func FromFloat64

func FromFloat64(v float64) dynamodb.AttributeValue

FromFloat64 creates a numeric attribute from a 64 bit float.

func FromInt64

func FromInt64(v int64) dynamodb.AttributeValue

FromInt64 creates a numeric attribute from a 64 bit integer.

func FromString

func FromString(str string) dynamodb.AttributeValue

FromString creates a string attribute.

func FromStringSet

func FromStringSet(list []string) dynamodb.AttributeValue

FromStringSet creates an unsorted set of strings.

The values are set in the same order as the incoming list, but values may be returned from DynamoDB in another order.

func FromStringSlice

func FromStringSlice(list []string) dynamodb.AttributeValue

FromStringSlice creates an attribute with a sorted list of strings.

func ToBool

func ToBool(attr dynamodb.AttributeValue) (bool, error)

ToBool returns the boolean value from an attribute.

func ToCtyPath

func ToCtyPath(attr dynamodb.AttributeValue) (cty.Path, error)

ToCtyPath decodes an attribute to a cty path.

func ToCtyValue

func ToCtyValue(attr dynamodb.AttributeValue, ty cty.Type) (cty.Value, error)

ToCtyValue decodes an attribute to a value in the cty type system.

The given type is used to determine how values are decoded. An error is returned if the type does not match.

func ToExpression

func ToExpression(attr dynamodb.AttributeValue) (resource.Expression, error)

ToExpression decodes an attribute to a graph expression.

func ToFloat64

func ToFloat64(attr dynamodb.AttributeValue) (float64, error)

ToFloat64 parses a numeric attribute as a 64 bit float.

func ToInt64

func ToInt64(attr dynamodb.AttributeValue) (int64, error)

ToInt64 parses a numeric attribute as a 64 bit integer.

func ToString

func ToString(attr dynamodb.AttributeValue) (string, error)

ToString returns the string from an attribute.

func ToStringSet

func ToStringSet(attr dynamodb.AttributeValue) []string

ToStringSet returns a set of strings from an attribute.

As the set is not sorted, the order is not deterministic.

func ToStringSlice

func ToStringSlice(attr dynamodb.AttributeValue) ([]string, error)

ToStringSlice returns a sorted list of strings.

Types

type NotSetError

type NotSetError struct {
	Target cty.Type
	Key    string
}

NotSetError is returned when trying to read a value and the corresponding field is not set in the DynamoDB attribute value.

func (NotSetError) Error

func (e NotSetError) Error() string

Jump to

Keyboard shortcuts

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