Class: Fog::Vcloud::Terremark::Ecloud::InternetService

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/vcloud/terremark/ecloud/models/internet_service.rb

Instance Attribute Summary

Attributes inherited from Model

#loaded

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#load_unless_loaded!, #reload

Methods inherited from Model

#initialize, #inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#backup_service_uriObject



62
63
64
65
66
# File 'lib/fog/vcloud/terremark/ecloud/models/internet_service.rb', line 62

def backup_service_uri
  if backup_service_data
    backup_service_data[:Href]
  end
end

#backup_service_uri=(new_value) ⇒ Object



68
69
70
71
72
# File 'lib/fog/vcloud/terremark/ecloud/models/internet_service.rb', line 68

def backup_service_uri=(new_value)
  self.backup_service_data = {
    :Href => new_value
  }
end

#deleteObject



23
24
25
26
27
# File 'lib/fog/vcloud/terremark/ecloud/models/internet_service.rb', line 23

def delete
  requires :href

  connection.delete_internet_service( href )
end

#monitor=(new_monitor = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/vcloud/terremark/ecloud/models/internet_service.rb', line 38

def monitor=(new_monitor = {})
  if new_monitor.nil? || new_monitor.empty?
    attributes[:monitor] = nil
  elsif new_monitor.is_a?(Hash)
    attributes[:monitor] = {}
    attributes[:monitor][:type] = new_monitor[:MonitorType] || new_monitor[:type]
    attributes[:monitor][:url_send_string] = new_monitor[:UrlSendString] || new_monitor[:url_send_string]
    attributes[:monitor][:http_headers] = new_monitor[:HttpHeader] || new_monitor[:http_headers]
    attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers].split("\n") unless attributes[:monitor][:http_headers].is_a?(Array)
    attributes[:monitor][:receive_string] = new_monitor[:ReceiveString] || new_monitor[:receive_string]
    attributes[:monitor][:interval] = new_monitor[:Interval] || new_monitor[:interval]
    attributes[:monitor][:response_timeout] = new_monitor[:ResponseTimeOut] || new_monitor[:response_timeout]
    attributes[:monitor][:downtime] = new_monitor[:DownTime] || new_monitor[:downtime]
    attributes[:monitor][:retries] = new_monitor[:Retries] || new_monitor[:retries]
    attributes[:monitor][:is_enabled] = new_monitor[:IsEnabled] || new_monitor[:is_enabled]
  else
    raise RuntimeError.new("monitor needs to either be nil or a Hash")
  end
end

#nodesObject



58
59
60
# File 'lib/fog/vcloud/terremark/ecloud/models/internet_service.rb', line 58

def nodes
  @nodes ||= Fog::Vcloud::Terremark::Ecloud::Nodes.new( :connection => connection, :href => href + "/nodeServices" )
end

#saveObject



29
30
31
32
33
34
35
36
# File 'lib/fog/vcloud/terremark/ecloud/models/internet_service.rb', line 29

def save
  if new_record?
    result = connection.add_internet_service( collection.href, _compose_service_data )
    merge_attributes(result.body)
  else
    connection.configure_internet_service( href, _compose_service_data, _compose_ip_data )
  end
end