Class: Route

Inherits:
Object
  • Object
show all
Includes:
ConfigReader
Defined in:
lib/route.rb

Constant Summary collapse

@@instance =
nil

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConfigReader

#param

Constructor Details

#initialize ⇒ Route

Returns a new instance of Route.



19
20
21
22
# File 'lib/route.rb', line 19

def initialize
  @common = CommonRestUtils.new(param("rest_base_url") + "mcc/")
  @availables = { }
end

Class Method Details

.do ⇒ Object



11
12
13
14
15
16
17
# File 'lib/route.rb', line 11

def self.do
  if @@instance
    @@instance
  else
    @@instance = Route.new
  end
end

Instance Method Details

#add_zone ⇒ Object



60
61
# File 'lib/route.rb', line 60

def add_zone()
end

#copy_zone(from, to) ⇒ Object



49
50
51
52
53
# File 'lib/route.rb', line 49

def copy_zone(from, to)
  suffix = customer_suffix("dns/routezone/copy")
  body = {:FromDomainName => from, :ToDomainName => to}
  @common.callMethod(suffix, :post, body)
end

#customer_suffix(suffix) ⇒ Object



24
25
26
# File 'lib/route.rb', line 24

def customer_suffix(suffix)
  "customers/" + param("acct-num") + "/" + suffix
end

#delete_zone(id) ⇒ Object



55
56
57
58
# File 'lib/route.rb', line 55

def delete_zone(id)
  suffix = customer_suffix("dns/routezone/" + id)
  @common.callMethod(suffix, :delete)
end

#get_all_zones(status = nil, zone_type = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/route.rb', line 32

def get_all_zones(status=nil, zone_type=nil)
  suffix = "dns/routezones"
  if status != nil && zone_type != nil
    suffix = suffix + "?status=" + status + "&zonetype=" + zone_type
  elsif status != nil
    suffix = suffix + "?status=" + status
  elsif zone_type != nil
    suffix = suffix + "?zonetype=" + zone_type
  end
  @common.callMethod(customer_suffix(suffix), :get)
end

#get_available(data) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/route.rb', line 79

def get_available(data)
  if @availables[data]
    @availables[data]
  else
    suffix =
      {:zone_type => "routezonetypes",
      :record_type => "routezonerecordtypes",
      :zone_status => "routezonestatus",
      :route_group => "routegrouptypes",
      :http_method => "routehttpmethodtypes",
      :ip_version => "routehealthcheckipversion",
      :hc_type => "routehealthchecktypes",
      :hc_rm => "routereintegrationmethodtypes"}[data]
    @availables[data] = @common.callMethod(non_customer_suffix(suffix), :get)
  end
end

#get_available_hc_rm ⇒ Object



124
125
126
# File 'lib/route.rb', line 124

def get_available_hc_rm()
  get_available(:hc_rm, "routereintegrationmethodtypes")
end

#get_available_hc_types ⇒ Object



120
121
122
# File 'lib/route.rb', line 120

def get_available_hc_types()
  get_available(:hc_type, "routehealthchecktypes")
end

#get_available_http_methods ⇒ Object



112
113
114
# File 'lib/route.rb', line 112

def get_available_http_methods()
  get_available(:http_method, "routehttpmethodtypes")
end

#get_available_ip_versions ⇒ Object



116
117
118
# File 'lib/route.rb', line 116

def get_available_ip_versions()
  get_available(:ip_version, "routehealthcheckipversion")
end

#get_available_record_types ⇒ Object



100
101
102
# File 'lib/route.rb', line 100

def get_available_record_types()
  get_available(:record_type, "routezonerecordtypes")
end

#get_available_route_groups ⇒ Object



108
109
110
# File 'lib/route.rb', line 108

def get_available_route_groups()
  get_available(:route_group, "routegrouptypes")
end

#get_available_zone_statuses ⇒ Object



104
105
106
# File 'lib/route.rb', line 104

def get_available_zone_statuses()
  get_available(:zone_status, "routezonestatus")
end

#get_available_zone_types ⇒ Object



96
97
98
# File 'lib/route.rb', line 96

def get_available_zone_types()
  get_available(:zone_type)
end

#get_zone(id, name) ⇒ Object



44
45
46
47
# File 'lib/route.rb', line 44

def get_zone(id, name)
  suffix = "dns/routezone?id=" + id + "&name=" + name
  @common.callMethod(customer_suffix(suffix), :get)
end

#non_customer_suffix(suffix) ⇒ Object



28
29
30
# File 'lib/route.rb', line 28

def non_customer_suffix(suffix)
  "/dns/" + suffix
end

#xlate_id(symbol, id) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/route.rb', line 71

def xlate_id(symbol, id)
  get_available(symbol).each { |hash|
    if hash["Id"] == id
      return hash["Name"]
    end
  }
end

#xlate_name(symbol, name) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/route.rb', line 63

def xlate_name(symbol, name)
  get_available(symbol).each { |hash|
    if hash["Name"] == name
      return hash["Id"]
    end
  }
end