Class: Porkbun::DNS
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#prio ⇒ Object
Returns the value of attribute prio.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Abstract
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #edit ⇒ Object
-
#initialize(options) ⇒ DNS
constructor
A new instance of DNS.
- #save ⇒ Object
- #to_s ⇒ Object
Methods inherited from Abstract
Constructor Details
#initialize(options) ⇒ DNS
Returns a new instance of DNS.
44 45 46 47 48 49 50 51 52 |
# File 'lib/porkbun.rb', line 44 def initialize() @name = [:name] @content = [:content] @type = [:type] @ttl = [:ttl] || 600 @prio = [:prio] @domain = [:domain] @id = [:id] end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
42 43 44 |
# File 'lib/porkbun.rb', line 42 def content @content end |
#domain ⇒ Object
Returns the value of attribute domain.
42 43 44 |
# File 'lib/porkbun.rb', line 42 def domain @domain end |
#id ⇒ Object
Returns the value of attribute id.
42 43 44 |
# File 'lib/porkbun.rb', line 42 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
42 43 44 |
# File 'lib/porkbun.rb', line 42 def name @name end |
#notes ⇒ Object
Returns the value of attribute notes.
42 43 44 |
# File 'lib/porkbun.rb', line 42 def notes @notes end |
#prio ⇒ Object
Returns the value of attribute prio.
42 43 44 |
# File 'lib/porkbun.rb', line 42 def prio @prio end |
#ttl ⇒ Object
Returns the value of attribute ttl.
42 43 44 |
# File 'lib/porkbun.rb', line 42 def ttl @ttl end |
#type ⇒ Object
Returns the value of attribute type.
42 43 44 |
# File 'lib/porkbun.rb', line 42 def type @type end |
Class Method Details
.create(options) ⇒ Object
54 55 56 57 |
# File 'lib/porkbun.rb', line 54 def self.create() record = DNS.new record.create end |
.retrieve(domain, id = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/porkbun.rb', line 72 def self.retrieve(domain, id = nil) raise Error, 'need domain' unless domain res = Porkbun.porkbun File.join('dns/retrieve', domain, id || '').chomp('/') return Error.new(res[:message]) if res[:status] == 'ERROR' res[:records].map do |record| DNS.new record.merge(domain:) end end |
Instance Method Details
#create ⇒ Object
105 106 107 108 109 110 |
# File 'lib/porkbun.rb', line 105 def create res = Porkbun.porkbun File.join('dns/create', domain), parse_response res @id = res[:id] self end |
#delete ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/porkbun.rb', line 83 def delete raise Error, 'Need ID to delete record' unless id res = Porkbun.porkbun File.join('dns/delete', domain, id) parse_response res self end |
#edit ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/porkbun.rb', line 59 def edit raise Error, 'Need ID to id record' unless id res = Porkbun.porkbun File.join('dns/edit', domain, id), parse_response res @id = res[:id] self end |
#save ⇒ Object
68 69 70 |
# File 'lib/porkbun.rb', line 68 def save edit end |
#to_s ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/porkbun.rb', line 91 def to_s content_str = case type when /TXT|SPF/ "\"#{content}\"" when /MX|CNAME|NS/ "#{content}." else String(content) end prio_str = prio == '0' ? '' : prio "#{name}. #{ttl} IN #{type} #{prio_str} #{content_str}".tr_s(' ', ' ') end |