dynamodb

package
v0.0.0-...-3d72318 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2014 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DynamoDB_API_VERSION = "20120810"
)

Variables

This section is empty.

Functions

func UnixDateTimeToTime

func UnixDateTimeToTime(dateTime float64) time.Time

/ Unix date time to systme time

Types

type AttributeDefinition

type AttributeDefinition struct {
	AttributeName string
	AttributeType string // Hash/Range Key: S | N | B, Attribute: S | N | B | SS | NS | BS
}

type AttributeValue

type AttributeValue struct {
	B  []byte   `json:",omitempty"`
	BS [][]byte `json:",omitempty"`
	N  string   `json:",omitempty"`
	NS []string `json:",omitempty"`
	S  string   `json:",omitempty"`
	SS []string `json:",omitempty"`
}

type AttributeValueUpdate

type AttributeValueUpdate struct {
	Action string // ADD | PUT | DELETE
	Value  AttributeValue
}

type Capacity

type Capacity struct {
	CapacityUnits float64
}

type Condition

type Condition struct {
	ComparisonOperator string // EQ | NE | LE | LT | GE | GT | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS | BEGINS_WITH | IN | BETWEEN
	AttributeValueList []AttributeValue
}

type ConsumedCapacity

type ConsumedCapacity struct {
	CapacityUnits          float64
	GlobalSecondaryIndexes map[string]Capacity
	LocalSecondaryIndexes  map[string]Capacity
	Table                  Capacity
	TableName              string
}

ref: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ConsumedCapacity.html

type CreateTableReq

type CreateTableReq struct {
	DynamoDBReq `json:"-"`

	TableName              string
	KeySchema              []KeySchemaElement
	AttributeDefinitions   []AttributeDefinition
	GlobalSecondaryIndexes []GlobalSecondaryIndex `json:",omitempty"`
	LocalSecondaryIndexes  []LocalSecondaryIndex  `json:",omitempty"`
	ProvisionedThroughput  ProvisionedThroughput
}

func (*CreateTableReq) Init

func (this *CreateTableReq) Init() *CreateTableReq

type CreateTableResp

type CreateTableResp struct {
	DynamoDBResp     `json:"-"`
	TableDescription TableDescription
}

==================================== CreateTableResp

func (*CreateTableResp) Init

func (this *CreateTableResp) Init(req *CreateTableReq, resp *http.Response) (*CreateTableResp, error)

type DeleteItemReq

type DeleteItemReq struct {
	DynamoDBReq `json:"-"`

	TableName                   string
	Key                         map[string]AttributeValue
	ConditionalOperator         string                            `json:",omitempty"` // "AND", "OR"
	Expected                    map[string]ExpectedAttributeValue `json:",omitempty"`
	ReturnConsumedCapacity      string                            `json:",omitempty"` // INDEXES | TOTAL | NONE
	ReturnItemCollectionMetrics string                            `json:",omitempty"` // "SIZE", "NONE"
	ReturnValues                string                            `json:",omitempty"` // NONE | ALL_OLD | UPDATED_OLD | ALL_NEW | UPDATED_NEW
}

func (*DeleteItemReq) Init

func (this *DeleteItemReq) Init() *DeleteItemReq

type DeleteItemResp

type DeleteItemResp struct {
	DynamoDBResp `json:"-"`

	Attributes            map[string]AttributeValue
	ConsumedCapacity      ConsumedCapacity
	ItemCollectionMetrics ItemCollectionMetrics
}

==================================== DeleteItemResp

func (*DeleteItemResp) Init

func (this *DeleteItemResp) Init(req *DeleteItemReq, resp *http.Response) (*DeleteItemResp, error)

type DeleteTableReq

type DeleteTableReq struct {
	DynamoDBReq `json:"-"`

	TableName string
}

func (*DeleteTableReq) Init

func (this *DeleteTableReq) Init() *DeleteTableReq

type DeleteTableResp

type DeleteTableResp struct {
	DynamoDBResp     `json:"-"`
	TableDescription TableDescription
}

==================================== DeleteTableResp

func (*DeleteTableResp) Init

func (this *DeleteTableResp) Init(req *DeleteTableReq, resp *http.Response) (*DeleteTableResp, error)

type DescribeTableReq

type DescribeTableReq struct {
	DynamoDBReq `json:"-"`
	TableName   string `json:"TableName"`
}

======================================= DescribeTableReq

func (*DescribeTableReq) Init

func (this *DescribeTableReq) Init() *DescribeTableReq

type DescribeTableResp

type DescribeTableResp struct {
	DynamoDBResp     `json:"-"`
	TableDescription TableDescription `json:"Table"`
}

func (*DescribeTableResp) Init

type DynamoDB

type DynamoDB struct {
	common.AWSService
}

*

ref: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/API.html

func NewDynamoDB

func NewDynamoDB(cred *common.Credentials) (*DynamoDB, error)

func (*DynamoDB) CreateTable

func (this *DynamoDB) CreateTable(req *CreateTableReq) (*CreateTableResp, error)

func (*DynamoDB) DeleteItem

func (this *DynamoDB) DeleteItem(req *DeleteItemReq) (*DeleteItemResp, error)

func (*DynamoDB) DeleteTable

func (this *DynamoDB) DeleteTable(req *DeleteTableReq) (*DeleteTableResp, error)

func (*DynamoDB) DescribeTable

func (this *DynamoDB) DescribeTable(req *DescribeTableReq) (*DescribeTableResp, error)

func (*DynamoDB) GetItem

func (this *DynamoDB) GetItem(req *GetItemReq) (*GetItemResp, error)

func (*DynamoDB) Init

func (this *DynamoDB) Init(cred *common.Credentials) (*DynamoDB, error)

func (*DynamoDB) ListTables

func (this *DynamoDB) ListTables(req *ListTablesReq) (*ListTablesResp, error)

func (*DynamoDB) PutItem

func (this *DynamoDB) PutItem(req *PutItemReq) (*PutItemResp, error)

func (*DynamoDB) Query

func (this *DynamoDB) Query(req *QueryReq) (*QueryResp, error)

func (*DynamoDB) Scan

func (this *DynamoDB) Scan(req *ScanReq) (*ScanResp, error)

func (*DynamoDB) UpdateItem

func (this *DynamoDB) UpdateItem(req *UpdateItemReq) (*UpdateItemResp, error)

type DynamoDBReq

type DynamoDBReq struct {
	common.AWSRequest
}

type DynamoDBResp

type DynamoDBResp struct {
	common.AWSResponse
	Error *Error // response error code from server
}

func (*DynamoDBResp) Init

func (this *DynamoDBResp) Init(req *DynamoDBReq, resp *http.Response) (*DynamoDBResp, error)

type Error

type Error struct {
	Type      string `json:"__type"`
	Message   string `json`
	Exception string `json:"-"` // parse from type

}

*

DynamoDB error handle: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html

func (*Error) Error

func (this *Error) Error() string

type ExpectedAttributeValue

type ExpectedAttributeValue struct {
	AttributeValueList []AttributeValue `json:",omitempty"`
	ComparisonOperator string           // EQ | NE | LE | LT | GE | GT | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS | BEGINS_WITH | IN | BETWEEN

}

ref: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ExpectedAttributeValue.html

type GetItemReq

type GetItemReq struct {
	DynamoDBReq `json:"-"`

	TableName              string                    `json:"TableName"`
	Key                    map[string]AttributeValue `json:"Key"`
	AttributesToGet        []string                  `json:",omitempty"`
	ConsistentRead         bool                      `json:",omitempty"`
	ReturnConsumedCapacity string                    `json:",omitempty"` // INDEXES | TOTAL | NONE
}

doc: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html

func (*GetItemReq) Init

func (this *GetItemReq) Init() *GetItemReq

type GetItemResp

type GetItemResp struct {
	DynamoDBResp `json:"-"`

	Attributes       map[string]AttributeValue `json:"Item"`
	ConsumedCapacity ConsumedCapacity
}

==================================== GetItemResp

func (*GetItemResp) Init

func (this *GetItemResp) Init(req *GetItemReq, resp *http.Response) (*GetItemResp, error)

type GlobalSecondaryIndex

type GlobalSecondaryIndex struct {
	IndexName             string
	KeySchema             []KeySchemaElement
	Projection            Projection
	ProvisionedThroughput ProvisionedThroughput
}

type GlobalSecondaryIndexDescription

type GlobalSecondaryIndexDescription struct {
	IndexName             string // 3 <= Len(IndexName) <= 255
	IndexSizeBytes        int64
	IndexStatus           string // "CREATING", "UPDATING", "DELETING", "ACTIVE"
	ItemCount             int64
	KeySchema             []KeySchemaElement
	Projection            Projection
	ProvisionedThroughput ProvisionedThroughputDescription
}

ref: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GlobalSecondaryIndexDescription.html

type ItemCollectionMetrics

type ItemCollectionMetrics struct {
	ItemCollectionKey   map[string]AttributeValue
	SizeEstimateRangeGB []float64
}

type KeySchemaElement

type KeySchemaElement struct {
	AttributeName string // 1 <= Len(AttributeName) <= 255
	KeyType       string // "HASH" or "RANGE"
}

type ListTablesReq

type ListTablesReq struct {
	DynamoDBReq             `json:"-"`
	ExclusiveStartTableName string `json:",omitempty"`
	Limit                   uint   `json:",string,omitempty"`
}

========================== ListTablesReq

func (*ListTablesReq) Init

func (this *ListTablesReq) Init() *ListTablesReq

func (*ListTablesReq) WithExclusiveStartTableName

func (this *ListTablesReq) WithExclusiveStartTableName(exclusive string) *ListTablesReq

type ListTablesResp

type ListTablesResp struct {
	DynamoDBResp           `json:"-"`
	TableNames             []string
	LastEvaluatedTableName string
}

================================= ListTablesResp

func (*ListTablesResp) Init

func (this *ListTablesResp) Init(req *ListTablesReq, resp *http.Response) (*ListTablesResp, error)

type LocalSecondaryIndex

type LocalSecondaryIndex struct {
	IndexName  string
	KeySchema  []KeySchemaElement
	Projection Projection
}

type LocalSecondaryIndexDescription

type LocalSecondaryIndexDescription struct {
	IndexName      string // 3 <= Len(IndexName) <= 255
	IndexSizeBytes int64
	ItemCount      int64
	KeySchema      []KeySchemaElement
	Projection     Projection
}

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_LocalSecondaryIndexDescription.html

type Projection

type Projection struct {
	NonKeyAttributes []string `json:",omitempty"` // one at least, no more than 20 attributes
	ProjectionType   string   `json:",omitempty"` // "KEYS_ONLY", "INCLUDE", "ALL"
}

type ProvisionedThroughput

type ProvisionedThroughput struct {
	ReadCapacityUnits  int //`json:",string"`
	WriteCapacityUnits int //`json:",string"`
}

type ProvisionedThroughputDescription

type ProvisionedThroughputDescription struct {
	LastDecreaseDateTime   float64
	LastIncreaseDateTime   float64
	NumberOfDecreasesToday int64
	ReadCapacityUnits      int64
	WriteCapacityUnits     int64
}

ref: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ProvisionedThroughputDescription.html

func (*ProvisionedThroughputDescription) LastDecreaseTime

func (this *ProvisionedThroughputDescription) LastDecreaseTime() time.Time

func (*ProvisionedThroughputDescription) LastIncreaseTime

func (this *ProvisionedThroughputDescription) LastIncreaseTime() time.Time

type PutItemReq

type PutItemReq struct {
	DynamoDBReq `json:"-"`

	TableName                   string
	Attributes                  map[string]AttributeValue         `json:"Item"`
	ConditionalOperator         string                            `json:",omitempty"` // "AND", "OR"
	Expected                    map[string]ExpectedAttributeValue `json:",omitempty"`
	ReturnConsumedCapacity      string                            `json:",omitempty"` // INDEXES | TOTAL | NONE
	ReturnItemCollectionMetrics string                            `json:",omitempty"` // "SIZE", "NONE"
	ReturnValues                string                            `json:",omitempty"` // NONE | ALL_OLD | UPDATED_OLD | ALL_NEW | UPDATED_NEW
}

ref: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html#DDB-PutItem-request-Expected

func (*PutItemReq) Init

func (this *PutItemReq) Init() *PutItemReq

type PutItemResp

type PutItemResp struct {
	DynamoDBResp `json:"-"`

	Attributes            map[string]AttributeValue
	ConsumedCapacity      ConsumedCapacity
	ItemCollectionMetrics ItemCollectionMetrics
}

func (*PutItemResp) Init

func (this *PutItemResp) Init(req *PutItemReq, resp *http.Response) (*PutItemResp, error)

type QueryReq

type QueryReq struct {
	DynamoDBReq

	TableName        string `json:"TableName"`
	KeyConditions    map[string]Condition
	Select           string   `json:",omitempty"` // ALL_ATTRIBUTES | ALL_PROJECTED_ATTRIBUTES | SPECIFIC_ATTRIBUTES | COUNT
	AttributesToGet  []string `json:",omitempty"`
	IndexName        string   `json:",omitempty"`
	ConsistentRead   bool
	ScanIndexForward bool

	ConditionalOperator string               `json:",omitempty"` // "AND", "OR"  // A logical operator to apply to the conditions in the QueryFilter map
	QueryFilter         map[string]Condition `json:",omitempty"`

	Limit             int                       `json:",omitempty"`
	ExclusiveStartKey map[string]AttributeValue `json:",omitempty"`

	ReturnConsumedCapacity string `json:",omitempty"` // INDEXES | TOTAL | NONE
}

==================================== QueryReq ref: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html

func (*QueryReq) Init

func (this *QueryReq) Init() *QueryReq

type QueryResp

type QueryResp struct {
	DynamoDBResp     `json:"-"`
	Count            int
	ScannedCount     int
	Items            []map[string]AttributeValue
	LastEvaluatedKey map[string]AttributeValue

	ConsumedCapacity ConsumedCapacity
}

func (*QueryResp) Init

func (this *QueryResp) Init(req *QueryReq, resp *http.Response) (*QueryResp, error)

type ScanReq

type ScanReq struct {
	DynamoDBReq `json:"-"`

	TableName         string                    `json:"TableName"`
	Select            string                    `json:",omitempty"` // ALL_ATTRIBUTES | ALL_PROJECTED_ATTRIBUTES | SPECIFIC_ATTRIBUTES | COUNT
	AttributesToGet   []string                  `json:",omitempty"`
	ExclusiveStartKey map[string]AttributeValue `json:",omitempty"`
	Limit             int                       `json:",omitempty"`

	ConditionalOperator string               `json:",omitempty"` // "AND", "OR"
	ScanFilter          map[string]Condition `json:",omitempty"`

	TotalSegments int `json:",omitempty"`
	Segment       int `json:",omitempty"`

	ReturnConsumedCapacity string `json:",omitempty"` // INDEXES | TOTAL | NONE
}

func (*ScanReq) Init

func (this *ScanReq) Init() *ScanReq

type ScanResp

type ScanResp struct {
	DynamoDBResp     `json:"-"`
	Count            int
	ScannedCount     int
	Items            []map[string]AttributeValue
	LastEvaluatedKey map[string]AttributeValue

	ConsumedCapacity ConsumedCapacity
}

================================== ScanResp

func (*ScanResp) Init

func (this *ScanResp) Init(req *ScanReq, resp *http.Response) (*ScanResp, error)

type TableDescription

type TableDescription struct {
	TableName              string // 3 <= Len(TableName) <= 255
	TableSizeBytes         int64
	TableStatus            string // "CREATING", "UPDATING", "DELETING", "ACTIVE"
	ItemCount              int64
	CreationDateTime       float64
	AttributeDefinitions   []AttributeDefinition
	KeySchema              []KeySchemaElement
	LocalSecondaryIndexes  []LocalSecondaryIndexDescription
	ProvisionedThroughput  ProvisionedThroughputDescription
	GlobalSecondaryIndexes []GlobalSecondaryIndexDescription
}

================================= DescribeTableResp ref: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TableDescription.html

func (*TableDescription) CreationTime

func (this *TableDescription) CreationTime() time.Time

type UpdateItemReq

type UpdateItemReq struct {
	DynamoDBReq `json:"-"`

	TableName        string
	Key              map[string]AttributeValue
	AttributeUpdates map[string]AttributeValueUpdate

	ConditionalOperator         string                            `json:",omitempty"` // "AND", "OR"
	Expected                    map[string]ExpectedAttributeValue `json:",omitempty"`
	ReturnConsumedCapacity      string                            `json:",omitempty"` // INDEXES | TOTAL | NONE
	ReturnItemCollectionMetrics string                            `json:",omitempty"` // "SIZE", "NONE"
	ReturnValues                string                            `json:",omitempty"` // NONE | ALL_OLD | UPDATED_OLD | ALL_NEW | UPDATED_NEW

}

func (*UpdateItemReq) Init

func (this *UpdateItemReq) Init() *UpdateItemReq

type UpdateItemResp

type UpdateItemResp struct {
	DynamoDBResp `json:"-"`

	Attributes            map[string]AttributeValue
	ConsumedCapacity      ConsumedCapacity
	ItemCollectionMetrics ItemCollectionMetrics
}

==================================== UpdateItemResp

func (*UpdateItemResp) Init

func (this *UpdateItemResp) Init(req *UpdateItemReq, resp *http.Response) (*UpdateItemResp, error)

Jump to

Keyboard shortcuts

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