fastly 1.00 → 1.01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changes +10 -0
- data/README.md +54 -50
- data/fastly.gemspec +1 -1
- data/lib/fastly.rb +77 -3
- data/lib/fastly/backend.rb +11 -2
- data/lib/fastly/belongs_to_service_and_version.rb +5 -0
- data/lib/fastly/client.rb +6 -0
- data/lib/fastly/condition.rb +40 -0
- data/lib/fastly/gem_version.rb +4 -0
- data/lib/fastly/service.rb +4 -4
- data/lib/fastly/settings.rb +9 -4
- data/lib/fastly/syslog.rb +6 -1
- data/test/common.rb +6 -3
- data/test/helper.rb +1 -0
- data/test/stats_test.rb +89 -0
- metadata +38 -11
- checksums.yaml +0 -7
data/Changes
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2013-10-03 v1.01
|
|
2
|
+
|
|
3
|
+
Add historical stats functionality
|
|
4
|
+
Fix settings
|
|
5
|
+
Add conditions
|
|
6
|
+
Add in auto_loadbalancing for backends
|
|
7
|
+
Fix some doc stuff (Sam Sharpe)
|
|
8
|
+
Reorganize library (Eric Saxby & Paul Henry)
|
|
9
|
+
Fix purge_all, purge_by_key and details (Kazuki Ohta)
|
|
10
|
+
|
|
1
11
|
2013-07-16 v1.00
|
|
2
12
|
|
|
3
13
|
Fix delete VCL (thanks Andrian Jardan)
|
data/README.md
CHANGED
|
@@ -1,56 +1,60 @@
|
|
|
1
1
|
Fastly - client library for interacting with the Fastly web acceleration service
|
|
2
2
|
|
|
3
3
|
# Example
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
fastly = Fastly.new(login_opts)
|
|
7
|
+
|
|
8
|
+
current_user = fastly.current_user
|
|
9
|
+
current_customer = fastly.current_customer
|
|
10
|
+
|
|
11
|
+
user = fastly.get_user(current_user.id)
|
|
12
|
+
customer = fastly.get_customer(current_customer.id)
|
|
13
|
+
|
|
14
|
+
puts "Name: #{user.name}"
|
|
15
|
+
puts "Works for #{user.customer.name}"
|
|
16
|
+
puts "Which is the same as #{customer.name}"
|
|
17
|
+
puts "Which has the owner #{customer.owner.name}"
|
|
18
|
+
|
|
19
|
+
# Let's see which services we have defined
|
|
20
|
+
fastly.list_services.each do |service|
|
|
21
|
+
puts "Service ID: #{service.id}"
|
|
22
|
+
puts "Service Name: #{service.name}"
|
|
23
|
+
puts "Service Versions:"
|
|
24
|
+
service.versions.each do |version|
|
|
25
|
+
puts "\t#{version.number}"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
service = fastly.create_service(:name => "MyFirstService")
|
|
30
|
+
latest_version = service.version
|
|
31
|
+
|
|
32
|
+
# Create a domain and a backend for the service ...
|
|
33
|
+
domain = fastly.create_domain(:service_id => service.id, :version => latest_version.number, :name => "www.example.com")
|
|
34
|
+
backend = fastly.create_backend(:service_id => service.id, :version => latest_version.number, :name => "Backend 1", :ipv4 => "192.0.43.10", :port => 80)
|
|
35
|
+
|
|
36
|
+
# ... and activate it. You're now hosted on Fastly.
|
|
37
|
+
latest_version.activate
|
|
38
|
+
|
|
39
|
+
# Let's take a peek at the VCL that Fastly generated for us
|
|
40
|
+
vcl = latest_version.generated_vcl
|
|
41
|
+
puts "Generated VCL file is:\n#{vcl.content}"
|
|
42
|
+
|
|
43
|
+
# Now let's create a new version ...
|
|
44
|
+
new_version = latest_version.clone
|
|
45
|
+
# ... add a new backend ...
|
|
46
|
+
new_backend = fastly.create_backend(:service_id => service.id, :version => new_version.number, :name => "Backend 2", :ipv4 => "74.125.224.136", :port => 8080)
|
|
47
|
+
# ... add a director to switch between them
|
|
48
|
+
director = fastly.create_director(:service_id => service.id, :version => new_version.number, :name => "My Director")
|
|
49
|
+
director.add_backend(backend)
|
|
50
|
+
director.add_backend(new_backend)
|
|
51
|
+
# ... and upload some custom vcl (presuming we have permissions)
|
|
52
|
+
new_version.upload_vcl(vcl_name, File.read(vcl_file))
|
|
53
|
+
# ... and set it as the service's main vcl
|
|
54
|
+
fastly.client.put("/service/#{service.id}/version/#{new_version.number}/vcl/#{vcl_name}/main")
|
|
55
|
+
|
|
56
|
+
new_version.activate!
|
|
57
|
+
```
|
|
54
58
|
|
|
55
59
|
# Copyright
|
|
56
60
|
|
data/fastly.gemspec
CHANGED
data/lib/fastly.rb
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# A client library for interacting with the Fastly web acceleration service
|
|
6
6
|
class Fastly
|
|
7
|
-
|
|
8
|
-
VERSION = "1.00"
|
|
9
|
-
|
|
7
|
+
require 'fastly/gem_version'
|
|
10
8
|
require 'fastly/fetcher'
|
|
11
9
|
require 'fastly/client'
|
|
12
10
|
|
|
@@ -89,6 +87,64 @@ class Fastly
|
|
|
89
87
|
#res = client.post("/purge/", :path => path)
|
|
90
88
|
end
|
|
91
89
|
|
|
90
|
+
# Fetches historical stats for each of your fastly services and groups the results by service id.
|
|
91
|
+
#
|
|
92
|
+
# If you pass in a :field opt then fetches only the specified field.
|
|
93
|
+
# If you pass in a :service opt then fetches only the specified service.
|
|
94
|
+
# The :field and :service opts can be combined.
|
|
95
|
+
#
|
|
96
|
+
# If you pass in an :aggregate flag then fetches historical stats information aggregated across all of your Fastly services. This cannot be combined with :field and :service.
|
|
97
|
+
#
|
|
98
|
+
# Other options available are:
|
|
99
|
+
#
|
|
100
|
+
# from:: earliest time from which to fetch historical statistics
|
|
101
|
+
# to:: latest time from which to fetch historical statistics
|
|
102
|
+
# by:: the sampling rate used to produce the result set (minute, hour, day)
|
|
103
|
+
# region:: restrict query to a particular region
|
|
104
|
+
#
|
|
105
|
+
# See http://docs.fastly.com/docs/stats for details.
|
|
106
|
+
def stats(opts)
|
|
107
|
+
raise Fastly::Error.new("You can't specify a field or a service for an aggregate request") if opts[:aggregate] && (opts[:field] || opts[:service])
|
|
108
|
+
|
|
109
|
+
url = "/stats"
|
|
110
|
+
|
|
111
|
+
if opts.delete(:aggregate)
|
|
112
|
+
url += "/aggregate"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if service = opts.delete(:service)
|
|
116
|
+
url += "/service/#{service}"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if field = opts.delete(:field)
|
|
120
|
+
url += "/field/#{field}"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
client.get_stats(url, opts);
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Returns usage information aggregated across all Fastly services and grouped by region.
|
|
127
|
+
#
|
|
128
|
+
# If the :by_service flag is passed then teturns usage information aggregated by service and grouped by service & region.
|
|
129
|
+
#
|
|
130
|
+
# Other options available are:
|
|
131
|
+
#
|
|
132
|
+
# from:: earliest time from which to fetch historical statistics
|
|
133
|
+
# to:: latest time from which to fetch historical statistics
|
|
134
|
+
# by:: the sampling rate used to produce the result set (minute, hour, day)
|
|
135
|
+
# region:: restrict query to a particular region
|
|
136
|
+
#
|
|
137
|
+
# See http://docs.fastly.com/docs/stats for details.
|
|
138
|
+
def usage(opts)
|
|
139
|
+
url = "/stats/usage";
|
|
140
|
+
url += "_by_service" if opts.delete(:by_service)
|
|
141
|
+
client.get_stats(url, opts)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Fetches the list of codes for regions that are covered by the Fastly CDN service.
|
|
145
|
+
def regions
|
|
146
|
+
client.get_stats("/stats/regions")
|
|
147
|
+
end
|
|
92
148
|
|
|
93
149
|
[User, Customer, Backend, Director, Domain, Healthcheck, Match, Origin, Service, Syslog, VCL, Version].each do |klass|
|
|
94
150
|
type = klass.to_s.downcase.split("::")[-1]
|
|
@@ -151,6 +207,10 @@ class Fastly
|
|
|
151
207
|
##
|
|
152
208
|
# :method: create_vcl(opts)
|
|
153
209
|
# opts must contain service_id, version and name params
|
|
210
|
+
|
|
211
|
+
##
|
|
212
|
+
# :method: create_condition(opts)
|
|
213
|
+
# opts must contain service_id, version and name params
|
|
154
214
|
|
|
155
215
|
##
|
|
156
216
|
# :method: get_user(id)
|
|
@@ -273,6 +333,11 @@ class Fastly
|
|
|
273
333
|
# You can also call
|
|
274
334
|
# vcl.save!
|
|
275
335
|
|
|
336
|
+
##
|
|
337
|
+
# :method: update_condition(condition)
|
|
338
|
+
# You can also call
|
|
339
|
+
# condition.save!
|
|
340
|
+
|
|
276
341
|
##
|
|
277
342
|
# :method: update_version(version)
|
|
278
343
|
# You can also call
|
|
@@ -345,6 +410,11 @@ class Fastly
|
|
|
345
410
|
# You can also call
|
|
346
411
|
# vcl.delete!
|
|
347
412
|
|
|
413
|
+
##
|
|
414
|
+
# :method: delete_condition(condition)
|
|
415
|
+
# You can also call
|
|
416
|
+
# condition.delete!
|
|
417
|
+
|
|
348
418
|
##
|
|
349
419
|
# :method: delete_version(version)
|
|
350
420
|
# You can also call
|
|
@@ -397,6 +467,10 @@ class Fastly
|
|
|
397
467
|
# :method: list_vcls
|
|
398
468
|
#
|
|
399
469
|
# Get a list of all vcls
|
|
470
|
+
|
|
471
|
+
# :method: list_conditions
|
|
472
|
+
#
|
|
473
|
+
# Get a list of all conditions
|
|
400
474
|
|
|
401
475
|
# :method: list_versions
|
|
402
476
|
#
|
data/lib/fastly/backend.rb
CHANGED
|
@@ -2,7 +2,7 @@ class Fastly
|
|
|
2
2
|
# An individual host you want to serve assets off
|
|
3
3
|
class Backend < BelongsToServiceAndVersion
|
|
4
4
|
attr_accessor :service_id, :name, :address, :ipv4, :ipv6, :hostname, :use_ssl, :client_cert, :port,
|
|
5
|
-
:connect_timeout, :first_byte_timeout, :between_bytes_timeout, :error_threshold, :max_conn, :weight, :comment, :healthcheck
|
|
5
|
+
:connect_timeout, :first_byte_timeout, :between_bytes_timeout, :error_threshold, :max_conn, :weight, :comment, :healthcheck, :auto_loadbalance, :request_condition
|
|
6
6
|
|
|
7
7
|
##
|
|
8
8
|
# :attr: service_id
|
|
@@ -99,6 +99,15 @@ class Fastly
|
|
|
99
99
|
# :attr: healthcheck
|
|
100
100
|
#
|
|
101
101
|
# the name of a healthcheck to associate with this backend. See the Healthcheck object
|
|
102
|
-
|
|
102
|
+
|
|
103
|
+
##
|
|
104
|
+
# :attr: auto_loadbalance
|
|
105
|
+
#
|
|
106
|
+
# set to true if you want to auto_loadbalance, set to false if you don't want to auto_loadbalance
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# :attr: request_condition
|
|
110
|
+
#
|
|
111
|
+
# name of a request_condition to filter the backend on
|
|
103
112
|
end
|
|
104
113
|
end
|
data/lib/fastly/client.rb
CHANGED
|
@@ -62,6 +62,12 @@ class Fastly
|
|
|
62
62
|
raise Fastly::Error, resp.message unless resp.success?
|
|
63
63
|
JSON.parse(resp.body)
|
|
64
64
|
end
|
|
65
|
+
|
|
66
|
+
def get_stats(path, params={})
|
|
67
|
+
content = get(path, params)
|
|
68
|
+
raise Fastly::Error, content["message"] unless content["status"] == 'success'
|
|
69
|
+
content["data"]
|
|
70
|
+
end
|
|
65
71
|
|
|
66
72
|
def post(path, params={})
|
|
67
73
|
post_and_put(:post, path, params)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
class Fastly
|
|
2
|
+
# An endpoint to stream syslogs to
|
|
3
|
+
class Condition < BelongsToServiceAndVersion
|
|
4
|
+
attr_accessor :service_id, :name, :priority, :statement, :type
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
# :attr: service_id
|
|
8
|
+
#
|
|
9
|
+
# The id of the service this belongs to.
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# :attr: version
|
|
13
|
+
#
|
|
14
|
+
# The number of the version this belongs to.
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# :attr: name
|
|
18
|
+
#
|
|
19
|
+
# The name of the condition
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# :attr: statement
|
|
23
|
+
#
|
|
24
|
+
# The statement of the condition, should be a varnish if statement line
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# :attr: priority
|
|
28
|
+
#
|
|
29
|
+
# What order to run them in, higher priority gets executed after lower priority
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# :attr: type
|
|
33
|
+
#
|
|
34
|
+
# request, cache or response
|
|
35
|
+
#
|
|
36
|
+
# request has req. object only
|
|
37
|
+
# cache has req. and beresp.
|
|
38
|
+
# response has req. and resp.
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/fastly/service.rb
CHANGED
|
@@ -59,13 +59,13 @@ class Fastly
|
|
|
59
59
|
|
|
60
60
|
# Purge all assets from this service.
|
|
61
61
|
def purge_all
|
|
62
|
-
res = client.
|
|
62
|
+
res = fetcher.client.post(Fastly::Service.get_path(self.id)+"/purge_all")
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
# Purge anything with the specific key from the given service.
|
|
67
67
|
def purge_by_key(key)
|
|
68
|
-
res = client.
|
|
68
|
+
res = fetcher.client.post(Fastly::Service.get_path(self.id)+"/purge/#{key}")
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
# Set all the versions that this service has had.
|
|
@@ -85,7 +85,7 @@ class Fastly
|
|
|
85
85
|
|
|
86
86
|
# A deep hash of nested details
|
|
87
87
|
def details(opts={})
|
|
88
|
-
client.get(get_path(self.id)+"/details", opts);
|
|
88
|
+
fetcher.client.get(Fastly::Service.get_path(self.id)+"/details", opts);
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
# Get the Customer object for this Service
|
|
@@ -109,4 +109,4 @@ class Fastly
|
|
|
109
109
|
return nil if hash.nil?
|
|
110
110
|
klass.new(hash, self)
|
|
111
111
|
end
|
|
112
|
-
end
|
|
112
|
+
end
|
data/lib/fastly/settings.rb
CHANGED
|
@@ -19,7 +19,6 @@ class Fastly
|
|
|
19
19
|
#
|
|
20
20
|
# Return a hash containing key/value pairs of settings
|
|
21
21
|
#
|
|
22
|
-
|
|
23
22
|
|
|
24
23
|
# :nodoc:
|
|
25
24
|
def self.get_path(service, number)
|
|
@@ -38,12 +37,12 @@ class Fastly
|
|
|
38
37
|
|
|
39
38
|
# :nodoc:
|
|
40
39
|
def self.post_path
|
|
41
|
-
raise "You can't POST to an
|
|
40
|
+
raise "You can't POST to an setting"
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
# :nodoc:
|
|
45
44
|
def self.delete_path
|
|
46
|
-
raise "You can't DELETE to an
|
|
45
|
+
raise "You can't DELETE to an setting"
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
# :nodoc:
|
|
@@ -59,7 +58,13 @@ class Fastly
|
|
|
59
58
|
|
|
60
59
|
# Get the Settings object for the specified Version
|
|
61
60
|
def get_settings(service, number)
|
|
62
|
-
|
|
61
|
+
klass = Fastly::Settings
|
|
62
|
+
hash = client.get(Fastly::Settings.get_path(service, number))
|
|
63
|
+
|
|
64
|
+
return nil if hash.nil?
|
|
65
|
+
hash["settings"] = Hash[["general.default_host", "general.default_ttl"].collect { |var| [var, hash.delete(var)] }]
|
|
66
|
+
|
|
67
|
+
return klass.new(hash, self)
|
|
63
68
|
end
|
|
64
69
|
|
|
65
70
|
# Update the Settings object for the specified Version
|
data/lib/fastly/syslog.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class Fastly
|
|
2
2
|
# An endpoint to stream syslogs to
|
|
3
3
|
class Syslog < BelongsToServiceAndVersion
|
|
4
|
-
attr_accessor :service_id, :name, :comment, :ipv4, :ipv6, :hostname, :port, :format
|
|
4
|
+
attr_accessor :service_id, :name, :comment, :ipv4, :ipv6, :hostname, :port, :format, :response_conditions
|
|
5
5
|
|
|
6
6
|
##
|
|
7
7
|
# :attr: service_id
|
|
@@ -61,5 +61,10 @@ class Fastly
|
|
|
61
61
|
# :attr: format
|
|
62
62
|
#
|
|
63
63
|
# Format to log like in apache format
|
|
64
|
+
|
|
65
|
+
##
|
|
66
|
+
# :attr: response_condition
|
|
67
|
+
#
|
|
68
|
+
# name of a response_condition to filter the log on, if empty it always logs
|
|
64
69
|
end
|
|
65
70
|
end
|
data/test/common.rb
CHANGED
|
@@ -139,9 +139,12 @@ module CommonTests
|
|
|
139
139
|
assert tmp
|
|
140
140
|
assert_equal name, tmp.name
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
begin
|
|
143
|
+
stats = service.stats
|
|
144
|
+
rescue Fastly::Error => e
|
|
145
|
+
end
|
|
146
|
+
assert stats.nil?
|
|
147
|
+
|
|
145
148
|
stats = service.stats(:all, :year => 2011, :month => 10)
|
|
146
149
|
assert stats
|
|
147
150
|
end
|
data/test/helper.rb
CHANGED
data/test/stats_test.rb
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'test/unit'
|
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
|
6
|
+
|
|
7
|
+
FROM = "2011-01-01 00:00:00"
|
|
8
|
+
|
|
9
|
+
class StatsTest < Test::Unit::TestCase
|
|
10
|
+
|
|
11
|
+
def setup
|
|
12
|
+
opts = login_opts(:api_key).merge(:use_curb => false)
|
|
13
|
+
begin
|
|
14
|
+
@fastly = Fastly.new(opts)
|
|
15
|
+
rescue Exception => e
|
|
16
|
+
warn e.inspect
|
|
17
|
+
warn e.backtrace.join("\n")
|
|
18
|
+
exit(-1)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_regions
|
|
23
|
+
regions = @fastly.regions
|
|
24
|
+
assert(regions.size>0)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_usage
|
|
28
|
+
usage = @fastly.usage(:from => FROM)
|
|
29
|
+
assert(usage["usa"], "Found a USA region in usage");
|
|
30
|
+
assert(usage["usa"]["requests"], "USA region has a requests field");
|
|
31
|
+
|
|
32
|
+
usage = @fastly.usage(:from => FROM, :by_service => 1)
|
|
33
|
+
assert(usage["usa"], "Found a USA region in usage");
|
|
34
|
+
assert(usage["usa"]["requests"].nil?, "USA region doesn't have a requests field");
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_stats
|
|
39
|
+
stats = @fastly.stats(:from => $FROM)
|
|
40
|
+
service1, service2 = stats.keys
|
|
41
|
+
assert(stats[service1][0]["requests"], "Found requests")
|
|
42
|
+
assert(stats[service1][0]["hits"], "Found hits")
|
|
43
|
+
assert(stats[service2][0]["requests"], "Found requests")
|
|
44
|
+
assert(stats[service2][0]["hits"], "Found hits")
|
|
45
|
+
|
|
46
|
+
stats = @fastly.stats(:from => $FROM, :field => "requests")
|
|
47
|
+
assert(stats[service1][0]["requests"], "Found requests")
|
|
48
|
+
assert(stats[service1][0]["hits"].nil?, "Didn't find hits")
|
|
49
|
+
assert(stats[service2][0]["requests"], "Found requests")
|
|
50
|
+
assert(stats[service2][0]["hits"].nil?, "Didn't find hits")
|
|
51
|
+
|
|
52
|
+
stats = @fastly.stats(:from => $FROM, :service => service1)
|
|
53
|
+
assert_equal(stats[0]["service_id"], service1, "Got correct service id")
|
|
54
|
+
assert(stats[0]["requests"], "Found requests")
|
|
55
|
+
assert(stats[0]["hits"], "Found hits")
|
|
56
|
+
|
|
57
|
+
stats = @fastly.stats(:from => $FROM, :field => "requests", :service => service1)
|
|
58
|
+
assert_equal(stats[0]["service_id"], service1, "Got correct service id")
|
|
59
|
+
assert(stats[0]["requests"], "Found requests")
|
|
60
|
+
assert(stats[0]["hits"].nil?, "Didn't find hits")
|
|
61
|
+
|
|
62
|
+
stats = @fastly.stats(:from => $FROM, :aggregate => true)
|
|
63
|
+
assert(stats[0]["service_id"].nil?, "No service id")
|
|
64
|
+
assert(stats[0]["requests"], "Found requests")
|
|
65
|
+
assert(stats[0]["hits"], "Found hits")
|
|
66
|
+
|
|
67
|
+
stats = nil
|
|
68
|
+
# stats aggregate with field
|
|
69
|
+
begin
|
|
70
|
+
stats = @fastly.stats(:from => $FROM, :field => "requests", :aggregate => true)
|
|
71
|
+
rescue Fastly::Error => e
|
|
72
|
+
end
|
|
73
|
+
assert stats.nil?
|
|
74
|
+
|
|
75
|
+
# stats aggregate with service
|
|
76
|
+
begin
|
|
77
|
+
stats = @fastly.stats(:from => $FROM, :service => service1, :aggregate => true)
|
|
78
|
+
rescue Fastly::Error => e
|
|
79
|
+
end
|
|
80
|
+
assert stats.nil?
|
|
81
|
+
|
|
82
|
+
begin
|
|
83
|
+
stats = @fastly.stats(:from => $FROM, :service => service1, :field => "requests", :aggregate => true)
|
|
84
|
+
rescue Fastly::Error => e
|
|
85
|
+
end
|
|
86
|
+
assert stats.nil?
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fastly
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 1
|
|
7
|
+
- 1
|
|
8
|
+
version: "1.01"
|
|
5
9
|
platform: ruby
|
|
6
10
|
authors:
|
|
7
11
|
- Fastly Inc
|
|
@@ -9,16 +13,18 @@ autorequire:
|
|
|
9
13
|
bindir: bin
|
|
10
14
|
cert_chain: []
|
|
11
15
|
|
|
12
|
-
date: 2013-
|
|
16
|
+
date: 2013-10-03 00:00:00 -07:00
|
|
17
|
+
default_executable:
|
|
13
18
|
dependencies:
|
|
14
19
|
- !ruby/object:Gem::Dependency
|
|
15
20
|
name: json
|
|
16
21
|
prerelease: false
|
|
17
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
18
23
|
requirements:
|
|
19
|
-
-
|
|
20
|
-
- ">="
|
|
24
|
+
- - ">="
|
|
21
25
|
- !ruby/object:Gem::Version
|
|
26
|
+
segments:
|
|
27
|
+
- 0
|
|
22
28
|
version: "0"
|
|
23
29
|
type: :runtime
|
|
24
30
|
version_requirements: *id001
|
|
@@ -29,6 +35,10 @@ dependencies:
|
|
|
29
35
|
requirements:
|
|
30
36
|
- - ">="
|
|
31
37
|
- !ruby/object:Gem::Version
|
|
38
|
+
segments:
|
|
39
|
+
- 0
|
|
40
|
+
- 7
|
|
41
|
+
- 15
|
|
32
42
|
version: 0.7.15
|
|
33
43
|
type: :runtime
|
|
34
44
|
version_requirements: *id002
|
|
@@ -39,6 +49,10 @@ dependencies:
|
|
|
39
49
|
requirements:
|
|
40
50
|
- - ">="
|
|
41
51
|
- !ruby/object:Gem::Version
|
|
52
|
+
segments:
|
|
53
|
+
- 0
|
|
54
|
+
- 6
|
|
55
|
+
- 1
|
|
42
56
|
version: 0.6.1
|
|
43
57
|
type: :runtime
|
|
44
58
|
version_requirements: *id003
|
|
@@ -49,6 +63,9 @@ dependencies:
|
|
|
49
63
|
requirements:
|
|
50
64
|
- - ">="
|
|
51
65
|
- !ruby/object:Gem::Version
|
|
66
|
+
segments:
|
|
67
|
+
- 3
|
|
68
|
+
- 11
|
|
52
69
|
version: "3.11"
|
|
53
70
|
type: :runtime
|
|
54
71
|
version_requirements: *id004
|
|
@@ -74,10 +91,12 @@ files:
|
|
|
74
91
|
- lib/fastly/base.rb
|
|
75
92
|
- lib/fastly/belongs_to_service_and_version.rb
|
|
76
93
|
- lib/fastly/client.rb
|
|
94
|
+
- lib/fastly/condition.rb
|
|
77
95
|
- lib/fastly/customer.rb
|
|
78
96
|
- lib/fastly/director.rb
|
|
79
97
|
- lib/fastly/domain.rb
|
|
80
98
|
- lib/fastly/fetcher.rb
|
|
99
|
+
- lib/fastly/gem_version.rb
|
|
81
100
|
- lib/fastly/healthcheck.rb
|
|
82
101
|
- lib/fastly/invoice.rb
|
|
83
102
|
- lib/fastly/match.rb
|
|
@@ -93,11 +112,11 @@ files:
|
|
|
93
112
|
- test/common.rb
|
|
94
113
|
- test/full_login_test.rb
|
|
95
114
|
- test/helper.rb
|
|
115
|
+
- test/stats_test.rb
|
|
116
|
+
has_rdoc: true
|
|
96
117
|
homepage: http://github.com/fastly/fastly-ruby
|
|
97
118
|
licenses: []
|
|
98
119
|
|
|
99
|
-
metadata: {}
|
|
100
|
-
|
|
101
120
|
post_install_message:
|
|
102
121
|
rdoc_options: []
|
|
103
122
|
|
|
@@ -105,16 +124,24 @@ require_paths:
|
|
|
105
124
|
- lib
|
|
106
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
126
|
requirements:
|
|
108
|
-
-
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
segments:
|
|
130
|
+
- 0
|
|
131
|
+
version: "0"
|
|
109
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
133
|
requirements:
|
|
111
|
-
-
|
|
134
|
+
- - ">="
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
segments:
|
|
137
|
+
- 0
|
|
138
|
+
version: "0"
|
|
112
139
|
requirements: []
|
|
113
140
|
|
|
114
141
|
rubyforge_project:
|
|
115
|
-
rubygems_version:
|
|
142
|
+
rubygems_version: 1.3.6
|
|
116
143
|
signing_key:
|
|
117
|
-
specification_version:
|
|
144
|
+
specification_version: 3
|
|
118
145
|
summary: Client library for the Fastly acceleration system
|
|
119
146
|
test_files:
|
|
120
147
|
- test/admin_test.rb
|
|
@@ -122,4 +149,4 @@ test_files:
|
|
|
122
149
|
- test/common.rb
|
|
123
150
|
- test/full_login_test.rb
|
|
124
151
|
- test/helper.rb
|
|
125
|
-
|
|
152
|
+
- test/stats_test.rb
|
checksums.yaml
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
SHA512:
|
|
3
|
-
data.tar.gz: 173bc2e9d43fbf193a73830700cbd0909e8999a204605330cfbfb9b8d773aacde089c9902f98ddedaad8166d8d412e2475c44bc784e7d0884a61b6c8599d7fd2
|
|
4
|
-
metadata.gz: 68c1f14d18fd3894e3c15864509db3984f57a4dde8a9b804ffe20b24df981d3512eb4f7446042971d677d138017ec1a092fe022bc2036c89ee8a90c24af84bc9
|
|
5
|
-
SHA1:
|
|
6
|
-
data.tar.gz: 3090d1395750ed869ebd3cc8947d38c688f99217
|
|
7
|
-
metadata.gz: 43141d3014baaca138f007d90e1de1411e80bf2a
|