class GandiNet::Client
Attributes
dryun[RW]
key[RW]
Public Class Methods
new(key=nil, dryrun:true)
click to toggle source
# File lib/gandinet.rb, line 16 def initialize(key=nil, dryrun:true) puts "Please provide an API Key." unless key @key = key @dryrun = dryrun end
Public Instance Methods
create(fqdn,given,family,country,streetaddr,orgname,email,phone,zip,city)
click to toggle source
client.create(“…”,“…”,…)
# File lib/gandinet.rb, line 31 def create(fqdn,given,family,country,streetaddr,orgname,email,phone,zip,city) url = URI("https://api.gandi.net/v5/domain/domains") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["authorization"] = "Apikey #{key}" request["dry-run"] = "1" if @dryrun request["content-type"] = 'application/json' #puts { fqdn: fqdn, owner: { given: given, family: family, country: country, streetaddr: streetaddr, type: "1", orgname: orgname, email: email, phone: phone, zip: zip, city: city}}.to_json request.body = "{\"fqdn\":\"#{fqdn}\",\"owner\":{\"given\":\"#{given}\",\"family\":\"#{family}\",\"country\":\"#{country}\",\"streetaddr\":\"#{streetaddr}\",\"type\":1,\"orgname\":\"#{orgname}\",\"email\":\"#{email}\",\"phone\":\"#{phone}\",\"zip\":\"#{zip}\",\"city\":\"#{city}\"}}" response = http.request(request) JSON.parse(response.read_body) end
domains()
click to toggle source
# File lib/gandinet.rb, line 21 def domains url = URI("https://api.gandi.net/v5/domain/domains") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["authorization"] = "Apikey #{key}" response = http.request(request) JSON.parse(response.read_body) end
info(fqdn)
click to toggle source
client.info(“fqdn”)
# File lib/gandinet.rb, line 45 def info(fqdn) url = URI("https://api.gandi.net/v5/domain/domains/#{fqdn}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["authorization"] = "Apikey #{key}" response = http.request(request) JSON.parse(response.read_body) end