Class: Files::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/certificate.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ Certificate

Returns a new instance of Certificate.



7
8
9
10
# File 'lib/files.com/models/certificate.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/certificate.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/certificate.rb', line 5

def options
  @options
end

Class Method Details

.activate(id, params = {}, options = {}) ⇒ Object

Activate SSL Certificate

Parameters:

replace_cert - string - Leave blank, set to `any` or `new_ips`.


410
411
412
413
414
415
416
417
418
419
# File 'lib/files.com/models/certificate.rb', line 410

def self.activate(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: replace_cert must be an String") if params.dig(:replace_cert) and !params.dig(:replace_cert).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, _options = Api.send_request("/certificates/#{params[:id]}/activate", :post, params, options)
  response.data
end

.all(params = {}, options = {}) ⇒ Object



335
336
337
# File 'lib/files.com/models/certificate.rb', line 335

def self.all(params = {}, options = {})
  list(params, options)
end

.create(params = {}, options = {}) ⇒ Object

Parameters:

name (required) - string - Internal name of the SSL certificate.
certificate_domain - string - Domain for certificate.
certificate_country - string - Country.
certificate_state_or_province - string - State or province.
certificate_city_or_locale - string - City or locale.
certificate_company_name - string - Company name.
csr_ou1 - string - Department name or organization unit 1
csr_ou2 - string - Department name or organization unit 2
csr_ou3 - string - Department name or organization unit 3
certificate_email_address - string - Email address for the certificate owner.
key_type - string - Any supported key type.  Defaults to `RSA-4096`.
key_type_confirm_given - string - Confirms the key type.
certificate - string - The certificate.  PEM or PKCS7 formats accepted.
private_key - string - Certificate private key.
password - string - Certificate password.
intermediates - string - Intermediate certificates.  PEM or PKCS7 formats accepted.


372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/files.com/models/certificate.rb', line 372

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate_domain must be an String") if params.dig(:certificate_domain) and !params.dig(:certificate_domain).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate_country must be an String") if params.dig(:certificate_country) and !params.dig(:certificate_country).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate_state_or_province must be an String") if params.dig(:certificate_state_or_province) and !params.dig(:certificate_state_or_province).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate_city_or_locale must be an String") if params.dig(:certificate_city_or_locale) and !params.dig(:certificate_city_or_locale).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate_company_name must be an String") if params.dig(:certificate_company_name) and !params.dig(:certificate_company_name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: csr_ou1 must be an String") if params.dig(:csr_ou1) and !params.dig(:csr_ou1).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: csr_ou2 must be an String") if params.dig(:csr_ou2) and !params.dig(:csr_ou2).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: csr_ou3 must be an String") if params.dig(:csr_ou3) and !params.dig(:csr_ou3).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate_email_address must be an String") if params.dig(:certificate_email_address) and !params.dig(:certificate_email_address).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: key_type must be an String") if params.dig(:key_type) and !params.dig(:key_type).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: key_type_confirm_given must be an String") if params.dig(:key_type_confirm_given) and !params.dig(:key_type_confirm_given).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate must be an String") if params.dig(:certificate) and !params.dig(:certificate).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: private_key must be an String") if params.dig(:private_key) and !params.dig(:private_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: intermediates must be an String") if params.dig(:intermediates) and !params.dig(:intermediates).is_a?(String)
  raise MissingParameterError.new("Parameter missing: name") unless params.dig(:name)

  response, options = Api.send_request("/certificates", :post, params, options)
  Certificate.new(response.data, options)
end

.deactivate(id, params = {}, options = {}) ⇒ Object

Deactivate SSL Certificate



396
397
398
399
400
401
402
403
404
# File 'lib/files.com/models/certificate.rb', line 396

def self.deactivate(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, _options = Api.send_request("/certificates/#{params[:id]}/deactivate", :post, params, options)
  response.data
end

.delete(id, params = {}, options = {}) ⇒ Object



438
439
440
441
442
443
444
445
446
# File 'lib/files.com/models/certificate.rb', line 438

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, _options = Api.send_request("/certificates/#{params[:id]}", :delete, params, options)
  response.data
end

.destroy(id, params = {}, options = {}) ⇒ Object



448
449
450
# File 'lib/files.com/models/certificate.rb', line 448

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - integer - Certificate ID.


341
342
343
344
345
346
347
348
349
# File 'lib/files.com/models/certificate.rb', line 341

def self.find(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/certificates/#{params[:id]}", :get, params, options)
  Certificate.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



351
352
353
# File 'lib/files.com/models/certificate.rb', line 351

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

page - integer - Current page number.
per_page - integer - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.


326
327
328
329
330
331
332
333
# File 'lib/files.com/models/certificate.rb', line 326

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)

  response, options = Api.send_request("/certificates", :get, params, options)
  response.data.map { |object| Certificate.new(object, options) }
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

name - string - Internal certificate name.
intermediates - string - Any intermediate certificates.  PEM or PKCS7 formats accepted.
certificate - string - The certificate.  PEM or PKCS7 formats accepted.


425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/files.com/models/certificate.rb', line 425

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: intermediates must be an String") if params.dig(:intermediates) and !params.dig(:intermediates).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate must be an String") if params.dig(:certificate) and !params.dig(:certificate).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/certificates/#{params[:id]}", :patch, params, options)
  Certificate.new(response.data, options)
end

Instance Method Details

#activate(params = {}) ⇒ Object

Activate SSL Certificate

Parameters:

replace_cert - string - Leave blank, set to `any` or `new_ips`.


271
272
273
274
275
276
277
278
279
280
# File 'lib/files.com/models/certificate.rb', line 271

def activate(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: replace_cert must be an String") if params.dig(:replace_cert) and !params.dig(:replace_cert).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/certificates/#{@attributes[:id]}/activate", :post, params, @options)
end

#brick_managedObject

boolean - Is this certificate automatically managed and renewed by Files.com?



63
64
65
# File 'lib/files.com/models/certificate.rb', line 63

def brick_managed
  @attributes[:brick_managed]
end

#brick_managed=(value) ⇒ Object



67
68
69
# File 'lib/files.com/models/certificate.rb', line 67

def brick_managed=(value)
  @attributes[:brick_managed] = value
end

#certificateObject

string - Full text of SSL certificate



22
23
24
# File 'lib/files.com/models/certificate.rb', line 22

def certificate
  @attributes[:certificate]
end

#certificate=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/certificate.rb', line 26

def certificate=(value)
  @attributes[:certificate] = value
end

#certificate_city_or_localeObject

string - City or locale.



176
177
178
# File 'lib/files.com/models/certificate.rb', line 176

def certificate_city_or_locale
  @attributes[:certificate_city_or_locale]
end

#certificate_city_or_locale=(value) ⇒ Object



180
181
182
# File 'lib/files.com/models/certificate.rb', line 180

def certificate_city_or_locale=(value)
  @attributes[:certificate_city_or_locale] = value
end

#certificate_company_nameObject

string - Company name.



185
186
187
# File 'lib/files.com/models/certificate.rb', line 185

def certificate_company_name
  @attributes[:certificate_company_name]
end

#certificate_company_name=(value) ⇒ Object



189
190
191
# File 'lib/files.com/models/certificate.rb', line 189

def certificate_company_name=(value)
  @attributes[:certificate_company_name] = value
end

#certificate_countryObject

string - Country.



158
159
160
# File 'lib/files.com/models/certificate.rb', line 158

def certificate_country
  @attributes[:certificate_country]
end

#certificate_country=(value) ⇒ Object



162
163
164
# File 'lib/files.com/models/certificate.rb', line 162

def certificate_country=(value)
  @attributes[:certificate_country] = value
end

#certificate_domainObject

string - Domain for certificate.



149
150
151
# File 'lib/files.com/models/certificate.rb', line 149

def certificate_domain
  @attributes[:certificate_domain]
end

#certificate_domain=(value) ⇒ Object



153
154
155
# File 'lib/files.com/models/certificate.rb', line 153

def certificate_domain=(value)
  @attributes[:certificate_domain] = value
end

#certificate_email_addressObject

string - Email address for the certificate owner.



221
222
223
# File 'lib/files.com/models/certificate.rb', line 221

def certificate_email_address
  @attributes[:certificate_email_address]
end

#certificate_email_address=(value) ⇒ Object



225
226
227
# File 'lib/files.com/models/certificate.rb', line 225

def certificate_email_address=(value)
  @attributes[:certificate_email_address] = value
end

#certificate_state_or_provinceObject

string - State or province.



167
168
169
# File 'lib/files.com/models/certificate.rb', line 167

def certificate_state_or_province
  @attributes[:certificate_state_or_province]
end

#certificate_state_or_province=(value) ⇒ Object



171
172
173
# File 'lib/files.com/models/certificate.rb', line 171

def certificate_state_or_province=(value)
  @attributes[:certificate_state_or_province] = value
end

#created_atObject

date-time - Certificate created at



31
32
33
# File 'lib/files.com/models/certificate.rb', line 31

def created_at
  @attributes[:created_at]
end

#csr_ou1Object

string - Department name or organization unit 1



194
195
196
# File 'lib/files.com/models/certificate.rb', line 194

def csr_ou1
  @attributes[:csr_ou1]
end

#csr_ou1=(value) ⇒ Object



198
199
200
# File 'lib/files.com/models/certificate.rb', line 198

def csr_ou1=(value)
  @attributes[:csr_ou1] = value
end

#csr_ou2Object

string - Department name or organization unit 2



203
204
205
# File 'lib/files.com/models/certificate.rb', line 203

def csr_ou2
  @attributes[:csr_ou2]
end

#csr_ou2=(value) ⇒ Object



207
208
209
# File 'lib/files.com/models/certificate.rb', line 207

def csr_ou2=(value)
  @attributes[:csr_ou2] = value
end

#csr_ou3Object

string - Department name or organization unit 3



212
213
214
# File 'lib/files.com/models/certificate.rb', line 212

def csr_ou3
  @attributes[:csr_ou3]
end

#csr_ou3=(value) ⇒ Object



216
217
218
# File 'lib/files.com/models/certificate.rb', line 216

def csr_ou3=(value)
  @attributes[:csr_ou3] = value
end

#deactivate(params = {}) ⇒ Object

Deactivate SSL Certificate



257
258
259
260
261
262
263
264
265
# File 'lib/files.com/models/certificate.rb', line 257

def deactivate(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/certificates/#{@attributes[:id]}/deactivate", :post, params, @options)
end

#delete(params = {}) ⇒ Object



299
300
301
302
303
304
305
306
307
# File 'lib/files.com/models/certificate.rb', line 299

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/certificates/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



309
310
311
# File 'lib/files.com/models/certificate.rb', line 309

def destroy(params = {})
  delete(params)
end

#display_statusObject

string - Certificate status. (One of ‘Request Generated`, `New`, `Active`, `Active/Expired`, `Expired`, or `Available`)



36
37
38
# File 'lib/files.com/models/certificate.rb', line 36

def display_status
  @attributes[:display_status]
end

#display_status=(value) ⇒ Object



40
41
42
# File 'lib/files.com/models/certificate.rb', line 40

def display_status=(value)
  @attributes[:display_status] = value
end

#domainsObject

array - Domains on this certificate other than files.com domains



45
46
47
# File 'lib/files.com/models/certificate.rb', line 45

def domains
  @attributes[:domains]
end

#domains=(value) ⇒ Object



49
50
51
# File 'lib/files.com/models/certificate.rb', line 49

def domains=(value)
  @attributes[:domains] = value
end

#expires_atObject

date-time - Certificate expiration date/time



54
55
56
# File 'lib/files.com/models/certificate.rb', line 54

def expires_at
  @attributes[:expires_at]
end

#expires_at=(value) ⇒ Object



58
59
60
# File 'lib/files.com/models/certificate.rb', line 58

def expires_at=(value)
  @attributes[:expires_at] = value
end

#idObject

int64 - Certificate ID



13
14
15
# File 'lib/files.com/models/certificate.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/certificate.rb', line 17

def id=(value)
  @attributes[:id] = value
end

#intermediatesObject

string - Intermediate certificates



72
73
74
# File 'lib/files.com/models/certificate.rb', line 72

def intermediates
  @attributes[:intermediates]
end

#intermediates=(value) ⇒ Object



76
77
78
# File 'lib/files.com/models/certificate.rb', line 76

def intermediates=(value)
  @attributes[:intermediates] = value
end

#ip_addressesObject

array - A list of IP addresses associated with this SSL Certificate



81
82
83
# File 'lib/files.com/models/certificate.rb', line 81

def ip_addresses
  @attributes[:ip_addresses]
end

#ip_addresses=(value) ⇒ Object



85
86
87
# File 'lib/files.com/models/certificate.rb', line 85

def ip_addresses=(value)
  @attributes[:ip_addresses] = value
end

#issuerObject

string - X509 issuer



90
91
92
# File 'lib/files.com/models/certificate.rb', line 90

def issuer
  @attributes[:issuer]
end

#issuer=(value) ⇒ Object



94
95
96
# File 'lib/files.com/models/certificate.rb', line 94

def issuer=(value)
  @attributes[:issuer] = value
end

#key_typeObject

string - Type of key



108
109
110
# File 'lib/files.com/models/certificate.rb', line 108

def key_type
  @attributes[:key_type]
end

#key_type=(value) ⇒ Object



112
113
114
# File 'lib/files.com/models/certificate.rb', line 112

def key_type=(value)
  @attributes[:key_type] = value
end

#key_type_confirm_givenObject

string - Confirms the key type.



230
231
232
# File 'lib/files.com/models/certificate.rb', line 230

def key_type_confirm_given
  @attributes[:key_type_confirm_given]
end

#key_type_confirm_given=(value) ⇒ Object



234
235
236
# File 'lib/files.com/models/certificate.rb', line 234

def key_type_confirm_given=(value)
  @attributes[:key_type_confirm_given] = value
end

#nameObject

string - Descriptive name of certificate



99
100
101
# File 'lib/files.com/models/certificate.rb', line 99

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



103
104
105
# File 'lib/files.com/models/certificate.rb', line 103

def name=(value)
  @attributes[:name] = value
end

#passwordObject

string - Certificate password.



248
249
250
# File 'lib/files.com/models/certificate.rb', line 248

def password
  @attributes[:password]
end

#password=(value) ⇒ Object



252
253
254
# File 'lib/files.com/models/certificate.rb', line 252

def password=(value)
  @attributes[:password] = value
end

#private_keyObject

string - Certificate private key.



239
240
241
# File 'lib/files.com/models/certificate.rb', line 239

def private_key
  @attributes[:private_key]
end

#private_key=(value) ⇒ Object



243
244
245
# File 'lib/files.com/models/certificate.rb', line 243

def private_key=(value)
  @attributes[:private_key] = value
end

#requestObject

string - Certificate signing request text



117
118
119
# File 'lib/files.com/models/certificate.rb', line 117

def request
  @attributes[:request]
end

#request=(value) ⇒ Object



121
122
123
# File 'lib/files.com/models/certificate.rb', line 121

def request=(value)
  @attributes[:request] = value
end

#saveObject



313
314
315
316
317
318
319
320
# File 'lib/files.com/models/certificate.rb', line 313

def save
  if @attributes[:id]
    update(@attributes)
  else
    new_obj = Certificate.create(@attributes, @options)
    @attributes = new_obj.attributes
  end
end

#statusObject

string - Certificate status (Request Generated, New, Active, Active/Expired, Expired, or Available)



126
127
128
# File 'lib/files.com/models/certificate.rb', line 126

def status
  @attributes[:status]
end

#status=(value) ⇒ Object



130
131
132
# File 'lib/files.com/models/certificate.rb', line 130

def status=(value)
  @attributes[:status] = value
end

#subjectObject

string - X509 Subject name



135
136
137
# File 'lib/files.com/models/certificate.rb', line 135

def subject
  @attributes[:subject]
end

#subject=(value) ⇒ Object



139
140
141
# File 'lib/files.com/models/certificate.rb', line 139

def subject=(value)
  @attributes[:subject] = value
end

#update(params = {}) ⇒ Object

Parameters:

name - string - Internal certificate name.
intermediates - string - Any intermediate certificates.  PEM or PKCS7 formats accepted.
certificate - string - The certificate.  PEM or PKCS7 formats accepted.


286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/files.com/models/certificate.rb', line 286

def update(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: intermediates must be an String") if params.dig(:intermediates) and !params.dig(:intermediates).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate must be an String") if params.dig(:certificate) and !params.dig(:certificate).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/certificates/#{@attributes[:id]}", :patch, params, @options)
end

#updated_atObject

date-time - Certificated last updated at



144
145
146
# File 'lib/files.com/models/certificate.rb', line 144

def updated_at
  @attributes[:updated_at]
end