diff --git a/daemon/logger/awslogs/cloudwatchlogs.go b/daemon/logger/awslogs/cloudwatchlogs.go index 23fc2835f9..b484cd2b86 100644 --- a/daemon/logger/awslogs/cloudwatchlogs.go +++ b/daemon/logger/awslogs/cloudwatchlogs.go @@ -12,6 +12,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/defaults" "github.com/aws/aws-sdk-go/service/cloudwatchlogs" "github.com/docker/docker/daemon/logger" ) @@ -57,7 +58,7 @@ type byTimestamp []*cloudwatchlogs.InputLogEvent // init registers the awslogs driver and sets the default region, if provided func init() { if os.Getenv(regionEnvKey) != "" { - aws.DefaultConfig.Region = aws.String(os.Getenv(regionEnvKey)) + defaults.DefaultConfig.Region = aws.String(os.Getenv(regionEnvKey)) } if err := logger.RegisterLogDriver(name, New); err != nil { logrus.Fatal(err) @@ -79,9 +80,9 @@ func New(ctx logger.Context) (logger.Logger, error) { if ctx.Config[logStreamKey] != "" { logStreamName = ctx.Config[logStreamKey] } - config := aws.DefaultConfig + config := defaults.DefaultConfig if ctx.Config[regionKey] != "" { - config = aws.DefaultConfig.Merge(&aws.Config{ + config = defaults.DefaultConfig.Merge(&aws.Config{ Region: aws.String(ctx.Config[regionKey]), }) } diff --git a/hack/vendor.sh b/hack/vendor.sh index d872d4a3fa..78a76344c1 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -64,7 +64,7 @@ clone git github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c clone git gopkg.in/fsnotify.v1 v1.2.0 # awslogs deps -clone git github.com/aws/aws-sdk-go v0.7.1 +clone git github.com/aws/aws-sdk-go v0.9.9 clone git github.com/vaughan0/go-ini a98ad7ee00ec53921f08832bc06ecf7fd600e6a1 clean diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/awserr/types.go b/vendor/src/github.com/aws/aws-sdk-go/aws/awserr/types.go index 418fc4c14b..003a6e8067 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/awserr/types.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/awserr/types.go @@ -113,7 +113,7 @@ func newRequestError(err Error, statusCode int, requestID string) *requestError // Error returns the string representation of the error. // Satisfies the error interface. func (r requestError) Error() string { - extra := fmt.Sprintf("status code: %d, request id: [%s]", + extra := fmt.Sprintf("status code: %d, request id: %s", r.statusCode, r.requestID) return SprintError(r.Code(), r.Message(), extra, r.OrigErr()) } diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/config.go b/vendor/src/github.com/aws/aws-sdk-go/aws/config.go index c27bdd3c10..a72f702229 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/config.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/config.go @@ -2,48 +2,20 @@ package aws import ( "net/http" - "os" "time" "github.com/aws/aws-sdk-go/aws/credentials" ) -// DefaultChainCredentials is a Credentials which will find the first available -// credentials Value from the list of Providers. -// -// This should be used in the default case. Once the type of credentials are -// known switching to the specific Credentials will be more efficient. -var DefaultChainCredentials = credentials.NewChainCredentials( - []credentials.Provider{ - &credentials.EnvProvider{}, - &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, - &credentials.EC2RoleProvider{ExpiryWindow: 5 * time.Minute}, - }) - // The default number of retries for a service. The value of -1 indicates that // the service specific retry default will be used. const DefaultRetries = -1 -// DefaultConfig is the default all service configuration will be based off of. -// By default, all clients use this structure for initialization options unless -// a custom configuration object is passed in. -// -// You may modify this global structure to change all default configuration -// in the SDK. Note that configuration options are copied by value, so any -// modifications must happen before constructing a client. -var DefaultConfig = NewConfig(). - WithCredentials(DefaultChainCredentials). - WithRegion(os.Getenv("AWS_REGION")). - WithHTTPClient(http.DefaultClient). - WithMaxRetries(DefaultRetries). - WithLogger(NewDefaultLogger()). - WithLogLevel(LogOff) - // A Config provides service configuration for service clients. By default, -// all clients will use the {DefaultConfig} structure. +// all clients will use the {defaults.DefaultConfig} structure. type Config struct { // The credentials object to use when signing requests. Defaults to - // {DefaultChainCredentials}. + // {defaults.DefaultChainCredentials}. Credentials *credentials.Credentials // An optional endpoint URL (hostname only or fully qualified URI) @@ -102,6 +74,8 @@ type Config struct { // @see http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html // Amazon S3: Virtual Hosting of Buckets S3ForcePathStyle *bool + + SleepDelay func(time.Duration) } // NewConfig returns a new Config pointer that can be chained with builder methods to @@ -190,6 +164,13 @@ func (c *Config) WithS3ForcePathStyle(force bool) *Config { return c } +// WithSleepDelay overrides the function used to sleep while waiting for the +// next retry. Defaults to time.Sleep. +func (c *Config) WithSleepDelay(fn func(time.Duration)) *Config { + c.SleepDelay = fn + return c +} + // Merge returns a new Config with the other Config's attribute values merged into // this Config. If the other Config's attribute is nil it will not be merged into // the new Config to be returned. @@ -244,6 +225,10 @@ func (c Config) Merge(other *Config) *Config { dst.S3ForcePathStyle = other.S3ForcePathStyle } + if other.SleepDelay != nil { + dst.SleepDelay = other.SleepDelay + } + return &dst } diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/convutil.go b/vendor/src/github.com/aws/aws-sdk-go/aws/convert_types.go similarity index 100% rename from vendor/src/github.com/aws/aws-sdk-go/aws/convutil.go rename to vendor/src/github.com/aws/aws-sdk-go/aws/convert_types.go diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/handler_functions.go b/vendor/src/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go similarity index 65% rename from vendor/src/github.com/aws/aws-sdk-go/aws/handler_functions.go rename to vendor/src/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go index 45ae880735..2fcb391a28 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/handler_functions.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go @@ -1,4 +1,4 @@ -package aws +package corehandlers import ( "bytes" @@ -9,15 +9,12 @@ import ( "net/url" "regexp" "strconv" - "time" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" ) -var sleepDelay = func(delay time.Duration) { - time.Sleep(delay) -} - // Interface for matching types which also have a Len method. type lener interface { Len() int @@ -26,7 +23,7 @@ type lener interface { // BuildContentLength builds the content length of a request based on the body, // or will use the HTTPRequest.Header's "Content-Length" if defined. If unable // to determine request body length and no "Content-Length" was specified it will panic. -func BuildContentLength(r *Request) { +var BuildContentLengthHandler = request.NamedHandler{"core.BuildContentLengthHandler", func(r *request.Request) { if slength := r.HTTPRequest.Header.Get("Content-Length"); slength != "" { length, _ := strconv.ParseInt(slength, 10, 64) r.HTTPRequest.ContentLength = length @@ -40,27 +37,27 @@ func BuildContentLength(r *Request) { case lener: length = int64(body.Len()) case io.Seeker: - r.bodyStart, _ = body.Seek(0, 1) + r.BodyStart, _ = body.Seek(0, 1) end, _ := body.Seek(0, 2) - body.Seek(r.bodyStart, 0) // make sure to seek back to original location - length = end - r.bodyStart + body.Seek(r.BodyStart, 0) // make sure to seek back to original location + length = end - r.BodyStart default: panic("Cannot get length of body, must provide `ContentLength`") } r.HTTPRequest.ContentLength = length r.HTTPRequest.Header.Set("Content-Length", fmt.Sprintf("%d", length)) -} +}} // UserAgentHandler is a request handler for injecting User agent into requests. -func UserAgentHandler(r *Request) { - r.HTTPRequest.Header.Set("User-Agent", SDKName+"/"+SDKVersion) -} +var UserAgentHandler = request.NamedHandler{"core.UserAgentHandler", func(r *request.Request) { + r.HTTPRequest.Header.Set("User-Agent", aws.SDKName+"/"+aws.SDKVersion) +}} -var reStatusCode = regexp.MustCompile(`^(\d+)`) +var reStatusCode = regexp.MustCompile(`^(\d{3})`) // SendHandler is a request handler to send service request using HTTP client. -func SendHandler(r *Request) { +var SendHandler = request.NamedHandler{"core.SendHandler", func(r *request.Request) { var err error r.HTTPResponse, err = r.Service.Config.HTTPClient.Do(r.HTTPRequest) if err != nil { @@ -68,8 +65,8 @@ func SendHandler(r *Request) { // response. e.g. 301 without location header comes back as string // error and r.HTTPResponse is nil. Other url redirect errors will // comeback in a similar method. - if e, ok := err.(*url.Error); ok { - if s := reStatusCode.FindStringSubmatch(e.Error()); s != nil { + if e, ok := err.(*url.Error); ok && e.Err != nil { + if s := reStatusCode.FindStringSubmatch(e.Err.Error()); s != nil { code, _ := strconv.ParseInt(s[1], 10, 64) r.HTTPResponse = &http.Response{ StatusCode: int(code), @@ -79,7 +76,7 @@ func SendHandler(r *Request) { return } } - if r.HTTPRequest == nil { + if r.HTTPResponse == nil { // Add a dummy request response object to ensure the HTTPResponse // value is consistent. r.HTTPResponse = &http.Response{ @@ -90,68 +87,50 @@ func SendHandler(r *Request) { } // Catch all other request errors. r.Error = awserr.New("RequestError", "send request failed", err) - r.Retryable = Bool(true) // network errors are retryable + r.Retryable = aws.Bool(true) // network errors are retryable } -} +}} // ValidateResponseHandler is a request handler to validate service response. -func ValidateResponseHandler(r *Request) { +var ValidateResponseHandler = request.NamedHandler{"core.ValidateResponseHandler", func(r *request.Request) { if r.HTTPResponse.StatusCode == 0 || r.HTTPResponse.StatusCode >= 300 { // this may be replaced by an UnmarshalError handler r.Error = awserr.New("UnknownError", "unknown error", nil) } -} +}} // AfterRetryHandler performs final checks to determine if the request should // be retried and how long to delay. -func AfterRetryHandler(r *Request) { +var AfterRetryHandler = request.NamedHandler{"core.AfterRetryHandler", func(r *request.Request) { // If one of the other handlers already set the retry state // we don't want to override it based on the service's state if r.Retryable == nil { - r.Retryable = Bool(r.Service.ShouldRetry(r)) + r.Retryable = aws.Bool(r.ShouldRetry(r)) } if r.WillRetry() { - r.RetryDelay = r.Service.RetryRules(r) - sleepDelay(r.RetryDelay) + r.RetryDelay = r.RetryRules(r) + r.Service.Config.SleepDelay(r.RetryDelay) // when the expired token exception occurs the credentials // need to be expired locally so that the next request to // get credentials will trigger a credentials refresh. - if r.Error != nil { - if err, ok := r.Error.(awserr.Error); ok { - if isCodeExpiredCreds(err.Code()) { - r.Config.Credentials.Expire() - } - } + if r.IsErrorExpired() { + r.Service.Config.Credentials.Expire() } r.RetryCount++ r.Error = nil } -} - -var ( - // ErrMissingRegion is an error that is returned if region configuration is - // not found. - // - // @readonly - ErrMissingRegion error = awserr.New("MissingRegion", "could not find region configuration", nil) - - // ErrMissingEndpoint is an error that is returned if an endpoint cannot be - // resolved for a service. - // - // @readonly - ErrMissingEndpoint error = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) -) +}} // ValidateEndpointHandler is a request handler to validate a request had the // appropriate Region and Endpoint set. Will set r.Error if the endpoint or // region is not valid. -func ValidateEndpointHandler(r *Request) { - if r.Service.SigningRegion == "" && StringValue(r.Service.Config.Region) == "" { - r.Error = ErrMissingRegion +var ValidateEndpointHandler = request.NamedHandler{"core.ValidateEndpointHandler", func(r *request.Request) { + if r.Service.SigningRegion == "" && aws.StringValue(r.Service.Config.Region) == "" { + r.Error = aws.ErrMissingRegion } else if r.Service.Endpoint == "" { - r.Error = ErrMissingEndpoint + r.Error = aws.ErrMissingEndpoint } -} +}} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.go b/vendor/src/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.go new file mode 100644 index 0000000000..a221977341 --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.go @@ -0,0 +1,144 @@ +package corehandlers + +import ( + "fmt" + "reflect" + "strconv" + "strings" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +// ValidateParameters is a request handler to validate the input parameters. +// Validating parameters only has meaning if done prior to the request being sent. +var ValidateParametersHandler = request.NamedHandler{"core.ValidateParametersHandler", func(r *request.Request) { + if r.ParamsFilled() { + v := validator{errors: []string{}} + v.validateAny(reflect.ValueOf(r.Params), "") + + if count := len(v.errors); count > 0 { + format := "%d validation errors:\n- %s" + msg := fmt.Sprintf(format, count, strings.Join(v.errors, "\n- ")) + r.Error = awserr.New("InvalidParameter", msg, nil) + } + } +}} + +// A validator validates values. Collects validations errors which occurs. +type validator struct { + errors []string +} + +// validateAny will validate any struct, slice or map type. All validations +// are also performed recursively for nested types. +func (v *validator) validateAny(value reflect.Value, path string) { + value = reflect.Indirect(value) + if !value.IsValid() { + return + } + + switch value.Kind() { + case reflect.Struct: + v.validateStruct(value, path) + case reflect.Slice: + for i := 0; i < value.Len(); i++ { + v.validateAny(value.Index(i), path+fmt.Sprintf("[%d]", i)) + } + case reflect.Map: + for _, n := range value.MapKeys() { + v.validateAny(value.MapIndex(n), path+fmt.Sprintf("[%q]", n.String())) + } + } +} + +// validateStruct will validate the struct value's fields. If the structure has +// nested types those types will be validated also. +func (v *validator) validateStruct(value reflect.Value, path string) { + prefix := "." + if path == "" { + prefix = "" + } + + for i := 0; i < value.Type().NumField(); i++ { + f := value.Type().Field(i) + if strings.ToLower(f.Name[0:1]) == f.Name[0:1] { + continue + } + fvalue := value.FieldByName(f.Name) + + err := validateField(f, fvalue, validateFieldRequired, validateFieldMin) + if err != nil { + v.errors = append(v.errors, fmt.Sprintf("%s: %s", err.Error(), path+prefix+f.Name)) + continue + } + + v.validateAny(fvalue, path+prefix+f.Name) + } +} + +type validatorFunc func(f reflect.StructField, fvalue reflect.Value) error + +func validateField(f reflect.StructField, fvalue reflect.Value, funcs ...validatorFunc) error { + for _, fn := range funcs { + if err := fn(f, fvalue); err != nil { + return err + } + } + return nil +} + +// Validates that a field has a valid value provided for required fields. +func validateFieldRequired(f reflect.StructField, fvalue reflect.Value) error { + if f.Tag.Get("required") == "" { + return nil + } + + switch fvalue.Kind() { + case reflect.Ptr, reflect.Slice, reflect.Map: + if fvalue.IsNil() { + return fmt.Errorf("missing required parameter") + } + default: + if !fvalue.IsValid() { + return fmt.Errorf("missing required parameter") + } + } + return nil +} + +// Validates that if a value is provided for a field, that value must be at +// least a minimum length. +func validateFieldMin(f reflect.StructField, fvalue reflect.Value) error { + minStr := f.Tag.Get("min") + if minStr == "" { + return nil + } + min, _ := strconv.ParseInt(minStr, 10, 64) + + kind := fvalue.Kind() + if kind == reflect.Ptr { + if fvalue.IsNil() { + return nil + } + fvalue = fvalue.Elem() + } + + switch fvalue.Kind() { + case reflect.String: + if int64(fvalue.Len()) < min { + return fmt.Errorf("field too short, minimum length %d", min) + } + case reflect.Slice, reflect.Map: + if fvalue.IsNil() { + return nil + } + if int64(fvalue.Len()) < min { + return fmt.Errorf("field too short, minimum length %d", min) + } + + // TODO min can also apply to number minimum value. + + } + return nil +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/credentials/ec2_role_provider.go b/vendor/src/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go similarity index 60% rename from vendor/src/github.com/aws/aws-sdk-go/aws/credentials/ec2_role_provider.go rename to vendor/src/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go index 0eecbe3b12..946a117206 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/credentials/ec2_role_provider.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go @@ -1,24 +1,25 @@ -package credentials +package ec2rolecreds import ( "bufio" "encoding/json" "fmt" - "net/http" + "path" + "strings" "time" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/ec2metadata" ) -const metadataCredentialsEndpoint = "http://169.254.169.254/latest/meta-data/iam/security-credentials/" - // A EC2RoleProvider retrieves credentials from the EC2 service, and keeps track if // those credentials are expired. // // Example how to configure the EC2RoleProvider with custom http Client, Endpoint // or ExpiryWindow // -// p := &credentials.EC2RoleProvider{ +// p := &ec2rolecreds.EC2RoleProvider{ // // Pass in a custom timeout to be used when requesting // // IAM EC2 Role credentials. // Client: &http.Client{ @@ -32,13 +33,10 @@ const metadataCredentialsEndpoint = "http://169.254.169.254/latest/meta-data/iam // ExpiryWindow: 0, // } type EC2RoleProvider struct { - Expiry + credentials.Expiry - // Endpoint must be fully quantified URL - Endpoint string - - // HTTP client to use when connecting to EC2 service - Client *http.Client + // EC2Metadata client to use when connecting to EC2 metadata service + Client *ec2metadata.Client // ExpiryWindow will allow the credentials to trigger refreshing prior to // the credentials actually expiring. This is beneficial so race conditions @@ -52,7 +50,7 @@ type EC2RoleProvider struct { ExpiryWindow time.Duration } -// NewEC2RoleCredentials returns a pointer to a new Credentials object +// NewCredentials returns a pointer to a new Credentials object // wrapping the EC2RoleProvider. // // Takes a custom http.Client which can be configured for custom handling of @@ -64,9 +62,8 @@ type EC2RoleProvider struct { // Window is the expiry window that will be subtracted from the expiry returned // by the role credential request. This is done so that the credentials will // expire sooner than their actual lifespan. -func NewEC2RoleCredentials(client *http.Client, endpoint string, window time.Duration) *Credentials { - return NewCredentials(&EC2RoleProvider{ - Endpoint: endpoint, +func NewCredentials(client *ec2metadata.Client, window time.Duration) *credentials.Credentials { + return credentials.NewCredentials(&EC2RoleProvider{ Client: client, ExpiryWindow: window, }) @@ -75,32 +72,29 @@ func NewEC2RoleCredentials(client *http.Client, endpoint string, window time.Dur // Retrieve retrieves credentials from the EC2 service. // Error will be returned if the request fails, or unable to extract // the desired credentials. -func (m *EC2RoleProvider) Retrieve() (Value, error) { +func (m *EC2RoleProvider) Retrieve() (credentials.Value, error) { if m.Client == nil { - m.Client = http.DefaultClient - } - if m.Endpoint == "" { - m.Endpoint = metadataCredentialsEndpoint + m.Client = ec2metadata.New(nil) } - credsList, err := requestCredList(m.Client, m.Endpoint) + credsList, err := requestCredList(m.Client) if err != nil { - return Value{}, err + return credentials.Value{}, err } if len(credsList) == 0 { - return Value{}, awserr.New("EmptyEC2RoleList", "empty EC2 Role list", nil) + return credentials.Value{}, awserr.New("EmptyEC2RoleList", "empty EC2 Role list", nil) } credsName := credsList[0] - roleCreds, err := requestCred(m.Client, m.Endpoint, credsName) + roleCreds, err := requestCred(m.Client, credsName) if err != nil { - return Value{}, err + return credentials.Value{}, err } m.SetExpiration(roleCreds.Expiration, m.ExpiryWindow) - return Value{ + return credentials.Value{ AccessKeyID: roleCreds.AccessKeyID, SecretAccessKey: roleCreds.SecretAccessKey, SessionToken: roleCreds.Token, @@ -110,29 +104,35 @@ func (m *EC2RoleProvider) Retrieve() (Value, error) { // A ec2RoleCredRespBody provides the shape for deserializing credential // request responses. type ec2RoleCredRespBody struct { + // Success State Expiration time.Time AccessKeyID string SecretAccessKey string Token string + + // Error state + Code string + Message string } +const iamSecurityCredsPath = "/iam/security-credentials" + // requestCredList requests a list of credentials from the EC2 service. // If there are no credentials, or there is an error making or receiving the request -func requestCredList(client *http.Client, endpoint string) ([]string, error) { - resp, err := client.Get(endpoint) +func requestCredList(client *ec2metadata.Client) ([]string, error) { + resp, err := client.GetMetadata(iamSecurityCredsPath) if err != nil { - return nil, awserr.New("ListEC2Role", "failed to list EC2 Roles", err) + return nil, awserr.New("EC2RoleRequestError", "failed to list EC2 Roles", err) } - defer resp.Body.Close() credsList := []string{} - s := bufio.NewScanner(resp.Body) + s := bufio.NewScanner(strings.NewReader(resp)) for s.Scan() { credsList = append(credsList, s.Text()) } if err := s.Err(); err != nil { - return nil, awserr.New("ReadEC2Role", "failed to read list of EC2 Roles", err) + return nil, awserr.New("SerializationError", "failed to read list of EC2 Roles", err) } return credsList, nil @@ -142,20 +142,26 @@ func requestCredList(client *http.Client, endpoint string) ([]string, error) { // // If the credentials cannot be found, or there is an error reading the response // and error will be returned. -func requestCred(client *http.Client, endpoint, credsName string) (*ec2RoleCredRespBody, error) { - resp, err := client.Get(endpoint + credsName) +func requestCred(client *ec2metadata.Client, credsName string) (ec2RoleCredRespBody, error) { + resp, err := client.GetMetadata(path.Join(iamSecurityCredsPath, credsName)) if err != nil { - return nil, awserr.New("GetEC2RoleCredentials", - fmt.Sprintf("failed to get %s EC2 Role credentials", credsName), - err) + return ec2RoleCredRespBody{}, + awserr.New("EC2RoleRequestError", + fmt.Sprintf("failed to get %s EC2 Role credentials", credsName), + err) } - defer resp.Body.Close() - respCreds := &ec2RoleCredRespBody{} - if err := json.NewDecoder(resp.Body).Decode(respCreds); err != nil { - return nil, awserr.New("DecodeEC2RoleCredentials", - fmt.Sprintf("failed to decode %s EC2 Role credentials", credsName), - err) + respCreds := ec2RoleCredRespBody{} + if err := json.NewDecoder(strings.NewReader(resp)).Decode(&respCreds); err != nil { + return ec2RoleCredRespBody{}, + awserr.New("SerializationError", + fmt.Sprintf("failed to decode %s EC2 Role credentials", credsName), + err) + } + + if respCreds.Code != "Success" { + // If an error code was returned something failed requesting the role. + return ec2RoleCredRespBody{}, awserr.New(respCreds.Code, respCreds.Message, nil) } return respCreds, nil diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go b/vendor/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go index b457e63a33..fac6d78c41 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go @@ -22,8 +22,12 @@ var ( // // Profile ini file example: $HOME/.aws/credentials type SharedCredentialsProvider struct { - // Path to the shared credentials file. If empty will default to current user's - // home directory. + // Path to the shared credentials file. + // + // If empty will look for "AWS_SHARED_CREDENTIALS_FILE" env variable. If the + // env value is empty will default to current user's home directory. + // Linux/OSX: "$HOME/.aws/credentials" + // Windows: "%USERPROFILE%\.aws\credentials" Filename string // AWS Profile to extract credentials from the shared credentials file. If empty @@ -106,6 +110,10 @@ func loadProfile(filename, profile string) (Value, error) { // Will return an error if the user's home directory path cannot be found. func (p *SharedCredentialsProvider) filename() (string, error) { if p.Filename == "" { + if p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); p.Filename != "" { + return p.Filename, nil + } + homeDir := os.Getenv("HOME") // *nix if homeDir == "" { // Windows homeDir = os.Getenv("USERPROFILE") diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/defaults/defaults.go b/vendor/src/github.com/aws/aws-sdk-go/aws/defaults/defaults.go new file mode 100644 index 0000000000..2f161b57f1 --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/defaults/defaults.go @@ -0,0 +1,39 @@ +package defaults + +import ( + "net/http" + "os" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" +) + +// DefaultChainCredentials is a Credentials which will find the first available +// credentials Value from the list of Providers. +// +// This should be used in the default case. Once the type of credentials are +// known switching to the specific Credentials will be more efficient. +var DefaultChainCredentials = credentials.NewChainCredentials( + []credentials.Provider{ + &credentials.EnvProvider{}, + &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, + &ec2rolecreds.EC2RoleProvider{ExpiryWindow: 5 * time.Minute}, + }) + +// DefaultConfig is the default all service configuration will be based off of. +// By default, all clients use this structure for initialization options unless +// a custom configuration object is passed in. +// +// You may modify this global structure to change all default configuration +// in the SDK. Note that configuration options are copied by value, so any +// modifications must happen before constructing a client. +var DefaultConfig = aws.NewConfig(). + WithCredentials(DefaultChainCredentials). + WithRegion(os.Getenv("AWS_REGION")). + WithHTTPClient(http.DefaultClient). + WithMaxRetries(aws.DefaultRetries). + WithLogger(aws.NewDefaultLogger()). + WithLogLevel(aws.LogOff). + WithSleepDelay(time.Sleep) diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go b/vendor/src/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go new file mode 100644 index 0000000000..9d784b6e6a --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go @@ -0,0 +1,43 @@ +package ec2metadata + +import ( + "path" + + "github.com/aws/aws-sdk-go/aws/request" +) + +// GetMetadata uses the path provided to request +func (c *Client) GetMetadata(p string) (string, error) { + op := &request.Operation{ + Name: "GetMetadata", + HTTPMethod: "GET", + HTTPPath: path.Join("/", "meta-data", p), + } + + output := &metadataOutput{} + req := request.New(c.Service.ServiceInfo, c.Service.Handlers, c.Service.Retryer, op, nil, output) + + return output.Content, req.Send() +} + +// Region returns the region the instance is running in. +func (c *Client) Region() (string, error) { + resp, err := c.GetMetadata("placement/availability-zone") + if err != nil { + return "", err + } + + // returns region without the suffix. Eg: us-west-2a becomes us-west-2 + return resp[:len(resp)-1], nil +} + +// Available returns if the application has access to the EC2 Metadata service. +// Can be used to determine if application is running within an EC2 Instance and +// the metadata service is available. +func (c *Client) Available() bool { + if _, err := c.GetMetadata("instance-id"); err != nil { + return false + } + + return true +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go b/vendor/src/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go new file mode 100644 index 0000000000..d230df6f9f --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go @@ -0,0 +1,135 @@ +package ec2metadata + +import ( + "io/ioutil" + "net/http" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/aws/service" + "github.com/aws/aws-sdk-go/aws/service/serviceinfo" +) + +// DefaultRetries states the default number of times the service client will +// attempt to retry a failed request before failing. +const DefaultRetries = 3 + +// A Config provides the configuration for the EC2 Metadata service. +type Config struct { + // An optional endpoint URL (hostname only or fully qualified URI) + // that overrides the default service endpoint for a client. Set this + // to nil, or `""` to use the default service endpoint. + Endpoint *string + + // The HTTP client to use when sending requests. Defaults to + // `http.DefaultClient`. + HTTPClient *http.Client + + // An integer value representing the logging level. The default log level + // is zero (LogOff), which represents no logging. To enable logging set + // to a LogLevel Value. + Logger aws.Logger + + // The logger writer interface to write logging messages to. Defaults to + // standard out. + LogLevel *aws.LogLevelType + + // The maximum number of times that a request will be retried for failures. + // Defaults to DefaultRetries for the number of retries to be performed + // per request. + MaxRetries *int +} + +// A Client is an EC2 Metadata service Client. +type Client struct { + *service.Service +} + +// New creates a new instance of the EC2 Metadata service client. +// +// In the general use case the configuration for this service client should not +// be needed and `nil` can be provided. Configuration is only needed if the +// `ec2metadata.Config` defaults need to be overridden. Eg. Setting LogLevel. +// +// @note This configuration will NOT be merged with the default AWS service +// client configuration `defaults.DefaultConfig`. Due to circular dependencies +// with the defaults package and credentials EC2 Role Provider. +func New(config *Config) *Client { + service := &service.Service{ + ServiceInfo: serviceinfo.ServiceInfo{ + Config: copyConfig(config), + ServiceName: "Client", + Endpoint: "http://169.254.169.254/latest", + APIVersion: "latest", + }, + } + service.Initialize() + service.Handlers.Unmarshal.PushBack(unmarshalHandler) + service.Handlers.UnmarshalError.PushBack(unmarshalError) + service.Handlers.Validate.Clear() + service.Handlers.Validate.PushBack(validateEndpointHandler) + + return &Client{service} +} + +func copyConfig(config *Config) *aws.Config { + if config == nil { + config = &Config{} + } + c := &aws.Config{ + Credentials: credentials.AnonymousCredentials, + Endpoint: config.Endpoint, + HTTPClient: config.HTTPClient, + Logger: config.Logger, + LogLevel: config.LogLevel, + MaxRetries: config.MaxRetries, + } + + if c.HTTPClient == nil { + c.HTTPClient = http.DefaultClient + } + if c.Logger == nil { + c.Logger = aws.NewDefaultLogger() + } + if c.LogLevel == nil { + c.LogLevel = aws.LogLevel(aws.LogOff) + } + if c.MaxRetries == nil { + c.MaxRetries = aws.Int(DefaultRetries) + } + + return c +} + +type metadataOutput struct { + Content string +} + +func unmarshalHandler(r *request.Request) { + defer r.HTTPResponse.Body.Close() + b, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "unable to unmarshal EC2 metadata respose", err) + } + + data := r.Data.(*metadataOutput) + data.Content = string(b) +} + +func unmarshalError(r *request.Request) { + defer r.HTTPResponse.Body.Close() + _, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "unable to unmarshal EC2 metadata error respose", err) + } + + // TODO extract the error... +} + +func validateEndpointHandler(r *request.Request) { + if r.Service.Endpoint == "" { + r.Error = aws.ErrMissingEndpoint + } +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/errors.go b/vendor/src/github.com/aws/aws-sdk-go/aws/errors.go new file mode 100644 index 0000000000..db2f481b01 --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/errors.go @@ -0,0 +1,17 @@ +package aws + +import "github.com/aws/aws-sdk-go/aws/awserr" + +var ( + // ErrMissingRegion is an error that is returned if region configuration is + // not found. + // + // @readonly + ErrMissingRegion error = awserr.New("MissingRegion", "could not find region configuration", nil) + + // ErrMissingEndpoint is an error that is returned if an endpoint cannot be + // resolved for a service. + // + // @readonly + ErrMissingEndpoint error = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) +) diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/logger.go b/vendor/src/github.com/aws/aws-sdk-go/aws/logger.go index 935661c0b7..f536948738 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/logger.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/logger.go @@ -62,6 +62,15 @@ const ( // see the body content of requests and responses made while using the SDK // Will also enable LogDebug. LogDebugWithHTTPBody + + // LogDebugWithRequestRetries states the SDK should log when service requests will + // be retried. This should be used to log when you want to log when service + // requests are being retried. Will also enable LogDebug. + LogDebugWithRequestRetries + + // LogDebugWithRequestErrors states the SDK should log when service requests fail + // to build, send, validate, or unmarshal. + LogDebugWithRequestErrors ) // A Logger is a minimalistic interface for the SDK to log messages to. Should diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/param_validator.go b/vendor/src/github.com/aws/aws-sdk-go/aws/param_validator.go deleted file mode 100644 index b4e95cebd5..0000000000 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/param_validator.go +++ /dev/null @@ -1,89 +0,0 @@ -package aws - -import ( - "fmt" - "reflect" - "strings" - - "github.com/aws/aws-sdk-go/aws/awserr" -) - -// ValidateParameters is a request handler to validate the input parameters. -// Validating parameters only has meaning if done prior to the request being sent. -func ValidateParameters(r *Request) { - if r.ParamsFilled() { - v := validator{errors: []string{}} - v.validateAny(reflect.ValueOf(r.Params), "") - - if count := len(v.errors); count > 0 { - format := "%d validation errors:\n- %s" - msg := fmt.Sprintf(format, count, strings.Join(v.errors, "\n- ")) - r.Error = awserr.New("InvalidParameter", msg, nil) - } - } -} - -// A validator validates values. Collects validations errors which occurs. -type validator struct { - errors []string -} - -// validateAny will validate any struct, slice or map type. All validations -// are also performed recursively for nested types. -func (v *validator) validateAny(value reflect.Value, path string) { - value = reflect.Indirect(value) - if !value.IsValid() { - return - } - - switch value.Kind() { - case reflect.Struct: - v.validateStruct(value, path) - case reflect.Slice: - for i := 0; i < value.Len(); i++ { - v.validateAny(value.Index(i), path+fmt.Sprintf("[%d]", i)) - } - case reflect.Map: - for _, n := range value.MapKeys() { - v.validateAny(value.MapIndex(n), path+fmt.Sprintf("[%q]", n.String())) - } - } -} - -// validateStruct will validate the struct value's fields. If the structure has -// nested types those types will be validated also. -func (v *validator) validateStruct(value reflect.Value, path string) { - prefix := "." - if path == "" { - prefix = "" - } - - for i := 0; i < value.Type().NumField(); i++ { - f := value.Type().Field(i) - if strings.ToLower(f.Name[0:1]) == f.Name[0:1] { - continue - } - fvalue := value.FieldByName(f.Name) - - notset := false - if f.Tag.Get("required") != "" { - switch fvalue.Kind() { - case reflect.Ptr, reflect.Slice, reflect.Map: - if fvalue.IsNil() { - notset = true - } - default: - if !fvalue.IsValid() { - notset = true - } - } - } - - if notset { - msg := "missing required parameter: " + path + prefix + f.Name - v.errors = append(v.errors, msg) - } else { - v.validateAny(fvalue, path+prefix+f.Name) - } - } -} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/handlers.go b/vendor/src/github.com/aws/aws-sdk-go/aws/request/handlers.go similarity index 57% rename from vendor/src/github.com/aws/aws-sdk-go/aws/handlers.go rename to vendor/src/github.com/aws/aws-sdk-go/aws/request/handlers.go index 1968cb9f8b..85bc122e7b 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/handlers.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/request/handlers.go @@ -1,4 +1,4 @@ -package aws +package request // A Handlers provides a collection of request handlers for various // stages of handling requests. @@ -15,8 +15,8 @@ type Handlers struct { AfterRetry HandlerList } -// copy returns of this handler's lists. -func (h *Handlers) copy() Handlers { +// Copy returns of this handler's lists. +func (h *Handlers) Copy() Handlers { return Handlers{ Validate: h.Validate.copy(), Build: h.Build.copy(), @@ -47,19 +47,25 @@ func (h *Handlers) Clear() { // A HandlerList manages zero or more handlers in a list. type HandlerList struct { - list []func(*Request) + list []NamedHandler +} + +// A NamedHandler is a struct that contains a name and function callback. +type NamedHandler struct { + Name string + Fn func(*Request) } // copy creates a copy of the handler list. func (l *HandlerList) copy() HandlerList { var n HandlerList - n.list = append([]func(*Request){}, l.list...) + n.list = append([]NamedHandler{}, l.list...) return n } // Clear clears the handler list. func (l *HandlerList) Clear() { - l.list = []func(*Request){} + l.list = []NamedHandler{} } // Len returns the number of handlers in the list. @@ -67,19 +73,40 @@ func (l *HandlerList) Len() int { return len(l.list) } -// PushBack pushes handlers f to the back of the handler list. -func (l *HandlerList) PushBack(f ...func(*Request)) { - l.list = append(l.list, f...) +// PushBack pushes handler f to the back of the handler list. +func (l *HandlerList) PushBack(f func(*Request)) { + l.list = append(l.list, NamedHandler{"__anonymous", f}) } -// PushFront pushes handlers f to the front of the handler list. -func (l *HandlerList) PushFront(f ...func(*Request)) { - l.list = append(f, l.list...) +// PushFront pushes handler f to the front of the handler list. +func (l *HandlerList) PushFront(f func(*Request)) { + l.list = append([]NamedHandler{{"__anonymous", f}}, l.list...) +} + +// PushBackNamed pushes named handler f to the back of the handler list. +func (l *HandlerList) PushBackNamed(n NamedHandler) { + l.list = append(l.list, n) +} + +// PushFrontNamed pushes named handler f to the front of the handler list. +func (l *HandlerList) PushFrontNamed(n NamedHandler) { + l.list = append([]NamedHandler{n}, l.list...) +} + +// Remove removes a NamedHandler n +func (l *HandlerList) Remove(n NamedHandler) { + newlist := []NamedHandler{} + for _, m := range l.list { + if m.Name != n.Name { + newlist = append(newlist, m) + } + } + l.list = newlist } // Run executes all handlers in the list with a given request object. func (l *HandlerList) Run(r *Request) { for _, f := range l.list { - f(r) + f.Fn(r) } } diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/request.go b/vendor/src/github.com/aws/aws-sdk-go/aws/request/request.go similarity index 79% rename from vendor/src/github.com/aws/aws-sdk-go/aws/request.go rename to vendor/src/github.com/aws/aws-sdk-go/aws/request/request.go index f3248fc467..70c28b8831 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/request.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/request/request.go @@ -1,7 +1,8 @@ -package aws +package request import ( "bytes" + "fmt" "io" "io/ioutil" "net/http" @@ -10,12 +11,15 @@ import ( "strings" "time" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/service/serviceinfo" ) // A Request is the service request to be made. type Request struct { - *Service + Retryer + Service serviceinfo.ServiceInfo Handlers Handlers Time time.Time ExpireTime time.Duration @@ -23,7 +27,7 @@ type Request struct { HTTPRequest *http.Request HTTPResponse *http.Response Body io.ReadSeeker - bodyStart int64 // offset from beginning of Body that the request body starts + BodyStart int64 // offset from beginning of Body that the request body starts Params interface{} Error error Data interface{} @@ -51,13 +55,13 @@ type Paginator struct { TruncationToken string } -// NewRequest returns a new Request pointer for the service API +// New returns a new Request pointer for the service API // operation and parameters. // // Params is any value of input parameters to be the request payload. // Data is pointer value to an object which the request's response // payload will be deserialized to. -func NewRequest(service *Service, operation *Operation, params interface{}, data interface{}) *Request { +func New(service serviceinfo.ServiceInfo, handlers Handlers, retryer Retryer, operation *Operation, params interface{}, data interface{}) *Request { method := operation.HTTPMethod if method == "" { method = "POST" @@ -71,8 +75,9 @@ func NewRequest(service *Service, operation *Operation, params interface{}, data httpReq.URL, _ = url.Parse(service.Endpoint + p) r := &Request{ + Retryer: retryer, Service: service, - Handlers: service.Handlers.copy(), + Handlers: handlers.Copy(), Time: time.Now(), ExpireTime: 0, Operation: operation, @@ -89,7 +94,7 @@ func NewRequest(service *Service, operation *Operation, params interface{}, data // WillRetry returns if the request's can be retried. func (r *Request) WillRetry() bool { - return r.Error != nil && BoolValue(r.Retryable) && r.RetryCount < r.Service.MaxRetries() + return r.Error != nil && aws.BoolValue(r.Retryable) && r.RetryCount < r.MaxRetries() } // ParamsFilled returns if the request's parameters have been populated @@ -134,6 +139,20 @@ func (r *Request) Presign(expireTime time.Duration) (string, error) { return r.HTTPRequest.URL.String(), nil } +func debugLogReqError(r *Request, stage string, retrying bool, err error) { + if !r.Service.Config.LogLevel.Matches(aws.LogDebugWithRequestErrors) { + return + } + + retryStr := "not retrying" + if retrying { + retryStr = "will retry" + } + + r.Service.Config.Logger.Log(fmt.Sprintf("DEBUG: %s %s/%s failed, %s, error %v", + stage, r.Service.ServiceName, r.Operation.Name, retryStr, err)) +} + // Build will build the request's object so it can be signed and sent // to the service. Build will also validate all the request's parameters. // Anny additional build Handlers set on this request will be run @@ -149,6 +168,7 @@ func (r *Request) Build() error { r.Error = nil r.Handlers.Validate.Run(r) if r.Error != nil { + debugLogReqError(r, "Validate Request", false, r.Error) return r.Error } r.Handlers.Build.Run(r) @@ -165,6 +185,7 @@ func (r *Request) Build() error { func (r *Request) Sign() error { r.Build() if r.Error != nil { + debugLogReqError(r, "Build Request", false, r.Error) return r.Error } @@ -183,42 +204,57 @@ func (r *Request) Send() error { return r.Error } - if BoolValue(r.Retryable) { + if aws.BoolValue(r.Retryable) { + if r.Service.Config.LogLevel.Matches(aws.LogDebugWithRequestRetries) { + r.Service.Config.Logger.Log(fmt.Sprintf("DEBUG: Retrying Request %s/%s, attempt %d", + r.Service.ServiceName, r.Operation.Name, r.RetryCount)) + } + // Re-seek the body back to the original point in for a retry so that // send will send the body's contents again in the upcoming request. - r.Body.Seek(r.bodyStart, 0) + r.Body.Seek(r.BodyStart, 0) + r.HTTPRequest.Body = ioutil.NopCloser(r.Body) } r.Retryable = nil r.Handlers.Send.Run(r) if r.Error != nil { + err := r.Error r.Handlers.Retry.Run(r) r.Handlers.AfterRetry.Run(r) if r.Error != nil { + debugLogReqError(r, "Send Request", false, r.Error) return r.Error } + debugLogReqError(r, "Send Request", true, err) continue } r.Handlers.UnmarshalMeta.Run(r) r.Handlers.ValidateResponse.Run(r) if r.Error != nil { + err := r.Error r.Handlers.UnmarshalError.Run(r) r.Handlers.Retry.Run(r) r.Handlers.AfterRetry.Run(r) if r.Error != nil { + debugLogReqError(r, "Validate Response", false, r.Error) return r.Error } + debugLogReqError(r, "Validate Response", true, err) continue } r.Handlers.Unmarshal.Run(r) if r.Error != nil { + err := r.Error r.Handlers.Retry.Run(r) r.Handlers.AfterRetry.Run(r) if r.Error != nil { + debugLogReqError(r, "Unmarshal Response", false, r.Error) return r.Error } + debugLogReqError(r, "Unmarshal Response", true, err) continue } @@ -279,7 +315,7 @@ func (r *Request) NextPage() *Request { } data := reflect.New(reflect.TypeOf(r.Data).Elem()).Interface() - nr := NewRequest(r.Service, r.Operation, awsutil.CopyOf(r.Params), data) + nr := New(r.Service, r.Handlers, r.Retryer, r.Operation, awsutil.CopyOf(r.Params), data) for i, intok := range nr.Operation.InputTokens { awsutil.SetValueAtAnyPath(nr.Params, intok, tokens[i]) } diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/request/retryer.go b/vendor/src/github.com/aws/aws-sdk-go/aws/request/retryer.go new file mode 100644 index 0000000000..f03b0c6596 --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/request/retryer.go @@ -0,0 +1,71 @@ +package request + +import ( + "time" + + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// Retryer is an interface to control retry logic for a given service. +// The default implementation used by most services is the service.DefaultRetryer +// structure, which contains basic retry logic using exponential backoff. +type Retryer interface { + RetryRules(*Request) time.Duration + ShouldRetry(*Request) bool + MaxRetries() uint +} + +// retryableCodes is a collection of service response codes which are retry-able +// without any further action. +var retryableCodes = map[string]struct{}{ + "RequestError": {}, + "ProvisionedThroughputExceededException": {}, + "Throttling": {}, + "ThrottlingException": {}, + "RequestLimitExceeded": {}, + "RequestThrottled": {}, +} + +// credsExpiredCodes is a collection of error codes which signify the credentials +// need to be refreshed. Expired tokens require refreshing of credentials, and +// resigning before the request can be retried. +var credsExpiredCodes = map[string]struct{}{ + "ExpiredToken": {}, + "ExpiredTokenException": {}, + "RequestExpired": {}, // EC2 Only +} + +func isCodeRetryable(code string) bool { + if _, ok := retryableCodes[code]; ok { + return true + } + + return isCodeExpiredCreds(code) +} + +func isCodeExpiredCreds(code string) bool { + _, ok := credsExpiredCodes[code] + return ok +} + +// IsErrorRetryable returns whether the error is retryable, based on its Code. +// Returns false if the request has no Error set. +func (r *Request) IsErrorRetryable() bool { + if r.Error != nil { + if err, ok := r.Error.(awserr.Error); ok { + return isCodeRetryable(err.Code()) + } + } + return false +} + +// IsErrorExpired returns whether the error code is a credential expiry error. +// Returns false if the request has no Error set. +func (r *Request) IsErrorExpired() bool { + if r.Error != nil { + if err, ok := r.Error.(awserr.Error); ok { + return isCodeExpiredCreds(err.Code()) + } + } + return false +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/service.go b/vendor/src/github.com/aws/aws-sdk-go/aws/service.go deleted file mode 100644 index 672f7de1d6..0000000000 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/service.go +++ /dev/null @@ -1,194 +0,0 @@ -package aws - -import ( - "fmt" - "math" - "math/rand" - "net/http" - "net/http/httputil" - "regexp" - "time" - - "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/aws/aws-sdk-go/internal/endpoints" -) - -// A Service implements the base service request and response handling -// used by all services. -type Service struct { - Config *Config - Handlers Handlers - ServiceName string - APIVersion string - Endpoint string - SigningName string - SigningRegion string - JSONVersion string - TargetPrefix string - RetryRules func(*Request) time.Duration - ShouldRetry func(*Request) bool - DefaultMaxRetries uint -} - -var schemeRE = regexp.MustCompile("^([^:]+)://") - -// NewService will return a pointer to a new Server object initialized. -func NewService(config *Config) *Service { - svc := &Service{Config: config} - svc.Initialize() - return svc -} - -// Initialize initializes the service. -func (s *Service) Initialize() { - if s.Config == nil { - s.Config = &Config{} - } - if s.Config.HTTPClient == nil { - s.Config.HTTPClient = http.DefaultClient - } - - if s.RetryRules == nil { - s.RetryRules = retryRules - } - - if s.ShouldRetry == nil { - s.ShouldRetry = shouldRetry - } - - s.DefaultMaxRetries = 3 - s.Handlers.Validate.PushBack(ValidateEndpointHandler) - s.Handlers.Build.PushBack(UserAgentHandler) - s.Handlers.Sign.PushBack(BuildContentLength) - s.Handlers.Send.PushBack(SendHandler) - s.Handlers.AfterRetry.PushBack(AfterRetryHandler) - s.Handlers.ValidateResponse.PushBack(ValidateResponseHandler) - s.AddDebugHandlers() - s.buildEndpoint() - - if !BoolValue(s.Config.DisableParamValidation) { - s.Handlers.Validate.PushBack(ValidateParameters) - } -} - -// buildEndpoint builds the endpoint values the service will use to make requests with. -func (s *Service) buildEndpoint() { - if StringValue(s.Config.Endpoint) != "" { - s.Endpoint = *s.Config.Endpoint - } else { - s.Endpoint, s.SigningRegion = - endpoints.EndpointForRegion(s.ServiceName, StringValue(s.Config.Region)) - } - - if s.Endpoint != "" && !schemeRE.MatchString(s.Endpoint) { - scheme := "https" - if BoolValue(s.Config.DisableSSL) { - scheme = "http" - } - s.Endpoint = scheme + "://" + s.Endpoint - } -} - -// AddDebugHandlers injects debug logging handlers into the service to log request -// debug information. -func (s *Service) AddDebugHandlers() { - if !s.Config.LogLevel.AtLeast(LogDebug) { - return - } - - s.Handlers.Send.PushFront(logRequest) - s.Handlers.Send.PushBack(logResponse) -} - -const logReqMsg = `DEBUG: Request %s/%s Details: ----[ REQUEST POST-SIGN ]----------------------------- -%s ------------------------------------------------------` - -func logRequest(r *Request) { - logBody := r.Config.LogLevel.Matches(LogDebugWithHTTPBody) - dumpedBody, _ := httputil.DumpRequestOut(r.HTTPRequest, logBody) - - r.Config.Logger.Log(fmt.Sprintf(logReqMsg, r.ServiceName, r.Operation.Name, string(dumpedBody))) -} - -const logRespMsg = `DEBUG: Response %s/%s Details: ----[ RESPONSE ]-------------------------------------- -%s ------------------------------------------------------` - -func logResponse(r *Request) { - var msg = "no reponse data" - if r.HTTPResponse != nil { - logBody := r.Config.LogLevel.Matches(LogDebugWithHTTPBody) - dumpedBody, _ := httputil.DumpResponse(r.HTTPResponse, logBody) - msg = string(dumpedBody) - } else if r.Error != nil { - msg = r.Error.Error() - } - r.Config.Logger.Log(fmt.Sprintf(logRespMsg, r.ServiceName, r.Operation.Name, msg)) -} - -// MaxRetries returns the number of maximum returns the service will use to make -// an individual API request. -func (s *Service) MaxRetries() uint { - if IntValue(s.Config.MaxRetries) < 0 { - return s.DefaultMaxRetries - } - return uint(IntValue(s.Config.MaxRetries)) -} - -var seededRand = rand.New(rand.NewSource(time.Now().UnixNano())) - -// retryRules returns the delay duration before retrying this request again -func retryRules(r *Request) time.Duration { - - delay := int(math.Pow(2, float64(r.RetryCount))) * (seededRand.Intn(30) + 30) - return time.Duration(delay) * time.Millisecond -} - -// retryableCodes is a collection of service response codes which are retry-able -// without any further action. -var retryableCodes = map[string]struct{}{ - "RequestError": {}, - "ProvisionedThroughputExceededException": {}, - "Throttling": {}, - "ThrottlingException": {}, - "RequestLimitExceeded": {}, - "RequestThrottled": {}, -} - -// credsExpiredCodes is a collection of error codes which signify the credentials -// need to be refreshed. Expired tokens require refreshing of credentials, and -// resigning before the request can be retried. -var credsExpiredCodes = map[string]struct{}{ - "ExpiredToken": {}, - "ExpiredTokenException": {}, - "RequestExpired": {}, // EC2 Only -} - -func isCodeRetryable(code string) bool { - if _, ok := retryableCodes[code]; ok { - return true - } - - return isCodeExpiredCreds(code) -} - -func isCodeExpiredCreds(code string) bool { - _, ok := credsExpiredCodes[code] - return ok -} - -// shouldRetry returns if the request should be retried. -func shouldRetry(r *Request) bool { - if r.HTTPResponse.StatusCode >= 500 { - return true - } - if r.Error != nil { - if err, ok := r.Error.(awserr.Error); ok { - return isCodeRetryable(err.Code()) - } - } - return false -} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/service/default_retryer.go b/vendor/src/github.com/aws/aws-sdk-go/aws/service/default_retryer.go new file mode 100644 index 0000000000..e642d16b71 --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/service/default_retryer.go @@ -0,0 +1,51 @@ +package service + +import ( + "math" + "math/rand" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/request" +) + +// DefaultRetryer implements basic retry logic using exponential backoff for +// most services. If you want to implement custom retry logic, implement the +// request.Retryer interface or create a structure type that composes this +// struct and override the specific methods. For example, to override only +// the MaxRetries method: +// +// type retryer struct { +// service.DefaultRetryer +// } +// +// // This implementation always has 100 max retries +// func (d retryer) MaxRetries() uint { return 100 } +type DefaultRetryer struct { + *Service +} + +// MaxRetries returns the number of maximum returns the service will use to make +// an individual API request. +func (d DefaultRetryer) MaxRetries() uint { + if aws.IntValue(d.Service.Config.MaxRetries) < 0 { + return d.DefaultMaxRetries + } + return uint(aws.IntValue(d.Service.Config.MaxRetries)) +} + +var seededRand = rand.New(rand.NewSource(time.Now().UnixNano())) + +// RetryRules returns the delay duration before retrying this request again +func (d DefaultRetryer) RetryRules(r *request.Request) time.Duration { + delay := int(math.Pow(2, float64(r.RetryCount))) * (seededRand.Intn(30) + 30) + return time.Duration(delay) * time.Millisecond +} + +// ShouldRetry returns if the request should be retried. +func (d DefaultRetryer) ShouldRetry(r *request.Request) bool { + if r.HTTPResponse.StatusCode >= 500 { + return true + } + return r.IsErrorRetryable() +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/service/service.go b/vendor/src/github.com/aws/aws-sdk-go/aws/service/service.go new file mode 100644 index 0000000000..7205212e19 --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/service/service.go @@ -0,0 +1,133 @@ +package service + +import ( + "fmt" + "io/ioutil" + "net/http" + "net/http/httputil" + "regexp" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/corehandlers" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/aws/service/serviceinfo" + "github.com/aws/aws-sdk-go/internal/endpoints" +) + +// A Service implements the base service request and response handling +// used by all services. +type Service struct { + serviceinfo.ServiceInfo + request.Retryer + DefaultMaxRetries uint + Handlers request.Handlers +} + +var schemeRE = regexp.MustCompile("^([^:]+)://") + +// New will return a pointer to a new Server object initialized. +func New(config *aws.Config) *Service { + svc := &Service{ServiceInfo: serviceinfo.ServiceInfo{Config: config}} + svc.Initialize() + return svc +} + +// Initialize initializes the service. +func (s *Service) Initialize() { + if s.Config == nil { + s.Config = &aws.Config{} + } + if s.Config.HTTPClient == nil { + s.Config.HTTPClient = http.DefaultClient + } + if s.Config.SleepDelay == nil { + s.Config.SleepDelay = time.Sleep + } + + s.Retryer = DefaultRetryer{s} + s.DefaultMaxRetries = 3 + s.Handlers.Validate.PushBackNamed(corehandlers.ValidateEndpointHandler) + s.Handlers.Build.PushBackNamed(corehandlers.UserAgentHandler) + s.Handlers.Sign.PushBackNamed(corehandlers.BuildContentLengthHandler) + s.Handlers.Send.PushBackNamed(corehandlers.SendHandler) + s.Handlers.AfterRetry.PushBackNamed(corehandlers.AfterRetryHandler) + s.Handlers.ValidateResponse.PushBackNamed(corehandlers.ValidateResponseHandler) + if !aws.BoolValue(s.Config.DisableParamValidation) { + s.Handlers.Validate.PushBackNamed(corehandlers.ValidateParametersHandler) + } + s.AddDebugHandlers() + s.buildEndpoint() +} + +// NewRequest returns a new Request pointer for the service API +// operation and parameters. +func (s *Service) NewRequest(operation *request.Operation, params interface{}, data interface{}) *request.Request { + return request.New(s.ServiceInfo, s.Handlers, s.Retryer, operation, params, data) +} + +// buildEndpoint builds the endpoint values the service will use to make requests with. +func (s *Service) buildEndpoint() { + if aws.StringValue(s.Config.Endpoint) != "" { + s.Endpoint = *s.Config.Endpoint + } else if s.Endpoint == "" { + s.Endpoint, s.SigningRegion = + endpoints.EndpointForRegion(s.ServiceName, aws.StringValue(s.Config.Region)) + } + + if s.Endpoint != "" && !schemeRE.MatchString(s.Endpoint) { + scheme := "https" + if aws.BoolValue(s.Config.DisableSSL) { + scheme = "http" + } + s.Endpoint = scheme + "://" + s.Endpoint + } +} + +// AddDebugHandlers injects debug logging handlers into the service to log request +// debug information. +func (s *Service) AddDebugHandlers() { + if !s.Config.LogLevel.AtLeast(aws.LogDebug) { + return + } + + s.Handlers.Send.PushFront(logRequest) + s.Handlers.Send.PushBack(logResponse) +} + +const logReqMsg = `DEBUG: Request %s/%s Details: +---[ REQUEST POST-SIGN ]----------------------------- +%s +-----------------------------------------------------` + +func logRequest(r *request.Request) { + logBody := r.Service.Config.LogLevel.Matches(aws.LogDebugWithHTTPBody) + dumpedBody, _ := httputil.DumpRequestOut(r.HTTPRequest, logBody) + + if logBody { + // Reset the request body because dumpRequest will re-wrap the r.HTTPRequest's + // Body as a NoOpCloser and will not be reset after read by the HTTP + // client reader. + r.Body.Seek(r.BodyStart, 0) + r.HTTPRequest.Body = ioutil.NopCloser(r.Body) + } + + r.Service.Config.Logger.Log(fmt.Sprintf(logReqMsg, r.Service.ServiceName, r.Operation.Name, string(dumpedBody))) +} + +const logRespMsg = `DEBUG: Response %s/%s Details: +---[ RESPONSE ]-------------------------------------- +%s +-----------------------------------------------------` + +func logResponse(r *request.Request) { + var msg = "no reponse data" + if r.HTTPResponse != nil { + logBody := r.Service.Config.LogLevel.Matches(aws.LogDebugWithHTTPBody) + dumpedBody, _ := httputil.DumpResponse(r.HTTPResponse, logBody) + msg = string(dumpedBody) + } else if r.Error != nil { + msg = r.Error.Error() + } + r.Service.Config.Logger.Log(fmt.Sprintf(logRespMsg, r.Service.ServiceName, r.Operation.Name, msg)) +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/service/serviceinfo/service_info.go b/vendor/src/github.com/aws/aws-sdk-go/aws/service/serviceinfo/service_info.go new file mode 100644 index 0000000000..a920e96a96 --- /dev/null +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/service/serviceinfo/service_info.go @@ -0,0 +1,15 @@ +package serviceinfo + +import "github.com/aws/aws-sdk-go/aws" + +// ServiceInfo wraps immutable data from the service.Service structure. +type ServiceInfo struct { + Config *aws.Config + ServiceName string + APIVersion string + Endpoint string + SigningName string + SigningRegion string + JSONVersion string + TargetPrefix string +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/types.go b/vendor/src/github.com/aws/aws-sdk-go/aws/types.go index 87905d7e06..846b732dda 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/types.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/types.go @@ -2,6 +2,7 @@ package aws import ( "io" + "sync" ) // ReadSeekCloser wraps a io.Reader returning a ReaderSeakerCloser @@ -53,3 +54,35 @@ func (r ReaderSeekerCloser) Close() error { } return nil } + +// A WriteAtBuffer provides a in memory buffer supporting the io.WriterAt interface +// Can be used with the s3manager.Downloader to download content to a buffer +// in memory. Safe to use concurrently. +type WriteAtBuffer struct { + buf []byte + m sync.Mutex +} + +// WriteAt writes a slice of bytes to a buffer starting at the position provided +// The number of bytes written will be returned, or error. Can overwrite previous +// written slices if the write ats overlap. +func (b *WriteAtBuffer) WriteAt(p []byte, pos int64) (n int, err error) { + b.m.Lock() + defer b.m.Unlock() + + expLen := pos + int64(len(p)) + if int64(len(b.buf)) < expLen { + newBuf := make([]byte, expLen) + copy(newBuf, b.buf) + b.buf = newBuf + } + copy(b.buf[pos:], p) + return len(p), nil +} + +// Bytes returns a slice of bytes written to the buffer. +func (b *WriteAtBuffer) Bytes() []byte { + b.m.Lock() + defer b.m.Unlock() + return b.buf[:len(b.buf):len(b.buf)] +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/aws/version.go b/vendor/src/github.com/aws/aws-sdk-go/aws/version.go index 51c3358efd..f89f1e112f 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/aws/version.go +++ b/vendor/src/github.com/aws/aws-sdk-go/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "0.7.1" +const SDKVersion = "0.9.9" diff --git a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil/build.go b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil/build.go index 58b65fb8fb..8625754362 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil/build.go +++ b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil/build.go @@ -66,6 +66,17 @@ func buildStruct(value reflect.Value, buf *bytes.Buffer, tag reflect.StructTag) return nil } + // unwrap payloads + if payload := tag.Get("payload"); payload != "" { + field, _ := value.Type().FieldByName(payload) + tag = field.Tag + value = elemOf(value.FieldByName(payload)) + + if !value.IsValid() { + return nil + } + } + buf.WriteString("{") t, fields := value.Type(), []*reflect.StructField{} @@ -197,3 +208,11 @@ func writeString(s string, buf *bytes.Buffer) { } buf.WriteByte('"') } + +// Returns the reflection element of a value, if it is a pointer. +func elemOf(value reflect.Value) reflect.Value { + for value.Kind() == reflect.Ptr { + value = value.Elem() + } + return value +} diff --git a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil/unmarshal.go b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil/unmarshal.go index 730dcd0f80..470b5ef182 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil/unmarshal.go +++ b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil/unmarshal.go @@ -7,7 +7,6 @@ import ( "io" "io/ioutil" "reflect" - "strings" "time" ) @@ -99,7 +98,7 @@ func unmarshalStruct(value reflect.Value, data interface{}, tag reflect.StructTa for i := 0; i < t.NumField(); i++ { field := t.Field(i) - if c := field.Name[0:1]; strings.ToLower(c) == c { + if field.PkgPath != "" { continue // ignore unexported fields } diff --git a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/jsonrpc/jsonrpc.go b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/jsonrpc/jsonrpc.go index daf1efd59b..a0df55b1e8 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/jsonrpc/jsonrpc.go +++ b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/jsonrpc/jsonrpc.go @@ -10,15 +10,16 @@ import ( "io/ioutil" "strings" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/internal/protocol/json/jsonutil" + "github.com/aws/aws-sdk-go/internal/protocol/rest" ) var emptyJSON = []byte("{}") // Build builds a JSON payload for a JSON RPC request. -func Build(req *aws.Request) { +func Build(req *request.Request) { var buf []byte var err error if req.ParamsFilled() { @@ -46,7 +47,7 @@ func Build(req *aws.Request) { } // Unmarshal unmarshals a response for a JSON RPC service. -func Unmarshal(req *aws.Request) { +func Unmarshal(req *request.Request) { defer req.HTTPResponse.Body.Close() if req.DataFilled() { err := jsonutil.UnmarshalJSON(req.Data, req.HTTPResponse.Body) @@ -58,12 +59,12 @@ func Unmarshal(req *aws.Request) { } // UnmarshalMeta unmarshals headers from a response for a JSON RPC service. -func UnmarshalMeta(req *aws.Request) { - req.RequestID = req.HTTPResponse.Header.Get("x-amzn-requestid") +func UnmarshalMeta(req *request.Request) { + rest.UnmarshalMeta(req) } // UnmarshalError unmarshals an error response for a JSON RPC service. -func UnmarshalError(req *aws.Request) { +func UnmarshalError(req *request.Request) { defer req.HTTPResponse.Body.Close() bodyBytes, err := ioutil.ReadAll(req.HTTPResponse.Body) if err != nil { @@ -88,7 +89,7 @@ func UnmarshalError(req *aws.Request) { req.Error = awserr.NewRequestFailure( awserr.New(codes[len(codes)-1], jsonErr.Message, nil), req.HTTPResponse.StatusCode, - "", + req.RequestID, ) } diff --git a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/rest/build.go b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/rest/build.go index cd5eef2351..326e96cc62 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/rest/build.go +++ b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/rest/build.go @@ -1,4 +1,4 @@ -// Package rest provides RESTful serialisation of AWS requests and responses. +// Package rest provides RESTful serialization of AWS requests and responses. package rest import ( @@ -13,8 +13,8 @@ import ( "strings" "time" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" ) // RFC822 returns an RFC822 formatted timestamp for AWS protocols @@ -37,7 +37,7 @@ func init() { } // Build builds the REST component of a service request. -func Build(r *aws.Request) { +func Build(r *request.Request) { if r.ParamsFilled() { v := reflect.ValueOf(r.Params).Elem() buildLocationElements(r, v) @@ -45,7 +45,7 @@ func Build(r *aws.Request) { } } -func buildLocationElements(r *aws.Request, v reflect.Value) { +func buildLocationElements(r *request.Request, v reflect.Value) { query := r.HTTPRequest.URL.Query() for i := 0; i < v.NumField(); i++ { @@ -87,7 +87,7 @@ func buildLocationElements(r *aws.Request, v reflect.Value) { updatePath(r.HTTPRequest.URL, r.HTTPRequest.URL.Path) } -func buildBody(r *aws.Request, v reflect.Value) { +func buildBody(r *request.Request, v reflect.Value) { if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok { if payloadName := field.Tag.Get("payload"); payloadName != "" { pfield, _ := v.Type().FieldByName(payloadName) @@ -112,7 +112,7 @@ func buildBody(r *aws.Request, v reflect.Value) { } } -func buildHeader(r *aws.Request, v reflect.Value, name string) { +func buildHeader(r *request.Request, v reflect.Value, name string) { str, err := convertType(v) if err != nil { r.Error = awserr.New("SerializationError", "failed to encode REST request", err) @@ -121,7 +121,7 @@ func buildHeader(r *aws.Request, v reflect.Value, name string) { } } -func buildHeaderMap(r *aws.Request, v reflect.Value, prefix string) { +func buildHeaderMap(r *request.Request, v reflect.Value, prefix string) { for _, key := range v.MapKeys() { str, err := convertType(v.MapIndex(key)) if err != nil { @@ -132,7 +132,7 @@ func buildHeaderMap(r *aws.Request, v reflect.Value, prefix string) { } } -func buildURI(r *aws.Request, v reflect.Value, name string) { +func buildURI(r *request.Request, v reflect.Value, name string) { value, err := convertType(v) if err != nil { r.Error = awserr.New("SerializationError", "failed to encode REST request", err) @@ -144,7 +144,7 @@ func buildURI(r *aws.Request, v reflect.Value, name string) { } } -func buildQueryString(r *aws.Request, v reflect.Value, name string, query url.Values) { +func buildQueryString(r *request.Request, v reflect.Value, name string, query url.Values) { str, err := convertType(v) if err != nil { r.Error = awserr.New("SerializationError", "failed to encode REST request", err) @@ -156,8 +156,13 @@ func buildQueryString(r *aws.Request, v reflect.Value, name string, query url.Va func updatePath(url *url.URL, urlPath string) { scheme, query := url.Scheme, url.RawQuery + hasSlash := strings.HasSuffix(urlPath, "/") + // clean up path urlPath = path.Clean(urlPath) + if hasSlash && !strings.HasSuffix(urlPath, "/") { + urlPath += "/" + } // get formatted URL minus scheme so we can build this into Opaque url.Scheme, url.Path, url.RawQuery = "", "", "" diff --git a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/rest/unmarshal.go b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/rest/unmarshal.go index a4155f1669..06d9accbac 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/rest/unmarshal.go +++ b/vendor/src/github.com/aws/aws-sdk-go/internal/protocol/rest/unmarshal.go @@ -12,18 +12,27 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" ) // Unmarshal unmarshals the REST component of a response in a REST service. -func Unmarshal(r *aws.Request) { +func Unmarshal(r *request.Request) { if r.DataFilled() { v := reflect.Indirect(reflect.ValueOf(r.Data)) unmarshalBody(r, v) + } +} + +// UnmarshalMeta unmarshals the REST metadata of a response in a REST service +func UnmarshalMeta(r *request.Request) { + r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") + if r.DataFilled() { + v := reflect.Indirect(reflect.ValueOf(r.Data)) unmarshalLocationElements(r, v) } } -func unmarshalBody(r *aws.Request, v reflect.Value) { +func unmarshalBody(r *request.Request, v reflect.Value) { if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok { if payloadName := field.Tag.Get("payload"); payloadName != "" { pfield, _ := v.Type().FieldByName(payloadName) @@ -64,7 +73,7 @@ func unmarshalBody(r *aws.Request, v reflect.Value) { } } -func unmarshalLocationElements(r *aws.Request, v reflect.Value) { +func unmarshalLocationElements(r *request.Request, v reflect.Value) { for i := 0; i < v.NumField(); i++ { m, field := v.Field(i), v.Type().Field(i) if n := field.Name; n[0:1] == strings.ToLower(n[0:1]) { diff --git a/vendor/src/github.com/aws/aws-sdk-go/internal/signer/v4/v4.go b/vendor/src/github.com/aws/aws-sdk-go/internal/signer/v4/v4.go index 748c37f2e6..fc7bc35350 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/internal/signer/v4/v4.go +++ b/vendor/src/github.com/aws/aws-sdk-go/internal/signer/v4/v4.go @@ -16,6 +16,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/internal/protocol/rest" ) @@ -63,7 +64,7 @@ type signer struct { // Will sign the requests with the service config's Credentials object // Signing is skipped if the credentials is the credentials.AnonymousCredentials // object. -func Sign(req *aws.Request) { +func Sign(req *request.Request) { // If the request does not need to be signed ignore the signing of the // request if the AnonymousCredentials object is used. if req.Service.Config.Credentials == credentials.AnonymousCredentials { diff --git a/vendor/src/github.com/aws/aws-sdk-go/service/cloudwatchlogs/api.go b/vendor/src/github.com/aws/aws-sdk-go/service/cloudwatchlogs/api.go index f81506c9e1..32d5356a6d 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/service/cloudwatchlogs/api.go +++ b/vendor/src/github.com/aws/aws-sdk-go/service/cloudwatchlogs/api.go @@ -4,15 +4,74 @@ package cloudwatchlogs import ( - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" ) +const opCancelExportTask = "CancelExportTask" + +// CancelExportTaskRequest generates a request for the CancelExportTask operation. +func (c *CloudWatchLogs) CancelExportTaskRequest(input *CancelExportTaskInput) (req *request.Request, output *CancelExportTaskOutput) { + op := &request.Operation{ + Name: opCancelExportTask, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CancelExportTaskInput{} + } + + req = c.newRequest(op, input, output) + output = &CancelExportTaskOutput{} + req.Data = output + return +} + +// Cancels an export task if it is in PENDING or RUNNING state. +func (c *CloudWatchLogs) CancelExportTask(input *CancelExportTaskInput) (*CancelExportTaskOutput, error) { + req, out := c.CancelExportTaskRequest(input) + err := req.Send() + return out, err +} + +const opCreateExportTask = "CreateExportTask" + +// CreateExportTaskRequest generates a request for the CreateExportTask operation. +func (c *CloudWatchLogs) CreateExportTaskRequest(input *CreateExportTaskInput) (req *request.Request, output *CreateExportTaskOutput) { + op := &request.Operation{ + Name: opCreateExportTask, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateExportTaskInput{} + } + + req = c.newRequest(op, input, output) + output = &CreateExportTaskOutput{} + req.Data = output + return +} + +// Creates an ExportTask which allows you to efficiently export data from a +// Log Group to your Amazon S3 bucket. +// +// This is an asynchronous call. If all the required information is provided, +// this API will initiate an export task and respond with the task Id. Once +// started, DescribeExportTasks can be used to get the status of an export task. +func (c *CloudWatchLogs) CreateExportTask(input *CreateExportTaskInput) (*CreateExportTaskOutput, error) { + req, out := c.CreateExportTaskRequest(input) + err := req.Send() + return out, err +} + const opCreateLogGroup = "CreateLogGroup" // CreateLogGroupRequest generates a request for the CreateLogGroup operation. -func (c *CloudWatchLogs) CreateLogGroupRequest(input *CreateLogGroupInput) (req *aws.Request, output *CreateLogGroupOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) CreateLogGroupRequest(input *CreateLogGroupInput) (req *request.Request, output *CreateLogGroupOutput) { + op := &request.Operation{ Name: opCreateLogGroup, HTTPMethod: "POST", HTTPPath: "/", @@ -44,8 +103,8 @@ func (c *CloudWatchLogs) CreateLogGroup(input *CreateLogGroupInput) (*CreateLogG const opCreateLogStream = "CreateLogStream" // CreateLogStreamRequest generates a request for the CreateLogStream operation. -func (c *CloudWatchLogs) CreateLogStreamRequest(input *CreateLogStreamInput) (req *aws.Request, output *CreateLogStreamOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) CreateLogStreamRequest(input *CreateLogStreamInput) (req *request.Request, output *CreateLogStreamOutput) { + op := &request.Operation{ Name: opCreateLogStream, HTTPMethod: "POST", HTTPPath: "/", @@ -77,8 +136,8 @@ func (c *CloudWatchLogs) CreateLogStream(input *CreateLogStreamInput) (*CreateLo const opDeleteDestination = "DeleteDestination" // DeleteDestinationRequest generates a request for the DeleteDestination operation. -func (c *CloudWatchLogs) DeleteDestinationRequest(input *DeleteDestinationInput) (req *aws.Request, output *DeleteDestinationOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DeleteDestinationRequest(input *DeleteDestinationInput) (req *request.Request, output *DeleteDestinationOutput) { + op := &request.Operation{ Name: opDeleteDestination, HTTPMethod: "POST", HTTPPath: "/", @@ -106,8 +165,8 @@ func (c *CloudWatchLogs) DeleteDestination(input *DeleteDestinationInput) (*Dele const opDeleteLogGroup = "DeleteLogGroup" // DeleteLogGroupRequest generates a request for the DeleteLogGroup operation. -func (c *CloudWatchLogs) DeleteLogGroupRequest(input *DeleteLogGroupInput) (req *aws.Request, output *DeleteLogGroupOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DeleteLogGroupRequest(input *DeleteLogGroupInput) (req *request.Request, output *DeleteLogGroupOutput) { + op := &request.Operation{ Name: opDeleteLogGroup, HTTPMethod: "POST", HTTPPath: "/", @@ -134,8 +193,8 @@ func (c *CloudWatchLogs) DeleteLogGroup(input *DeleteLogGroupInput) (*DeleteLogG const opDeleteLogStream = "DeleteLogStream" // DeleteLogStreamRequest generates a request for the DeleteLogStream operation. -func (c *CloudWatchLogs) DeleteLogStreamRequest(input *DeleteLogStreamInput) (req *aws.Request, output *DeleteLogStreamOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DeleteLogStreamRequest(input *DeleteLogStreamInput) (req *request.Request, output *DeleteLogStreamOutput) { + op := &request.Operation{ Name: opDeleteLogStream, HTTPMethod: "POST", HTTPPath: "/", @@ -162,8 +221,8 @@ func (c *CloudWatchLogs) DeleteLogStream(input *DeleteLogStreamInput) (*DeleteLo const opDeleteMetricFilter = "DeleteMetricFilter" // DeleteMetricFilterRequest generates a request for the DeleteMetricFilter operation. -func (c *CloudWatchLogs) DeleteMetricFilterRequest(input *DeleteMetricFilterInput) (req *aws.Request, output *DeleteMetricFilterOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DeleteMetricFilterRequest(input *DeleteMetricFilterInput) (req *request.Request, output *DeleteMetricFilterOutput) { + op := &request.Operation{ Name: opDeleteMetricFilter, HTTPMethod: "POST", HTTPPath: "/", @@ -189,8 +248,8 @@ func (c *CloudWatchLogs) DeleteMetricFilter(input *DeleteMetricFilterInput) (*De const opDeleteRetentionPolicy = "DeleteRetentionPolicy" // DeleteRetentionPolicyRequest generates a request for the DeleteRetentionPolicy operation. -func (c *CloudWatchLogs) DeleteRetentionPolicyRequest(input *DeleteRetentionPolicyInput) (req *aws.Request, output *DeleteRetentionPolicyOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DeleteRetentionPolicyRequest(input *DeleteRetentionPolicyInput) (req *request.Request, output *DeleteRetentionPolicyOutput) { + op := &request.Operation{ Name: opDeleteRetentionPolicy, HTTPMethod: "POST", HTTPPath: "/", @@ -217,8 +276,8 @@ func (c *CloudWatchLogs) DeleteRetentionPolicy(input *DeleteRetentionPolicyInput const opDeleteSubscriptionFilter = "DeleteSubscriptionFilter" // DeleteSubscriptionFilterRequest generates a request for the DeleteSubscriptionFilter operation. -func (c *CloudWatchLogs) DeleteSubscriptionFilterRequest(input *DeleteSubscriptionFilterInput) (req *aws.Request, output *DeleteSubscriptionFilterOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DeleteSubscriptionFilterRequest(input *DeleteSubscriptionFilterInput) (req *request.Request, output *DeleteSubscriptionFilterOutput) { + op := &request.Operation{ Name: opDeleteSubscriptionFilter, HTTPMethod: "POST", HTTPPath: "/", @@ -244,11 +303,17 @@ func (c *CloudWatchLogs) DeleteSubscriptionFilter(input *DeleteSubscriptionFilte const opDescribeDestinations = "DescribeDestinations" // DescribeDestinationsRequest generates a request for the DescribeDestinations operation. -func (c *CloudWatchLogs) DescribeDestinationsRequest(input *DescribeDestinationsInput) (req *aws.Request, output *DescribeDestinationsOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DescribeDestinationsRequest(input *DescribeDestinationsInput) (req *request.Request, output *DescribeDestinationsOutput) { + op := &request.Operation{ Name: opDescribeDestinations, HTTPMethod: "POST", HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"nextToken"}, + OutputTokens: []string{"nextToken"}, + LimitToken: "limit", + TruncationToken: "", + }, } if input == nil { @@ -275,15 +340,56 @@ func (c *CloudWatchLogs) DescribeDestinations(input *DescribeDestinationsInput) return out, err } +func (c *CloudWatchLogs) DescribeDestinationsPages(input *DescribeDestinationsInput, fn func(p *DescribeDestinationsOutput, lastPage bool) (shouldContinue bool)) error { + page, _ := c.DescribeDestinationsRequest(input) + return page.EachPage(func(p interface{}, lastPage bool) bool { + return fn(p.(*DescribeDestinationsOutput), lastPage) + }) +} + +const opDescribeExportTasks = "DescribeExportTasks" + +// DescribeExportTasksRequest generates a request for the DescribeExportTasks operation. +func (c *CloudWatchLogs) DescribeExportTasksRequest(input *DescribeExportTasksInput) (req *request.Request, output *DescribeExportTasksOutput) { + op := &request.Operation{ + Name: opDescribeExportTasks, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DescribeExportTasksInput{} + } + + req = c.newRequest(op, input, output) + output = &DescribeExportTasksOutput{} + req.Data = output + return +} + +// Returns all the export tasks that are associated with the AWS account making +// the request. The export tasks can be filtered based on TaskId or TaskStatus. +// +// By default, this operation returns up to 50 export tasks that satisfy the +// specified filters. If there are more export tasks to list, the response would +// contain a nextToken value in the response body. You can also limit the number +// of export tasks returned in the response by specifying the limit parameter +// in the request. +func (c *CloudWatchLogs) DescribeExportTasks(input *DescribeExportTasksInput) (*DescribeExportTasksOutput, error) { + req, out := c.DescribeExportTasksRequest(input) + err := req.Send() + return out, err +} + const opDescribeLogGroups = "DescribeLogGroups" // DescribeLogGroupsRequest generates a request for the DescribeLogGroups operation. -func (c *CloudWatchLogs) DescribeLogGroupsRequest(input *DescribeLogGroupsInput) (req *aws.Request, output *DescribeLogGroupsOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DescribeLogGroupsRequest(input *DescribeLogGroupsInput) (req *request.Request, output *DescribeLogGroupsOutput) { + op := &request.Operation{ Name: opDescribeLogGroups, HTTPMethod: "POST", HTTPPath: "/", - Paginator: &aws.Paginator{ + Paginator: &request.Paginator{ InputTokens: []string{"nextToken"}, OutputTokens: []string{"nextToken"}, LimitToken: "limit", @@ -325,12 +431,12 @@ func (c *CloudWatchLogs) DescribeLogGroupsPages(input *DescribeLogGroupsInput, f const opDescribeLogStreams = "DescribeLogStreams" // DescribeLogStreamsRequest generates a request for the DescribeLogStreams operation. -func (c *CloudWatchLogs) DescribeLogStreamsRequest(input *DescribeLogStreamsInput) (req *aws.Request, output *DescribeLogStreamsOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DescribeLogStreamsRequest(input *DescribeLogStreamsInput) (req *request.Request, output *DescribeLogStreamsOutput) { + op := &request.Operation{ Name: opDescribeLogStreams, HTTPMethod: "POST", HTTPPath: "/", - Paginator: &aws.Paginator{ + Paginator: &request.Paginator{ InputTokens: []string{"nextToken"}, OutputTokens: []string{"nextToken"}, LimitToken: "limit", @@ -373,12 +479,12 @@ func (c *CloudWatchLogs) DescribeLogStreamsPages(input *DescribeLogStreamsInput, const opDescribeMetricFilters = "DescribeMetricFilters" // DescribeMetricFiltersRequest generates a request for the DescribeMetricFilters operation. -func (c *CloudWatchLogs) DescribeMetricFiltersRequest(input *DescribeMetricFiltersInput) (req *aws.Request, output *DescribeMetricFiltersOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DescribeMetricFiltersRequest(input *DescribeMetricFiltersInput) (req *request.Request, output *DescribeMetricFiltersOutput) { + op := &request.Operation{ Name: opDescribeMetricFilters, HTTPMethod: "POST", HTTPPath: "/", - Paginator: &aws.Paginator{ + Paginator: &request.Paginator{ InputTokens: []string{"nextToken"}, OutputTokens: []string{"nextToken"}, LimitToken: "limit", @@ -419,11 +525,17 @@ func (c *CloudWatchLogs) DescribeMetricFiltersPages(input *DescribeMetricFilters const opDescribeSubscriptionFilters = "DescribeSubscriptionFilters" // DescribeSubscriptionFiltersRequest generates a request for the DescribeSubscriptionFilters operation. -func (c *CloudWatchLogs) DescribeSubscriptionFiltersRequest(input *DescribeSubscriptionFiltersInput) (req *aws.Request, output *DescribeSubscriptionFiltersOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) DescribeSubscriptionFiltersRequest(input *DescribeSubscriptionFiltersInput) (req *request.Request, output *DescribeSubscriptionFiltersOutput) { + op := &request.Operation{ Name: opDescribeSubscriptionFilters, HTTPMethod: "POST", HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"nextToken"}, + OutputTokens: []string{"nextToken"}, + LimitToken: "limit", + TruncationToken: "", + }, } if input == nil { @@ -450,14 +562,27 @@ func (c *CloudWatchLogs) DescribeSubscriptionFilters(input *DescribeSubscription return out, err } +func (c *CloudWatchLogs) DescribeSubscriptionFiltersPages(input *DescribeSubscriptionFiltersInput, fn func(p *DescribeSubscriptionFiltersOutput, lastPage bool) (shouldContinue bool)) error { + page, _ := c.DescribeSubscriptionFiltersRequest(input) + return page.EachPage(func(p interface{}, lastPage bool) bool { + return fn(p.(*DescribeSubscriptionFiltersOutput), lastPage) + }) +} + const opFilterLogEvents = "FilterLogEvents" // FilterLogEventsRequest generates a request for the FilterLogEvents operation. -func (c *CloudWatchLogs) FilterLogEventsRequest(input *FilterLogEventsInput) (req *aws.Request, output *FilterLogEventsOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) FilterLogEventsRequest(input *FilterLogEventsInput) (req *request.Request, output *FilterLogEventsOutput) { + op := &request.Operation{ Name: opFilterLogEvents, HTTPMethod: "POST", HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"nextToken"}, + OutputTokens: []string{"nextToken"}, + LimitToken: "limit", + TruncationToken: "", + }, } if input == nil { @@ -490,15 +615,22 @@ func (c *CloudWatchLogs) FilterLogEvents(input *FilterLogEventsInput) (*FilterLo return out, err } +func (c *CloudWatchLogs) FilterLogEventsPages(input *FilterLogEventsInput, fn func(p *FilterLogEventsOutput, lastPage bool) (shouldContinue bool)) error { + page, _ := c.FilterLogEventsRequest(input) + return page.EachPage(func(p interface{}, lastPage bool) bool { + return fn(p.(*FilterLogEventsOutput), lastPage) + }) +} + const opGetLogEvents = "GetLogEvents" // GetLogEventsRequest generates a request for the GetLogEvents operation. -func (c *CloudWatchLogs) GetLogEventsRequest(input *GetLogEventsInput) (req *aws.Request, output *GetLogEventsOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) GetLogEventsRequest(input *GetLogEventsInput) (req *request.Request, output *GetLogEventsOutput) { + op := &request.Operation{ Name: opGetLogEvents, HTTPMethod: "POST", HTTPPath: "/", - Paginator: &aws.Paginator{ + Paginator: &request.Paginator{ InputTokens: []string{"nextToken"}, OutputTokens: []string{"nextForwardToken"}, LimitToken: "limit", @@ -542,8 +674,8 @@ func (c *CloudWatchLogs) GetLogEventsPages(input *GetLogEventsInput, fn func(p * const opPutDestination = "PutDestination" // PutDestinationRequest generates a request for the PutDestination operation. -func (c *CloudWatchLogs) PutDestinationRequest(input *PutDestinationInput) (req *aws.Request, output *PutDestinationOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) PutDestinationRequest(input *PutDestinationInput) (req *request.Request, output *PutDestinationOutput) { + op := &request.Operation{ Name: opPutDestination, HTTPMethod: "POST", HTTPPath: "/", @@ -579,8 +711,8 @@ func (c *CloudWatchLogs) PutDestination(input *PutDestinationInput) (*PutDestina const opPutDestinationPolicy = "PutDestinationPolicy" // PutDestinationPolicyRequest generates a request for the PutDestinationPolicy operation. -func (c *CloudWatchLogs) PutDestinationPolicyRequest(input *PutDestinationPolicyInput) (req *aws.Request, output *PutDestinationPolicyOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) PutDestinationPolicyRequest(input *PutDestinationPolicyInput) (req *request.Request, output *PutDestinationPolicyOutput) { + op := &request.Operation{ Name: opPutDestinationPolicy, HTTPMethod: "POST", HTTPPath: "/", @@ -609,8 +741,8 @@ func (c *CloudWatchLogs) PutDestinationPolicy(input *PutDestinationPolicyInput) const opPutLogEvents = "PutLogEvents" // PutLogEventsRequest generates a request for the PutLogEvents operation. -func (c *CloudWatchLogs) PutLogEventsRequest(input *PutLogEventsInput) (req *aws.Request, output *PutLogEventsOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) PutLogEventsRequest(input *PutLogEventsInput) (req *request.Request, output *PutLogEventsOutput) { + op := &request.Operation{ Name: opPutLogEvents, HTTPMethod: "POST", HTTPPath: "/", @@ -648,8 +780,8 @@ func (c *CloudWatchLogs) PutLogEvents(input *PutLogEventsInput) (*PutLogEventsOu const opPutMetricFilter = "PutMetricFilter" // PutMetricFilterRequest generates a request for the PutMetricFilter operation. -func (c *CloudWatchLogs) PutMetricFilterRequest(input *PutMetricFilterInput) (req *aws.Request, output *PutMetricFilterOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) PutMetricFilterRequest(input *PutMetricFilterInput) (req *request.Request, output *PutMetricFilterOutput) { + op := &request.Operation{ Name: opPutMetricFilter, HTTPMethod: "POST", HTTPPath: "/", @@ -680,8 +812,8 @@ func (c *CloudWatchLogs) PutMetricFilter(input *PutMetricFilterInput) (*PutMetri const opPutRetentionPolicy = "PutRetentionPolicy" // PutRetentionPolicyRequest generates a request for the PutRetentionPolicy operation. -func (c *CloudWatchLogs) PutRetentionPolicyRequest(input *PutRetentionPolicyInput) (req *aws.Request, output *PutRetentionPolicyOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) PutRetentionPolicyRequest(input *PutRetentionPolicyInput) (req *request.Request, output *PutRetentionPolicyOutput) { + op := &request.Operation{ Name: opPutRetentionPolicy, HTTPMethod: "POST", HTTPPath: "/", @@ -709,8 +841,8 @@ func (c *CloudWatchLogs) PutRetentionPolicy(input *PutRetentionPolicyInput) (*Pu const opPutSubscriptionFilter = "PutSubscriptionFilter" // PutSubscriptionFilterRequest generates a request for the PutSubscriptionFilter operation. -func (c *CloudWatchLogs) PutSubscriptionFilterRequest(input *PutSubscriptionFilterInput) (req *aws.Request, output *PutSubscriptionFilterOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) PutSubscriptionFilterRequest(input *PutSubscriptionFilterInput) (req *request.Request, output *PutSubscriptionFilterOutput) { + op := &request.Operation{ Name: opPutSubscriptionFilter, HTTPMethod: "POST", HTTPPath: "/", @@ -745,8 +877,8 @@ func (c *CloudWatchLogs) PutSubscriptionFilter(input *PutSubscriptionFilterInput const opTestMetricFilter = "TestMetricFilter" // TestMetricFilterRequest generates a request for the TestMetricFilter operation. -func (c *CloudWatchLogs) TestMetricFilterRequest(input *TestMetricFilterInput) (req *aws.Request, output *TestMetricFilterOutput) { - op := &aws.Operation{ +func (c *CloudWatchLogs) TestMetricFilterRequest(input *TestMetricFilterInput) (req *request.Request, output *TestMetricFilterOutput) { + op := &request.Operation{ Name: opTestMetricFilter, HTTPMethod: "POST", HTTPPath: "/", @@ -771,9 +903,113 @@ func (c *CloudWatchLogs) TestMetricFilter(input *TestMetricFilterInput) (*TestMe return out, err } +type CancelExportTaskInput struct { + // Id of the export task to cancel. + TaskId *string `locationName:"taskId" min:"1" type:"string" required:"true"` + + metadataCancelExportTaskInput `json:"-" xml:"-"` +} + +type metadataCancelExportTaskInput struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s CancelExportTaskInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CancelExportTaskInput) GoString() string { + return s.String() +} + +type CancelExportTaskOutput struct { + metadataCancelExportTaskOutput `json:"-" xml:"-"` +} + +type metadataCancelExportTaskOutput struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s CancelExportTaskOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CancelExportTaskOutput) GoString() string { + return s.String() +} + +type CreateExportTaskInput struct { + // Name of Amazon S3 bucket to which the log data will be exported. NOTE: Only + // buckets in the same AWS region are supported + Destination *string `locationName:"destination" min:"1" type:"string" required:"true"` + + // Prefix that will be used as the start of Amazon S3 key for every object exported. + // If not specified, this defaults to 'exportedlogs'. + DestinationPrefix *string `locationName:"destinationPrefix" type:"string"` + + // A unix timestamp indicating the start time of the range for the request. + // Events with a timestamp prior to this time will not be exported. + From *int64 `locationName:"from" type:"long" required:"true"` + + // The name of the log group to export. + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` + + // Will only export log streams that match the provided logStreamNamePrefix. + // If you don't specify a value, no prefix filter is applied. + LogStreamNamePrefix *string `locationName:"logStreamNamePrefix" min:"1" type:"string"` + + // The name of the export task. + TaskName *string `locationName:"taskName" min:"1" type:"string"` + + // A unix timestamp indicating the end time of the range for the request. Events + // with a timestamp later than this time will not be exported. + To *int64 `locationName:"to" type:"long" required:"true"` + + metadataCreateExportTaskInput `json:"-" xml:"-"` +} + +type metadataCreateExportTaskInput struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s CreateExportTaskInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateExportTaskInput) GoString() string { + return s.String() +} + +type CreateExportTaskOutput struct { + // Id of the export task that got created. + TaskId *string `locationName:"taskId" min:"1" type:"string"` + + metadataCreateExportTaskOutput `json:"-" xml:"-"` +} + +type metadataCreateExportTaskOutput struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s CreateExportTaskOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateExportTaskOutput) GoString() string { + return s.String() +} + type CreateLogGroupInput struct { // The name of the log group to create. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` metadataCreateLogGroupInput `json:"-" xml:"-"` } @@ -812,10 +1048,10 @@ func (s CreateLogGroupOutput) GoString() string { type CreateLogStreamInput struct { // The name of the log group under which the log stream is to be created. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // The name of the log stream to create. - LogStreamName *string `locationName:"logStreamName" type:"string" required:"true"` + LogStreamName *string `locationName:"logStreamName" min:"1" type:"string" required:"true"` metadataCreateLogStreamInput `json:"-" xml:"-"` } @@ -854,7 +1090,7 @@ func (s CreateLogStreamOutput) GoString() string { type DeleteDestinationInput struct { // The name of destination to delete. - DestinationName *string `locationName:"destinationName" type:"string" required:"true"` + DestinationName *string `locationName:"destinationName" min:"1" type:"string" required:"true"` metadataDeleteDestinationInput `json:"-" xml:"-"` } @@ -893,7 +1129,7 @@ func (s DeleteDestinationOutput) GoString() string { type DeleteLogGroupInput struct { // The name of the log group to delete. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` metadataDeleteLogGroupInput `json:"-" xml:"-"` } @@ -932,10 +1168,10 @@ func (s DeleteLogGroupOutput) GoString() string { type DeleteLogStreamInput struct { // The name of the log group under which the log stream to delete belongs. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // The name of the log stream to delete. - LogStreamName *string `locationName:"logStreamName" type:"string" required:"true"` + LogStreamName *string `locationName:"logStreamName" min:"1" type:"string" required:"true"` metadataDeleteLogStreamInput `json:"-" xml:"-"` } @@ -974,10 +1210,10 @@ func (s DeleteLogStreamOutput) GoString() string { type DeleteMetricFilterInput struct { // The name of the metric filter to delete. - FilterName *string `locationName:"filterName" type:"string" required:"true"` + FilterName *string `locationName:"filterName" min:"1" type:"string" required:"true"` // The name of the log group that is associated with the metric filter to delete. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` metadataDeleteMetricFilterInput `json:"-" xml:"-"` } @@ -1017,7 +1253,7 @@ func (s DeleteMetricFilterOutput) GoString() string { type DeleteRetentionPolicyInput struct { // The name of the log group that is associated with the retention policy to // delete. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` metadataDeleteRetentionPolicyInput `json:"-" xml:"-"` } @@ -1056,11 +1292,11 @@ func (s DeleteRetentionPolicyOutput) GoString() string { type DeleteSubscriptionFilterInput struct { // The name of the subscription filter to delete. - FilterName *string `locationName:"filterName" type:"string" required:"true"` + FilterName *string `locationName:"filterName" min:"1" type:"string" required:"true"` // The name of the log group that is associated with the subscription filter // to delete. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` metadataDeleteSubscriptionFilterInput `json:"-" xml:"-"` } @@ -1100,15 +1336,15 @@ func (s DeleteSubscriptionFilterOutput) GoString() string { type DescribeDestinationsInput struct { // Will only return destinations that match the provided destinationNamePrefix. // If you don't specify a value, no prefix is applied. - DestinationNamePrefix *string `type:"string"` + DestinationNamePrefix *string `min:"1" type:"string"` // The maximum number of results to return. - Limit *int64 `locationName:"limit" type:"integer"` + Limit *int64 `locationName:"limit" min:"1" type:"integer"` // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` metadataDescribeDestinationsInput `json:"-" xml:"-"` } @@ -1133,7 +1369,7 @@ type DescribeDestinationsOutput struct { // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` metadataDescribeDestinationsOutput `json:"-" xml:"-"` } @@ -1152,19 +1388,80 @@ func (s DescribeDestinationsOutput) GoString() string { return s.String() } +type DescribeExportTasksInput struct { + // The maximum number of items returned in the response. If you don't specify + // a value, the request would return up to 50 items. + Limit *int64 `locationName:"limit" min:"1" type:"integer"` + + // A string token used for pagination that points to the next page of results. + // It must be a value obtained from the response of the previous DescribeExportTasks + // request. + NextToken *string `locationName:"nextToken" min:"1" type:"string"` + + // All export tasks that matches the specified status code will be returned. + // This can return zero or more export tasks. + StatusCode *string `locationName:"statusCode" type:"string" enum:"ExportTaskStatusCode"` + + // Export task that matches the specified task Id will be returned. This can + // result in zero or one export task. + TaskId *string `locationName:"taskId" min:"1" type:"string"` + + metadataDescribeExportTasksInput `json:"-" xml:"-"` +} + +type metadataDescribeExportTasksInput struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s DescribeExportTasksInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeExportTasksInput) GoString() string { + return s.String() +} + +type DescribeExportTasksOutput struct { + // A list of export tasks. + ExportTasks []*ExportTask `locationName:"exportTasks" type:"list"` + + // A string token used for pagination that points to the next page of results. + // It must be a value obtained from the response of the previous request. The + // token expires after 24 hours. + NextToken *string `locationName:"nextToken" min:"1" type:"string"` + + metadataDescribeExportTasksOutput `json:"-" xml:"-"` +} + +type metadataDescribeExportTasksOutput struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s DescribeExportTasksOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeExportTasksOutput) GoString() string { + return s.String() +} + type DescribeLogGroupsInput struct { // The maximum number of items returned in the response. If you don't specify // a value, the request would return up to 50 items. - Limit *int64 `locationName:"limit" type:"integer"` + Limit *int64 `locationName:"limit" min:"1" type:"integer"` // Will only return log groups that match the provided logGroupNamePrefix. If // you don't specify a value, no prefix filter is applied. - LogGroupNamePrefix *string `locationName:"logGroupNamePrefix" type:"string"` + LogGroupNamePrefix *string `locationName:"logGroupNamePrefix" min:"1" type:"string"` // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous DescribeLogGroups // request. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` metadataDescribeLogGroupsInput `json:"-" xml:"-"` } @@ -1190,7 +1487,7 @@ type DescribeLogGroupsOutput struct { // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` metadataDescribeLogGroupsOutput `json:"-" xml:"-"` } @@ -1216,19 +1513,19 @@ type DescribeLogStreamsInput struct { // The maximum number of items returned in the response. If you don't specify // a value, the request would return up to 50 items. - Limit *int64 `locationName:"limit" type:"integer"` + Limit *int64 `locationName:"limit" min:"1" type:"integer"` // The log group name for which log streams are to be listed. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // Will only return log streams that match the provided logStreamNamePrefix. // If you don't specify a value, no prefix filter is applied. - LogStreamNamePrefix *string `locationName:"logStreamNamePrefix" type:"string"` + LogStreamNamePrefix *string `locationName:"logStreamNamePrefix" min:"1" type:"string"` // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous DescribeLogStreams // request. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` // Specifies what to order the returned log streams by. Valid arguments are // 'LogStreamName' or 'LastEventTime'. If you don't specify a value, results @@ -1260,7 +1557,7 @@ type DescribeLogStreamsOutput struct { // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` metadataDescribeLogStreamsOutput `json:"-" xml:"-"` } @@ -1282,19 +1579,19 @@ func (s DescribeLogStreamsOutput) GoString() string { type DescribeMetricFiltersInput struct { // Will only return metric filters that match the provided filterNamePrefix. // If you don't specify a value, no prefix filter is applied. - FilterNamePrefix *string `locationName:"filterNamePrefix" type:"string"` + FilterNamePrefix *string `locationName:"filterNamePrefix" min:"1" type:"string"` // The maximum number of items returned in the response. If you don't specify // a value, the request would return up to 50 items. - Limit *int64 `locationName:"limit" type:"integer"` + Limit *int64 `locationName:"limit" min:"1" type:"integer"` // The log group name for which metric filters are to be listed. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous DescribeMetricFilters // request. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` metadataDescribeMetricFiltersInput `json:"-" xml:"-"` } @@ -1319,7 +1616,7 @@ type DescribeMetricFiltersOutput struct { // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` metadataDescribeMetricFiltersOutput `json:"-" xml:"-"` } @@ -1341,18 +1638,18 @@ func (s DescribeMetricFiltersOutput) GoString() string { type DescribeSubscriptionFiltersInput struct { // Will only return subscription filters that match the provided filterNamePrefix. // If you don't specify a value, no prefix filter is applied. - FilterNamePrefix *string `locationName:"filterNamePrefix" type:"string"` + FilterNamePrefix *string `locationName:"filterNamePrefix" min:"1" type:"string"` // The maximum number of results to return. - Limit *int64 `locationName:"limit" type:"integer"` + Limit *int64 `locationName:"limit" min:"1" type:"integer"` // The log group name for which subscription filters are to be listed. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` metadataDescribeSubscriptionFiltersInput `json:"-" xml:"-"` } @@ -1375,7 +1672,7 @@ type DescribeSubscriptionFiltersOutput struct { // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` SubscriptionFilters []*SubscriptionFilter `locationName:"subscriptionFilters" type:"list"` @@ -1396,20 +1693,28 @@ func (s DescribeSubscriptionFiltersOutput) GoString() string { return s.String() } +// A cross account destination that is the recipient of subscription log events. type Destination struct { - ARN *string `locationName:"arn" type:"string"` + // An IAM policy document that governs which AWS accounts can create subscription + // filters against this destination. + AccessPolicy *string `locationName:"accessPolicy" min:"1" type:"string"` - AccessPolicy *string `locationName:"accessPolicy" type:"string"` + // ARN of this destination. + Arn *string `locationName:"arn" type:"string"` // A point in time expressed as the number of milliseconds since Jan 1, 1970 - // 00:00:00 UTC. + // 00:00:00 UTC specifying when this destination was created. CreationTime *int64 `locationName:"creationTime" type:"long"` - DestinationName *string `locationName:"destinationName" type:"string"` + // Name of the destination. + DestinationName *string `locationName:"destinationName" min:"1" type:"string"` - RoleARN *string `locationName:"roleArn" type:"string"` + // A role for impersonation for delivering log events to the target. + RoleArn *string `locationName:"roleArn" min:"1" type:"string"` - TargetARN *string `locationName:"targetArn" type:"string"` + // ARN of the physical target where the log events will be delivered (eg. ARN + // of a Kinesis stream). + TargetArn *string `locationName:"targetArn" min:"1" type:"string"` metadataDestination `json:"-" xml:"-"` } @@ -1428,6 +1733,104 @@ func (s Destination) GoString() string { return s.String() } +// Represents an export task. +type ExportTask struct { + // Name of Amazon S3 bucket to which the log data was exported. + Destination *string `locationName:"destination" min:"1" type:"string"` + + // Prefix that was used as the start of Amazon S3 key for every object exported. + DestinationPrefix *string `locationName:"destinationPrefix" type:"string"` + + // Execution info about the export task. + ExecutionInfo *ExportTaskExecutionInfo `locationName:"executionInfo" type:"structure"` + + // A unix timestamp indicating the start time of the range for the request. + // Events with a timestamp prior to this time were not exported. + From *int64 `locationName:"from" type:"long"` + + // The name of the log group from which logs data was exported. + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string"` + + // Status of the export task. + Status *ExportTaskStatus `locationName:"status" type:"structure"` + + // Id of the export task. + TaskId *string `locationName:"taskId" min:"1" type:"string"` + + // The name of the export task. + TaskName *string `locationName:"taskName" min:"1" type:"string"` + + // A unix timestamp indicating the end time of the range for the request. Events + // with a timestamp later than this time were not exported. + To *int64 `locationName:"to" type:"long"` + + metadataExportTask `json:"-" xml:"-"` +} + +type metadataExportTask struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s ExportTask) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ExportTask) GoString() string { + return s.String() +} + +// Represents the status of an export task. +type ExportTaskExecutionInfo struct { + // A point in time when the export task got completed. + CompletionTime *int64 `locationName:"completionTime" type:"long"` + + // A point in time when the export task got created. + CreationTime *int64 `locationName:"creationTime" type:"long"` + + metadataExportTaskExecutionInfo `json:"-" xml:"-"` +} + +type metadataExportTaskExecutionInfo struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s ExportTaskExecutionInfo) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ExportTaskExecutionInfo) GoString() string { + return s.String() +} + +// Represents the status of an export task. +type ExportTaskStatus struct { + // Status code of the export task. + Code *string `locationName:"code" type:"string" enum:"ExportTaskStatusCode"` + + // Status message related to the code. + Message *string `locationName:"message" type:"string"` + + metadataExportTaskStatus `json:"-" xml:"-"` +} + +type metadataExportTaskStatus struct { + SDKShapeTraits bool `type:"structure"` +} + +// String returns the string representation +func (s ExportTaskStatus) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ExportTaskStatus) GoString() string { + return s.String() +} + type FilterLogEventsInput struct { // A unix timestamp indicating the end time of the range for the request. If // provided, events with a timestamp later than this time will not be returned. @@ -1445,18 +1848,18 @@ type FilterLogEventsInput struct { // The maximum number of events to return in a page of results. Default is 10,000 // events. - Limit *int64 `locationName:"limit" type:"integer"` + Limit *int64 `locationName:"limit" min:"1" type:"integer"` // The name of the log group to query. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // Optional list of log stream names within the specified log group to search. // Defaults to all the log streams in the log group. - LogStreamNames []*string `locationName:"logStreamNames" type:"list"` + LogStreamNames []*string `locationName:"logStreamNames" min:"1" type:"list"` // A pagination token obtained from a FilterLogEvents response to continue paginating // the FilterLogEvents results. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` // A unix timestamp indicating the start time of the range for the request. // If provided, events with a timestamp prior to this time will not be returned. @@ -1486,7 +1889,7 @@ type FilterLogEventsOutput struct { // A pagination token obtained from a FilterLogEvents response to continue paginating // the FilterLogEvents results. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` // A list of SearchedLogStream objects indicating which log streams have been // searched in this request and whether each has been searched completely or @@ -1513,17 +1916,17 @@ func (s FilterLogEventsOutput) GoString() string { // Represents a matched event from a FilterLogEvents request. type FilteredLogEvent struct { // A unique identifier for this event. - EventID *string `locationName:"eventId" type:"string"` + EventId *string `locationName:"eventId" type:"string"` // A point in time expressed as the number of milliseconds since Jan 1, 1970 // 00:00:00 UTC. IngestionTime *int64 `locationName:"ingestionTime" type:"long"` // The name of the log stream this event belongs to. - LogStreamName *string `locationName:"logStreamName" type:"string"` + LogStreamName *string `locationName:"logStreamName" min:"1" type:"string"` // The data contained in the log event. - Message *string `locationName:"message" type:"string"` + Message *string `locationName:"message" min:"1" type:"string"` // A point in time expressed as the number of milliseconds since Jan 1, 1970 // 00:00:00 UTC. @@ -1554,18 +1957,18 @@ type GetLogEventsInput struct { // The maximum number of log events returned in the response. If you don't specify // a value, the request would return as many log events as can fit in a response // size of 1MB, up to 10,000 log events. - Limit *int64 `locationName:"limit" type:"integer"` + Limit *int64 `locationName:"limit" min:"1" type:"integer"` // The name of the log group to query. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // The name of the log stream to query. - LogStreamName *string `locationName:"logStreamName" type:"string" required:"true"` + LogStreamName *string `locationName:"logStreamName" min:"1" type:"string" required:"true"` // A string token used for pagination that points to the next page of results. // It must be a value obtained from the nextForwardToken or nextBackwardToken // fields in the response of the previous GetLogEvents request. - NextToken *string `locationName:"nextToken" type:"string"` + NextToken *string `locationName:"nextToken" min:"1" type:"string"` // If set to true, the earliest log events would be returned first. The default // is false (the latest log events are returned first). @@ -1598,12 +2001,12 @@ type GetLogEventsOutput struct { // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextBackwardToken *string `locationName:"nextBackwardToken" type:"string"` + NextBackwardToken *string `locationName:"nextBackwardToken" min:"1" type:"string"` // A string token used for pagination that points to the next page of results. // It must be a value obtained from the response of the previous request. The // token expires after 24 hours. - NextForwardToken *string `locationName:"nextForwardToken" type:"string"` + NextForwardToken *string `locationName:"nextForwardToken" min:"1" type:"string"` metadataGetLogEventsOutput `json:"-" xml:"-"` } @@ -1627,7 +2030,7 @@ func (s GetLogEventsOutput) GoString() string { // Logs understands contains two properties: the timestamp of when the event // occurred, and the raw event message. type InputLogEvent struct { - Message *string `locationName:"message" type:"string" required:"true"` + Message *string `locationName:"message" min:"1" type:"string" required:"true"` // A point in time expressed as the number of milliseconds since Jan 1, 1970 // 00:00:00 UTC. @@ -1651,13 +2054,13 @@ func (s InputLogEvent) GoString() string { } type LogGroup struct { - ARN *string `locationName:"arn" type:"string"` + Arn *string `locationName:"arn" type:"string"` // A point in time expressed as the number of milliseconds since Jan 1, 1970 // 00:00:00 UTC. CreationTime *int64 `locationName:"creationTime" type:"long"` - LogGroupName *string `locationName:"logGroupName" type:"string"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string"` // The number of metric filters associated with the log group. MetricFilterCount *int64 `locationName:"metricFilterCount" type:"integer"` @@ -1688,7 +2091,7 @@ func (s LogGroup) GoString() string { // A log stream is sequence of log events from a single emitter of logs. type LogStream struct { - ARN *string `locationName:"arn" type:"string"` + Arn *string `locationName:"arn" type:"string"` // A point in time expressed as the number of milliseconds since Jan 1, 1970 // 00:00:00 UTC. @@ -1706,14 +2109,14 @@ type LogStream struct { // 00:00:00 UTC. LastIngestionTime *int64 `locationName:"lastIngestionTime" type:"long"` - LogStreamName *string `locationName:"logStreamName" type:"string"` + LogStreamName *string `locationName:"logStreamName" min:"1" type:"string"` StoredBytes *int64 `locationName:"storedBytes" type:"long"` // A string token used for making PutLogEvents requests. A sequenceToken can // only be used once, and PutLogEvents requests must include the sequenceToken // obtained from the response of the previous request. - UploadSequenceToken *string `locationName:"uploadSequenceToken" type:"string"` + UploadSequenceToken *string `locationName:"uploadSequenceToken" min:"1" type:"string"` metadataLogStream `json:"-" xml:"-"` } @@ -1741,7 +2144,7 @@ type MetricFilter struct { CreationTime *int64 `locationName:"creationTime" type:"long"` // A name for a metric or subscription filter. - FilterName *string `locationName:"filterName" type:"string"` + FilterName *string `locationName:"filterName" min:"1" type:"string"` // A symbolic description of how Amazon CloudWatch Logs should interpret the // data in each log event. For example, a log event may contain timestamps, @@ -1749,7 +2152,7 @@ type MetricFilter struct { // to look for in the log event message. FilterPattern *string `locationName:"filterPattern" type:"string"` - MetricTransformations []*MetricTransformation `locationName:"metricTransformations" type:"list"` + MetricTransformations []*MetricTransformation `locationName:"metricTransformations" min:"1" type:"list"` metadataMetricFilter `json:"-" xml:"-"` } @@ -1769,7 +2172,7 @@ func (s MetricFilter) GoString() string { } type MetricFilterMatchRecord struct { - EventMessage *string `locationName:"eventMessage" type:"string"` + EventMessage *string `locationName:"eventMessage" min:"1" type:"string"` EventNumber *int64 `locationName:"eventNumber" type:"long"` @@ -1828,7 +2231,7 @@ type OutputLogEvent struct { // 00:00:00 UTC. IngestionTime *int64 `locationName:"ingestionTime" type:"long"` - Message *string `locationName:"message" type:"string"` + Message *string `locationName:"message" min:"1" type:"string"` // A point in time expressed as the number of milliseconds since Jan 1, 1970 // 00:00:00 UTC. @@ -1853,14 +2256,14 @@ func (s OutputLogEvent) GoString() string { type PutDestinationInput struct { // A name for the destination. - DestinationName *string `locationName:"destinationName" type:"string" required:"true"` + DestinationName *string `locationName:"destinationName" min:"1" type:"string" required:"true"` // The ARN of an IAM role that grants Amazon CloudWatch Logs permissions to // do Amazon Kinesis PutRecord requests on the desitnation stream. - RoleARN *string `locationName:"roleArn" type:"string" required:"true"` + RoleArn *string `locationName:"roleArn" min:"1" type:"string" required:"true"` // The ARN of an Amazon Kinesis stream to deliver matching log events to. - TargetARN *string `locationName:"targetArn" type:"string" required:"true"` + TargetArn *string `locationName:"targetArn" min:"1" type:"string" required:"true"` metadataPutDestinationInput `json:"-" xml:"-"` } @@ -1880,6 +2283,7 @@ func (s PutDestinationInput) GoString() string { } type PutDestinationOutput struct { + // A cross account destination that is the recipient of subscription log events. Destination *Destination `locationName:"destination" type:"structure"` metadataPutDestinationOutput `json:"-" xml:"-"` @@ -1902,10 +2306,10 @@ func (s PutDestinationOutput) GoString() string { type PutDestinationPolicyInput struct { // An IAM policy document that authorizes cross-account users to deliver their // log events to associated destination. - AccessPolicy *string `locationName:"accessPolicy" type:"string" required:"true"` + AccessPolicy *string `locationName:"accessPolicy" min:"1" type:"string" required:"true"` // A name for an existing destination. - DestinationName *string `locationName:"destinationName" type:"string" required:"true"` + DestinationName *string `locationName:"destinationName" min:"1" type:"string" required:"true"` metadataPutDestinationPolicyInput `json:"-" xml:"-"` } @@ -1944,17 +2348,17 @@ func (s PutDestinationPolicyOutput) GoString() string { type PutLogEventsInput struct { // A list of log events belonging to a log stream. - LogEvents []*InputLogEvent `locationName:"logEvents" type:"list" required:"true"` + LogEvents []*InputLogEvent `locationName:"logEvents" min:"1" type:"list" required:"true"` // The name of the log group to put log events to. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // The name of the log stream to put log events to. - LogStreamName *string `locationName:"logStreamName" type:"string" required:"true"` + LogStreamName *string `locationName:"logStreamName" min:"1" type:"string" required:"true"` // A string token that must be obtained from the response of the previous PutLogEvents // request. - SequenceToken *string `locationName:"sequenceToken" type:"string"` + SequenceToken *string `locationName:"sequenceToken" min:"1" type:"string"` metadataPutLogEventsInput `json:"-" xml:"-"` } @@ -1977,7 +2381,7 @@ type PutLogEventsOutput struct { // A string token used for making PutLogEvents requests. A sequenceToken can // only be used once, and PutLogEvents requests must include the sequenceToken // obtained from the response of the previous request. - NextSequenceToken *string `locationName:"nextSequenceToken" type:"string"` + NextSequenceToken *string `locationName:"nextSequenceToken" min:"1" type:"string"` RejectedLogEventsInfo *RejectedLogEventsInfo `locationName:"rejectedLogEventsInfo" type:"structure"` @@ -2000,17 +2404,17 @@ func (s PutLogEventsOutput) GoString() string { type PutMetricFilterInput struct { // A name for the metric filter. - FilterName *string `locationName:"filterName" type:"string" required:"true"` + FilterName *string `locationName:"filterName" min:"1" type:"string" required:"true"` // A valid CloudWatch Logs filter pattern for extracting metric data out of // ingested log events. FilterPattern *string `locationName:"filterPattern" type:"string" required:"true"` // The name of the log group to associate the metric filter with. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // A collection of information needed to define how metric data gets emitted. - MetricTransformations []*MetricTransformation `locationName:"metricTransformations" type:"list" required:"true"` + MetricTransformations []*MetricTransformation `locationName:"metricTransformations" min:"1" type:"list" required:"true"` metadataPutMetricFilterInput `json:"-" xml:"-"` } @@ -2049,7 +2453,7 @@ func (s PutMetricFilterOutput) GoString() string { type PutRetentionPolicyInput struct { // The name of the log group to associate the retention policy with. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // Specifies the number of days you want to retain log events in the specified // log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, @@ -2097,23 +2501,23 @@ type PutSubscriptionFilterInput struct { // same account as the subscription filter, for same-account delivery. A logical // destination (used via an ARN of Destination) belonging to a different account, // for cross-account delivery. - DestinationARN *string `locationName:"destinationArn" type:"string" required:"true"` + DestinationArn *string `locationName:"destinationArn" min:"1" type:"string" required:"true"` // A name for the subscription filter. - FilterName *string `locationName:"filterName" type:"string" required:"true"` + FilterName *string `locationName:"filterName" min:"1" type:"string" required:"true"` // A valid CloudWatch Logs filter pattern for subscribing to a filtered stream // of log events. FilterPattern *string `locationName:"filterPattern" type:"string" required:"true"` // The name of the log group to associate the subscription filter with. - LogGroupName *string `locationName:"logGroupName" type:"string" required:"true"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string" required:"true"` // The ARN of an IAM role that grants Amazon CloudWatch Logs permissions to // deliver ingested log events to the destination stream. You don't need to // provide the ARN when you are working with a logical destination (used via // an ARN of Destination) for cross-account delivery. - RoleARN *string `locationName:"roleArn" type:"string"` + RoleArn *string `locationName:"roleArn" min:"1" type:"string"` metadataPutSubscriptionFilterInput `json:"-" xml:"-"` } @@ -2178,7 +2582,7 @@ func (s RejectedLogEventsInfo) GoString() string { // request. type SearchedLogStream struct { // The name of the log stream. - LogStreamName *string `locationName:"logStreamName" type:"string"` + LogStreamName *string `locationName:"logStreamName" min:"1" type:"string"` // Indicates whether all the events in this log stream were searched or more // data exists to search by paginating further. @@ -2206,10 +2610,10 @@ type SubscriptionFilter struct { // 00:00:00 UTC. CreationTime *int64 `locationName:"creationTime" type:"long"` - DestinationARN *string `locationName:"destinationArn" type:"string"` + DestinationArn *string `locationName:"destinationArn" min:"1" type:"string"` // A name for a metric or subscription filter. - FilterName *string `locationName:"filterName" type:"string"` + FilterName *string `locationName:"filterName" min:"1" type:"string"` // A symbolic description of how Amazon CloudWatch Logs should interpret the // data in each log event. For example, a log event may contain timestamps, @@ -2217,9 +2621,9 @@ type SubscriptionFilter struct { // to look for in the log event message. FilterPattern *string `locationName:"filterPattern" type:"string"` - LogGroupName *string `locationName:"logGroupName" type:"string"` + LogGroupName *string `locationName:"logGroupName" min:"1" type:"string"` - RoleARN *string `locationName:"roleArn" type:"string"` + RoleArn *string `locationName:"roleArn" min:"1" type:"string"` metadataSubscriptionFilter `json:"-" xml:"-"` } @@ -2246,7 +2650,7 @@ type TestMetricFilterInput struct { FilterPattern *string `locationName:"filterPattern" type:"string" required:"true"` // A list of log event messages to test. - LogEventMessages []*string `locationName:"logEventMessages" type:"list" required:"true"` + LogEventMessages []*string `locationName:"logEventMessages" min:"1" type:"list" required:"true"` metadataTestMetricFilterInput `json:"-" xml:"-"` } @@ -2285,6 +2689,21 @@ func (s TestMetricFilterOutput) GoString() string { return s.String() } +const ( + // @enum ExportTaskStatusCode + ExportTaskStatusCodeCancelled = "CANCELLED" + // @enum ExportTaskStatusCode + ExportTaskStatusCodeCompleted = "COMPLETED" + // @enum ExportTaskStatusCode + ExportTaskStatusCodeFailed = "FAILED" + // @enum ExportTaskStatusCode + ExportTaskStatusCodePending = "PENDING" + // @enum ExportTaskStatusCode + ExportTaskStatusCodePendingCancel = "PENDING_CANCEL" + // @enum ExportTaskStatusCode + ExportTaskStatusCodeRunning = "RUNNING" +) + const ( // @enum OrderBy OrderByLogStreamName = "LogStreamName" diff --git a/vendor/src/github.com/aws/aws-sdk-go/service/cloudwatchlogs/service.go b/vendor/src/github.com/aws/aws-sdk-go/service/cloudwatchlogs/service.go index ef86db0d1b..a9dcc590fd 100644 --- a/vendor/src/github.com/aws/aws-sdk-go/service/cloudwatchlogs/service.go +++ b/vendor/src/github.com/aws/aws-sdk-go/service/cloudwatchlogs/service.go @@ -4,6 +4,10 @@ package cloudwatchlogs import ( "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/defaults" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/aws/service" + "github.com/aws/aws-sdk-go/aws/service/serviceinfo" "github.com/aws/aws-sdk-go/internal/protocol/jsonrpc" "github.com/aws/aws-sdk-go/internal/signer/v4" ) @@ -41,23 +45,25 @@ import ( // AWS Ruby Developer Center (http://aws.amazon.com/ruby/) AWS Windows and .NET // Developer Center (http://aws.amazon.com/net/) type CloudWatchLogs struct { - *aws.Service + *service.Service } // Used for custom service initialization logic -var initService func(*aws.Service) +var initService func(*service.Service) // Used for custom request initialization logic -var initRequest func(*aws.Request) +var initRequest func(*request.Request) // New returns a new CloudWatchLogs client. func New(config *aws.Config) *CloudWatchLogs { - service := &aws.Service{ - Config: aws.DefaultConfig.Merge(config), - ServiceName: "logs", - APIVersion: "2014-03-28", - JSONVersion: "1.1", - TargetPrefix: "Logs_20140328", + service := &service.Service{ + ServiceInfo: serviceinfo.ServiceInfo{ + Config: defaults.DefaultConfig.Merge(config), + ServiceName: "logs", + APIVersion: "2014-03-28", + JSONVersion: "1.1", + TargetPrefix: "Logs_20140328", + }, } service.Initialize() @@ -78,8 +84,8 @@ func New(config *aws.Config) *CloudWatchLogs { // newRequest creates a new request for a CloudWatchLogs operation and runs any // custom request initialization. -func (c *CloudWatchLogs) newRequest(op *aws.Operation, params, data interface{}) *aws.Request { - req := aws.NewRequest(c.Service, op, params, data) +func (c *CloudWatchLogs) newRequest(op *request.Operation, params, data interface{}) *request.Request { + req := c.NewRequest(op, params, data) // Run custom request initialization if present if initRequest != nil {