forked from dnsimple/dnsimple-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add client support for vanity name servers
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module Dnsimple | ||
class Client | ||
module VanityNameServers | ||
|
||
# Enable vanity name servers for a domain. | ||
# | ||
# @see https://developer.dnsimple.com/nameservers/vanity-nameservers/#enable | ||
# | ||
# @param [#to_s] domain The domain id or domain name. | ||
# @param [Hash] names A hash of up to 4 external name servers; hash keys | ||
# are ns1 through ns4, e.g. | ||
# { | ||
# "ns1": "ns1.example.com", | ||
# "ns2": "ns2.example.com" | ||
# } | ||
# | ||
# @return [void] | ||
# @raise [RequestError] When the request fails. | ||
def enable(domain, names) | ||
options = { | ||
"vanity_nameserver_configuration": { | ||
"server_source": "external" | ||
} | ||
} | ||
options[:vanity_nameserver_configuration].merge!(names) | ||
client.post("v1/domains/#{domain}/vanity_name_servers", options) | ||
end | ||
|
||
# Disable vanity name servers for a domain. | ||
# | ||
# @see https://developer.dnsimple.com/nameservers/vanity-nameservers/#disable | ||
# | ||
# @param [#to_s] domain The domain id or domain name. | ||
# | ||
# @return [void] | ||
# @raise [RequestError] When the request fails. | ||
def disable(domain) | ||
client.delete("v1/domains/#{domain}/vanity_name_servers") | ||
end | ||
|
||
end | ||
end | ||
end |