Class: AcmeManager::IssueRequest
- Inherits:
-
Object
- Object
- AcmeManager::IssueRequest
- Defined in:
- lib/acme_manager/issue_request.rb
Overview
Handles the request and response associated with issuing a new certificate through acme-manager
Constant Summary collapse
- SUCCESSFUL_RESULTS =
%w(issued not_due).freeze
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#error_type ⇒ Object
readonly
Returns the value of attribute error_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Class Method Summary collapse
-
.make(name) ⇒ IssueRequest
Convenience method for issuing a new certificate.
Instance Method Summary collapse
-
#initialize(name) ⇒ IssueRequest
constructor
A new instance of IssueRequest.
-
#make ⇒ Boolean
Send a request to acme-manager to issue a new certificate.
-
#success? ⇒ Boolean
Was the request sucessful? This will return false if the request hasn’t been made yet.
Constructor Details
#initialize(name) ⇒ IssueRequest
Returns a new instance of IssueRequest.
9 10 11 |
# File 'lib/acme_manager/issue_request.rb', line 9 def initialize(name) @name = name end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
6 7 8 |
# File 'lib/acme_manager/issue_request.rb', line 6 def error @error end |
#error_type ⇒ Object (readonly)
Returns the value of attribute error_type.
6 7 8 |
# File 'lib/acme_manager/issue_request.rb', line 6 def error_type @error_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/acme_manager/issue_request.rb', line 6 def name @name end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
6 7 8 |
# File 'lib/acme_manager/issue_request.rb', line 6 def success @success end |
Class Method Details
.make(name) ⇒ IssueRequest
Convenience method for issuing a new certificate
18 19 20 21 22 |
# File 'lib/acme_manager/issue_request.rb', line 18 def self.make(name) request = new(name) request.make request end |
Instance Method Details
#make ⇒ Boolean
Send a request to acme-manager to issue a new certificate. If the request is a failure error_type and error will be set containing the failure details.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/acme_manager/issue_request.rb', line 28 def make AcmeManager.logger.info "Requesting certificate issue for '#{name}'" response = Request.make("issue/#{name}") if SUCCESSFUL_RESULTS.include?(response['result']) AcmeManager.logger.info "Issue for '#{name}' successful" @success = true else @error_type = response['reason']['type'] @error = response['reason']['detail'] AcmeManager.logger.warn "Issue for '#{name}' failed - #{error_type}, #{error}" @success = false end end |
#success? ⇒ Boolean
Was the request sucessful? This will return false if the request hasn’t been made yet
44 45 46 |
# File 'lib/acme_manager/issue_request.rb', line 44 def success? !!@success end |