Class: Fastly::Version
Overview
An iteration of your configuration
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#deployed ⇒ Object
Returns the value of attribute deployed.
-
#locked ⇒ Object
Returns the value of attribute locked.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#service_id ⇒ Object
Returns the value of attribute service_id.
-
#staging ⇒ Object
Returns the value of attribute staging.
-
#testing ⇒ Object
Returns the value of attribute testing.
Attributes inherited from Base
Class Method Summary collapse
-
.create_new(fetcher, opts) ⇒ Object
Create an entirely new version, not cloned from the previous one.
- .delete_path(obj) ⇒ Object
- .get_path(service, number) ⇒ Object
- .post_path(opts = {}) ⇒ Object
- .put_path(obj) ⇒ Object
Instance Method Summary collapse
-
#activate! ⇒ Object
Activate this version.
-
#active? ⇒ Boolean
Is version active?.
-
#clone ⇒ Object
Clone this Version.
-
#deactivate! ⇒ Object
Deactivate this version.
-
#delete_vcl(name) ⇒ Object
Delete a VCL file for this Version.
- #dictionaries ⇒ Object
-
#generated_vcl(opts = {}) ⇒ Object
Get the generated VCL object for this Version (which must have been activated first).
-
#locked? ⇒ Boolean
Is this Version locked.
-
#service ⇒ Object
Get the Service object this Version belongs to.
-
#settings ⇒ Object
Get the Settings object for this Version.
-
#upload_main_vcl(name, contents) ⇒ Object
Upload a VCL file for this Version and set as the main VCL.
-
#upload_vcl(name, content) ⇒ Object
Upload a VCL file for this Version.
-
#validate ⇒ Object
Validate this Version.
-
#vcl(name, opts = {}) ⇒ Object
Get the named VCL for this version.
Methods inherited from Base
#as_hash, #delete!, #initialize, list_path, path, #require_api_key!, #save!
Constructor Details
This class inherits a constructor from Fastly::Base
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def active @active end |
#comment ⇒ Object
Returns the value of attribute comment.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def comment @comment end |
#deployed ⇒ Object
Returns the value of attribute deployed.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def deployed @deployed end |
#locked ⇒ Object
Returns the value of attribute locked.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def locked @locked end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def number @number end |
#service_id ⇒ Object
Returns the value of attribute service_id.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def service_id @service_id end |
#staging ⇒ Object
Returns the value of attribute staging.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def staging @staging end |
#testing ⇒ Object
Returns the value of attribute testing.
4 5 6 |
# File 'lib/fastly/version.rb', line 4 def testing @testing end |
Class Method Details
.create_new(fetcher, opts) ⇒ Object
Create an entirely new version, not cloned from the previous one.
91 92 93 94 95 96 |
# File 'lib/fastly/version.rb', line 91 def self.create_new(fetcher, opts) hash = fetcher.client.post(Version.post_path(opts)) return nil if hash.nil? Version.new(hash, fetcher) end |
.delete_path(obj) ⇒ Object
168 169 170 |
# File 'lib/fastly/version.rb', line 168 def self.delete_path(obj) put_path(obj) end |
.get_path(service, number) ⇒ Object
156 157 158 |
# File 'lib/fastly/version.rb', line 156 def self.get_path(service, number) "/service/#{service}/version/#{number}" end |
.post_path(opts = {}) ⇒ Object
160 161 162 |
# File 'lib/fastly/version.rb', line 160 def self.post_path(opts = {}) "/service/#{opts[:service_id]}/version" end |
.put_path(obj) ⇒ Object
164 165 166 |
# File 'lib/fastly/version.rb', line 164 def self.put_path(obj) get_path(obj.service_id, obj.number) end |
Instance Method Details
#activate! ⇒ Object
Activate this version
72 73 74 75 |
# File 'lib/fastly/version.rb', line 72 def activate! hash = fetcher.client.put("#{Version.put_path(self)}/activate") !hash.nil? end |
#active? ⇒ Boolean
Is version active?
67 68 69 |
# File 'lib/fastly/version.rb', line 67 def active? true == @active end |
#clone ⇒ Object
Clone this Version
84 85 86 87 88 |
# File 'lib/fastly/version.rb', line 84 def clone hash = fetcher.client.put("#{Version.put_path(self)}/clone") return nil if hash.nil? Version.new(hash, fetcher) end |
#deactivate! ⇒ Object
Deactivate this version
78 79 80 81 |
# File 'lib/fastly/version.rb', line 78 def deactivate! hash = fetcher.client.put("#{Version.put_path(self)}/deactivate") !hash.nil? end |
#delete_vcl(name) ⇒ Object
Delete a VCL file for this Version
137 138 139 140 |
# File 'lib/fastly/version.rb', line 137 def delete_vcl(name) hash = fetcher.client.delete("#{Version.put_path(self)}/vcl/#{name}") hash.nil? ? nil : hash end |
#dictionaries ⇒ Object
142 143 144 |
# File 'lib/fastly/version.rb', line 142 def dictionaries fetcher.list_dictionaries(:service_id => service_id, :version => number) end |
#generated_vcl(opts = {}) ⇒ Object
Get the generated VCL object for this Version (which must have been activated first)
Won’t return the content of the VCL unless you pass in
:include_content => true
in the opts
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fastly/version.rb', line 103 def generated_vcl(opts = {}) hash = fetcher.client.get("#{Version.put_path(self)}/generated_vcl", opts) opts = { 'content' => hash['vcl'] || hash['content'], 'name' => hash['md5'], 'version' => hash['version'], 'service_id' => hash['service'] } VCL.new(opts, fetcher) end |
#locked? ⇒ Boolean
Is this Version locked
52 53 54 |
# File 'lib/fastly/version.rb', line 52 def locked? true == @locked end |
#service ⇒ Object
Get the Service object this Version belongs to
57 58 59 |
# File 'lib/fastly/version.rb', line 57 def service fetcher.get(Service, service_id) end |
#settings ⇒ Object
Get the Settings object for this Version
62 63 64 |
# File 'lib/fastly/version.rb', line 62 def settings fetcher.get_settings(service_id, number) end |
#upload_main_vcl(name, contents) ⇒ Object
Upload a VCL file for this Version and set as the main VCL
123 124 125 |
# File 'lib/fastly/version.rb', line 123 def upload_main_vcl(name, contents) upload_vcl(name, contents).set_main! end |
#upload_vcl(name, content) ⇒ Object
Upload a VCL file for this Version
116 117 118 119 120 |
# File 'lib/fastly/version.rb', line 116 def upload_vcl(name, content) hash = fetcher.client.post("#{Version.put_path(self)}/vcl", name: name, content: content) return nil if hash.nil? VCL.new(hash, fetcher) end |
#validate ⇒ Object
Validate this Version
147 148 149 150 151 152 153 154 |
# File 'lib/fastly/version.rb', line 147 def validate hash = fetcher.client.get("#{Version.put_path(self)}/validate") valid = ("ok" == hash["status"]) = hash['msg'] [valid, ] end |
#vcl(name, opts = {}) ⇒ Object
Get the named VCL for this version
Won’t return the content of the VCL unless you pass in
:include_content => true
in the opts
132 133 134 |
# File 'lib/fastly/version.rb', line 132 def vcl(name, opts = {}) fetcher.get_vcl(service_id, number, name, opts) end |