aws/aws-sdk-core-ruby — pull request #94 by stat (2014-08-09 04:52:20+00:00)
Title: Added optional placeholders for uri if placeholder is last

These changes breaks PUT vs POST conventions and allows a service to create and update in the same block without specifying the resource id. The resource id is generated at the service vs the client, but has helped me maintain DRY principles in Sinatra projects.

The following code changes allow for the last uri parameter to be optional across all api paths. Brief example included below...

API
"operations":{
"PutObject":{
"name":"PutObject",
"http":{
"method":"PUT",
"requestUri":"/{Bucket}/{Key+}"
},
"input":{"shape":"Input"},
"output":{"shape":"Output"},
}
...
},
"shapes":{
"PutObjectRequest":{
"type":"structure",
"required":[
"Bucket"
],
"members":{
"Bucket":{
"shape":"BucketName",
"location":"uri",
"locationName":"Bucket"
},
"Key":{
"shape":"ObjectKey",
"location":"uri",
"locationName":"Key"
},
...
}
}
}

Sinatra route:
put %r{((?:/)(?[^&/?#]+)){0,1}/?\z} do
@object = if (uuid = params.delete('uuid'))
Object.find(uuid)
else
Object.new

@object.update_attributes(params)
@object.save
end

The Sinatra code is pretty boilerplate and is used just as an example.