// Build builds the REST component of a service request. func Build(r *aws.Request) { if r.ParamsFilled() { v := reflect.ValueOf(r.Params).Elem() buildLocationElements(r, v) buildBody(r, v) } }
func verifySendMessage(r *aws.Request) { if r.DataFilled() && r.ParamsFilled() { in := r.Params.(*SendMessageInput) out := r.Data.(*SendMessageOutput) err := checksumsMatch(in.MessageBody, out.MD5OfMessageBody) if err != nil { setChecksumError(r, err.Error()) } } }
func populateLocationConstraint(r *aws.Request) { if r.ParamsFilled() && r.Config.Region != "us-east-1" { in := r.Params.(*CreateBucketInput) if in.CreateBucketConfiguration == nil { r.Params = awsutil.CopyOf(r.Params) in = r.Params.(*CreateBucketInput) in.CreateBucketConfiguration = &CreateBucketConfiguration{ LocationConstraint: &r.Config.Region, } } } }
func verifyReceiveMessage(r *aws.Request) { if r.DataFilled() && r.ParamsFilled() { ids := []string{} out := r.Data.(*ReceiveMessageOutput) for _, msg := range out.Messages { err := checksumsMatch(msg.Body, msg.MD5OfBody) if err != nil { ids = append(ids, *msg.MessageID) } } if len(ids) > 0 { setChecksumError(r, "invalid messages: %s", strings.Join(ids, ", ")) } } }
func fillPresignedURL(r *aws.Request) { if !r.ParamsFilled() { return } params := r.Params.(*CopySnapshotInput) // Stop if PresignedURL/DestinationRegion is set if params.PresignedURL != nil || params.DestinationRegion != nil { return } // First generate a copy of parameters r.Params = awsutil.CopyOf(r.Params) params = r.Params.(*CopySnapshotInput) // Set destination region. Avoids infinite handler loop. // Also needed to sign sub-request. params.DestinationRegion = &r.Service.Config.Region // Create a new client pointing at source region. // We will use this to presign the CopySnapshot request against // the source region config := r.Service.Config.Copy() config.Endpoint = "" config.Region = *params.SourceRegion client := New(&config) // Presign a CopySnapshot request with modified params req, _ := client.CopySnapshotRequest(params) url, err := req.Presign(300 * time.Second) // 5 minutes should be enough. if err != nil { // bubble error back up to original request r.Error = err } // We have our URL, set it on params params.PresignedURL = &url }
func verifySendMessageBatch(r *aws.Request) { if r.DataFilled() && r.ParamsFilled() { entries := map[string]*SendMessageBatchResultEntry{} ids := []string{} out := r.Data.(*SendMessageBatchOutput) for _, entry := range out.Successful { entries[*entry.ID] = entry } in := r.Params.(*SendMessageBatchInput) for _, entry := range in.Entries { if e := entries[*entry.ID]; e != nil { err := checksumsMatch(entry.MessageBody, e.MD5OfMessageBody) if err != nil { ids = append(ids, *e.MessageID) } } } if len(ids) > 0 { setChecksumError(r, "invalid messages: %s", strings.Join(ids, ", ")) } } }