Class: RightAws::Route53Interface
- Inherits:
-
RightAwsBase
- Object
- RightAwsBase
- RightAws::Route53Interface
- Includes:
- RightAwsBaseInterface
- Defined in:
- lib/route_53/right_route_53_interface.rb
Overview
RightAws::Route53Interface – Amazon Route 53 web service interface.
The RightAws::Route53Interface class provides a complete interface to Amazon Route 53: a web service that enables you to manage your DNS service.
For explanations of the semantics of each call, please refer to Amazon’s documentation at aws.amazon.com/documentation/route53/
Examples:
# Create Route53 handler
r53 = RightAws::Route53Interface.new(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
#------------------------
# Create Hosted Zone
#------------------------
hosted_zone_config = {
:name => 'my-awesome-site.com.',
:config => {
:comment => 'My test site!'
}
}
r53.create_hosted_zone(hosted_zone_config) #=>
{:name_servers=>
["ns-1115.awsdns-11.org",
"ns-696.awsdns-23.net",
"ns-1963.awsdns-53.co.uk",
"ns-362.awsdns-45.com"],
:aws_id=>"/hostedzone/Z1K6NCF0EB26FB",
:caller_reference=>"1295424990-710392-gqMuw-KcY8F-LFlrB-SQhp9",
:config=>{:comment=>"My test site!"},
:change_info=>
{:status=>"PENDING",
:aws_id=>"/change/C23QGMT8XTCAJY",
:submitted_at=>"2011-01-19T08:16:31.046Z"},
:name=>"my-awesome-site.com."}
# List Hosted Zones
r53.list_hosted_zones #=> []
[{:aws_id=>"/hostedzone/Z1K6NCF0EB26FB",
:caller_reference=>"1295424990-710392-gqMuw-KcY8F-LFlrB-SQhp9",
:config=>{:comment=>"My test site!"},
:name=>"my-awesome-site.com."}]
#--------------------------------
# Manage DNS Records and Changes
#--------------------------------
# Create DNS Records
resource_record_sets = [ { :name => 'www1.my-awesome-site.com.',
:type => 'NS',
:ttl => 600,
:resource_records => 'www.mysite.com' },
{ :name => 'www2.my-awesome-site.com.',
:type => 'A',
:ttl => 600,
:resource_records => ['10.0.0.1'] } ]
r53.create_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'my first set of records') #=>
{ :status=>"PENDING",
:aws_id=>"/change/C2C6IGNRTKA0AY",
:submitted_at=>"2011-01-19T08:29:26.160Z" }
# Delete DNS records
r53.delete_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'I dont need them any more') #=>
{ :status=>"PENDING",
:aws_id=>"/change/C1CYJ10EZBFLO7",
:submitted_at=>"2011-01-19T08:26:41.220Z" }
# Create or delete DNS records (:action key must be provided):
resource_record_sets = [ { :action => :create,
:name => 'www1.my-awesome-site.com.',
:type => 'NS',
:ttl => 600,
:resource_records => 'www.mysite.com' },
{ :action => :delete,
:name => 'www2.my-awesome-site.com.',
:type => 'A',
:ttl => 600,
:resource_records => ['10.0.0.1'] } ]
r53.change_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'do change records')
{ :status=>"PENDING",
:aws_id=>"/change/C2PWXVECN794LK",
:submitted_at=>"2011-01-19T08:31:33.301Z" }
# List DNS Records
r53.list_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB") #=>
[{:type=>"NS",
:ttl=>172800,
:resource_records=>
["ns-1115.awsdns-11.org.",
"ns-696.awsdns-23.net.",
"ns-1963.awsdns-53.co.uk.",
"ns-362.awsdns-45.com."],
:name=>"my-awesome-site.com."},
{:type=>"SOA",
:ttl=>900,
:resource_records=>
["ns-1115.awsdns-11.org. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"],
:name=>"my-awesome-site.com."},
{:type=>"NS",
:ttl=>600,
:resource_records=>["www.mysite.com"],
:name=>"www1.my-awesome-site.com."}]
# Get Change info
r53.get_change("/change/C2C6IGNRTKA0AY")
{:status=>"INSYNC",
:aws_id=>"/change/C2C6IGNRTKA0AY",
:submitted_at=>"2011-01-19T08:29:26.160Z"}
#------------------------
# Delete Hosted Zone
#------------------------
# Get a list of DNS records I have created (the first 2 records were added by Amazon and cannot be deleted)
resource_record_sets = r53.list_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB")
resource_record_sets.shift
resource_record_sets.shift
# Delete them all
delete_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'kill all records I have created') #=>
{ :status=>"PENDING",
:aws_id=>"/change/C6NCO8Z50MHXV",
:submitted_at=>"2011-01-19T08:46:37.307Z" }
# Delete Hosted Zone
r53.delete_hosted_zone("/hostedzone/Z1K6NCF0EB26FB") #=>
{ :status=>"PENDING",
:aws_id=>"/change/C3OJ31D4V5P2LU",
:submitted_at=>"2011-01-19T08:46:37.530Z" }
Defined Under Namespace
Classes: GetChangeParser, GetHostedZoneParser, ListHostedZonesParser, ListResourceRecordSetsParser
Constant Summary collapse
- API_VERSION =
"2010-10-01"
- DEFAULT_HOST =
"route53.amazonaws.com"
- DEFAULT_PATH =
'/'
- DEFAULT_PROTOCOL =
'https'
- DEFAULT_PORT =
443
- @@bench =
AwsBenchmarkingBlock.new
Constants included from RightAwsBaseInterface
RightAws::RightAwsBaseInterface::BLOCK_DEVICE_KEY_MAPPING, RightAws::RightAwsBaseInterface::DEFAULT_SIGNATURE_VERSION
Constants inherited from RightAwsBase
RightAws::RightAwsBase::AMAZON_PROBLEMS, RightAws::RightAwsBase::RAISE_ON_TIMEOUT_ON_ACTIONS
Instance Attribute Summary
Attributes included from RightAwsBaseInterface
#aws_access_key_id, #aws_secret_access_key, #cache, #connection, #last_errors, #last_request, #last_request_id, #last_response, #logger, #params, #signature_version
Class Method Summary collapse
Instance Method Summary collapse
-
#change_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') ⇒ Object
Create or delete DNS records.
-
#create_hosted_zone(config) ⇒ Object
Create new hosted zone.
-
#create_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') ⇒ Object
Create DNS records.
-
#delete_hosted_zone(hosted_zone_aws_id) ⇒ Object
Delete hosted zone.
-
#delete_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') ⇒ Object
Delete DNS records.
-
#expand_change_id(aws_id) ⇒ Object
:nodoc:.
-
#expand_hosted_zone_id(aws_id) ⇒ Object
:nodoc:.
-
#generate_request(method, path, params = {}, body = nil, headers = {}) ⇒ Object
Generates request hash for REST API.
-
#get_change(change_aws_id) ⇒ Object
Get the current state of a change request.
-
#get_hosted_zone(hosted_zone_aws_id) ⇒ Object
Get your hosted zone.
-
#hosted_zone_config_to_xml(config) ⇒ Object
:nodoc:.
-
#incrementally_list_hosted_zones(path, parser, params = {}, &block) ⇒ Object
:nodoc:.
-
#incrementally_list_resource_records(path, parser, params = {}, &block) ⇒ Object
:nodoc:.
-
#initialize(aws_access_key_id = nil, aws_secret_access_key = nil, params = {}) ⇒ Route53Interface
constructor
Create a new handle to an Route53 account.
-
#list_hosted_zones ⇒ Object
List your hosted zones.
-
#list_resource_record_sets(hosted_zone_aws_id, options = {}) ⇒ Object
List your resource record sets.
-
#request_info(request, parser, &block) ⇒ Object
Sends request to Amazon and parses the response.
-
#resource_record_sets_to_xml(resource_record_changes, comment) ⇒ Object
:nodoc:.
Methods included from RightAwsBaseInterface
#amazonize_block_device_mappings, #amazonize_list, #cache_hits?, caching, caching=, #caching?, #destroy_connection, #generate_request_impl, #get_connection, #get_connections_storage, #get_server_url, #incrementally_list_items, #init, #on_exception, #request_cache_or_info, #request_info_impl, #signed_service_params, #update_cache, #with_connection_options
Methods inherited from RightAwsBase
amazon_problems, amazon_problems=, raise_on_timeout_on_actions, raise_on_timeout_on_actions=
Constructor Details
#initialize(aws_access_key_id = nil, aws_secret_access_key = nil, params = {}) ⇒ Route53Interface
Create a new handle to an Route53 account. All handles share the same per process or per thread HTTP connection to Amazon Route53. Each handle is for a specific account. The params have the following options:
-
:endpoint_url
a fully qualified url to Amazon API endpoint (this overwrites: :server, :port, :service, :protocol). -
:server
: Route53 service host, default: DEFAULT_HOST -
:port
: Route53 service port, default: DEFAULT_PORT -
:protocol
: ‘http’ or ‘https’, default: DEFAULT_PROTOCOL -
:logger
: for log messages, default: RAILS_DEFAULT_LOGGER else STDOUT -
:signature_version
: The signature version : ‘0’,‘1’ or ‘2’(default)
185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/route_53/right_route_53_interface.rb', line 185 def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={}) init({ :name => 'ROUTE_53', :default_host => ENV['ROUTE_53_URL'] ? URI.parse(ENV['ROUTE_53_URL']).host : DEFAULT_HOST, :default_port => ENV['ROUTE_53_URL'] ? URI.parse(ENV['ROUTE_53_URL']).port : DEFAULT_PORT, :default_service => ENV['ROUTE_53_URL'] ? URI.parse(ENV['ROUTE_53_URL']).path : DEFAULT_PATH, :default_protocol => ENV['ROUTE_53_URL'] ? URI.parse(ENV['ROUTE_53_URL']).scheme : DEFAULT_PROTOCOL, :default_api_version => ENV['ROUTE_53_API_VERSION'] || API_VERSION }, aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] , aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'], params) end |
Class Method Details
.bench_service ⇒ Object
171 172 173 |
# File 'lib/route_53/right_route_53_interface.rb', line 171 def self.bench_service @@bench.service end |
.bench_xml ⇒ Object
168 169 170 |
# File 'lib/route_53/right_route_53_interface.rb', line 168 def self.bench_xml @@bench.xml end |
Instance Method Details
#change_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') ⇒ Object
Create or delete DNS records.
resource_record_sets = { :action => :create,
:name => 'm3.mysite.patch-island.com',
:type => 'NS',
:ttl => 600,
:resource_records => 'xxx.mysite.com' },
{ :action => :delete,
:name => 'm2.mysite.patch-island.com',
:type => 'A',
:ttl => 600,
:resource_records => ['10.0.0.1'] }
r53.change_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'KD: Comment#1') #=>
{:status=>"PENDING",
:submitted_at=>"2011-01-18T20:21:56.828Z",
:aws_id=>"/change/C394PNLM1B2P08"}
PS: resource_record_sets must have an :action key set (== :create or :delete) PPS: docs.amazonwebservices.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
472 473 474 475 |
# File 'lib/route_53/right_route_53_interface.rb', line 472 def change_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') link = generate_request('POST', "#{(hosted_zone_aws_id)}/rrset", {}, resource_record_sets_to_xml(resource_record_sets, comment)) request_info(link, GetChangeParser.new(:logger => @logger)) end |
#create_hosted_zone(config) ⇒ Object
Create new hosted zone
config = {
:name => 'mysite.patch-island.com.',
:config => {
:comment => 'My awesome site!'
}
}
r53.create_hosted_zone(config) #=>
{:config=>{:comment=>"My awesome site!"},
:change_info=>
{:status=>"PENDING",
:aws_id=>"/change/C2NOTVGL7IOFFF",
:submitted_at=>"2011-01-18T15:34:18.086Z"},
:aws_id=>"/hostedzone/ZWEC7PPVACGQ4",
:caller_reference=>"1295365357-227168-NfZ4P-VGHWi-Yq0p7-nuN6q",
:name_servers=>
["ns-794.awsdns-35.net",
"ns-459.awsdns-57.com",
"ns-1537.awsdns-00.co.uk",
"ns-1165.awsdns-17.org"],
:name=>"mysite.patch-island.com."}
PS: docs.amazonwebservices.com/Route53/latest/APIReference/index.html?API_CreateHostedZone.html
371 372 373 374 375 |
# File 'lib/route_53/right_route_53_interface.rb', line 371 def create_hosted_zone(config) config[:caller_reference] ||= AwsUtils::generate_unique_token link = generate_request('POST', 'hostedzone', {}, hosted_zone_config_to_xml(config)) request_info(link, GetHostedZoneParser.new(:logger => @logger)) end |
#create_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') ⇒ Object
Create DNS records.
resource_record_sets = { :name => 'm3.mysite.patch-island.com',
:type => 'NS',
:ttl => 600,
:resource_records => 'xxx.mysite.com' },
{ :name => 'm2.mysite.patch-island.com',
:type => 'A',
:ttl => 600,
:resource_records => ['10.0.0.1'] }
r53.create_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'KD: Comment#1') #=>
{:status=>"PENDING",
:submitted_at=>"2011-01-18T20:21:56.828Z",
:aws_id=>"/change/C394PNLM1B2P08"}
PS: docs.amazonwebservices.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
494 495 496 497 |
# File 'lib/route_53/right_route_53_interface.rb', line 494 def create_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') resource_record_sets.each{|rrs| rrs[:action] = :create} change_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment) end |
#delete_hosted_zone(hosted_zone_aws_id) ⇒ Object
Delete hosted zone.
r53.delete_hosted_zone("/hostedzone/Z2P714ENJN23PN") #=>
{:status=>"PENDING",
:submitted_at=>"2011-01-18T15:45:45.060Z",
:aws_id=>"/change/C1PN1SDWZKPTAC"}
PS: docs.amazonwebservices.com/Route53/latest/APIReference/API_DeleteHostedZone.html
406 407 408 409 |
# File 'lib/route_53/right_route_53_interface.rb', line 406 def delete_hosted_zone(hosted_zone_aws_id) link = generate_request('DELETE', (hosted_zone_aws_id)) request_info(link, GetChangeParser.new(:logger => @logger)) end |
#delete_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') ⇒ Object
Delete DNS records.
resource_record_sets = { :name => 'm3.mysite.patch-island.com',
:type => 'NS',
:ttl => 600,
:resource_records => 'xxx.mysite.com' },
{ :name => 'm2.mysite.patch-island.com',
:type => 'A',
:ttl => 600,
:resource_records => ['10.0.0.1'] }
r53.create_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'KD: Comment#1') #=>
{:status=>"PENDING",
:submitted_at=>"2011-01-18T20:21:56.828Z",
:aws_id=>"/change/C394PNLM1B2P08"}
PS: docs.amazonwebservices.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
516 517 518 519 |
# File 'lib/route_53/right_route_53_interface.rb', line 516 def delete_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment = '') resource_record_sets.each{|rrs| rrs[:action] = :delete} change_resource_record_sets(hosted_zone_aws_id, resource_record_sets, comment) end |
#expand_change_id(aws_id) ⇒ Object
:nodoc:
266 267 268 |
# File 'lib/route_53/right_route_53_interface.rb', line 266 def (aws_id) # :nodoc: aws_id[%r{^/change/}] ? aws_id : "/change/#{aws_id}" end |
#expand_hosted_zone_id(aws_id) ⇒ Object
:nodoc:
262 263 264 |
# File 'lib/route_53/right_route_53_interface.rb', line 262 def (aws_id) # :nodoc: aws_id[%r{^/hostedzone/}] ? aws_id : "/hostedzone/#{aws_id}" end |
#generate_request(method, path, params = {}, body = nil, headers = {}) ⇒ Object
Generates request hash for REST API.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/route_53/right_route_53_interface.rb', line 202 def generate_request(method, path, params={}, body=nil, headers={}) # :nodoc: # Params params.delete_if{ |key, val| val.right_blank? } unless params.right_blank? path += "?" + params.to_a.collect{ |key,val| "#{AwsUtils::amz_escape(key)}=#{AwsUtils::amz_escape(val.to_s)}" }.join("&") end # Headers headers['content-type'] ||= 'text/xml' if body headers['date'] = Time.now.httpdate # Auth signature = AwsUtils::sign(@aws_secret_access_key, headers['date']) headers['X-Amzn-Authorization'] = "AWS3-HTTPS AWSAccessKeyId=#{@aws_access_key_id},Algorithm=HmacSHA1,Signature=#{signature}" # Request path = "#{@params[:service]}#{@params[:api_version]}/#{path}" request = "Net::HTTP::#{method.capitalize}".right_constantize.new(path) request.body = body if body # Set request headers headers.each { |key, value| request[key.to_s] = value } # prepare output hash { :request => request, :server => @params[:server], :port => @params[:port], :protocol => @params[:protocol] } end |
#get_change(change_aws_id) ⇒ Object
Get the current state of a change request.
r53.get_change("/change/C1PN1SDWZKPTAC") #=>
{:status=>"INSYNC",
:aws_id=>"/change/C1PN1SDWZKPTAC",
:submitted_at=>"2011-01-18T15:45:45.060Z"}
PS: docs.amazonwebservices.com/Route53/latest/APIReference/API_GetChange.html
531 532 533 534 |
# File 'lib/route_53/right_route_53_interface.rb', line 531 def get_change(change_aws_id) link = generate_request('GET', (change_aws_id)) request_info(link, GetChangeParser.new(:logger => @logger)) end |
#get_hosted_zone(hosted_zone_aws_id) ⇒ Object
Get your hosted zone.
r53.get_hosted_zone("ZWEC7PPVACGQ4") #=>
{:config=>{:comment=>"My awesome site!"},
:aws_id=>"/hostedzone/ZWEC7PPVACGQ4",
:caller_reference=>"1295422234-657482-hfkeo-JFKid-Ldfle-Sdrty",
:name_servers=>
["ns-794.awsdns-35.net",
"ns-459.awsdns-57.com",
"ns-1537.awsdns-00.co.uk",
"ns-1165.awsdns-17.org"],
:name=>"mysite.patch-island.com."}
PS: docs.amazonwebservices.com/Route53/latest/APIReference/API_GetHostedZone.html
392 393 394 395 |
# File 'lib/route_53/right_route_53_interface.rb', line 392 def get_hosted_zone(hosted_zone_aws_id) link = generate_request('GET', (hosted_zone_aws_id)) request_info(link, GetHostedZoneParser.new(:logger => @logger)) end |
#hosted_zone_config_to_xml(config) ⇒ Object
:nodoc:
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/route_53/right_route_53_interface.rb', line 270 def hosted_zone_config_to_xml(config) # :nodoc: config[:caller_reference] ||= AwsUtils::generate_call_reference hosted_zone_config = '' unless config[:config].right_blank? hosted_zone_config = " <HostedZoneConfig>\n" + " <Comment>#{AwsUtils::xml_escape config[:config][:comment]}</Comment>\n" + " </HostedZoneConfig>\n" end # XML "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<CreateHostedZoneRequest xmlns=\"https://#{@params[:server]}/doc/#{API_VERSION}/\">\n" + " <Name>#{config[:name]}</Name>\n" + " <CallerReference>#{config[:caller_reference]}</CallerReference>\n" + hosted_zone_config + "</CreateHostedZoneRequest>\n" end |
#incrementally_list_hosted_zones(path, parser, params = {}, &block) ⇒ Object
:nodoc:
233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/route_53/right_route_53_interface.rb', line 233 def incrementally_list_hosted_zones(path, parser, params={}, &block) # :nodoc: opts = {} opts['MaxItems'] = params[:max_items] if params[:max_items] opts['Marker'] = params[:marker] if params[:marker] last_response = nil loop do link = generate_request('GET', path, opts) last_response = request_info(link, parser.new(:logger => @logger)) opts['Marker'] = last_response[:next_marker] break unless block && block.call(last_response) && !last_response[:next_marker].right_blank? end last_response end |
#incrementally_list_resource_records(path, parser, params = {}, &block) ⇒ Object
:nodoc:
247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/route_53/right_route_53_interface.rb', line 247 def incrementally_list_resource_records(path, parser, params={}, &block) # :nodoc: opts = {} opts[:maxitems] = params.delete(:max_items) if params[:max_items] last_response = nil loop do link = generate_request('GET', path, opts) last_response = request_info(link, parser.new(:logger => @logger)) opts[:maxitems] = last_response[:max_items] opts[:name] = last_response[:next_record_name] opts[:type] = last_response[:next_record_type] break unless block && block.call(last_response) && last_response[:is_truncated] end last_response end |
#list_hosted_zones ⇒ Object
List your hosted zones.
r53.list_hosted_zones #=>
[{:config=>{:comment=>"KD1, description"},
:aws_id=>"/hostedzone/Z2P714ENJN23PN",
:caller_reference=>"1295424990-710392-gqMuw-KcY8F-LFlrB-SQhp9",
:name=>"patch-island.com."},
{:config=>{:comment=>"My awesome site!"},
:aws_id=>"/hostedzone/ZWEC7PPVACGQ4",
:caller_reference=>"1295422234-657482-hfkeo-JFKid-Ldfle-Sdrty",
:name=>"mysite.patch-island.com."}, ...]
PS: docs.amazonwebservices.com/Route53/latest/APIReference/API_ListHostedZones.html
337 338 339 340 341 342 343 344 |
# File 'lib/route_53/right_route_53_interface.rb', line 337 def list_hosted_zones result = [] incrementally_list_hosted_zones('hostedzone', ListHostedZonesParser) do |response| result += response[:items] true end result end |
#list_resource_record_sets(hosted_zone_aws_id, options = {}) ⇒ Object
List your resource record sets. Options: :type, :name, :max_items
r53.list_resource_record_sets("/hostedzone/ZWEC7PPVACGQ4") #=>
{:items=>
[{:type=>"NS",
:ttl=>172800,
:name=>"mysite.patch-island.com.",
:resource_records=>
["ns-459.awsdns-57.com.",
"ns-794.awsdns-35.net.",
"ns-1165.awsdns-17.org.",
"ns-1537.awsdns-00.co.uk."]},
{:type=>"SOA",
:ttl=>900,
:name=>"mysite.patch-island.com.",
:resource_records=>
["ns-794.awsdns-35.net. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"]},
{:type=>"NS",
:ttl=>600,
:resource_records=>["xxx.mysite.com"],
:name=>"m1.mysite.patch-island.com."}],
:is_truncated=>false,
:max_items=>100}
PS: docs.amazonwebservices.com/Route53/latest/APIReference/API_ListResourceRecordSets.html
442 443 444 445 446 447 448 449 450 |
# File 'lib/route_53/right_route_53_interface.rb', line 442 def list_resource_record_sets(hosted_zone_aws_id, ={}) = .dup result = [] incrementally_list_resource_records("#{(hosted_zone_aws_id)}/rrset", ListResourceRecordSetsParser, ) do |response| result += response[:items] true end result end |
#request_info(request, parser, &block) ⇒ Object
Sends request to Amazon and parses the response. Raises AwsError if any banana happened.
229 230 231 |
# File 'lib/route_53/right_route_53_interface.rb', line 229 def request_info(request, parser, &block) # :nodoc: request_info_impl(:acf_connection, @@bench, request, parser, &block) end |
#resource_record_sets_to_xml(resource_record_changes, comment) ⇒ Object
:nodoc:
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/route_53/right_route_53_interface.rb', line 287 def resource_record_sets_to_xml(resource_record_changes, comment) # :nodoc: # Comment xml_comment = comment.right_blank? ? '' : " <Comment>#{AwsUtils::xml_escape(comment)}</Comment>\n" # Changes xml_changes = '' resource_record_changes.each do |change| xml_resource_records = Array(change[:resource_records]).map{|record| " <ResourceRecord><Value>#{AwsUtils::xml_escape(record)}</Value></ResourceRecord>\n" }.join('') xml_changes += " <Change>\n" + " <Action>#{AwsUtils::xml_escape(change[:action].to_s.upcase)}</Action>\n" + " <ResourceRecordSet>\n" + " <Name>#{AwsUtils::xml_escape(change[:name])}</Name>\n" + " <Type>#{AwsUtils::xml_escape(change[:type].to_s.upcase)}</Type>\n" + " <TTL>#{AwsUtils::xml_escape(change[:ttl].to_s)}</TTL>\n" + " <ResourceRecords>\n" + xml_resource_records + " </ResourceRecords>\n" + " </ResourceRecordSet>\n" + " </Change>\n" end # XML "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<ChangeResourceRecordSetsRequest xmlns=\"https://#{@params[:server]}/doc/#{API_VERSION}/\">\n" + " <ChangeBatch>\n" + xml_comment + " <Changes>\n" + xml_changes + " </Changes>\n" + " </ChangeBatch>\n" + "</ChangeResourceRecordSetsRequest>\n" end |