Class: AWS::IAM::SigningCertificateCollection

Inherits:
Object
  • Object
show all
Includes:
Collection
Defined in:
lib/aws/iam/signing_certificate_collection.rb

Overview

This is the primary interface for uploading X.509 signing certificates to an AWS account or an IAM user.

iam = AWS::IAM.new

# upload a certificate for the AWS account:
iam.signing_certificates.upload(<<-CERT)
-----BEGIN CERTIFICATE-----
MIICdzCCAeCgAwIBAgIFGS4fY6owDQYJKoZIhvcNAQEFBQAwUzELMAkGA1UEBhMC
......
Glli79yh87PRi0vNDlFEoHXNynkvC/c4TiWruZ4haM9BR9EdWr1DBNNu73ui093K
F9TbdXSWdgMl7E0=
-----END CERTIFICATE-----
CERT

If you want to work with an IAM user’s certificates just use the signing certificate interface on a user:

user = iam.users['someuser']
user.signing_certificates.upload(cert_body)

Instance Attribute Summary collapse

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods included from Core::Collection::Limitable

#each_batch

Methods included from Core::Collection

#each_batch, #enum, #first, #in_groups_of, #page

Methods included from Core::Model

#client, #config_prefix, #inspect

Constructor Details

#initialize(options = {}) ⇒ SigningCertificateCollection

Returns a new instance of SigningCertificateCollection.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :user (User) — default: nil

    When :user is provided the collection will represents the signing certificates belonging only to that user. When :user is omitted the collection will manage root credentials on the AWS account (instead those belonging to a particular user).



47
48
49
50
# File 'lib/aws/iam/signing_certificate_collection.rb', line 47

def initialize options = {}
  @user = options[:user]
  @user ? super(@user, options) : super(options)
end

Instance Attribute Details

#userUser? (readonly)

Returns the user this collection belongs to.

Returns nil if the collection represents the root credentials for the account. If the configured credentials belong to an IAM user, then that user is the implied owner.

Returns:

  • (User, nil)

    Returns the user this collection belongs to.

    Returns nil if the collection represents the root credentials for the account. If the configured credentials belong to an IAM user, then that user is the implied owner.



56
57
58
# File 'lib/aws/iam/signing_certificate_collection.rb', line 56

def user
  @user
end

Instance Method Details

#[](certificate_id) ⇒ SigningCertificate

Returns a reference to the signing certificate with the given certificate ID.

Parameters:

  • certificate_id (String)

    The ID of the signing certificate.

Returns:

  • (SigningCertificate)

    Returns a reference to the signing certificate with the given certificate ID.



80
81
82
# File 'lib/aws/iam/signing_certificate_collection.rb', line 80

def [] certificate_id
  SigningCertificate.new(certificate_id.to_s, new_options)
end

#clearnil

Deletes all of the signing certificates from this collection.

Returns:

  • (nil)


86
87
88
89
90
91
# File 'lib/aws/iam/signing_certificate_collection.rb', line 86

def clear
  each do |certificate|
    certificate.delete
  end
  nil
end

#each(options = {}) {|signing_certificate| ... } ⇒ nil

Yields once for each signing certificate.

You can limit the number of certificates yielded using :limit.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :limit (Integer)

    The maximum number of certificates to yield.

  • :batch_size (Integer)

    The maximum number of certificates received each service reqeust.

Yield Parameters:

Returns:

  • (nil)


104
105
106
107
108
# File 'lib/aws/iam/signing_certificate_collection.rb', line 104

def each options = {}, &block
  each_options = options.dup
  each_options[:user_name] = user.name if user
  super(each_options, &block)
end

#upload(certificate_body) ⇒ SigningCertificate Also known as: create

Returns the newly created signing certificate.

Parameters:

  • certificate_body (String)

    The contents of the signing certificate.

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/aws/iam/signing_certificate_collection.rb', line 62

def upload certificate_body

  options = {}
  options[:certificate_body] = certificate_body
  options[:user_name] = user.name if user

  resp = client.upload_signing_certificate(options)

  SigningCertificate.new_from(:upload_signing_certificate, 
    resp.certificate, resp.certificate.certificate_id, new_options)

end