awsgo

package module
v0.0.0-...-1a19813 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2015 License: BSD-3-Clause Imports: 25 Imported by: 1

README

awsgo

An incomplete go library to talk to AWS services. http://godoc.org/github.com/fromkeith/awsgo

This is by no means a fully, complete, or well tested library. It will evolve as needed. Pull requests are more then welcome. As well as any go related tips or feedback.

Services

Supported operations for each service:

Caveat: Not every operation has had each option fully tested. See examples for some minor tests / uses.

Cloud Watch
  • Put Metric
  • Get Metric Statistics
  • Logs:
    • Create Log Group
    • Create Log Stream
    • Get Log Events
    • Put Log Events
    • Put Rentention Policy
DynamoDB

Caveat: Binary values are not yet supported.

Godoc: http://godoc.org/github.com/fromkeith/awsgo/dynamo

  • Batch Get Item
  • Batch Write Item
  • Delete Item
  • Describe Table
  • Get Item
  • Put Item
  • Query
  • Scan
  • Update Item
  • Update Table
S3
  • Get Object
  • Head Object
  • Put Object
SES
  • Send Email
  • Some helpers for dealing with the SNS notifications
SQS
  • Batch Send Message
  • Change Message Visibility
  • Delete Message
  • Receive Message
  • Send Message
  • Document Batch Write
EC2
  • Describe Instances
  • Get Instance Metadata
SNS
  • Publish

SWF

  • Poll For Activity Task
  • Poll For Decision Task
  • Record Activity Task Heartbeat
  • Respond Activity Task Canceled
  • Respond Activity Task Completed
  • Respond Activity Task Failed
  • Respond Decision Task Completed
  • Start Workflow Execution
  • A custom workflow execution helper, to make the incrmental decision process easier. See swf/swfhelper

Depends on

github.com/pmylund/sortutil
- for sorting

License

See LICENSE file.

Documentation

Overview

awsgo

Awsgo is a wrapper around AWS API calls. It is divided into separate namespaces for each AWS service. Check each package for their documentation.

This package holds the base/shared functionality between all requests. Most likely, from this package, you will only be using a few methods, and now the AwsRequest object directly.

Credentials

Awsgo supports two 'automatic' methods for getting your security keys.

The first is via a json file. THis is useful when testing locally. It expects a file named 'awskeys.json' to exist in your working directory. This json should marshall to awsgo.Credentials struct.

The second is via the EC2 Security Role. This is done via a request to http://169.254.169.254/latest/meta-data/iam/security-credentials. The EC2 Security Role is only used if 'awskeys.json' does not exist.

In order to use these 'automatic' methods of Key population, you should call awsgo.GetSecurityKeys()

Index

Constants

View Source
const (
	RequestSigningType_AWS4 = 1
	RequestSigningType_REST = 2
	RequestSigningType_AWS2 = 3
	RequestSigningType_AWS3 = 4
)

Variables

View Source
var (
	Verification_Error_AccessKeyEmpty       = errors.New("Key.AccessKeyId cannot be empty")
	Verification_Error_SecretAccessKeyEmpty = errors.New("Key.SecretAccessKey cannot be empty")
	Error_Code_InvalidParameterValue        = "InvalidParameterValue"
)

Functions

func CheckForErrorXml

func CheckForErrorXml(response []byte) error

Looks at a raw response for an XML error response

func ConvertToAwsItem

func ConvertToAwsItem(unknown interface{}) interface{}

Converts from an unknown interface... like:

string, []string, float, []float64

into the expected awsgo.AwsStringItem or awsgo.AwsNumberItem

func CreateCertApprovedClient

func CreateCertApprovedClient(certsToAdd []*x509.Certificate) *http.Client

helper function to create a http client that accepts certain certs

func Escape

func Escape(it string) string

func FromRawMapToEasyTypedMap

func FromRawMapToEasyTypedMap(raw map[string]map[string]interface{}, item map[string]interface{})

converts from raw JSON map to the expected types Eg. float64, string

func IsoDate

func IsoDate(t time.Time) string

20130315T092054Z ISO 8601 basic format

func SetDefaultHttpClient

func SetDefaultHttpClient(client *http.Client)

Types

type AwsHost

type AwsHost struct {
	// Eg. dynamo
	Service string
	// Eg us-west-2
	Region string
	// Eg. amazonaws.com
	Domain string
	// Overrides the url actuall hit
	Override string
}

The host of the service we are hitting. Urls are formed by taking Service.Region.Domain

func (AwsHost) ToString

func (h AwsHost) ToString() string

concat the parts together into a hostname.

type AwsNumberItem

type AwsNumberItem struct {
	Value     float64   `json:"-"`
	Values    []float64 `json:"-"`
	ValuesStr []string  `json:"NS,omitempty"`
	ValueStr  string    `json:"N,omitempty"`
}

type AwsRequest

type AwsRequest struct {
	Host               AwsHost
	Date               time.Time
	Headers            map[string]string
	Payload            string
	PayloadReader      io.ReadCloser
	Key                Credentials
	RequestMethod      string
	CanonicalUri       string
	RequestSigningType int
	HttpClient         *http.Client
	// contains filtered or unexported fields
}

func BuildEmptyContentRequest

func BuildEmptyContentRequest(rb RequestBuilderInterface) (request AwsRequest, verifyError error)

func NewAwsRequest

func NewAwsRequest(rb RequestBuilderInterface, marsh interface{}) (request AwsRequest, verifyError error)

Given the RequestBuilderInterface this will verify the underlying request and then create a new AwsRequest instance. returned Request is only valid if error is not nill

func (AwsRequest) Do

func (req AwsRequest) Do() (io.ReadCloser, map[string]string, int, error)

Performs the actual request Returns:

io.ReaderCloser - the unclosed response of the request
map[string]string - the headers in the response
int - that status code the response
error - any errors that occured

func (AwsRequest) DoAndDemarshall

func (request AwsRequest) DoAndDemarshall(rb RequestBuilderInterface) (interface{}, error)

Perform the actual request, calling the demarshall on the RequestBuilderInterface returns the result of the Demarshall, or other errors.

type AwsStringItem

type AwsStringItem struct {
	Value  string   `json:"S,omitempty"`
	Values []string `json:"SS,omitempty"`
}

type CredentialMetaData

type CredentialMetaData struct {
	Code            string
	LastUpdated     string
	Type            string
	AccessKeyId     string
	SecretAccessKey string
	Token           string
	Expiration      string
}

type Credentials

type Credentials struct {
	AccessKeyId     string
	SecretAccessKey string
	// contains filtered or unexported fields
}

Aws credentials

func GetSecurityKeys

func GetSecurityKeys() (finalCred Credentials, err error)

* Returns security credentials either from a JSON file 'awskeys.json' or

  • from AWS Metadata service
  • @return credentials, error

func (Credentials) GetToken

func (c Credentials) GetToken() string

type Error

type Error struct {
	Type    string
	Code    string
	Message string
}

type ErrorResponse

type ErrorResponse struct {
	ErrorT    Error `xml:"Error"`
	RequestId string
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type RequestBuilder

type RequestBuilder struct {
	// The Host we are hitting
	Host AwsHost `json:"-"`
	// The Credentials to use
	Key Credentials `json:"-"`
	// Any custom headers
	Headers map[string]string `json:"-"`
	// The method we are using GET, PUT, POST, ...
	RequestMethod string `json:"-"`
	// The uri we are hitting.
	CanonicalUri string `json:"-"`
	// The http client to use. A default one will be used if not specified
	HttpClient *http.Client `json:"-"`
}

Base of a request. Used across all requests.

func (*RequestBuilder) GetRequestBuilder

func (r *RequestBuilder) GetRequestBuilder() *RequestBuilder

type RequestBuilderInterface

type RequestBuilderInterface interface {
	// verify the request before we send it
	VerifyInput() error
	// Get the underlying RequestBuilder in the struct
	GetRequestBuilder() *RequestBuilder
	// Unmarshal the response
	DeMarshalResponse(response []byte, headers map[string]string, statusCode int) interface{}
}

Implemented by each AWS request Provides some standard steps to doing a request, and handling its response.

type RequestError

type RequestError struct {
	BaseError error
	Location  string
	Action    string
}

func (RequestError) Error

func (r RequestError) Error() string

type ResponseMetaData

type ResponseMetaData struct {
	RequestId string
}

Meta data in a lot of aws requests

type UnmarhsallingError

type UnmarhsallingError struct {
	ActualContent string
	MarshallError error
}

func (*UnmarhsallingError) Error

func (e *UnmarhsallingError) Error() string

Directories

Path Synopsis
Dynamo This package contains objects needed to do request to DynamoDB.
Dynamo This package contains objects needed to do request to DynamoDB.
* Copyright (c) 2013, fromkeith * All rights reserved.
* Copyright (c) 2013, fromkeith * All rights reserved.
swf
swfhelper
The SwfHelper is meant to make the decision process execution task easier.
The SwfHelper is meant to make the decision process execution task easier.

Jump to

Keyboard shortcuts

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