Class: Route53::DNSRecord
- Inherits:
-
Object
- Object
- Route53::DNSRecord
- Defined in:
- lib/route53/dns_record.rb
Instance Attribute Summary collapse
-
#ident ⇒ Object
readonly
Returns the value of attribute ident.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
-
#zone_apex ⇒ Object
readonly
Returns the value of attribute zone_apex.
Instance Method Summary collapse
- #create(comment = nil) ⇒ Object
- #delete(comment = nil) ⇒ Object
- #gen_change_xml(xml, action) ⇒ Object
-
#initialize(name, type, ttl, values, zone, zone_apex = nil, weight = nil, ident = nil, evaluate_target_health = false) ⇒ DNSRecord
constructor
A new instance of DNSRecord.
- #to_s ⇒ Object
-
#update(name, type, ttl, values, comment = nil, zone_apex = nil) ⇒ Object
Need to modify to a param hash.
-
#update_dirty(name, type, ttl, values, zone_apex = nil) ⇒ Object
Returns the raw array so the developer can update large batches manually Need to modify to a param hash.
Constructor Details
#initialize(name, type, ttl, values, zone, zone_apex = nil, weight = nil, ident = nil, evaluate_target_health = false) ⇒ DNSRecord
Returns a new instance of DNSRecord.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/route53/dns_record.rb', line 11 def initialize(name,type,ttl,values,zone,zone_apex=nil,weight=nil,ident=nil, evaluate_target_health=false) @name = name unless @name.end_with?(".") @name += "." end @type = type.upcase @ttl = ttl @values = values @zone = zone @zone_apex = zone_apex @weight = weight @ident = ident @evaluate_target_health = evaluate_target_health end |
Instance Attribute Details
#ident ⇒ Object (readonly)
Returns the value of attribute ident.
8 9 10 |
# File 'lib/route53/dns_record.rb', line 8 def ident @ident end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/route53/dns_record.rb', line 3 def name @name end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
5 6 7 |
# File 'lib/route53/dns_record.rb', line 5 def ttl @ttl end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/route53/dns_record.rb', line 4 def type @type end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
6 7 8 |
# File 'lib/route53/dns_record.rb', line 6 def values @values end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
7 8 9 |
# File 'lib/route53/dns_record.rb', line 7 def weight @weight end |
#zone_apex ⇒ Object (readonly)
Returns the value of attribute zone_apex.
9 10 11 |
# File 'lib/route53/dns_record.rb', line 9 def zone_apex @zone_apex end |
Instance Method Details
#create(comment = nil) ⇒ Object
58 59 60 |
# File 'lib/route53/dns_record.rb', line 58 def create(comment=nil) @zone.perform_actions([{:action => "CREATE", :record => self}],comment) end |
#delete(comment = nil) ⇒ Object
54 55 56 |
# File 'lib/route53/dns_record.rb', line 54 def delete(comment=nil) @zone.perform_actions([{:action => "DELETE", :record => self}],comment) end |
#gen_change_xml(xml, action) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/route53/dns_record.rb', line 26 def gen_change_xml(xml,action) xml.Change { |change| change.Action(action.upcase) change.ResourceRecordSet { |record| record.Name(@name) record.Type(@type) record.SetIdentifier(@ident) if @ident record.Weight(@weight) if @weight record.TTL(@ttl) unless @zone_apex if @zone_apex record.AliasTarget { |targets| targets.HostedZoneId(@zone_apex) targets.DNSName(@values.first) targets.EvaluateTargetHealth(@evaluate_target_health) } else record.ResourceRecords { |resources| @values.each { |val| resources.ResourceRecord { |record| record.Value(val) } } } end } } end |
#to_s ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/route53/dns_record.rb', line 89 def to_s if @weight "#{@name} #{@type} #{@ttl} '#{@ident}' #{@weight} #{@values.join(",")}" elsif @zone_apex "#{@name} #{@type} #{@zone_apex} #{@values.join(",")}" else "#{@name} #{@type} #{@ttl} #{@values.join(",")}" end end |
#update(name, type, ttl, values, comment = nil, zone_apex = nil) ⇒ Object
Need to modify to a param hash
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/route53/dns_record.rb', line 63 def update(name,type,ttl,values,comment=nil, zone_apex = nil) prev = self.clone @name = name unless name.nil? @type = type unless type.nil? @ttl = ttl unless ttl.nil? @values = values unless values.nil? @zone_apex = zone_apex unless zone_apex.nil? @zone.perform_actions([ {:action => "DELETE", :record => prev}, {:action => "CREATE", :record => self}, ],comment) end |
#update_dirty(name, type, ttl, values, zone_apex = nil) ⇒ Object
Returns the raw array so the developer can update large batches manually Need to modify to a param hash
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/route53/dns_record.rb', line 78 def update_dirty(name,type,ttl,values,zone_apex = nil) prev = self.clone @name = name unless name.nil? @type = type unless type.nil? @ttl = ttl unless ttl.nil? @values = values unless values.nil? @zone_apex = zone_apex unless zone_apex.nil? return [{:action => "DELETE", :record => prev}, {:action => "CREATE", :record => self}] end |