lib/fastly.rb in fastly-0.5 vs lib/fastly.rb in fastly-0.9

- old
+ new

@@ -3,26 +3,28 @@ # License:: Distributes under the same terms as Ruby # A client library for interacting with the Fastly web acceleration service class Fastly # The current version of the library - VERSION = "0.5" + VERSION = "0.9" require 'fastly/fetcher' require 'fastly/client' require 'fastly/base' require 'fastly/belongs_to_service_and_version' require 'fastly/backend' require 'fastly/customer' require 'fastly/director' require 'fastly/domain' + require 'fastly/healthcheck' require 'fastly/invoice' require 'fastly/match' require 'fastly/origin' require 'fastly/service' require 'fastly/settings' + require 'fastly/syslog' require 'fastly/user' require 'fastly/vcl' require 'fastly/version' include Fastly::Fetcher @@ -77,16 +79,19 @@ res = client.post("/purge/#{path}") #res = client.post("/purge/", :path => path) end - [User, Customer, Backend, Director, Domain, Match, Origin, Service, VCL, Version].each do |klass| + [User, Customer, Backend, Director, Domain, Healthcheck, Match, Origin, Service, Syslog, VCL, Version].each do |klass| type = klass.to_s.downcase.split("::")[-1] - # self.send :define_method, "list_#{type}s".to_sym do - # list(klass) - # end - + # unless the class doesn't have a list path or it already exists + unless klass.list_path.nil? || klass.respond_to?("list_#{type}s".to_sym) + self.send :define_method, "list_#{type}s".to_sym do |*args| + list(klass, *args) + end + end + self.send :define_method, "get_#{type}".to_sym do |*args| get(klass, *args) end self.send :define_method, "create_#{type}".to_sym do |obj| @@ -123,10 +128,18 @@ # opts must contain service_id, version and name params ## # :method: create_origin(opts) # opts must contain service_id, version and name params + + ## + # :method: create_healthcheck(opts) + # opts must contain service_id, version and name params + + ## + # :method: create_syslog(opts) + # opts must contain service_id, version and name params ## # :method: create_vcl(opts) # opts must contain service_id, version and name params @@ -155,18 +168,26 @@ # Get a Director ## # :method: get_domain(service_id, number, name) # Get a Domain + + ## + # :method: get_healthcheck(service_id, number, name) + # Get a Healthcheck ## # :method: get_match(service_id, number, name) # Get a Match ## # :method: get_origin(service_id, number, name) # Get an Origin + + ## + # :method: get_syslog(service_id, number, name) + # Get a Syslog ## # :method: get_vcl(service_id, number, name) # Get a VCL @@ -210,37 +231,47 @@ ## # :method: update_domain(domain) # You can also call # domain.save! + + ## + # :method: update_healthcheck(healthcheck) + # You can also call + # healthcheck.save! ## # :method: update_match(match) # You can also call # match.save! ## # :method: update_origin(origin) # You can also call # origin.save! + + ## + # :method: update_settings(settings) + # You can also call + # settings.save! ## + # :method: update_syslog(syslog) + # You can also call + # syslog.save! + + ## # :method: update_vcl(vcl) # You can also call # vcl.save! ## # :method: update_version(version) # You can also call # version.save! - ## - # :method: update_settings(settings) - # You can also call - # settings.save! - ## # :method: delete_user(user) # You can also call # user.delete! @@ -276,10 +307,14 @@ ## # :method: delete_domain(domain # You can also call # domain.delete! + ## + # :method: delete_healthcheck(healthcheck) + # You can also call + # healthcheck.delete! ## # :method: delete_match(match) # You can also call # match.delete!(match) @@ -288,20 +323,76 @@ ## # :method: delete_origin(origin) # You can also call # origin.delete! + ## + # :method: delete_syslog(syslog) + # You can also call + # syslog.delete! + ## # :method: delete_vcl(vcl) # You can also call # vcl.delete! - ## # :method: delete_version(version) # You can also call # version.delete! + + # :method: list_users + # + # Get a list of all users + + # :method: list_customers + # + # Get a list of all customers + + # :method: list_versions + # + # Get a list of all versions + + # :method: list_services + # + # Get a list of all services + + # :method: list_backends + # + # Get a list of all backends + + # :method: list_directors + # + # Get a list of all directors + + # :method: list_domains + # + # Get a list of all domains + + # :method: list_healthchecks + # + # Get a list of all healthchecks + + # :method: list_matchs + # + # Get a list of all matches + + # :method: list_origins + # + # Get a list of all origins + + # :method: list_syslogs + # + # Get a list of all syslogs + + # :method: list_vcls + # + # Get a list of all vcls + + # :method: list_versions + # + # Get a list of all versions ## # Attempts to load various config options in the form