lib/fastly.rb in fastly-1.4.3 vs lib/fastly.rb in fastly-1.5.0
- old
+ new
@@ -12,10 +12,11 @@
require 'fastly/backend'
require 'fastly/cache_setting'
require 'fastly/condition'
require 'fastly/customer'
require 'fastly/dictionary'
+require 'fastly/dictionary_item'
require 'fastly/director'
require 'fastly/domain'
require 'fastly/header'
require 'fastly/healthcheck'
require 'fastly/gzip'
@@ -44,10 +45,14 @@
#
# You only need to pass in C<api_key> OR C<user> and C<password>.
#
# Some methods require full username and password rather than just auth token.
def initialize(opts)
+ if opts[:api_key].nil? && (opts[:password].nil? || opts[:user].nil?)
+ raise ArgumentError, "Required options missing. Please pass either ':api_key' or both ':user' and ':password'."
+ end
+
client(opts)
self
end
# Whether or not we're authed at all by either username & password or API key
@@ -136,11 +141,11 @@
# 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, Dictionary, Director, Domain, Header, Healthcheck, Gzip, Match, Origin, RequestSetting, ResponseObject, Service, S3Logging, Syslog, VCL, Version].each do |klass|
+ [User, Customer, Backend, CacheSetting, Condition, Dictionary, DictionaryItem, 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
@@ -181,10 +186,14 @@
##
# :method: create_dictionary(opts)
# opts must contain service_id, version and name params
##
+ # :method: create_dictionary_item(opts)
+ # opts must contain service_id, dictionary_id, item_key and item_value params
+
+ ##
# :method: create_director(opts)
# opts must contain service_id, version and name params
##
# :method: create_domain(opts)
@@ -261,10 +270,14 @@
##
# :method: get_dictionary(service_id, number, name)
# Get a single dictionary
##
+ # :method: get_dictionary_item(service_id, dictionary_id, name)
+ # Get a single dictionary item
+
+ ##
# :method: get_director(service_id, number, name)
# Get a Director
##
# :method: get_domain(service_id, number, name)
@@ -355,10 +368,15 @@
# :method: update_dictionary(dictionary)
# You can also call
# dictionary.save!
##
+ # :method: update_dictionary_item(dictionary_item)
+ # You can also call
+ # dictionary_item.save!
+
+ ##
# :method: update_director(director)
# You can also call
# director.save!
##
@@ -465,10 +483,15 @@
# :method: delete_dictionary(dictionary)
# You can also call
# dictionary.delete!
##
+ # :method: delete_dictionary_item(dictionary_item)
+ # You can also call
+ # dictionary_item.delete!
+
+ ##
# :method: delete_director(backend)
# You can also call
# backend.delete!
##
@@ -566,9 +589,13 @@
# Get a list of all directors
# :method: list_dictionaries(:service_id => service.id, :version => version.number)
#
# Get a list of all dictionaries
+
+ # :method: list_dictionary_items(:service_id => service.id, :dictionary_id => dictionary.name)
+ #
+ # Get a list of all items belonging to a dictionary
# :method: list_domains(:service_id => service.id, :version => version.number)
#
# Get a list of all domains