lib/fastly/service.rb in fastly-0.97 vs lib/fastly/service.rb in fastly-0.98

- old
+ new

@@ -36,11 +36,10 @@ # * minutely # * hourly # * daily # * all def stats(type=:all, opts={}) - raise Fastly::FullAuthRequired unless fetcher.fully_authed? raise Fastly::Error "Unknown stats type #{type}" unless [:minutely,:hourly,:daily,:all].include?(type.to_sym) hash = fetcher.client.get(Fastly::Service.get_path(self.id)+"/stats/#{type}", opts) return hash end @@ -48,42 +47,49 @@ # # 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. def invoice(year=nil, month=nil) - raise Fastly::FullAuthRequired unless fetcher.fully_authed? opts = { :service_id => self.id } unless year.nil? || month.nil? opts[:year] = year opts[:month] = month end fetcher.get(Fastly::Invoice, opts) end # Purge all assets from this service. def purge_all - raise Fastly::AuthRequired unless self.authed? res = client.put(get_path(self.id)+"/purge_all") end + + # Purge anything with the specific key from the given service. + def purge_by_key(key) + res = client.put(get_path(self.id)+"/purge/#{key}") + end + # Set all the versions that this service has had. def versions=(versions) @versions = versions end # Get a sorted array of all the versions that this service has had. def versions - raise Fastly::FullAuthRequired unless fetcher.fully_authed? @versions.map { |v| Fastly::Version.new(v, fetcher) }.sort { |a,b| a.number.to_i <=> b.number.to_i } end # Get an individual Version object. By default returns the latest version def version(number=-1) - raise Fastly::FullAuthRequired unless fetcher.fully_authed? versions[number] end + # A deep hash of nested details + def details(opts={}) + client.get(get_path(self.id)+"/details", opts); + end + # Get the Customer object for this Service def customer fetcher.get(Fastly::Customer, customer_id) end end @@ -96,10 +102,9 @@ # # or # # service = fastly.search_services(:name => name, :version => number) def search_services(opts) - raise Fastly::FullAuthRequired unless self.fully_authed? klass = Fastly::Service hash = client.get(klass.post_path+"/search", opts) return nil if hash.nil? klass.new(hash, self) end \ No newline at end of file