mwunsch / weary

A framework and DSL for building RESTful web service clients
MIT License
482 stars 23 forks source link

Rambling Thoughts on Weary and Amazon AWS #12

Closed hakanensari closed 12 years ago

hakanensari commented 12 years ago

I was dabbling in this library today to see if I could retrofit my work-in-progress AWS wrapper and ran into some deal breakers. At least that's how they appeared at the end of the day.

  1. AWS is not your typical Rails-y API. It's very verbose. For instance, this operation alone has over 20 parameters.

    It feels quite labourious to have to spell out every single parameter for each resource. On top of that, there's the nightmare of maintenance as Amazon liberally adds and removes parameters in every release.

    My solution was to leave it to the user to specify her parameters at will — kind of like dynamic typing. It seems this is not possible in Weary unless I'm missing something.

  2. AWS parameters are camel-cased, as in AWSAccessKeyId. It feels ugly to specify these names as is.

    Again, my earlier solution was to have underscored Symbol keys converted to camelcased Strings on the fly. I also mapped some long-winded keys, like the one above to shorter method names (eg. :key sets 'AWSAccessKeyId').

    I'm wondering if this would have any application here.

  3. AWS has multiple country endpoints. The APIs work more or less the same way, but the domains are different. Setting the domain as a String when defining the client seems to call for some creative hack to change the domain based on whatever country is specified when initialising the Client. Or the uglier solution is to define a "sub-client" for each country.

    I couldn't figure out the first solution, and the second one just feels ugly.

Just wanted to share the above to see if you have any suggestions or ideas.

BTW, your code is awesomely clean.

adelevie commented 12 years ago

+1 on # 3. I'm working on a wrapper for Pwinty. Pwinty's API has two different domains: one for sandbox mode and another for production. Some way to handle different domains for the same client would be nice. Maybe something like this:

class Client < Weary::Client
  domain :default => "http://api.pwinty.com"
  domain :sandbox => "http://sandbox.api.pwinty.com"
  #...
end

c = Client.new
c.use_domain :sandbox
mwunsch commented 12 years ago

Haha no I'm still keeping an eye on this -- it's just taking me a moment to gather my thoughts for a response. Forthcoming, I promise!