Class: HerokuDnsimpleCert::DnsimpleCertificate
- Inherits:
-
Object
- Object
- HerokuDnsimpleCert::DnsimpleCertificate
- Defined in:
- lib/heroku_dnsimple_cert/dnsimple_certificate.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#common_name ⇒ Object
readonly
Returns the value of attribute common_name.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
Instance Method Summary collapse
- #certificate ⇒ Object
- #certificate_chain ⇒ Object
-
#initialize(token:, account_id:, domain:, common_name:, client: nil) ⇒ DnsimpleCertificate
constructor
A new instance of DnsimpleCertificate.
- #private_key ⇒ Object
Constructor Details
#initialize(token:, account_id:, domain:, common_name:, client: nil) ⇒ DnsimpleCertificate
Returns a new instance of DnsimpleCertificate.
7 8 9 10 11 12 |
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 7 def initialize(token:, account_id:, domain:, common_name:, client: nil) @client = client || Dnsimple::Client.new(access_token: token) @account_id = account_id.to_i @domain = domain @common_name = common_name end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
5 6 7 |
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 5 def account_id @account_id end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 5 def client @client end |
#common_name ⇒ Object (readonly)
Returns the value of attribute common_name.
5 6 7 |
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 5 def common_name @common_name end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
5 6 7 |
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 5 def domain @domain end |
Instance Method Details
#certificate ⇒ Object
29 30 31 32 33 34 |
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 29 def certificate @certificate ||= client .certificates.certificates(account_id, domain) .data.select { |certificate| certificate_for_common_name?(certificate) } .first end |
#certificate_chain ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 14 def certificate_chain @certificate_key ||= begin cert = client.certificates .download_certificate(account_id, domain, certificate.id).data [cert.server, cert.root, cert.chain].join("\n") end end |
#private_key ⇒ Object
23 24 25 26 27 |
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 23 def private_key @certificate_private_key ||= client.certificates .certificate_private_key(account_id, domain, certificate.id) .data.private_key end |