Class: LeasewebCDN

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/leaseweb-cdn-rest-api.rb

Instance Method Summary collapse

Constructor Details

#initialize(key, customerNumber) ⇒ LeasewebCDN

Returns a new instance of LeasewebCDN.



12
13
14
15
# File 'lib/leaseweb-cdn-rest-api.rb', line 12

def initialize (key, customerNumber)
  @key = key
  @customerNumber = customerNumber.to_s
end

Instance Method Details

#avg_trafficObject



53
54
55
# File 'lib/leaseweb-cdn-rest-api.rb', line 53

def avg_traffic
  self.class.get create_url("/stats/traffic/#customerNumber")
end

#create_url(path) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/leaseweb-cdn-rest-api.rb', line 17

def create_url (path)
  path = path.gsub("#customerNumber", @customerNumber)
  timestamp = Time.now.utc.to_i
  signature = Digest::SHA1.hexdigest("#{@key}#{timestamp}#{path}")

  return "#{path}/#{timestamp}/#{signature}"
end

#delete_zone(zoneID, type = 'pull') ⇒ Object



33
34
35
# File 'lib/leaseweb-cdn-rest-api.rb', line 33

def delete_zone (zoneID, type = 'pull')
  self.class.delete create_url("/zones/#{type}/#customerNumber/#{zoneID}")
end

#nine_five_percentile(billing_region, timestamp_start, timestamp_end) ⇒ Object



57
58
59
# File 'lib/leaseweb-cdn-rest-api.rb', line 57

def nine_five_percentile (billing_region, timestamp_start, timestamp_end)
  self.class.get create_url("/stats/95thpercentile/#customerNumber/#{billing_region}/#{timestamp_start}/#{timestamp_end}")
end

#nine_five_percentile_points(billing_region, timestamp_start, timestamp_end) ⇒ Object



61
62
63
# File 'lib/leaseweb-cdn-rest-api.rb', line 61

def nine_five_percentile_points (billing_region, timestamp_start, timestamp_end)
  self.class.get create_url("/stats/95thpercentilepoints/#customerNumber/#{billing_region}/#{timestamp_start}/#{timestamp_end}")
end

#purge(zoneID, expression) ⇒ Object



69
70
71
# File 'lib/leaseweb-cdn-rest-api.rb', line 69

def purge (zoneID, expression)
  self.class.delete create_url("/content/purge/#customerNumber/#{zoneID}/#{expression}")
end

#purge_status(zoneID, jobID) ⇒ Object



65
66
67
# File 'lib/leaseweb-cdn-rest-api.rb', line 65

def purge_status (zoneID, jobID)
  self.class.get create_url("/content/purge/#customerNumber/#{zoneID}/#{jobID}")
end

#search(query, zone_type = 'pull') ⇒ Object



73
74
75
# File 'lib/leaseweb-cdn-rest-api.rb', line 73

def search (query, zone_type = 'pull')
  self.class.get create_url("/search/#{zone_type}/#customerNumber/#{query}")
end

#stats_apicalls(year, month) ⇒ Object



49
50
51
# File 'lib/leaseweb-cdn-rest-api.rb', line 49

def stats_apicalls (year, month)
  self.class.get create_url("/stats/api/#customerNumber/#{year}/#{month}")
end

#stats_billing_region(type, granularity, timestamp_start, timestamp_end, cname, country, pop) ⇒ Object



45
46
47
# File 'lib/leaseweb-cdn-rest-api.rb', line 45

def stats_billing_region (type, granularity, timestamp_start, timestamp_end, cname, country, pop)
  self.class.get create_url("/stats/#{type}/#customerNumber/#{granularity}/#{timestamp_start}/#{timestamp_end}/#{cname}/#{country}/#{pop}")
end

#stats_cname(type, granularity, timestamp_start, timestamp_end, cname = 'all') ⇒ Object



37
38
39
# File 'lib/leaseweb-cdn-rest-api.rb', line 37

def stats_cname (type, granularity, timestamp_start, timestamp_end, cname = 'all')
  self.class.get create_url("/stats/#{type}/#customerNumber/#{granularity}/#{timestamp_start}/#{timestamp_end}/#{cname}")
end

#stats_country_pop(type, granularity, timestamp_start, timestamp_end, cname, country, pop) ⇒ Object



41
42
43
# File 'lib/leaseweb-cdn-rest-api.rb', line 41

def stats_country_pop (type, granularity, timestamp_start, timestamp_end, cname, country, pop)
  self.class.get create_url("/stats/#{type}/#customerNumber/#{granularity}/#{timestamp_start}/#{timestamp_end}/#{cname}/#{country}/#{pop}")
end

#update_zone(zoneID, zone, type = 'pull') ⇒ Object



29
30
31
# File 'lib/leaseweb-cdn-rest-api.rb', line 29

def update_zone (zoneID, zone, type = 'pull')
  self.class.post(create_url("/zones/#{type}/#customerNumber/#{zoneID}"), :body => zone )
end

#versionObject



77
78
79
# File 'lib/leaseweb-cdn-rest-api.rb', line 77

def version
  self.class.get create_url("/version")
end

#zone(zoneID = 'all', type = 'pull') ⇒ Object



25
26
27
# File 'lib/leaseweb-cdn-rest-api.rb', line 25

def zone (zoneID = 'all', type = 'pull')
  self.class.get create_url("/zones/#{type}/#customerNumber/#{zoneID}")
end