Class: Fog::Rackspace::CDNV2::Service

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/cdn_v2/service.rb

Constant Summary collapse

UUID_REGEX =
/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Service

Returns a new instance of Service.



23
24
25
26
# File 'lib/fog/rackspace/models/cdn_v2/service.rb', line 23

def initialize(options={})
  self.operations = []
  super
end

Instance Attribute Details

#operationsObject

Returns the value of attribute operations.



8
9
10
# File 'lib/fog/rackspace/models/cdn_v2/service.rb', line 8

def operations
  @operations
end

Instance Method Details

#add_domain(domain, options = {}) ⇒ Object



28
29
30
31
32
# File 'lib/fog/rackspace/models/cdn_v2/service.rb', line 28

def add_domain(domain, options={})
  self.domains ||= []
  self.domains << {domain: domain}.merge(options)
  self.domains
end

#add_operation(options = {}) ⇒ Object



40
41
42
# File 'lib/fog/rackspace/models/cdn_v2/service.rb', line 40

def add_operation(options={})
  self.operations << options
end

#add_origin(origin, options = {}) ⇒ Object



34
35
36
37
38
# File 'lib/fog/rackspace/models/cdn_v2/service.rb', line 34

def add_origin(origin, options={})
  self.origins ||= []
  self.origins << {origin: origin}.merge(options)
  self.origins
end

#destroyObject



55
56
57
# File 'lib/fog/rackspace/models/cdn_v2/service.rb', line 55

def destroy
  service.delete_service(self)
end

#destroy_assets(options = {}) ⇒ Object



59
60
61
# File 'lib/fog/rackspace/models/cdn_v2/service.rb', line 59

def destroy_assets(options={})
  service.delete_assets(self, options)
end

#saveObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/rackspace/models/cdn_v2/service.rb', line 44

def save
  if id.nil?
    data = service.create_service(self)
    loc  = data.headers["Location"]
    id   = UUID_REGEX.match(loc)[0]
    merge_attributes(id: id)
  else
    service.update_service(self)
  end
end