I updated and resent the patches to address feedback and add more test cases. I also renamed the resource type and provider back to 'web' as I thought that better represented the 'web resource' concept that is being implemented here. If ya'll think http_request would be a better name for the resource type and provider, I have no problem renaming it to that for upstream inclusion.
http://groups.google.com/group/puppet-dev/browse_thread/thread/468646ba47fdd4e On May 17, 1:40 am, Luke Kanies <[email protected]> wrote: > Thanks for the patches. > > How do you expect to use this type? Can you provide some example use cases? > No problem, thanks for the feedback. A very simple example of using this would be to query google for example: web{google: get => "http://google.com", follow => true } A more detailed example would be to request the aeolus conductor API (http://aeolusproject.org) Web{ login => { 'http_method' => 'post', 'uri' => 'https://localhost/conductor/ user_session', 'user_session[login]' => "$admin_user", 'user_session[password]' => "$admin_password", 'commit' => 'submit' }, logout => { 'http_method' => 'post', 'uri' => 'https://localhost/conductor/ logout' } } web{"provider-foobar": post => "https://localhost/conductor/admin/providers", parameters => { 'provider[name]' => 'foobar', 'provider[url]' => 'http://localhost:3003/api', 'provider[provider_type_codename]' => 'ec2' }, returns => '200', verify => '.*Provider added.*', follow => true, unless => { 'http_method' => 'get', 'uri' => 'https://localhost/conductor/ admin/providers', 'verify' => '.*foobar.*' } } I elaborate on this example in my blog posting on this subject http://mo.morsi.org/blog/node/336 > I've got a comment below, too. > > On May 16, 2011, at 8:22 PM, Mo Morsi wrote: > > > > > Adds a new resource type to puppet for web requests > > and implements a provider of that type using the > > ruby curl interface provided by the 'curb' rubygem > > > Signed-off-by: Mo Morsi <[email protected]> > > --- > > Local-branch: feature/master/7474 > > lib/puppet/provider/web_request/curl.rb | 128 > > +++++++++++++++++++++++++++++++ > > lib/puppet/type/web_request.rb | 50 ++++++++++++ > > 2 files changed, 178 insertions(+), 0 deletions(-) > > create mode 100644 lib/puppet/provider/web_request/curl.rb > > create mode 100644 lib/puppet/type/web_request.rb > > > diff --git a/lib/puppet/provider/web_request/curl.rb > > b/lib/puppet/provider/web_request/curl.rb > > new file mode 100644 > > index 0000000..479bfd5 > > --- /dev/null > > +++ b/lib/puppet/provider/web_request/curl.rb > > @@ -0,0 +1,128 @@ > > +require 'curb' > > +require 'uuid' > > +require 'fileutils' > > + > > +# Helper to invoke the web request w/ curl > > +def web_request(method, uri, request_params, params = {}) > > These methods should really all be in the provider, rather than at the global > level. > Done. I encapsulated these all in the scopes which I believe they belong. Feel free to send additional comments my way on anything that you think could use improvement. -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
