You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
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.
-
#upload_date ⇒ Time
readonly
The current value of upload_date.
-
#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.
-
#exists? ⇒ Boolean
Returns
true
if the resource exists. -
#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 |
#upload_date ⇒ Time (readonly)
Returns the current value of upload_date
56 57 58 |
# File 'lib/aws/iam/signing_certificate.rb', line 56 def upload_date @upload_date 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.
121 122 123 124 |
# File 'lib/aws/iam/signing_certificate.rb', line 121 def activate! self.status = 'Active' nil end |
#active? ⇒ Boolean
Returns true if this signing certificate is active.
104 105 106 |
# File 'lib/aws/iam/signing_certificate.rb', line 104 def active? status == :active end |
#deactivate! ⇒ nil
Deactivates this signing cerificate.
134 135 136 137 |
# File 'lib/aws/iam/signing_certificate.rb', line 134 def deactivate! self.status = 'Inactive' nil end |
#delete ⇒ Object
Deletes the signing certificate.
140 141 142 143 |
# File 'lib/aws/iam/signing_certificate.rb', line 140 def delete client.delete_signing_certificate() nil end |
#exists? ⇒ Boolean
Returns true
if the resource exists.
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/aws/iam/signing_certificate.rb', line 146 def exists? exists = false SigningCertificateCollection.new(:config => config).each do |cert| if cert.id == self.id exists = true break end end exists end |
#inactive? ⇒ Boolean
Returns true if this signing certificate is inactive.
109 110 111 |
# File 'lib/aws/iam/signing_certificate.rb', line 109 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.
99 100 101 |
# File 'lib/aws/iam/signing_certificate.rb', line 99 def user_name @user ? @user.name : nil end |