Skip to content

Commit

Permalink
Merge pull request #469 from sue445/fix_dns_deprecation_warning
Browse files Browse the repository at this point in the history
Rename DNS::AWS to AWS::DNS
  • Loading branch information
geemus authored Sep 17, 2018
2 parents daa50bb + d6aa7f4 commit 3025957
Show file tree
Hide file tree
Showing 28 changed files with 94 additions and 84 deletions.
5 changes: 1 addition & 4 deletions lib/fog/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ module CDN
autoload :AWS, File.expand_path('../aws/cdn', __FILE__)
end

module DNS
autoload :AWS, File.expand_path('../aws/dns', __FILE__)
end

module AWS
extend Fog::Provider

Expand All @@ -28,6 +24,7 @@ module AWS
autoload :CloudWatch, File.expand_path('../aws/cloud_watch', __FILE__)
autoload :Compute, File.expand_path('../aws/compute', __FILE__)
autoload :DataPipeline, File.expand_path('../aws/data_pipeline', __FILE__)
autoload :DNS, File.expand_path('../aws/dns', __FILE__)
autoload :DynamoDB, File.expand_path('../aws/dynamodb', __FILE__)
autoload :ECS, File.expand_path('../aws/ecs', __FILE__)
autoload :EFS, File.expand_path('../aws/efs', __FILE__)
Expand Down
23 changes: 18 additions & 5 deletions lib/fog/aws/dns.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS < Fog::Service
module AWS
class DNS < Fog::Service
extend Fog::AWS::CredentialFetcher::ServiceMethods

requires :aws_access_key_id, :aws_secret_access_key
Expand Down Expand Up @@ -77,7 +77,7 @@ class Real
# :aws_secret_access_key in order to create a connection
#
# ==== Examples
# dns = Fog::DNS::AWS.new(
# dns = Fog::AWS::DNS.new(
# :aws_access_key_id => your_aws_access_key_id,
# :aws_secret_access_key => your_aws_secret_access_key
# )
Expand Down Expand Up @@ -147,9 +147,9 @@ def _request(params, &block)
else
raise case match[:code]
when 'NoSuchHostedZone', 'NoSuchChange' then
Fog::DNS::AWS::NotFound.slurp(error, match[:message])
Fog::AWS::DNS::NotFound.slurp(error, match[:message])
else
Fog::DNS::AWS::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
Fog::AWS::DNS::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
end
end
end
Expand All @@ -162,4 +162,17 @@ def signature(params)
end
end
end

# @deprecated
module DNS
# @deprecated
class AWS < Fog::AWS::DNS
# @deprecated
# @overrides Fog::Service.new (from the fog-core gem)
def self.new(*)
Fog::Logger.deprecation 'Fog::DNS::AWS is deprecated, please use Fog::AWS::DNS.'
super
end
end
end
end
4 changes: 2 additions & 2 deletions lib/fog/aws/models/dns/record.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS
module AWS
class DNS
class Record < Fog::Model
extend Fog::Deprecation
deprecate :ip, :value
Expand Down
8 changes: 4 additions & 4 deletions lib/fog/aws/models/dns/records.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'fog/aws/models/dns/record'

module Fog
module DNS
class AWS
module AWS
class DNS
class Records < Fog::Collection
attribute :is_truncated, :aliases => ['IsTruncated']
attribute :max_items, :aliases => ['MaxItems']
Expand All @@ -15,7 +15,7 @@ class Records < Fog::Collection

attribute :zone

model Fog::DNS::AWS::Record
model Fog::AWS::DNS::Record

def all(options = {})
requires :zone
Expand Down Expand Up @@ -99,7 +99,7 @@ def get(record_name, record_type = nil, record_identifier = nil)
record
end
end.compact.first
rescue Fog::DNS::AWS::NotFound
rescue Fog::AWS::DNS::NotFound
nil
end

Expand Down
6 changes: 3 additions & 3 deletions lib/fog/aws/models/dns/zone.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# require 'fog/aws/models/dns/records'

module Fog
module DNS
class AWS
module AWS
class DNS
class Zone < Fog::Model
identity :id, :aliases => 'Id'

Expand All @@ -20,7 +20,7 @@ def destroy

def records
@records ||= begin
Fog::DNS::AWS::Records.new(
Fog::AWS::DNS::Records.new(
:zone => self,
:service => service
)
Expand Down
8 changes: 4 additions & 4 deletions lib/fog/aws/models/dns/zones.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'fog/aws/models/dns/zone'

module Fog
module DNS
class AWS
module AWS
class DNS
class Zones < Fog::Collection
attribute :marker, :aliases => 'Marker'
attribute :max_items, :aliases => 'MaxItems'

model Fog::DNS::AWS::Zone
model Fog::AWS::DNS::Zone

def all(options = {})
options[:marker] ||= marker unless marker.nil?
Expand All @@ -19,7 +19,7 @@ def all(options = {})
def get(zone_id)
data = service.get_hosted_zone(zone_id).body
new(data)
rescue Fog::DNS::AWS::NotFound
rescue Fog::AWS::DNS::NotFound
nil
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/change_resource_record_sets.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class ChangeResourceRecordSets < Fog::Parsers::Base
def reset
@response = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/create_hosted_zone.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class CreateHostedZone < Fog::Parsers::Base
def reset
@hosted_zone = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/delete_hosted_zone.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class DeleteHostedZone < Fog::Parsers::Base
def reset
@response = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/get_change.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class GetChange < Fog::Parsers::Base
def reset
@response = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/get_hosted_zone.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class GetHostedZone < Fog::Parsers::Base
def reset
@hosted_zone = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/health_check.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class HealthCheck < Fog::Parsers::Base
def reset
@health_check = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/list_health_checks.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class ListHealthChecks < Fog::Parsers::Base
def reset
@health_checks = []
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/list_hosted_zones.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class ListHostedZones < Fog::Parsers::Base
def reset
@hosted_zones = []
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/dns/list_resource_record_sets.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module DNS
module AWS
module AWS
module DNS
class ListResourceRecordSets < Fog::Parsers::Base
def reset
@resource_record = []
Expand Down
10 changes: 5 additions & 5 deletions lib/fog/aws/requests/dns/change_resource_record_sets.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS
module AWS
class DNS

def self.hosted_zone_for_alias_target(dns_name)
hosted_zones = if dns_name.match(/^dualstack\./)
Expand Down Expand Up @@ -198,7 +198,7 @@ def change_resource_record_sets(zone_id, change_batch, options = {})
request({
:body => body,
:idempotent => true,
:parser => Fog::Parsers::DNS::AWS::ChangeResourceRecordSets.new,
:parser => Fog::Parsers::AWS::DNS::ChangeResourceRecordSets.new,
:expects => 200,
:method => 'POST',
:path => "hostedzone/#{zone_id}/rrset"
Expand Down Expand Up @@ -302,10 +302,10 @@ def change_resource_record_sets(zone_id, change_batch, options = {})
}
response
else
raise Fog::DNS::AWS::Error.new("InvalidChangeBatch => #{errors.join(", ")}")
raise Fog::AWS::DNS::Error.new("InvalidChangeBatch => #{errors.join(", ")}")
end
else
raise Fog::DNS::AWS::NotFound.new("NoSuchHostedZone => A hosted zone with the specified hosted zone ID does not exist.")
raise Fog::AWS::DNS::NotFound.new("NoSuchHostedZone => A hosted zone with the specified hosted zone ID does not exist.")
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/fog/aws/requests/dns/create_health_check.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS
module AWS
class DNS
class Real
require 'fog/aws/parsers/dns/health_check'

Expand Down Expand Up @@ -55,7 +55,7 @@ def create_health_check(ip_address, port, type, options = {})
:expects => 201,
:method => 'POST',
:path => 'healthcheck',
:parser => Fog::Parsers::DNS::AWS::HealthCheck.new
:parser => Fog::Parsers::AWS::DNS::HealthCheck.new
})
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/fog/aws/requests/dns/create_hosted_zone.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS
module AWS
class DNS
class Real
require 'fog/aws/parsers/dns/create_hosted_zone'

Expand Down Expand Up @@ -48,7 +48,7 @@ def create_hosted_zone(name, options = {})

request({
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/#{@version}/"><Name>#{name}</Name>#{optional_tags}</CreateHostedZoneRequest>},
:parser => Fog::Parsers::DNS::AWS::CreateHostedZone.new,
:parser => Fog::Parsers::AWS::DNS::CreateHostedZone.new,
:expects => 201,
:method => 'POST',
:path => "hostedzone"
Expand Down Expand Up @@ -102,7 +102,7 @@ def create_hosted_zone(name, options = {})
}
response
else
raise Fog::DNS::AWS::Error.new("DelegationSetNotAvailable => Amazon Route 53 allows some duplication, but Amazon Route 53 has a maximum threshold of duplicated domains. This error is generated when you reach that threshold. In this case, the error indicates that too many hosted zones with the given domain name exist. If you want to create a hosted zone and Amazon Route 53 generates this error, contact Customer Support.")
raise Fog::AWS::DNS::Error.new("DelegationSetNotAvailable => Amazon Route 53 allows some duplication, but Amazon Route 53 has a maximum threshold of duplicated domains. This error is generated when you reach that threshold. In this case, the error indicates that too many hosted zones with the given domain name exist. If you want to create a hosted zone and Amazon Route 53 generates this error, contact Customer Support.")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/requests/dns/delete_health_check.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS
module AWS
class DNS
class Real
# This action deletes a health check.
# http://docs.aws.amazon.com/Route53/latest/APIReference/API_DeleteHealthCheck.html
Expand Down
8 changes: 4 additions & 4 deletions lib/fog/aws/requests/dns/delete_hosted_zone.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS
module AWS
class DNS
class Real
require 'fog/aws/parsers/dns/delete_hosted_zone'

Expand All @@ -24,7 +24,7 @@ def delete_hosted_zone(zone_id)

request({
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::DeleteHostedZone.new,
:parser => Fog::Parsers::AWS::DNS::DeleteHostedZone.new,
:method => 'DELETE',
:path => "hostedzone/#{zone_id}"
})
Expand All @@ -37,7 +37,7 @@ class Mock
def delete_hosted_zone(zone_id)
response = Excon::Response.new
key = [zone_id, "/hostedzone/#{zone_id}"].find { |k| !self.data[:zones][k].nil? } ||
raise(Fog::DNS::AWS::NotFound.new("NoSuchHostedZone => A hosted zone with the specified hosted zone does not exist."))
raise(Fog::AWS::DNS::NotFound.new("NoSuchHostedZone => A hosted zone with the specified hosted zone does not exist."))

change = {
:id => Fog::AWS::Mock.change_id,
Expand Down
8 changes: 4 additions & 4 deletions lib/fog/aws/requests/dns/get_change.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS
module AWS
class DNS
class Real
require 'fog/aws/parsers/dns/get_change'

Expand All @@ -23,7 +23,7 @@ def get_change(change_id)

request({
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::GetChange.new,
:parser => Fog::Parsers::AWS::DNS::GetChange.new,
:method => 'GET',
:path => "change/#{change_id}"
})
Expand All @@ -36,7 +36,7 @@ def get_change(change_id)
# find the record with matching change_id
# records = data[:zones].values.map{|z| z[:records].values.map{|r| r.values}}.flatten
change = self.data[:changes][change_id] ||
raise(Fog::DNS::AWS::NotFound.new("NoSuchChange => Could not find resource with ID: #{change_id}"))
raise(Fog::AWS::DNS::NotFound.new("NoSuchChange => Could not find resource with ID: #{change_id}"))

response.status = 200
submitted_at = Time.parse(change[:submitted_at])
Expand Down
6 changes: 3 additions & 3 deletions lib/fog/aws/requests/dns/get_health_check.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module DNS
class AWS
module AWS
class DNS
class Real
require 'fog/aws/parsers/dns/health_check'

Expand Down Expand Up @@ -30,7 +30,7 @@ class Real
def get_health_check(id)
request({
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::HealthCheck.new,
:parser => Fog::Parsers::AWS::DNS::HealthCheck.new,
:method => 'GET',
:path => "healthcheck/#{id}"
})
Expand Down
Loading

0 comments on commit 3025957

Please sign in to comment.