Class: 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.
Methods inherited from Resource
Constructor Details
#initialize(certificate_id, options = {}) ⇒ SigningCertificate
Returns a new instance of SigningCertificate.
59 60 61 62 63 |
# File 'lib/aws/iam/signing_certificate.rb', line 59 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.
54 55 56 |
# File 'lib/aws/iam/signing_certificate.rb', line 54 def contents @contents end |
#id ⇒ String (readonly)
Returns the signing certificate’s ID.
66 67 68 |
# File 'lib/aws/iam/signing_certificate.rb', line 66 def id @id end |
#status ⇒ Symbol (readonly)
The status of this signing certificate. Status may be :active
or :inactive
.
54 55 56 |
# File 'lib/aws/iam/signing_certificate.rb', line 54 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.
72 73 74 |
# File 'lib/aws/iam/signing_certificate.rb', line 72 def user @user end |
Instance Method Details
#activate! ⇒ nil
Activates this signing cerificate.
116 117 118 119 |
# File 'lib/aws/iam/signing_certificate.rb', line 116 def activate! self.status = 'Active' nil end |
#active? ⇒ Boolean
Returns true if this signing certificate is active.
99 100 101 |
# File 'lib/aws/iam/signing_certificate.rb', line 99 def active? status == :active end |
#deactivate! ⇒ nil
Deactivates this signing cerificate.
129 130 131 132 |
# File 'lib/aws/iam/signing_certificate.rb', line 129 def deactivate! self.status = 'Inactive' nil end |
#delete ⇒ Object
Deletes the signing certificate.
135 136 137 138 |
# File 'lib/aws/iam/signing_certificate.rb', line 135 def delete client.delete_signing_certificate() nil end |
#inactive? ⇒ Boolean
Returns true if this signing certificate is inactive.
104 105 106 |
# File 'lib/aws/iam/signing_certificate.rb', line 104 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.
94 95 96 |
# File 'lib/aws/iam/signing_certificate.rb', line 94 def user_name @user ? @user.name : nil end |