Class: Aws::Iam

Inherits:
AwsBase show all
Includes:
AwsBaseInterface
Defined in:
lib/iam/iam.rb

Constant Summary collapse

API_VERSION =
"2010-05-08"
DEFAULT_HOST =
"iam.amazonaws.com"
DEFAULT_PATH =
'/'
DEFAULT_PROTOCOL =
'https'
DEFAULT_PORT =
443
@@bench =
AwsBenchmarkingBlock.new
@@api =

Current API version (sometimes we have to check it outside the GEM).

ENV['IAM_API_VERSION'] || API_VERSION

Constants included from AwsBaseInterface

AwsBaseInterface::DEFAULT_SIGNATURE_VERSION

Constants inherited from AwsBase

AwsBase::AMAZON_PROBLEMS

Instance Attribute Summary

Attributes included from AwsBaseInterface

#aws_access_key_id, #cache, #last_errors, #last_request, #last_request_id, #last_response, #logger, #params, #signature_version

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AwsBaseInterface

#cache_hits?, caching, caching=, #caching?, #close_conn, #close_connection, #connection, #generate_request, #generate_request2, #get_conn, #hash_params, #init, #multi_thread, #on_exception, #request_cache_or_info, #request_info2, #request_info3, #request_info_impl, #request_info_xml_simple, #signed_service_params, #symbolize, #update_cache

Methods inherited from AwsBase

amazon_problems, amazon_problems=

Constructor Details

#initialize(aws_access_key_id = nil, aws_secret_access_key = nil, params = {}) ⇒ Iam

Returns a new instance of Iam.



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/iam/iam.rb', line 35

def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
  init({:name             => 'IAM',
        :default_host     => ENV['IAM_URL'] ? URI.parse(ENV['IAM_URL']).host : DEFAULT_HOST,
        :default_port     => ENV['IAM_URL'] ? URI.parse(ENV['IAM_URL']).port : DEFAULT_PORT,
        :default_service  => ENV['IAM_URL'] ? URI.parse(ENV['IAM_URL']).path : DEFAULT_PATH,
        :default_protocol => ENV['IAM_URL'] ? URI.parse(ENV['IAM_URL']).scheme : DEFAULT_PROTOCOL,
        :api_version      => API_VERSION},
       aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'],
       aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
       params)
end

Class Method Details

.apiObject



30
31
32
# File 'lib/iam/iam.rb', line 30

def self.api
  @@api
end

.benchObject



16
17
18
# File 'lib/iam/iam.rb', line 16

def self.bench
  @@bench
end

.bench_ec2Object



23
24
25
# File 'lib/iam/iam.rb', line 23

def self.bench_ec2
  @@bench.service
end

.bench_xmlObject



19
20
21
# File 'lib/iam/iam.rb', line 19

def self.bench_xml
  @@bench.xml
end

Instance Method Details

#do_request(action, params, options = {}) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/iam/iam.rb', line 47

def do_request(action, params, options={})
  link = generate_request(action, params)
  p link[:request]
  resp = request_info_xml_simple(:iam_connection, @params, link, @logger,
                                 :group_tags     =>{"LoadBalancersDescriptions"=>"LoadBalancersDescription",
                                                    "DBParameterGroups"        =>"DBParameterGroup",
                                                    "DBSecurityGroups"         =>"DBSecurityGroup",
                                                    "EC2SecurityGroups"        =>"EC2SecurityGroup",
                                                    "IPRanges"                 =>"IPRange"},
                                 :force_array    =>["DBInstances",
                                                    "DBParameterGroups",
                                                    "DBSecurityGroups",
                                                    "EC2SecurityGroups",
                                                    "IPRanges"],
                                 :pull_out_array =>options[:pull_out_array],
                                 :pull_out_single=>options[:pull_out_single],
                                 :wrapper        =>options[:wrapper])
end

#list_server_certificates(options = {}) ⇒ Object

options:

:marker => value received from previous response if IsTruncated = true
:max_items => number of items you want returned
:path_previx => for filtering results, default is /


76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/iam/iam.rb', line 76

def list_server_certificates(options={})
  @logger.info("Listing server certificates...")

  params = {}
  params['Marker'] = options[:marker] if options[:marker]
  params['MaxItems'] = options[:max_items] if options[:max_items]
  params['PathPrefix'] = options[:path_prefix] if options[:path_prefix]

  resp = do_request("ListServerCertificates", params, :pull_out_array=>[:list_server_certificates_result, :server_certificate_metadata_list])


rescue Exception
  on_exception
end

#upload_server_certificate(name, public_key, private_key, options = {}) ⇒ Object

name: name of certificate public_key: public key certificate in PEM-encoded format private_key: private key in PEM-encoded format options:

:path => specify a path you want it stored in
:certificate_chain => contents of certificate chain


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/iam/iam.rb', line 98

def upload_server_certificate(name, public_key, private_key, options={})
  params                          = {}
  params['ServerCertificateName'] = name
  params['PrivateKey']            = private_key
  params['CertificateBody']       = public_key

  params['CertificateChain'] = options[:certificate_chain] if options[:certificate_chain]
  params['Path'] = options[:path] if options[:path]

  p params

  resp = do_request("UploadServerCertificate", params, :pull_out_array=>[:list_server_certificates_result, :server_certificate_metadata_list])


rescue Exception
  on_exception
end