Class: GeneratorLabs::CertMonitors
- Inherits:
-
Object
- Object
- GeneratorLabs::CertMonitors
- Defined in:
- lib/generatorlabs/cert.rb
Overview
Certificate monitor management
Instance Method Summary collapse
-
#create(params) ⇒ Hash
Create a new certificate monitor.
-
#delete(id) ⇒ Hash
Delete a certificate monitor.
-
#get(*ids) ⇒ Hash
Get monitors (all, by ID, or by array of IDs).
-
#get_all(params = {}) ⇒ Array
Get all monitors with automatic pagination.
-
#initialize(handler) ⇒ CertMonitors
constructor
A new instance of CertMonitors.
-
#pause(id) ⇒ Hash
Pause monitoring for a certificate.
-
#resume(id) ⇒ Hash
Resume monitoring for a certificate.
-
#update(id, params) ⇒ Hash
Update a certificate monitor.
Constructor Details
#initialize(handler) ⇒ CertMonitors
Returns a new instance of CertMonitors.
77 78 79 |
# File 'lib/generatorlabs/cert.rb', line 77 def initialize(handler) @handler = handler end |
Instance Method Details
#create(params) ⇒ Hash
Create a new certificate monitor
121 122 123 |
# File 'lib/generatorlabs/cert.rb', line 121 def create(params) @handler.post('cert/monitors', params) end |
#delete(id) ⇒ Hash
Delete a certificate monitor
136 137 138 |
# File 'lib/generatorlabs/cert.rb', line 136 def delete(id) @handler.delete("cert/monitors/#{id}") end |
#get(*ids) ⇒ Hash
Get monitors (all, by ID, or by array of IDs)
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/generatorlabs/cert.rb', line 84 def get(*ids) return @handler.get('cert/monitors') if ids.empty? # Check if first argument is a hash (parameters) return @handler.get('cert/monitors', ids.first) if ids.first.is_a?(Hash) return @handler.get("cert/monitors/#{ids.first}") if ids.length == 1 @handler.get('cert/monitors', { ids: ids.join(',') }) end |
#get_all(params = {}) ⇒ Array
Get all monitors with automatic pagination
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/generatorlabs/cert.rb', line 98 def get_all(params = {}) all_items = [] page = 1 params = params.dup loop do params[:page] = page response = get(params) monitors = response['monitors'] || [] all_items.concat(monitors) break unless page < (response['total_pages'] || 1) && !monitors.empty? page += 1 end all_items end |
#pause(id) ⇒ Hash
Pause monitoring for a certificate
143 144 145 |
# File 'lib/generatorlabs/cert.rb', line 143 def pause(id) @handler.post("cert/monitors/#{id}/pause") end |
#resume(id) ⇒ Hash
Resume monitoring for a certificate
150 151 152 |
# File 'lib/generatorlabs/cert.rb', line 150 def resume(id) @handler.post("cert/monitors/#{id}/resume") end |
#update(id, params) ⇒ Hash
Update a certificate monitor
129 130 131 |
# File 'lib/generatorlabs/cert.rb', line 129 def update(id, params) @handler.put("cert/monitors/#{id}", params) end |