lib/fastly.rb in fastly-1.4.1 vs lib/fastly.rb in fastly-1.4.2

- old
+ new

@@ -11,10 +11,11 @@ require 'fastly/belongs_to_service_and_version' require 'fastly/backend' require 'fastly/cache_setting' require 'fastly/condition' require 'fastly/customer' +require 'fastly/dictionary' require 'fastly/director' require 'fastly/domain' require 'fastly/header' require 'fastly/healthcheck' require 'fastly/gzip' @@ -135,16 +136,22 @@ # Fetches the list of codes for regions that are covered by the Fastly CDN service. def regions client.get_stats('/stats/regions') end - [User, Customer, Backend, CacheSetting, Condition, Director, Domain, Header, Healthcheck, Gzip, Match, Origin, RequestSetting, ResponseObject, Service, S3Logging, Syslog, VCL, Version].each do |klass| + [User, Customer, Backend, CacheSetting, Condition, Dictionary, Director, Domain, Header, Healthcheck, Gzip, Match, Origin, RequestSetting, ResponseObject, Service, S3Logging, Syslog, VCL, Version].each do |klass| type = Util.class_to_path(klass) + if klass.respond_to?(:pluralize) + plural = klass.pluralize + else + plural = "#{type}s" + 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) - send :define_method, "list_#{type}s".to_sym do |*args| + unless klass.list_path.nil? || klass.respond_to?("list_#{plural}".to_sym) + send :define_method, "list_#{plural}".to_sym do |*args| list(klass, *args) end end send :define_method, "get_#{type}".to_sym do |*args| @@ -170,15 +177,19 @@ ## # :method: create_backend(opts) # opts must contain service_id, version and name params ## + # :method: create_dictionary(opts) + # opts must contain service_id, version and name params + + ## # :method: create_director(opts) # opts must contain service_id, version and name params ## - # :method: reate_domain(opts) + # :method: create_domain(opts) # opts must contain service_id, version and name params ## # :method: create_match(opts) # opts must contain service_id, version and name params @@ -246,10 +257,14 @@ ## # :method: get_backend(service_id, number, name) # Get a backend ## + # :method: get_dictionary(service_id, number, name) + # Get a single dictionary + + ## # :method: get_director(service_id, number, name) # Get a Director ## # :method: get_domain(service_id, number, name) @@ -335,10 +350,15 @@ # :method: update_backend(backend) # You can also call # backend.save! ## + # :method: update_dictionary(dictionary) + # You can also call + # dictionary.save! + + ## # :method: update_director(director) # You can also call # director.save! ## @@ -440,10 +460,15 @@ # :method:delete_backend(backend) # You can also call # backend.delete! ## + # :method: delete_dictionary(dictionary) + # You can also call + # dictionary.delete! + + ## # :method: delete_director(backend) # You can also call # backend.delete! ## @@ -537,9 +562,13 @@ # Get a list of all backends # :method: list_directors(:service_id => service.id, :version => version.number) # # Get a list of all directors + + # :method: list_dictionaries(:service_id => service.id, :version => version.number) + # + # Get a list of all dictionaries # :method: list_domains(:service_id => service.id, :version => version.number) # # Get a list of all domains