class BunnyCdn::Pullzone
Constants
- BASE_URL
Public Class Methods
apiKey()
click to toggle source
Sets the apiKey to that in configuration
# File lib/bunny_cdn/pullzone.rb, line 9 def self.apiKey @apiKey = BunnyCdn.configuration.apiKey end
createPullzone(name, type = 0, originUrl)
click to toggle source
Creates a new pullzone Params:
name
-
the name of the new Pull Zone
type
-
the pricing type of the pull zone you wish to add. 0 = Standard, 1 = High Volume
- originURL+
-
the origin URL where the pull zone files are pulled from.
# File lib/bunny_cdn/pullzone.rb, line 37 def self.createPullzone(name, type = 0, originUrl) values = { :name => name, :type => type, :originUrl => originUrl } begin response = RestClient.post(BASE_URL, values.to_json, headers) rescue RestClient::ExceptionWithResponse => exception return exception end return response end
deletePullzone(id)
click to toggle source
Deletes the pull zone using the given ID Params:
id
-
the ID of the Pull Zone to delete
# File lib/bunny_cdn/pullzone.rb, line 66 def self.deletePullzone(id) begin response = RestClient.delete("#{BASE_URL}/#{id}", headers) rescue RestClient::ExceptionWithResponse => exception return exception end return response end
getAllPullzones()
click to toggle source
Gets all Pull Zones from BunnyCDN
# File lib/bunny_cdn/pullzone.rb, line 23 def self.getAllPullzones begin response = RestClient.get(BASE_URL, headers) rescue RestClient::ExceptionWithResponse => exception return exception end return response end
getSinglePullzone(id)
click to toggle source
Gets the details of the pull zone using the given ID Params:
id
-
the ID of the Pull Zone to return
# File lib/bunny_cdn/pullzone.rb, line 54 def self.getSinglePullzone(id) begin response = RestClient.get("#{BASE_URL}/#{id}", headers) rescue RestClient::ExceptionWithResponse => exception return exception end return response end
headers()
click to toggle source
Sets the necessary headers to make requests to the BunnyCDN API
# File lib/bunny_cdn/pullzone.rb, line 14 def self.headers { :accesskey => apiKey, :accept => 'application/json', :content_type => 'application/json' } end
purgeCache(id)
click to toggle source
Purges the cache for the Pull Zone using the given ID Params:
id
-
the ID of the zone which should have the cache purged
# File lib/bunny_cdn/pullzone.rb, line 78 def self.purgeCache(id) begin response = RestClient.post("#{BASE_URL}/#{id}/purgeCache", {}.to_json, headers) rescue RestClient::ExceptionWithResponse => exception return exception end return response end