Class: Fastly::Service
Overview
Represents something you want to serve - this can be, for example, a whole web site, a Wordpress site, or just your image servers
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#customer_id ⇒ Object
Returns the value of attribute customer_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#versions ⇒ Object
Get a sorted array of all the versions that this service has had.
Attributes inherited from Base
Instance Method Summary collapse
-
#customer ⇒ Object
Get the Customer object for this Service.
-
#details(opts = {}) ⇒ Object
A deep hash of nested details.
-
#invoice(year = nil, month = nil) ⇒ Object
Return a Invoice object representing the invoice for this service.
-
#purge_all ⇒ Object
Purge all assets from this service.
-
#purge_by_key(key, soft = false) ⇒ Object
Purge anything with the specific key from the given service.
-
#stats(type = :all, opts = {}) ⇒ Object
Get a hash of stats from different data centers.
-
#version(number = -1)) ⇒ Object
Get an individual Version object.
Methods inherited from Base
#as_hash, #delete!, delete_path, get_path, #initialize, list_path, path, post_path, put_path, #require_api_key!, #save!
Constructor Details
This class inherits a constructor from Fastly::Base
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
5 6 7 |
# File 'lib/fastly/service.rb', line 5 def comment @comment end |
#customer_id ⇒ Object
Returns the value of attribute customer_id.
5 6 7 |
# File 'lib/fastly/service.rb', line 5 def customer_id @customer_id end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/fastly/service.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/fastly/service.rb', line 5 def name @name end |
#versions ⇒ Object
Get a sorted array of all the versions that this service has had.
78 79 80 |
# File 'lib/fastly/service.rb', line 78 def versions @versions end |
Instance Method Details
#customer ⇒ Object
Get the Customer object for this Service
93 94 95 |
# File 'lib/fastly/service.rb', line 93 def customer fetcher.get(Customer, customer_id) end |
#details(opts = {}) ⇒ Object
A deep hash of nested details
88 89 90 |
# File 'lib/fastly/service.rb', line 88 def details(opts = {}) fetcher.client.get("#{Service.get_path(id)}/details", opts) end |
#invoice(year = nil, month = nil) ⇒ Object
Return a Invoice object representing the invoice for this service
If a year and month are passed in returns the invoice for that whole month.
Otherwise it returns the invoice for the current month so far.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fastly/service.rb', line 51 def invoice(year = nil, month = nil) opts = { service_id: id } unless year.nil? || month.nil? opts[:year] = year opts[:month] = month end fetcher.get(Invoice, opts) end |
#purge_all ⇒ Object
Purge all assets from this service.
See README.md for examples of purging
65 66 67 |
# File 'lib/fastly/service.rb', line 65 def purge_all fetcher.client.post("#{Service.get_path(id)}/purge_all") end |
#purge_by_key(key, soft = false) ⇒ Object
Purge anything with the specific key from the given service.
See README.md for examples of purging
72 73 74 75 |
# File 'lib/fastly/service.rb', line 72 def purge_by_key(key, soft=false) require_api_key! fetcher.client.post("#{Service.get_path(id)}/purge/#{key}", soft ? { headers: { 'Fastly-Soft-Purge' => "1"} } : {}) end |
#stats(type = :all, opts = {}) ⇒ Object
Get a hash of stats from different data centers.
Type can be one of
-
minutely
-
hourly
-
daily
-
all
41 42 43 44 |
# File 'lib/fastly/service.rb', line 41 def stats(type = :all, opts = {}) fail Error, "Unknown stats type #{type}" unless [:minutely, :hourly, :daily, :all].include?(type.to_sym) fetcher.client.get("#{Service.get_path(id)}/stats/#{type}", opts) end |
#version(number = -1)) ⇒ Object
Get an individual Version object. By default returns the latest version
83 84 85 |
# File 'lib/fastly/service.rb', line 83 def version(number = -1) versions[number] end |