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

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

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?

Returns:

  • (Boolean)


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

#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



104
105
106
107
108
109
110
111
112
113
# File 'lib/fastly/version.rb', line 104

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

Returns:

  • (Boolean)


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_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(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



132
133
134
135
# File 'lib/fastly/version.rb', line 132

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



127
128
129
# File 'lib/fastly/version.rb', line 127

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