mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Cleanup documentation and resource representations
Remove deprecated attributes and make the documentation more consistent.
This commit is contained in:
parent
b2ff51eccc
commit
49a46b4513
10 changed files with 113 additions and 141 deletions
|
@ -11,14 +11,14 @@ module Fog
|
|||
|
||||
identity :id
|
||||
|
||||
attribute :zone_id, :aliases => "domain_id"
|
||||
attribute :name
|
||||
attribute :value, :aliases => "content"
|
||||
attribute :ttl
|
||||
attribute :priority, :aliases => "prio"
|
||||
attribute :type, :aliases => "record_type"
|
||||
attribute :created_at
|
||||
attribute :updated_at
|
||||
attribute :zone_id, :aliases => "domain_id"
|
||||
attribute :type, :aliases => "record_type"
|
||||
attribute :priority, :aliases => "prio"
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
|
|
|
@ -4,21 +4,27 @@ module Fog
|
|||
class Real
|
||||
|
||||
# Create a single domain in DNSimple in your account.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * name<~String> - domain name to host (ie example.com)
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'name'<~String>
|
||||
# * 'domain'<~Hash> The representation of the domain.
|
||||
def create_domain(name)
|
||||
body = { "domain" => { "name" => name } }
|
||||
body = {
|
||||
"domain" => {
|
||||
"name" => name
|
||||
}
|
||||
}
|
||||
|
||||
request(
|
||||
:body => Fog::JSON.encode(body),
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:path => '/domains'
|
||||
)
|
||||
:body => Fog::JSON.encode(body),
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:path => "/domains"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -26,32 +32,30 @@ module Fog
|
|||
class Mock
|
||||
|
||||
def create_domain(name)
|
||||
response = Excon::Response.new
|
||||
response.status = 201
|
||||
|
||||
body = {
|
||||
"domain" => {
|
||||
"auto_renew" => nil,
|
||||
"created_at" => Time.now.iso8601,
|
||||
"expires_on" => Date.today + 365,
|
||||
"id" => Fog::Mock.random_numbers(1).to_i,
|
||||
"user_id" => 1,
|
||||
"registrant_id" => nil,
|
||||
"name" => name,
|
||||
"unicode_name" => name,
|
||||
"token" => "4fIFYWYiJayvL2tkf_mkBkqC4L+4RtYqDA",
|
||||
"state" => "registered",
|
||||
"language" => nil,
|
||||
"lockable" => true,
|
||||
"name" => name,
|
||||
"name_server_status" => "unknown",
|
||||
"registrant_id" => nil,
|
||||
"state" => "registered",
|
||||
"token" => "4fIFYWYiJayvL2tkf_mkBkqC4L+4RtYqDA",
|
||||
"unicode_name" => name,
|
||||
"updated_at" => Time.now.iso8601,
|
||||
"user_id" => 1,
|
||||
"auto_renew" => nil,
|
||||
"whois_protected" => false,
|
||||
"record_count" => 0,
|
||||
"service_count" => 0,
|
||||
"private_whois?" => false
|
||||
"expires_on" => Date.today + 365,
|
||||
"created_at" => Time.now.iso8601,
|
||||
"updated_at" => Time.now.iso8601,
|
||||
}
|
||||
}
|
||||
self.data[:domains] << body
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 201
|
||||
response.body = body
|
||||
response
|
||||
end
|
||||
|
|
|
@ -6,40 +6,35 @@ module Fog
|
|||
# Create a new host in the specified zone
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain<~String>
|
||||
# * domain<~String> - domain name or numeric ID
|
||||
# * name<~String>
|
||||
# * type<~String>
|
||||
# * content<~String>
|
||||
# * options<~Hash> - optional
|
||||
# * priority<~Integer>
|
||||
# * ttl<~Integer>
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>
|
||||
# * name<~String>
|
||||
# * ttl<~Integer>
|
||||
# * created_at<~String>
|
||||
# * special_type<~String>
|
||||
# * updated_at<~String>
|
||||
# * domain_id<~Integer>
|
||||
# * id<~Integer>
|
||||
# * content<~String>
|
||||
# * record_type<~String>
|
||||
# * prio<~Integer>
|
||||
# * body<~Hash>:
|
||||
# * 'record'<~Hash> The representation of the record.
|
||||
def create_record(domain, name, type, content, options = {})
|
||||
|
||||
body = {
|
||||
"record" => {
|
||||
"name" => name,
|
||||
"record_type" => type,
|
||||
"content" => content } }
|
||||
"content" => content
|
||||
}
|
||||
}
|
||||
|
||||
body["record"].merge!(options)
|
||||
|
||||
request( :body => Fog::JSON.encode(body),
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:path => "/domains/#{domain}/records" )
|
||||
request(
|
||||
:body => Fog::JSON.encode(body),
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:path => "/domains/#{domain}/records"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -47,23 +42,25 @@ module Fog
|
|||
class Mock
|
||||
|
||||
def create_record(domain, name, type, content, options = {})
|
||||
response = Excon::Response.new
|
||||
response.status = 201
|
||||
body = {
|
||||
"record" => {
|
||||
"id" => Fog::Mock.random_numbers(1).to_i,
|
||||
"domain_id" => domain,
|
||||
"name" => name,
|
||||
"record_type" => type,
|
||||
"content" => content,
|
||||
"ttl" => 3600,
|
||||
"prio" => nil,
|
||||
"record_type" => type,
|
||||
"system_record" => nil,
|
||||
"created_at" => Time.now.iso8601,
|
||||
"updated_at" => Time.now.iso8601,
|
||||
"id" => Fog::Mock.random_numbers(1).to_i,
|
||||
"domain_id" => domain
|
||||
}.merge(options)
|
||||
}
|
||||
|
||||
self.data[:records][domain] ||= []
|
||||
self.data[:records][domain] << body
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 201
|
||||
response.body = body
|
||||
response
|
||||
end
|
||||
|
|
|
@ -10,14 +10,14 @@ module Fog
|
|||
# DNSimple this will not delete the domain from the registry.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * name<~String> - domain name or numeric ID
|
||||
# * domain<~String> - domain name or numeric ID
|
||||
#
|
||||
def delete_domain(name)
|
||||
def delete_domain(domain)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'DELETE',
|
||||
:path => "/domains/#{name}"
|
||||
)
|
||||
:expects => 200,
|
||||
:method => 'DELETE',
|
||||
:path => "/domains/#{domain}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -27,6 +27,7 @@ module Fog
|
|||
def delete_domain(name)
|
||||
self.data[:records].delete name
|
||||
self.data[:domains].reject! { |domain| domain["domain"]["name"] == name }
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response
|
||||
|
|
|
@ -6,13 +6,14 @@ module Fog
|
|||
# Delete the record with the given ID for the given domain.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain<~String>
|
||||
# * domain<~String> - domain name or numeric ID
|
||||
# * record_id<~String>
|
||||
def delete_record(domain, record_id)
|
||||
|
||||
request( :expects => 200,
|
||||
:method => "DELETE",
|
||||
:path => "/domains/#{domain}/records/#{record_id}" )
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => "DELETE",
|
||||
:path => "/domains/#{domain}/records/#{record_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -21,6 +22,7 @@ module Fog
|
|||
|
||||
def delete_record(domain, record_id)
|
||||
self.data[:records][domain].reject! { |record| record["record"]["id"] == record_id }
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response
|
||||
|
|
|
@ -8,27 +8,18 @@ module Fog
|
|||
# itself.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * id<~String> - domain name or numeric ID
|
||||
# * domain<~String> - domain name or numeric ID
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'domain'<~Hash>
|
||||
# * 'name'<~String>
|
||||
# * 'expires_at'<~String>
|
||||
# * 'created_at'<~String>
|
||||
# * 'registration_status'<~String>
|
||||
# * 'updated_at'<~String>
|
||||
# * 'registrant_id'<~Integer>
|
||||
# * 'id'<~Integer>
|
||||
# * 'user_id'<~Integer>
|
||||
# * 'name_server_status'<~String>
|
||||
def get_domain(id)
|
||||
# * 'domain'<~Hash> The representation of the domain.
|
||||
def get_domain(domain)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => "GET",
|
||||
:path => "/domains/#{id}"
|
||||
)
|
||||
:expects => 200,
|
||||
:method => "GET",
|
||||
:path => "/domains/#{domain}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -39,6 +30,7 @@ module Fog
|
|||
domain = self.data[:domains].detect do |domain|
|
||||
domain["domain"]["id"] == id || domain["domain"]["name"] == id
|
||||
end
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = domain
|
||||
|
|
|
@ -6,26 +6,19 @@ module Fog
|
|||
# Gets record from given domain.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain<~String>
|
||||
# * domain<~String> - domain name or numeric ID
|
||||
# * record_id<~String>
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * record<~Hash>
|
||||
# * name<~String>
|
||||
# * ttl<~Integer>
|
||||
# * created_at<~String>
|
||||
# * special_type<~String>
|
||||
# * updated_at<~String>
|
||||
# * domain_id<~Integer>
|
||||
# * id<~Integer>
|
||||
# * content<~String>
|
||||
# * record_type<~String>
|
||||
# * prio<~Integer>
|
||||
# * body<~Hash>:
|
||||
# * 'record'<~Hash> The representation of the record.
|
||||
def get_record(domain, record_id)
|
||||
|
||||
request( :expects => 200,
|
||||
:method => "GET",
|
||||
:path => "/domains/#{domain}/records/#{record_id}" )
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => "GET",
|
||||
:path => "/domains/#{domain}/records/#{record_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -34,7 +27,8 @@ module Fog
|
|||
|
||||
def get_record(domain, record_id)
|
||||
response = Excon::Response.new
|
||||
if self.data[:records].has_key? domain
|
||||
|
||||
if self.data[:records].has_key?(domain)
|
||||
response.status = 200
|
||||
response.body = self.data[:records][domain].detect { |record| record["record"]["id"] == record_id }
|
||||
|
||||
|
|
|
@ -5,28 +5,20 @@ module Fog
|
|||
|
||||
# Get the details for a specific domain in your account. You
|
||||
# may pass either the domain numeric ID or the domain name itself.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * id<~String> - domain name or numeric ID
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'domains'<~Array>
|
||||
# * 'name'<~String>
|
||||
# * 'expires_at'<~String>
|
||||
# * 'created_at'<~String>
|
||||
# * 'registration_status'<~String>
|
||||
# * 'updated_at'<~String>
|
||||
# * 'registrant_id'<~Integer>
|
||||
# * 'id'<~Integer>
|
||||
# * 'user_id'<~Integer>
|
||||
# * 'name_server_status'<~String>
|
||||
# * <~Array>:
|
||||
# * 'domain'<~Hash> The representation of the domain.
|
||||
def list_domains
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => '/domains'
|
||||
)
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => '/domains'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,24 +6,19 @@ module Fog
|
|||
# Get the list of records for the specific domain.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain<~String>
|
||||
# * domain<~String> - domain name or numeric ID
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * records<Array~>
|
||||
# * name<~String>
|
||||
# * ttl<~Integer>
|
||||
# * created_at<~String>
|
||||
# * special_type<~String>
|
||||
# * updated_at<~String>
|
||||
# * domain_id<~Integer>
|
||||
# * id<~Integer>
|
||||
# * content<~String>
|
||||
# * record_type<~String>
|
||||
# * prio<~Integer>
|
||||
# * body<~Hash>:
|
||||
# * <~Array>:
|
||||
# * 'record'<~Hash> The representation of the record.
|
||||
def list_records(domain)
|
||||
request( :expects => 200,
|
||||
:method => "GET",
|
||||
:path => "/domains/#{domain}/records" )
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => "GET",
|
||||
:path => "/domains/#{domain}/records"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,34 +6,29 @@ module Fog
|
|||
# Update the given record for the given domain.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain<~String>
|
||||
# * domain<~String> - domain name or numeric ID
|
||||
# * record_id<~String>
|
||||
# * options<~Hash> - optional
|
||||
# * type<~String>
|
||||
# * content<~String>
|
||||
# * priority<~Integer>
|
||||
# * ttl<~Integer>
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * record<~Hash>
|
||||
# * name<~String>
|
||||
# * ttl<~Integer>
|
||||
# * created_at<~String>
|
||||
# * special_type<~String>
|
||||
# * updated_at<~String>
|
||||
# * domain_id<~Integer>
|
||||
# * id<~Integer>
|
||||
# * content<~String>
|
||||
# * record_type<~String>
|
||||
# * prio<~Integer>
|
||||
# * body<~Hash>:
|
||||
# * 'record'<~Hash> The representation of the record.
|
||||
def update_record(domain, record_id, options)
|
||||
body = {
|
||||
"record" => options
|
||||
}
|
||||
|
||||
body = { "record" => options }
|
||||
|
||||
request( :body => Fog::JSON.encode(body),
|
||||
:expects => 200,
|
||||
:method => "PUT",
|
||||
:path => "/domains/#{domain}/records/#{record_id}" )
|
||||
request(
|
||||
:body => Fog::JSON.encode(body),
|
||||
:expects => 200,
|
||||
:method => "PUT",
|
||||
:path => "/domains/#{domain}/records/#{record_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue