class AWS::Route53::ResourceRecordSet

# Modify resource record set

rrsets = AWS::Route53::HostedZone.new(hosted_zone_id).rrsets
rrset = rrsets['foo.example.com.', 'A']
rrset.ttl = 3600
rrset.update

# Delete existing resource record set

rrsets = AWS::Route53::HostedZone.new(hosted_zone_id).rrsets
rrset = rrsets['foo.example.com.', 'A']
rrset.delete

@attr_reader [Hash] alias_target

@attr_reader [Integer] weight

@attr_reader [String] region

@attr_reader [Integer] ttl

@attr_reader [Array<Hash>] resource_records

Attributes

change_info[R]

@return [ChangeInfo]

hosted_zone_id[R]

@return [String] The hosted zone ID.

identifier[R]

@return [String]

name[R]

@return [String] name

set_identifier[R]

@return [String]

type[R]

@return [String]

Public Class Methods

new(name, type, options = {}) click to toggle source

@api private

Calls superclass method AWS::Core::Resource.new
# File lib/aws/route_53/resource_record_set.rb, line 43
def initialize name, type, options = {}
  @name = name
  @type = type
  @set_identifier = options[:set_identifier]
  @hosted_zone_id = options[:hosted_zone_id]
  @change_info = options[:change_info]
  @create_options = {}
  super
end

Public Instance Methods

alias_target=(new_target) click to toggle source

@param [Hash] new_target @return [Hash]

# File lib/aws/route_53/resource_record_set.rb, line 94
def alias_target= new_target
  @create_options[:alias_target] = new_target
end
delete(options = {}) click to toggle source

Delete resource record set. @param [Hash] options Options for change batch. @return [ChangeInfo]

# File lib/aws/route_53/resource_record_set.rb, line 190
def delete options = {}
  batch = new_change_batch(options)
  batch << new_delete_request

  change_info = batch.call()
end
exists?() click to toggle source

@return [Boolean] Returns `true` if this rrset exists.

# File lib/aws/route_53/resource_record_set.rb, line 159
def exists?
  !get_resource.data[:resource_record_sets].find { |details|
    if set_identifier
      details[:name] == name and details[:type] == type and details[:set_identifier] == set_identifier
    else
      details[:name] == name and details[:type] == type
    end
  }.nil?
end
failover=(new_failover) click to toggle source
# File lib/aws/route_53/resource_record_set.rb, line 130
def failover= new_failover
  @create_options[:failover] = new_failover
end
geo_location=(new_geo_location) click to toggle source
# File lib/aws/route_53/resource_record_set.rb, line 124
def geo_location= new_geo_location
  @create_options[:geo_location] = new_geo_location
end
health_check_id=(new_health_check_id) click to toggle source
# File lib/aws/route_53/resource_record_set.rb, line 136
def health_check_id= new_health_check_id
  @create_options[:health_check_id] = new_health_check_id
end
identifier=(new_identifier)
Alias for: set_identifier=
name=(new_name) click to toggle source

@param [String] new_name @return [String]

# File lib/aws/route_53/resource_record_set.rb, line 64
def name= new_name
  @create_options[:name] = new_name
end
new_change_batch(options = {}) click to toggle source

Return a new change batch for this hosted zone. @param [Hash] options Options for change batch. @return [ChangeBatch]

# File lib/aws/route_53/resource_record_set.rb, line 200
def new_change_batch options = {}
  ChangeBatch.new(hosted_zone_id, options.merge(:config => config))
end
new_create_request() click to toggle source

Return the create request that update would include in its change batch. Note that update also includes a delete request. @return [CreateRequest]

# File lib/aws/route_53/resource_record_set.rb, line 207
def new_create_request
  create_options = delete_options.merge(@create_options)
  CreateRequest.new(create_options[:name], create_options[:type],
                    create_options)
end
new_delete_request() click to toggle source

Return a delete request that would delete this resource record set. @return [DeleteRequest]

# File lib/aws/route_53/resource_record_set.rb, line 215
def new_delete_request
  options = delete_options
  DeleteRequest.new(options[:name], options[:type], options)
end
region=(new_region) click to toggle source

@param [String] new_region @return [String]

# File lib/aws/route_53/resource_record_set.rb, line 110
def region= new_region
  @create_options[:region] = new_region
end
resource_records=(new_rrs) click to toggle source

@param [Array<Hash>] new_rrs @return [Array<Hash>]

# File lib/aws/route_53/resource_record_set.rb, line 144
def resource_records= new_rrs
  @create_options[:resource_records] = new_rrs
end
set_identifier=(new_identifier) click to toggle source

@param [String] new_identifier @return [String]

# File lib/aws/route_53/resource_record_set.rb, line 84
def set_identifier= new_identifier
  @create_options[:set_identifier] = new_identifier
end
Also aliased as: identifier=
ttl=(new_ttl) click to toggle source

@param [Integer] new_ttl @return [Integer]

# File lib/aws/route_53/resource_record_set.rb, line 118
def ttl= new_ttl
  @create_options[:ttl] = new_ttl
end
type=(new_type) click to toggle source

@param [String] new_type @return [String]

# File lib/aws/route_53/resource_record_set.rb, line 73
def type= new_type
  @create_options[:type] = new_type
end
update(options = {}) click to toggle source

Update values of resource record set. @param [Hash] options Options for change batch. @return [ResourceRecordSet] New resource record set with current value.

# File lib/aws/route_53/resource_record_set.rb, line 172
def update options = {}
  batch = new_change_batch(options)
  AWS.memoize do
    batch << new_delete_request
    batch << new_create_request
  end

  @change_info = batch.call()
  @name = @create_options[:name] || @name
  @type = @create_options[:type] || @type
  @set_identifier = @create_options[:set_identifier] || @set_identifier
  @create_options = {}
  self
end
weight=(new_weight) click to toggle source

@param [Integer] new_weight @return [Integer]

# File lib/aws/route_53/resource_record_set.rb, line 102
def weight= new_weight
  @create_options[:weight] = new_weight
end

Protected Instance Methods

get_resource(attr_name = nil) click to toggle source
# File lib/aws/route_53/resource_record_set.rb, line 226
def get_resource attr_name = nil
  options = {}
  options[:start_record_name] = name
  options[:start_record_type] = type
  options[:start_record_identifier] = set_identifier if set_identifier
  options[:hosted_zone_id] = hosted_zone_id

  client.list_resource_record_sets(options)
end
resource_identifiers() click to toggle source
# File lib/aws/route_53/resource_record_set.rb, line 222
def resource_identifiers
  [[:name, name], [:type, type], [:set_identifier, set_identifier]]
end

Private Instance Methods

delete_options() click to toggle source

Format a hash of options that can be used to initialize a change request. @return [Hash]

# File lib/aws/route_53/resource_record_set.rb, line 241
def delete_options
  options = {:name => name, :type => type}
  AWS.memoize do
    options[:set_identifier] = set_identifier if set_identifier
    options[:alias_target] = alias_target if alias_target
    options[:weight] = weight if weight
    options[:region] = region if region
    options[:ttl] = ttl if ttl
    options[:resource_records] = resource_records if resource_records && !resource_records.empty?
    options[:geo_location] = geo_location if geo_location
    options[:failover] = failover if failover
    options[:health_check_id] = health_check_id if health_check_id
  end
  options
end