github.com/aavshr/aws-sdk-go@v1.41.3/service/s3control/validate.go (about) 1 package s3control 2 3 import ( 4 "fmt" 5 6 "github.com/aavshr/aws-sdk-go/aws/request" 7 "github.com/aavshr/aws-sdk-go/internal/s3shared" 8 ) 9 10 // updateAccountIDWithARNHandler is a request named handler that is used to validate and populate the request account id 11 // input if it may also be present in the resource ARN. 12 var updateAccountIDWithARNHandler = request.NamedHandler{ 13 Name: "updateAccountIDWithARNHandler", 14 Fn: func(req *request.Request) { 15 endpoint, ok := req.Params.(endpointARNGetter) 16 if !ok || !endpoint.hasEndpointARN() { 17 return 18 } 19 20 // fetch endpoint arn resource 21 resource, err := endpoint.getEndpointARN() 22 if err != nil { 23 req.Error = fmt.Errorf("error while fetching endpoint ARN: %v", err) 24 return 25 } 26 27 // Validate that the present account id in a request input matches the account id 28 // present in an ARN. If a value for request input account id member is not provided, 29 // the accountID member is populated using the account id present in the ARN 30 // and a pointer to copy of updatedInput is returned. 31 if accountIDValidator, ok := req.Params.(accountIDValidator); ok { 32 accID := resource.GetARN().AccountID 33 updatedInput, err := accountIDValidator.updateAccountID(accID) 34 if err != nil { 35 req.Error = s3shared.NewInvalidARNError(resource, err) 36 return 37 } 38 // update request params to use modified account id, if not nil 39 if updatedInput != nil { 40 req.Params = updatedInput 41 } 42 } 43 }, 44 }