Class: GeneratorLabs::CertProfiles
- Inherits:
-
Object
- Object
- GeneratorLabs::CertProfiles
- Defined in:
- lib/generatorlabs/cert.rb
Overview
Certificate profile management
Instance Method Summary collapse
-
#create(params) ⇒ Hash
Create a new certificate monitoring profile.
-
#delete(id) ⇒ Hash
Delete a certificate monitoring profile.
-
#get(*ids) ⇒ Hash
Get profiles (all, by ID, or by array of IDs).
-
#get_all(params = {}) ⇒ Array
Get all profiles with automatic pagination.
-
#initialize(handler) ⇒ CertProfiles
constructor
A new instance of CertProfiles.
-
#update(id, params) ⇒ Hash
Update a certificate monitoring profile.
Constructor Details
#initialize(handler) ⇒ CertProfiles
Returns a new instance of CertProfiles.
157 158 159 |
# File 'lib/generatorlabs/cert.rb', line 157 def initialize(handler) @handler = handler end |
Instance Method Details
#create(params) ⇒ Hash
Create a new certificate monitoring profile
201 202 203 |
# File 'lib/generatorlabs/cert.rb', line 201 def create(params) @handler.post('cert/profiles', params) end |
#delete(id) ⇒ Hash
Delete a certificate monitoring profile
216 217 218 |
# File 'lib/generatorlabs/cert.rb', line 216 def delete(id) @handler.delete("cert/profiles/#{id}") end |
#get(*ids) ⇒ Hash
Get profiles (all, by ID, or by array of IDs)
164 165 166 167 168 169 170 171 172 173 |
# File 'lib/generatorlabs/cert.rb', line 164 def get(*ids) return @handler.get('cert/profiles') if ids.empty? # Check if first argument is a hash (parameters) return @handler.get('cert/profiles', ids.first) if ids.first.is_a?(Hash) return @handler.get("cert/profiles/#{ids.first}") if ids.length == 1 @handler.get('cert/profiles', { ids: ids.join(',') }) end |
#get_all(params = {}) ⇒ Array
Get all profiles with automatic pagination
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/generatorlabs/cert.rb', line 178 def get_all(params = {}) all_items = [] page = 1 params = params.dup loop do params[:page] = page response = get(params) profiles = response['profiles'] || [] all_items.concat(profiles) break unless page < (response['total_pages'] || 1) && !profiles.empty? page += 1 end all_items end |
#update(id, params) ⇒ Hash
Update a certificate monitoring profile
209 210 211 |
# File 'lib/generatorlabs/cert.rb', line 209 def update(id, params) @handler.put("cert/profiles/#{id}", params) end |