open-vault/vendor/github.com/aws/aws-sdk-go/private/protocol/ec2query/build.go

36 lines
1.2 KiB
Go
Raw Normal View History

2016-09-02 22:05:09 +00:00
// Package ec2query provides serialization of AWS EC2 requests and responses.
2015-08-06 16:41:01 +00:00
package ec2query
2015-10-30 22:07:00 +00:00
//go:generate go run ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/ec2.json build_test.go
2015-08-06 16:41:01 +00:00
import (
"net/url"
"github.com/aws/aws-sdk-go/aws/awserr"
2015-09-22 15:44:21 +00:00
"github.com/aws/aws-sdk-go/aws/request"
2015-10-30 22:07:00 +00:00
"github.com/aws/aws-sdk-go/private/protocol/query/queryutil"
2015-08-06 16:41:01 +00:00
)
// BuildHandler is a named request handler for building ec2query protocol requests
var BuildHandler = request.NamedHandler{Name: "awssdk.ec2query.Build", Fn: Build}
2015-08-06 16:41:01 +00:00
// Build builds a request for the EC2 protocol.
2015-09-22 15:44:21 +00:00
func Build(r *request.Request) {
2015-08-06 16:41:01 +00:00
body := url.Values{
"Action": {r.Operation.Name},
2015-10-30 22:07:00 +00:00
"Version": {r.ClientInfo.APIVersion},
2015-08-06 16:41:01 +00:00
}
if err := queryutil.Parse(body, r.Params, true); err != nil {
r.Error = awserr.New("SerializationError", "failed encoding EC2 Query request", err)
}
if r.ExpireTime == 0 {
r.HTTPRequest.Method = "POST"
r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
r.SetBufferBody([]byte(body.Encode()))
} else { // This is a pre-signed request
r.HTTPRequest.Method = "GET"
r.HTTPRequest.URL.RawQuery = body.Encode()
}
}