Class: Spaceship::ConnectAPI::Certificate
- Inherits:
-
Object
- Object
- Spaceship::ConnectAPI::Certificate
- Includes:
- Model
- Defined in:
- spaceship/lib/spaceship/connect_api/models/certificate.rb
Defined Under Namespace
Modules: CertificateType
Instance Attribute Summary collapse
-
#certificate_content ⇒ Object
Returns the value of attribute certificate_content.
-
#certificate_type ⇒ Object
Returns the value of attribute certificate_type.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
-
#name ⇒ Object
Returns the value of attribute name.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#requester_email ⇒ Object
Returns the value of attribute requester_email.
-
#requester_first_name ⇒ Object
Returns the value of attribute requester_first_name.
-
#requester_last_name ⇒ Object
Returns the value of attribute requester_last_name.
-
#serial_number ⇒ Object
Returns the value of attribute serial_number.
Attributes included from Model
Class Method Summary collapse
-
.all(client: nil, filter: {}, includes: nil, fields: nil, limit: nil, sort: nil) ⇒ Object
API.
- .create(client: nil, certificate_type: nil, csr_content: nil) ⇒ Object
-
.create_certificate_signing_request ⇒ Object
Create a new code signing request that can be used to generate a new certificate.
- .get(client: nil, certificate_id: nil, includes: nil) ⇒ Object
- .type ⇒ Object
Instance Method Summary collapse
Methods included from Model
#attr_mapping, included, #initialize, #reverse_attr_mapping, #to_json, #update_attributes
Instance Attribute Details
#certificate_content ⇒ Object
Returns the value of attribute certificate_content.
10 11 12 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 10 def certificate_content @certificate_content end |
#certificate_type ⇒ Object
Returns the value of attribute certificate_type.
16 17 18 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 16 def certificate_type @certificate_type end |
#display_name ⇒ Object
Returns the value of attribute display_name.
11 12 13 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 11 def display_name @display_name end |
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
12 13 14 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 12 def expiration_date @expiration_date end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 13 def name @name end |
#platform ⇒ Object
Returns the value of attribute platform.
14 15 16 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 14 def platform @platform end |
#requester_email ⇒ Object
Returns the value of attribute requester_email.
17 18 19 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 17 def requester_email @requester_email end |
#requester_first_name ⇒ Object
Returns the value of attribute requester_first_name.
18 19 20 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 18 def requester_first_name @requester_first_name end |
#requester_last_name ⇒ Object
Returns the value of attribute requester_last_name.
19 20 21 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 19 def requester_last_name @requester_last_name end |
#serial_number ⇒ Object
Returns the value of attribute serial_number.
15 16 17 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 15 def serial_number @serial_number end |
Class Method Details
.all(client: nil, filter: {}, includes: nil, fields: nil, limit: nil, sort: nil) ⇒ Object
API
82 83 84 85 86 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 82 def self.all(client: nil, filter: {}, includes: nil, fields: nil, limit: nil, sort: nil) client ||= Spaceship::ConnectAPI resps = client.get_certificates(filter: filter, includes: includes, fields: fields, limit: limit, sort: sort).all_pages return resps.flat_map(&:to_models) end |
.create(client: nil, certificate_type: nil, csr_content: nil) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 88 def self.create(client: nil, certificate_type: nil, csr_content: nil) client ||= Spaceship::ConnectAPI attributes = { certificateType: certificate_type, csrContent: csr_content } resp = client.post_certificate(attributes: attributes) return resp.to_models.first end |
.create_certificate_signing_request ⇒ Object
Create a new code signing request that can be used to generate a new certificate
66 67 68 69 70 71 72 73 74 75 76 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 66 def self.create_certificate_signing_request key = OpenSSL::PKey::RSA.new(2048) csr = OpenSSL::X509::Request.new csr.version = 0 csr.subject = OpenSSL::X509::Name.new([ ['CN', 'PEM', OpenSSL::ASN1::UTF8STRING] ]) csr.public_key = key.public_key csr.sign(key, OpenSSL::Digest::SHA1.new) return [csr, key] end |
.get(client: nil, certificate_id: nil, includes: nil) ⇒ Object
98 99 100 101 102 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 98 def self.get(client: nil, certificate_id: nil, includes: nil) client ||= Spaceship::ConnectAPI resp = client.get_certificate(certificate_id: certificate_id, includes: includes) return resp.to_models.first end |
.type ⇒ Object
50 51 52 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 50 def self.type return "certificates" end |
Instance Method Details
#delete!(client: nil) ⇒ Object
104 105 106 107 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 104 def delete!(client: nil) client ||= Spaceship::ConnectAPI client.delete_certificate(certificate_id: id) end |
#valid? ⇒ Boolean
54 55 56 |
# File 'spaceship/lib/spaceship/connect_api/models/certificate.rb', line 54 def valid? Time.parse(expiration_date) > Time.now end |