Class: Fastly::Version

Inherits:
Base
  • Object
show all
Defined in:
lib/fastly/version.rb

Overview

An iteration of your configuration

Instance Attribute Summary collapse

Attributes inherited from Base

#fetcher

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_hash, #delete!, #initialize, list_path, path, #save!

Constructor Details

This class inherits a constructor from Fastly::Base

Instance Attribute Details

#activeObject

Returns the value of attribute active.



4
5
6
# File 'lib/fastly/version.rb', line 4

def active
  @active
end

#commentObject

Returns the value of attribute comment.



4
5
6
# File 'lib/fastly/version.rb', line 4

def comment
  @comment
end

#deployedObject

Returns the value of attribute deployed.



4
5
6
# File 'lib/fastly/version.rb', line 4

def deployed
  @deployed
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/fastly/version.rb', line 4

def name
  @name
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/fastly/version.rb', line 4

def number
  @number
end

#service_idObject

Returns the value of attribute service_id.



4
5
6
# File 'lib/fastly/version.rb', line 4

def service_id
  @service_id
end

#stagingObject

Returns the value of attribute staging.



4
5
6
# File 'lib/fastly/version.rb', line 4

def staging
  @staging
end

#testingObject

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.



100
101
102
103
104
# File 'lib/fastly/version.rb', line 100

def self.create_new(fetcher, opts)
  hash = fetcher.client.post(Fastly::Version.post_path(opts))
  return nil if hash.nil?
  return Fastly::Version.new(hash, fetcher)
end

Instance Method Details

#activate!Object

Activate this version



81
82
83
84
# File 'lib/fastly/version.rb', line 81

def activate!
  hash = fetcher.client.put(Fastly::Version.put_path(self)+"/activate")
  return !hash.nil?
end

#active?Boolean

Is version active?



76
77
78
# File 'lib/fastly/version.rb', line 76

def active?
  return @active.to_i > 0
end

#cloneObject

Clone this Version



93
94
95
96
97
# File 'lib/fastly/version.rb', line 93

def clone
  hash = fetcher.client.put(Fastly::Version.put_path(self)+"/clone")
  return nil if hash.nil?
  return Fastly::Version.new(hash, fetcher)
end

#deactivate!Object

Deactivate this version



87
88
89
90
# File 'lib/fastly/version.rb', line 87

def deactivate!
   hash = fetcher.client.put(Fastly::Version.put_path(self)+"/deactivate")
   return !hash.nil?
end

#delete_vcl(name) ⇒ Object

Delete a VCL file for this Version



144
145
146
147
148
# File 'lib/fastly/version.rb', line 144

def delete_vcl(name)
  hash = fetcher.client.delete(Fastly::Version.put_path(self)+"/vcl/" + name )
  return nil if hash.nil?
  return hash
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



111
112
113
114
115
116
117
118
119
120
# File 'lib/fastly/version.rb', line 111

def generated_vcl(opts={})
  hash = fetcher.client.get(Fastly::Version.put_path(self)+"/generated_vcl", opts)
  opts = {
    'content'    => hash['vcl'] || hash['content'],
    'name'       => hash['md5'],
    'version'    => hash['version'],
    'service_id' => hash['service']
  }
  return Fastly::VCL.new(opts, fetcher)
end

#locked=(is_locked) ⇒ Object

Set whether this Version is locked



61
62
63
# File 'lib/fastly/version.rb', line 61

def locked=(is_locked)
  @locked = is_locked ? "1" : "0"
end

#locked?Boolean

Is this Version locked



56
57
58
# File 'lib/fastly/version.rb', line 56

def locked?
  return @locked.to_i > 0
end

#serviceObject

Get the Service object this Version belongs to



66
67
68
# File 'lib/fastly/version.rb', line 66

def service
  fetcher.get(Fastly::Service, service_id)
end

#settingsObject

Get the Settings object for this Version



71
72
73
# File 'lib/fastly/version.rb', line 71

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



130
131
132
# File 'lib/fastly/version.rb', line 130

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



123
124
125
126
127
# File 'lib/fastly/version.rb', line 123

def upload_vcl(name, content)
  hash = fetcher.client.post(Fastly::Version.put_path(self)+"/vcl", :name => name, :content => content)
  return nil if hash.nil?
  return Fastly::VCL.new(hash, fetcher)
end

#validateObject

Validate this Version



151
152
153
154
# File 'lib/fastly/version.rb', line 151

def validate
  hash = fetcher.client.get(Fastly::Version.put_path(self)+"/validate")
  return !hash.nil?
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



139
140
141
# File 'lib/fastly/version.rb', line 139

def vcl(name, opts={})
  fetcher.get_vcl(service_id, number, name, opts)
end