fastly 1.1.4 → 1.1.5
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.
- checksums.yaml +4 -4
- data/HISTORY.md +7 -3
- data/README.md +0 -2
- data/bin/fastly_upload_vcl +18 -18
- data/fastly.gemspec +11 -11
- data/lib/ext/curb_fu/response/base.rb +20 -0
- data/lib/fastly.rb +69 -83
- data/lib/fastly/base.rb +9 -9
- data/lib/fastly/belongs_to_service_and_version.rb +9 -14
- data/lib/fastly/cache_setting.rb +32 -34
- data/lib/fastly/client.rb +55 -120
- data/lib/fastly/client/curl.rb +57 -0
- data/lib/fastly/condition.rb +32 -32
- data/lib/fastly/customer.rb +1 -1
- data/lib/fastly/director.rb +4 -4
- data/lib/fastly/fetcher.rb +10 -12
- data/lib/fastly/gem_version.rb +2 -2
- data/lib/fastly/gzip.rb +26 -27
- data/lib/fastly/header.rb +67 -68
- data/lib/fastly/invoice.rb +17 -16
- data/lib/fastly/origin.rb +4 -5
- data/lib/fastly/request_setting.rb +68 -69
- data/lib/fastly/response_object.rb +46 -47
- data/lib/fastly/s3_logging.rb +48 -50
- data/lib/fastly/service.rb +20 -26
- data/lib/fastly/settings.rb +10 -11
- data/lib/fastly/syslog.rb +53 -57
- data/lib/fastly/user.rb +4 -6
- data/lib/fastly/util.rb +1 -0
- data/lib/fastly/version.rb +25 -30
- data/test/admin_test.rb +8 -8
- data/test/api_key_test.rb +20 -39
- data/test/common.rb +64 -66
- data/test/fastly/util_test.rb +1 -0
- data/test/full_login_test.rb +77 -82
- data/test/helper.rb +15 -24
- data/test/missing_api_key_test.rb +1 -1
- data/test/stats_test.rb +42 -50
- metadata +17 -13
data/lib/fastly/origin.rb
CHANGED
@@ -20,21 +20,20 @@ class Fastly
|
|
20
20
|
#
|
21
21
|
# The domain name of this domain
|
22
22
|
|
23
|
-
|
24
23
|
# Add a Director object to an Origin
|
25
24
|
#
|
26
25
|
# Return true on success and false on failure
|
27
26
|
def add_director(director)
|
28
|
-
hash = fetcher.client.post(
|
29
|
-
|
27
|
+
hash = fetcher.client.post("#{Origin.put_path(self)}/director/#{director.name}")
|
28
|
+
!hash.nil?
|
30
29
|
end
|
31
30
|
|
32
31
|
# Delete a Director object from an Origin
|
33
32
|
#
|
34
33
|
# Return true on success and false on failure
|
35
34
|
def delete_director(director)
|
36
|
-
hash = fetcher.client.delete(
|
37
|
-
|
35
|
+
hash = fetcher.client.delete("#{Origin.put_path(self)}/director/#{director.name}")
|
36
|
+
!hash.nil?
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -3,88 +3,87 @@ class Fastly
|
|
3
3
|
class RequestSetting < BelongsToServiceAndVersion
|
4
4
|
attr_accessor :service_id, :name, :force_miss, :force_ssl, :action, :bypass_busy_wait, :max_stale_age, :hash_keys, :xff, :time_support, :geo_headers, :default_host, :request_condition
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
##
|
7
|
+
# :attr: service_id
|
8
|
+
#
|
9
|
+
# The id of the service this belongs to.
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
##
|
12
|
+
# :attr: version
|
13
|
+
#
|
14
|
+
# The number of the version this belongs to.
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
##
|
17
|
+
# :attr: name
|
18
|
+
#
|
19
|
+
# The name of the request setting
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
##
|
22
|
+
# :attr: force_miss
|
23
|
+
#
|
24
|
+
# Allows you to force a cache miss for the request. Replaces the item
|
25
|
+
# in the cache if the content is cacheable
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
##
|
28
|
+
# :attr: force_ssl
|
29
|
+
#
|
30
|
+
# Force the request to use SSL, redirecting a non-SSL request to SSL.
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
##
|
33
|
+
# :attr: action
|
34
|
+
#
|
35
|
+
# Allows you to terminate request handling and immediately perform an
|
36
|
+
# action. When set it can be lookup or pass (ignore the cache completely)
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
##
|
39
|
+
# :attr: bypass_busy_wait
|
40
|
+
#
|
41
|
+
# Disable collapsed forwarding, so you don't wait for other objects to
|
42
|
+
# origin
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
##
|
45
|
+
# :attr: max_stale_age
|
46
|
+
#
|
47
|
+
# How old an object is allowed to be to serve stale-if-error or
|
48
|
+
# state-while-revalidate
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
##
|
51
|
+
# :attr: hash_keys
|
52
|
+
#
|
53
|
+
# Comma separated list of varnish request object fields that should be
|
54
|
+
# in the hash key
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
##
|
57
|
+
# :attr: xff
|
58
|
+
#
|
59
|
+
# X-Forwarded-For: should be clear, leave, append, append_all, or
|
60
|
+
# overwrite
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
##
|
63
|
+
# :attr: timer_support
|
64
|
+
#
|
65
|
+
# Injects the X-Timer info into the request for viewing origin fetch
|
66
|
+
# durations
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
##
|
69
|
+
# :attr: geo_headers
|
70
|
+
#
|
71
|
+
# Injects Fastly-Geo-Country, Fastly-Geo-City, and Fastly-Geo-Region
|
72
|
+
# into the request headers
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
##
|
75
|
+
# :attr: default_host
|
76
|
+
#
|
77
|
+
# Sets the host header
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
##
|
80
|
+
# :attr: request_condition
|
81
|
+
#
|
82
|
+
# Name of condition object used to test whether or not these settings
|
83
|
+
# should be used
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
85
|
+
def self.path
|
86
|
+
Util.class_to_path(self, true)
|
87
|
+
end
|
89
88
|
end
|
90
89
|
end
|
@@ -3,52 +3,51 @@ class Fastly
|
|
3
3
|
class ResponseObject < BelongsToServiceAndVersion
|
4
4
|
attr_accessor :service_id, :name, :cache_condition, :request_condition, :status, :response, :content, :content_type
|
5
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
|
-
|
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 response object
|
20
|
+
|
21
|
+
##
|
22
|
+
# :attr: cache_condition
|
23
|
+
#
|
24
|
+
# Name of the cache condition used to test whether this response object
|
25
|
+
# should be used.
|
26
|
+
|
27
|
+
##
|
28
|
+
# :attr: request_condition
|
29
|
+
#
|
30
|
+
# Name of the request condition used to test whether this response object
|
31
|
+
# should be used.
|
32
|
+
|
33
|
+
##
|
34
|
+
# :attr: status
|
35
|
+
#
|
36
|
+
# The HTTP status code, defaults to 200
|
37
|
+
|
38
|
+
##
|
39
|
+
# :attr: response
|
40
|
+
#
|
41
|
+
# The HTTP response, defaults to "Ok"
|
42
|
+
|
43
|
+
##
|
44
|
+
# :attr: content
|
45
|
+
#
|
46
|
+
# The content to deliver for the response object, can be empty.
|
47
|
+
|
48
|
+
##
|
49
|
+
# :attr: content_type
|
50
|
+
#
|
51
|
+
# The MIME type of the content, can be empty.
|
53
52
|
end
|
54
53
|
end
|
data/lib/fastly/s3_logging.rb
CHANGED
@@ -3,66 +3,64 @@ class Fastly
|
|
3
3
|
class S3Logging < BelongsToServiceAndVersion
|
4
4
|
attr_accessor :service_id, :name, :bucket_name, :access_key, :secret_key, :path, :period, :gzip_level, :format, :response_condition
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
##
|
7
|
+
# :attr: service_id
|
8
|
+
#
|
9
|
+
# The id of the service this belongs to.
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
##
|
12
|
+
# :attr: version
|
13
|
+
#
|
14
|
+
# The number of the version this belongs to.
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
##
|
17
|
+
# :attr: name
|
18
|
+
#
|
19
|
+
# The name for this s3 rule
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
##
|
22
|
+
# :attr: bucket_name
|
23
|
+
#
|
24
|
+
# The name of the s3 bucket
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
##
|
27
|
+
# :attr: access_key
|
28
|
+
#
|
29
|
+
# The bucket's s3 account access key
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
##
|
32
|
+
# :attr: secret_key
|
33
|
+
#
|
34
|
+
# The bucket's s3 account secret key
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
##
|
37
|
+
# :attr: path
|
38
|
+
#
|
39
|
+
# The path to upload logs to
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
##
|
42
|
+
# :attr: period
|
43
|
+
#
|
44
|
+
# How frequently the logs should be dumped (in seconds, default 3600)
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
##
|
47
|
+
# :attr: gzip_level
|
48
|
+
#
|
49
|
+
# What level of gzip compression to have when dumping the logs (default
|
50
|
+
# 0, no compression).
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
##
|
53
|
+
# :attr: format
|
54
|
+
#
|
55
|
+
# Apache style log formatting
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
##
|
58
|
+
# :attr: response_condition
|
59
|
+
#
|
60
|
+
# When to execute the s3 logging. If empty, always execute.
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
"logging/s3"
|
66
|
-
end
|
62
|
+
def self.path
|
63
|
+
'logging/s3'
|
64
|
+
end
|
67
65
|
end
|
68
66
|
end
|
data/lib/fastly/service.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# Service object
|
1
2
|
class Fastly
|
2
3
|
# Represents something you want to serve - this can be, for example, a whole web site, a Wordpress site, or just your image servers
|
3
4
|
class Service < Base
|
4
|
-
attr_accessor :id, :customer_id, :name, :comment
|
5
|
+
attr_accessor :id, :customer_id, :name, :comment, :versions
|
6
|
+
|
5
7
|
@versions = []
|
6
8
|
|
7
9
|
##
|
@@ -27,7 +29,6 @@ class Fastly
|
|
27
29
|
#
|
28
30
|
# a free form comment field
|
29
31
|
|
30
|
-
|
31
32
|
##
|
32
33
|
#
|
33
34
|
# Get a hash of stats from different data centers.
|
@@ -37,10 +38,9 @@ class Fastly
|
|
37
38
|
# * hourly
|
38
39
|
# * daily
|
39
40
|
# * all
|
40
|
-
def stats(type
|
41
|
-
|
42
|
-
|
43
|
-
return hash
|
41
|
+
def stats(type = :all, opts = {})
|
42
|
+
fail Error, "Unknown stats type #{type}" unless [:minutely, :hourly, :daily, :all].include?(type.to_sym)
|
43
|
+
fetcher.client.get("#{Service.get_path(id)}/stats/#{type}", opts)
|
44
44
|
end
|
45
45
|
|
46
46
|
# Return a Invoice object representing the invoice for this service
|
@@ -48,50 +48,46 @@ class Fastly
|
|
48
48
|
# If a year and month are passed in returns the invoice for that whole month.
|
49
49
|
#
|
50
50
|
# Otherwise it returns the invoice for the current month so far.
|
51
|
-
def invoice(year=nil, month=nil)
|
52
|
-
opts = { :
|
51
|
+
def invoice(year = nil, month = nil)
|
52
|
+
opts = { service_id: id }
|
53
|
+
|
53
54
|
unless year.nil? || month.nil?
|
54
55
|
opts[:year] = year
|
55
56
|
opts[:month] = month
|
56
57
|
end
|
57
|
-
|
58
|
+
|
59
|
+
fetcher.get(Invoice, opts)
|
58
60
|
end
|
59
61
|
|
60
62
|
# Purge all assets from this service.
|
61
63
|
def purge_all
|
62
|
-
fetcher.client.post(
|
64
|
+
fetcher.client.post("#{Service.get_path(id)}/purge_all")
|
63
65
|
end
|
64
66
|
|
65
67
|
# Purge anything with the specific key from the given service.
|
66
68
|
def purge_by_key(key)
|
67
69
|
require_api_key!
|
68
|
-
|
69
|
-
fetcher.client.post(Fastly::Service.get_path(self.id)+"/purge/#{key}")
|
70
|
-
end
|
71
|
-
|
72
|
-
# Set all the versions that this service has had.
|
73
|
-
def versions=(versions)
|
74
|
-
@versions = versions
|
70
|
+
fetcher.client.post("#{Service.get_path(id)}/purge/#{key}")
|
75
71
|
end
|
76
72
|
|
77
73
|
# Get a sorted array of all the versions that this service has had.
|
78
74
|
def versions
|
79
|
-
@versions.map { |v|
|
75
|
+
@versions.map { |v| Version.new(v, fetcher) }.sort { |a, b| a.number.to_i <=> b.number.to_i }
|
80
76
|
end
|
81
77
|
|
82
78
|
# Get an individual Version object. By default returns the latest version
|
83
|
-
def version(number
|
79
|
+
def version(number = -1)
|
84
80
|
versions[number]
|
85
81
|
end
|
86
82
|
|
87
83
|
# A deep hash of nested details
|
88
|
-
def details(opts={})
|
89
|
-
fetcher.client.get(
|
84
|
+
def details(opts = {})
|
85
|
+
fetcher.client.get("#{Service.get_path(id)}/details", opts)
|
90
86
|
end
|
91
87
|
|
92
88
|
# Get the Customer object for this Service
|
93
89
|
def customer
|
94
|
-
fetcher.get(
|
90
|
+
fetcher.get(Customer, customer_id)
|
95
91
|
end
|
96
92
|
end
|
97
93
|
|
@@ -105,9 +101,7 @@ class Fastly
|
|
105
101
|
#
|
106
102
|
# service = fastly.search_services(:name => name, :version => number)
|
107
103
|
def search_services(opts)
|
108
|
-
|
109
|
-
hash
|
110
|
-
return nil if hash.nil?
|
111
|
-
klass.new(hash, self)
|
104
|
+
hash = client.get("#{Service.post_path}/search", opts)
|
105
|
+
hash.nil? ? nil : Service.new(hash, self)
|
112
106
|
end
|
113
107
|
end
|