Class: AWS::IAM::SigningCertificate
- Inherits:
-
Resource
- Object
- Resource
- Resource
- AWS::IAM::SigningCertificate
- Defined in:
- lib/aws/iam/signing_certificate.rb
Overview
Signing certificates can be activated and deactivated. By default, newly-uploaded certifictes are active.
certificate = iam.signing_certificates.upload(cert_body)
certificate.status
#=> :active
certificate.deactivate!
certificate.active?
#=> false
Contents
You can access the certificate contents you uploaded:
> puts certificate.contents
-----BEGIN CERTIFICATE-----
MIICdzCCAeCgAwIBAgIFGS4fY6owDQYJKoZIhvcNAQEFBQAwUzELMAkGA1UEBhMC
......
Glli79yh87PRi0vNDlFEoHXNynkvC/c4TiWruZ4haM9BR9EdWr1DBNNu73ui093K
F9TbdXSWdgMl7E0=
-----END CERTIFICATE-----
User
A certificate can also return the user it belongs to. If the certificate belongs to the AWS account, then #user will return nil
.
user = iam.users['someuser'].signing_certificates.first
user.name
#=> 'someuser'
Instance Attribute Summary collapse
-
#contents ⇒ String
readonly
Returns the contents of this signing certificate.
-
#id ⇒ String
readonly
Returns the signing certificate’s ID.
-
#status ⇒ Symbol
readonly
The status of this signing certificate.
-
#user ⇒ User?
readonly
Returns the user this cerficiate belongs to.
Instance Method Summary collapse
-
#activate! ⇒ nil
Activates this signing cerificate.
-
#active? ⇒ Boolean
Returns true if this signing certificate is active.
-
#deactivate! ⇒ nil
Deactivates this signing cerificate.
-
#delete ⇒ Object
Deletes the signing certificate.
-
#inactive? ⇒ Boolean
Returns true if this signing certificate is inactive.
-
#initialize(certificate_id, options = {}) ⇒ SigningCertificate
constructor
A new instance of SigningCertificate.
-
#user_name ⇒ String?
Returns the name of the user this certificate belogns to.
Constructor Details
#initialize(certificate_id, options = {}) ⇒ SigningCertificate
Returns a new instance of SigningCertificate.
61 62 63 64 65 |
# File 'lib/aws/iam/signing_certificate.rb', line 61 def initialize certificate_id, = {} @id = certificate_id @user = [:user] @user ? super(@user, ) : super() end |
Instance Attribute Details
#contents ⇒ String (readonly)
Returns the contents of this signing certificate.
56 57 58 |
# File 'lib/aws/iam/signing_certificate.rb', line 56 def contents @contents end |
#id ⇒ String (readonly)
Returns the signing certificate’s ID.
68 69 70 |
# File 'lib/aws/iam/signing_certificate.rb', line 68 def id @id end |
#status ⇒ Symbol (readonly)
The status of this signing certificate. Status may be :active
or :inactive
.
56 57 58 |
# File 'lib/aws/iam/signing_certificate.rb', line 56 def status @status end |
#user ⇒ User? (readonly)
Returns the user this cerficiate belongs to.
Returns nil
if the cerficiate is a root credential for the account. If the configured credentials belong to an IAM user, then that user is the implied owner.
74 75 76 |
# File 'lib/aws/iam/signing_certificate.rb', line 74 def user @user end |
Instance Method Details
#activate! ⇒ nil
Activates this signing cerificate.
118 119 120 121 |
# File 'lib/aws/iam/signing_certificate.rb', line 118 def activate! self.status = 'Active' nil end |
#active? ⇒ Boolean
Returns true if this signing certificate is active.
101 102 103 |
# File 'lib/aws/iam/signing_certificate.rb', line 101 def active? status == :active end |
#deactivate! ⇒ nil
Deactivates this signing cerificate.
131 132 133 134 |
# File 'lib/aws/iam/signing_certificate.rb', line 131 def deactivate! self.status = 'Inactive' nil end |
#delete ⇒ Object
Deletes the signing certificate.
137 138 139 140 |
# File 'lib/aws/iam/signing_certificate.rb', line 137 def delete client.delete_signing_certificate() nil end |
#inactive? ⇒ Boolean
Returns true if this signing certificate is inactive.
106 107 108 |
# File 'lib/aws/iam/signing_certificate.rb', line 106 def inactive? status == :inactive end |
#user_name ⇒ String?
Returns the name of the user this certificate belogns to. If the certificate belongs to the account, nil
is returned.
96 97 98 |
# File 'lib/aws/iam/signing_certificate.rb', line 96 def user_name @user ? @user.name : nil end |