diff --git a/cloudflare.gemspec b/cloudflare.gemspec index 50e8799..229409d 100644 --- a/cloudflare.gemspec +++ b/cloudflare.gemspec @@ -3,23 +3,23 @@ $LOAD_PATH.push File.expand_path("../lib", __FILE__) require 'cloudflare/version' Gem::Specification.new do |s| - s.name = 'cloudflare' - s.version = CloudFlare::VERSION - s.platform = Gem::Platform::RUBY + s.name = 'cloudflare' + s.version = CloudFlare::VERSION + s.platform = Gem::Platform::RUBY - s.description = 'A Ruby wrapper for the CloudFlare API.' - s.summary = 'A Ruby wrapper for the CloudFlare API.' - s.authors = ['Marcin Prokop'] - s.email = 'marcin@prokop.co' - s.homepage = 'https://github.com/b4k3r/cloudflare' - s.licenses = ['MIT'] + s.description = 'A Ruby wrapper for the CloudFlare API.' + s.summary = 'A Ruby wrapper for the CloudFlare API.' + s.authors = ['Marcin Prokop'] + s.email = 'marcin@prokop.co' + s.homepage = 'https://github.com/b4k3r/cloudflare' + s.licenses = ['MIT'] - s.files = `git ls-files`.split("\n") - s.test_files = ['test/test_cloudflare.rb'] - s.rdoc_options = ['--main', 'README.md', '--charset=UTF-8'] - s.extra_rdoc_files = ['README.md', 'LICENSE'] + s.files = `git ls-files`.split("\n") + s.test_files = ['test/test_cloudflare.rb'] + s.rdoc_options = ['--main', 'README.md', '--charset=UTF-8'] + s.extra_rdoc_files = ['README.md', 'LICENSE'] - s.required_ruby_version = '>= 1.9.0' - s.add_runtime_dependency 'json', '~> 1' - s.add_development_dependency 'rake' + s.required_ruby_version = '>= 1.9.0' + s.add_runtime_dependency 'json', '~> 1' + s.add_development_dependency 'rake' end diff --git a/lib/cloudflare.rb b/lib/cloudflare.rb index 0c269af..c15e731 100644 --- a/lib/cloudflare.rb +++ b/lib/cloudflare.rb @@ -1,15 +1,15 @@ # Copyright, 2012, by Marcin Prokop. -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -21,7 +21,7 @@ require 'cloudflare/connection' module CloudFlare - def self.connection(api_key, email = nil) - Connection.new(api_key, email) - end + def self.connection(api_key, email = nil) + Connection.new(api_key, email) + end end diff --git a/lib/cloudflare/connection.rb b/lib/cloudflare/connection.rb index 5ab2dc3..9d0f122 100644 --- a/lib/cloudflare/connection.rb +++ b/lib/cloudflare/connection.rb @@ -56,7 +56,6 @@ def initialize(api_key, email = nil) @params[:api_key] = api_key @params[:email] = email end - end # CLIENT @@ -100,6 +99,7 @@ def zone_check(*zones) send_req({a: :zone_check, zones: zones.kind_of?(Array) ? zones.join(',') : zones}) end + # DEPRECATED! # This function pulls recent IPs hitting your site. # # @see http://www.cloudflare.com/docs/client-api.html#s3.5 @@ -110,6 +110,7 @@ def zone_check(*zones) # @param geo [Fixnum] (optional) def zone_ips(zone, classification = nil, hours = 24, geo = 1) + puts 'Warning! This method is deprecated.' send_req({a: :zone_ips, z: zone, hours: hours, "class" => classification, geo: geo}) end @@ -187,19 +188,9 @@ def zone_file_purge(zone, url) send_req({a: :zone_file_purge, z: zone, url: url}) end - # This function updates the snapshot of your site for CloudFlare's challenge page. - # - # @see http://www.cloudflare.com/docs/client-api.html#s4.6 - # - # @param zoneid [Integer] - - def zone_grab(zoneid) - send_req({a: :zone_grab, zid: zoneid}) - end - # This function adds an IP address to your white lists. # - # @see http://www.cloudflare.com/docs/client-api.html#s4.7 + # @see http://www.cloudflare.com/docs/client-api.html#s4.6 # # @param ip [String] @@ -210,7 +201,7 @@ def whitelist(ip) # This function adds an IP address to your black lists. # - # @see http://www.cloudflare.com/docs/client-api.html#s4.7 + # @see http://www.cloudflare.com/docs/client-api.html#s4.6 # # @param ip [String] @@ -220,7 +211,7 @@ def blacklist(ip) # This function removes the IP from whitelist or blacklist. # - # @see http://www.cloudflare.com/docs/client-api.html#s4.7 + # @see http://www.cloudflare.com/docs/client-api.html#s4.6 # # @param ip [String] @@ -230,7 +221,7 @@ def remove_ip(ip) # This function toggles IPv6 support. # - # @see http://www.cloudflare.com/docs/client-api.html#s4.8 + # @see http://www.cloudflare.com/docs/client-api.html#s4.7 # # @param zone [String] # @param value [Boolean] @@ -241,7 +232,7 @@ def ipv46(zone, value) # This function changes Rocket Loader setting. # - # @see http://www.cloudflare.com/docs/client-api.html#s4.9 + # @see http://www.cloudflare.com/docs/client-api.html#s4.8 # # @param zone [String] # @param value [Integer or String] values: 0|a|m @@ -252,7 +243,7 @@ def async(zone, value) # This function changes minification settings. # - # @see http://www.cloudflare.com/docs/client-api.html#s4.10 + # @see http://www.cloudflare.com/docs/client-api.html#s4.9 # # @param zone [String] # @param value [Integer] values: 0|2|3|4|5|6|7 @@ -264,7 +255,7 @@ def minify(zone, value) # This function changes mirage2 settings. # - # @see http://www.cloudflare.com/docs/client-api.html#s4.11 + # @see http://www.cloudflare.com/docs/client-api.html#s4.10 # # @param zone [String] # @param value [Integer] values: 0|1 @@ -289,9 +280,9 @@ def mirage2(zone, value) # @param weight [Intger] (applies to SRV) # @param port [Integer] (applies to SRV) # @param target [String] (applies to SRV) - # @param service_mode [String] + # @param service_mode [Boolean] (applies to A/AAAA/CNAME) - def rec_new(zone, type, name, content, ttl, prio = nil, service = nil, srvname = nil, protocol = nil, weight = nil, port = nil, target = nil, service_mode = '1') + def rec_new(zone, type, name, content, ttl, prio = nil, service = nil, srvname = nil, protocol = nil, weight = nil, port = nil, target = nil, service_mode = true) send_req({ a: :rec_new, z: zone, @@ -306,7 +297,7 @@ def rec_new(zone, type, name, content, ttl, prio = nil, service = nil, srvname = weight: weight, port: port, target: target, - service_mode: service_mode + service_mode: service_mode ? 1 : 0, }) end @@ -320,7 +311,6 @@ def rec_new(zone, type, name, content, ttl, prio = nil, service = nil, srvname = # @param name [String] # @param content [String] # @param ttl [Integer] values: 1|120...4294967295 - # @param service_mode [Boolean] (applies to A/AAAA/CNAME) # @param prio [Integer] (applies to MX/SRV) # @param service [String] (applies to SRV) # @param srvname [String] (applies to SRV) @@ -328,8 +318,9 @@ def rec_new(zone, type, name, content, ttl, prio = nil, service = nil, srvname = # @param weight [Intger] (applies to SRV) # @param port [Integer] (applies to SRV) # @param target [String] (applies to SRV) + # @param service_mode [Boolean] (applies to A/AAAA/CNAME) - def rec_edit(zone, type, record_id, name, content, ttl, service_mode = nil, prio = nil, service = nil, srvname = nil, protocol = nil, weight = nil, port = nil, target = nil) + def rec_edit(zone, type, record_id, name, content, ttl, prio = nil, service = nil, srvname = nil, protocol = nil, weight = nil, port = nil, target = nil, service_mode = true) send_req({ a: :rec_edit, z: zone, @@ -338,14 +329,14 @@ def rec_edit(zone, type, record_id, name, content, ttl, service_mode = nil, prio name: name, content: content, ttl: ttl, - service_mode: service_mode ? 1 : 0, prio: prio, service: service, srvname: srvname, protocol: protocol, weight: weight, port: port, - target: target + target: target, + service_mode: service_mode ? 1 : 0, }) end @@ -402,10 +393,25 @@ def add_zone(user_key, zone, resolve_to, subdomains) }) end - # This function lookups a user's CloudFlare account information. + # This function adds a zone using the full setup. # # @see http://www.cloudflare.com/docs/host-api.html#s3.2.3 # + # @param user_key [String] + # @param zone [String] + + def add_full_zone(user_key, zone) + send_req({ + act: :full_zone_set, + user_key: user_key, + zone_name: zone + }) + end + + # This function lookups a user's CloudFlare account information. + # + # @see http://www.cloudflare.com/docs/host-api.html#s3.2.4 + # # *Example:* # # cf = CloudFlare('your_host_key') @@ -426,7 +432,7 @@ def user_lookup(email, id = false) # This function authorizes access to a user's existing CloudFlare account. # - # @see http://www.cloudflare.com/docs/host-api.html#s3.2.4 + # @see http://www.cloudflare.com/docs/host-api.html#s3.2.5 # # @param email [String] # @param pass [String] @@ -445,7 +451,7 @@ def user_auth(email, pass, id = nil, cui = nil) # This function lookups a specific user's zone. # - # @see http://www.cloudflare.com/docs/host-api.html#s3.2.5 + # @see http://www.cloudflare.com/docs/host-api.html#s3.2.6 # # @param user_key [String] # @param zone [String] @@ -456,7 +462,7 @@ def zone_lookup(user_key, zone) # This function deletes a specific zone on behalf of a user. # - # @see http://www.cloudflare.com/docs/host-api.html#s3.2.6 + # @see http://www.cloudflare.com/docs/host-api.html#s3.2.7 # # @param user_key [String] # @param zone [String] @@ -465,26 +471,6 @@ def del_zone(user_key, zone) send_req({act: :zone_delete, user_key: user_key, zone_name: zone}) end - # This function creates a new child host provider. - # - # @see http://www.cloudflare.com/docs/host-api.html#s3.2.7 - # - # @param host_name [String] - # @param pub_name [String] - # @param prefix [String] - # @param website [String] - # @param email [String] - - def host_child_new(host_name, pub_name, prefix, website, email) - send_req({ - act: :host_child_new, - pub_name: pub_name, - prefix: prefix, - website: website, - email: email - }) - end - # This function regenerates your host key. # # @see http://www.cloudflare.com/docs/host-api.html#s3.2.8 @@ -512,14 +498,16 @@ def host_child_stop(id) # @param name [String] (optional) zone_name # @param sub_id [Integer] (optional) sub_id # @param status [String] (optional) values: V|D|ALL + # @param sub_status [String] (optional) values: V|CNL|ALL - def zone_list(limit = 100, offset = 0, name = nil, sub_id = nil, status = nil) + def zone_list(limit = 100, offset = 0, name = nil, sub_id = nil, status = nil, sub_status = nil) send_req({ act: :zone_list, offset: offset, zone_name: name, sub_id: sub_id, - zone_status: status + zone_status: status, + sub_status: sub_status }) end diff --git a/lib/cloudflare/version.rb b/lib/cloudflare/version.rb index 6cf4496..47c6d37 100644 --- a/lib/cloudflare/version.rb +++ b/lib/cloudflare/version.rb @@ -19,5 +19,5 @@ # THE SOFTWARE. module CloudFlare - VERSION = '2.0.3' + VERSION = '2.1.0' end