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 or set to `any` to replace any currently active certificate, if applicable.  Set to `new_ips` to activate this certificate as an additional certificate on your Site by allocating a new set of Dedicated IPs (may require a Plan upgrade).  Set to the ID of a currently active certificate to replace that certificate on its set of dedicated IPs.


407
408
409
410
411
412
413
414
415
416
# File 'lib/files.com/models/certificate.rb', line 407

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

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

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



332
333
334
# File 'lib/files.com/models/certificate.rb', line 332

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_extra_domains - array(string) - Additional domains for the certificate CSR.
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`.
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.


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

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

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

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



418
419
420
421
# File 'lib/files.com/models/certificate.rb', line 418

def self.create_export(params = {}, options = {})
  response, options = Api.send_request("/certificates/create_export", :post, params, options)
  Export.new(response.data, options)
end

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

Deactivate SSL Certificate



393
394
395
396
397
398
399
400
401
# File 'lib/files.com/models/certificate.rb', line 393

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

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

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



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

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

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

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



450
451
452
453
# File 'lib/files.com/models/certificate.rb', line 450

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

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

Parameters:

id (required) - int64 - Certificate ID.


338
339
340
341
342
343
344
345
346
# File 'lib/files.com/models/certificate.rb', line 338

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

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

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



348
349
350
# File 'lib/files.com/models/certificate.rb', line 348

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

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

Parameters:

cursor - string - Used for pagination.  When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`.  Send one of those cursor value here to resume an existing list from the next available record.  Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page.  (Max: 10000, 1,000 or less is recommended).


323
324
325
326
327
328
329
330
# File 'lib/files.com/models/certificate.rb', line 323

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

  List.new(Certificate, params) do
    Api.send_request("/certificates", :get, params, options)
  end
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.


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

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: intermediates must be an String") if params[:intermediates] and !params[:intermediates].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate must be an String") if params[:certificate] and !params[:certificate].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[: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 or set to `any` to replace any currently active certificate, if applicable.  Set to `new_ips` to activate this certificate as an additional certificate on your Site by allocating a new set of Dedicated IPs (may require a Plan upgrade).  Set to the ID of a currently active certificate to replace that certificate on its set of dedicated IPs.


266
267
268
269
270
271
272
273
274
275
# File 'lib/files.com/models/certificate.rb', line 266

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[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: replace_cert must be an String") if params[:replace_cert] and !params[:replace_cert].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[: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?



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

def brick_managed
  @attributes[:brick_managed]
end

#brick_managed=(value) ⇒ Object



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

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

#certificateObject

string - Full text of SSL certificate



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

def certificate
  @attributes[:certificate]
end

#certificate=(value) ⇒ Object



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

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

#certificate_city_or_localeObject

string - City or locale.



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

def certificate_city_or_locale
  @attributes[:certificate_city_or_locale]
end

#certificate_city_or_locale=(value) ⇒ Object



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

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

#certificate_company_nameObject

string - Company name.



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

def certificate_company_name
  @attributes[:certificate_company_name]
end

#certificate_company_name=(value) ⇒ Object



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

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

#certificate_countryObject

string - Country.



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

def certificate_country
  @attributes[:certificate_country]
end

#certificate_country=(value) ⇒ Object



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

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

#certificate_domainObject

string - Domain for certificate.



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

def certificate_domain
  @attributes[:certificate_domain]
end

#certificate_domain=(value) ⇒ Object



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

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

#certificate_email_addressObject

string - Email address for the certificate owner.



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

def certificate_email_address
  @attributes[:certificate_email_address]
end

#certificate_email_address=(value) ⇒ Object



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

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

#certificate_extra_domainsObject

array(string) - Additional domains for the certificate CSR.



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

def certificate_extra_domains
  @attributes[:certificate_extra_domains]
end

#certificate_extra_domains=(value) ⇒ Object



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

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

#certificate_state_or_provinceObject

string - State or province.



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

def certificate_state_or_province
  @attributes[:certificate_state_or_province]
end

#certificate_state_or_province=(value) ⇒ Object



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

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

#created_atObject

date-time - Certificate created at



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

def created_at
  @attributes[:created_at]
end

#csr_ou1Object

string - Department name or organization unit 1



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

def csr_ou1
  @attributes[:csr_ou1]
end

#csr_ou1=(value) ⇒ Object



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

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

#csr_ou2Object

string - Department name or organization unit 2



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

def csr_ou2
  @attributes[:csr_ou2]
end

#csr_ou2=(value) ⇒ Object



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

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

#csr_ou3Object

string - Department name or organization unit 3



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

def csr_ou3
  @attributes[:csr_ou3]
end

#csr_ou3=(value) ⇒ Object



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

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

#deactivate(params = {}) ⇒ Object

Deactivate SSL Certificate



252
253
254
255
256
257
258
259
260
# File 'lib/files.com/models/certificate.rb', line 252

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[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

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

#delete(params = {}) ⇒ Object



294
295
296
297
298
299
300
301
302
# File 'lib/files.com/models/certificate.rb', line 294

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[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

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

#destroy(params = {}) ⇒ Object



304
305
306
307
# File 'lib/files.com/models/certificate.rb', line 304

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

#display_statusObject

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



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

def display_status
  @attributes[:display_status]
end

#display_status=(value) ⇒ Object



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

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

#domainsObject

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



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

def domains
  @attributes[:domains]
end

#domains=(value) ⇒ Object



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

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

#expires_atObject

date-time - Certificate expiration date/time



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

def expires_at
  @attributes[:expires_at]
end

#expires_at=(value) ⇒ Object



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

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



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

def intermediates
  @attributes[:intermediates]
end

#intermediates=(value) ⇒ Object



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

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

#ip_addressesObject

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



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

def ip_addresses
  @attributes[:ip_addresses]
end

#ip_addresses=(value) ⇒ Object



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

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

#issuerObject

string - X509 issuer



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

def issuer
  @attributes[:issuer]
end

#issuer=(value) ⇒ Object



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

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

#nameObject

string - Descriptive name of certificate



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

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



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

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

#passwordObject

string - Certificate password.



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

def password
  @attributes[:password]
end

#password=(value) ⇒ Object



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

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

#private_keyObject

string - Certificate private key.



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

def private_key
  @attributes[:private_key]
end

#private_key=(value) ⇒ Object



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

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



309
310
311
312
313
314
315
316
317
318
# File 'lib/files.com/models/certificate.rb', line 309

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

  @attributes = new_obj.attributes
  true
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.


281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/files.com/models/certificate.rb', line 281

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[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: intermediates must be an String") if params[:intermediates] and !params[:intermediates].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: certificate must be an String") if params[:certificate] and !params[:certificate].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

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