Class: AwsAccountUtils::AwsAccountUtils
- Inherits:
-
Object
- Object
- AwsAccountUtils::AwsAccountUtils
- Defined in:
- lib/aws_account_utils.rb
Instance Attribute Summary collapse
-
#log_level ⇒ Object
readonly
Returns the value of attribute log_level.
-
#screenshots ⇒ Object
readonly
Returns the value of attribute screenshots.
Instance Method Summary collapse
- #change_root_password(account_email:, account_password:, new_password:) ⇒ Object
- #check_enterprise_support(account_email:, account_password:) ⇒ Object
- #close_account(account_email:, account_password:) ⇒ Object
- #confirm_consolidated_billing(account_email:, account_password:, confirmation_link:) ⇒ Object
- #create_account(account_name:, account_email:, account_password:, account_details:) ⇒ Object
- #create_root_access_keys(account_email:, account_password:) ⇒ Object
- #delete_root_access_keys(account_email:, account_password:) ⇒ Object
- #email_opt_out(account_email:, account_password:) ⇒ Object
- #enable_enterprise_support(account_email:, account_password:) ⇒ Object
- #enable_iam_billing(account_email:, account_password:) ⇒ Object
- #existing_consolidated_billing?(account_email:, account_password:) ⇒ Boolean
-
#initialize(log_level: :info, logger: nil, browser: nil, screenshots: nil) ⇒ AwsAccountUtils
constructor
A new instance of AwsAccountUtils.
- #logout_from_console ⇒ Object
- #request_consolidated_billing(master_account_email:, master_account_password:, account_email:) ⇒ Object
- #set_alternate_contacts(account_email:, account_password:, contact_info:) ⇒ Object
- #set_challenge_questions(account_email:, account_password:, answers:) ⇒ Object
- #set_company_name(account_email:, account_password:, name:) ⇒ Object
Constructor Details
#initialize(log_level: :info, logger: nil, browser: nil, screenshots: nil) ⇒ AwsAccountUtils
Returns a new instance of AwsAccountUtils.
23 24 25 26 27 28 29 30 |
# File 'lib/aws_account_utils.rb', line 23 def initialize(log_level: :info, logger: nil, browser: nil, screenshots: nil) @log_level = log_level @logger = logger @browser = browser @screenshots = screenshots Settings.set_screenshot_dir screenshots if screenshots end |
Instance Attribute Details
#log_level ⇒ Object (readonly)
Returns the value of attribute log_level.
21 22 23 |
# File 'lib/aws_account_utils.rb', line 21 def log_level @log_level end |
#screenshots ⇒ Object (readonly)
Returns the value of attribute screenshots.
21 22 23 |
# File 'lib/aws_account_utils.rb', line 21 def screenshots @screenshots end |
Instance Method Details
#change_root_password(account_email:, account_password:, new_password:) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/aws_account_utils.rb', line 50 def change_root_password(account_email:, account_password:, new_password:) resp = password.change(account_email, account_password, new_password) logger.info 'Changed root password.' if resp resp ensure browser.close rescue nil end |
#check_enterprise_support(account_email:, account_password:) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/aws_account_utils.rb', line 42 def check_enterprise_support(account_email:, account_password:) resp = enterprise_support.existing_support? account_email, account_password logger.info 'Enterprise support was already enabled' if resp resp ensure browser.close rescue nil end |
#close_account(account_email:, account_password:) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/aws_account_utils.rb', line 58 def close_account(account_email:, account_password:) resp = account.close(account_email, account_password) logger.info 'Closed Account.' if resp resp ensure browser.close rescue nil end |
#confirm_consolidated_billing(account_email:, account_password:, confirmation_link:) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/aws_account_utils.rb', line 66 def confirm_consolidated_billing(account_email:, account_password:, confirmation_link:) resp = consolidated_billing.confirm account_email, account_password, confirmation_link logger.info 'Consolidated billing has been confirmed' if resp resp ensure browser.close rescue nil end |
#create_account(account_name:, account_email:, account_password:, account_details:) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/aws_account_utils.rb', line 32 def create_account(account_name:, account_email:, account_password:, account_details:) raise ArgumentError, "account_detials: must be a hash." unless account_details.is_a?(Hash) account_registration.signup account_name, account_email, account_password resp = customer_information.submit account_email, account_password, account_details logger.info 'Successfully created account.' if resp resp ensure browser.close rescue nil end |
#create_root_access_keys(account_email:, account_password:) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/aws_account_utils.rb', line 74 def create_root_access_keys(account_email:, account_password:) resp = root_access_keys.create account_email, account_password logger.info 'Created root access keys.' if resp resp ensure browser.close rescue nil end |
#delete_root_access_keys(account_email:, account_password:) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/aws_account_utils.rb', line 82 def delete_root_access_keys(account_email:, account_password:) resp = root_access_keys.delete account_email, account_password logger.info 'Deleted all root access keys.' if resp resp ensure browser.close rescue nil end |
#email_opt_out(account_email:, account_password:) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/aws_account_utils.rb', line 90 def email_opt_out(account_email:, account_password:) resp = email_preferences.opt_out account_email, account_password logger.info 'Successfully opted out of all emails' if resp resp ensure browser.close rescue nil end |
#enable_enterprise_support(account_email:, account_password:) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/aws_account_utils.rb', line 98 def enable_enterprise_support(account_email:, account_password:) resp = enterprise_support.enable account_email, account_password logger.info 'Enabled enterprise support' if resp resp ensure browser.close rescue nil end |
#enable_iam_billing(account_email:, account_password:) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/aws_account_utils.rb', line 106 def enable_iam_billing(account_email:, account_password:) resp = iam_billing.enable account_email, account_password logger.info 'Successfully enabled IAM billing' if resp resp ensure browser.close rescue nil end |
#existing_consolidated_billing?(account_email:, account_password:) ⇒ Boolean
114 115 116 117 118 119 120 |
# File 'lib/aws_account_utils.rb', line 114 def existing_consolidated_billing?(account_email:, account_password:) resp = consolidated_billing.existing? account_email, account_password logger.info 'Consolidated billing has already been setup' if resp resp ensure browser.close rescue nil end |
#logout_from_console ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/aws_account_utils.rb', line 122 def logout_from_console resp = logout.execute logger.info 'Logged out of console' if resp resp ensure browser.close rescue nil end |
#request_consolidated_billing(master_account_email:, master_account_password:, account_email:) ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/aws_account_utils.rb', line 130 def request_consolidated_billing(master_account_email:, master_account_password:, account_email:) resp = consolidated_billing.request master_account_email, master_account_password, account_email logger.info 'Consolidated billing has been requested' if resp resp ensure browser.close rescue nil end |
#set_alternate_contacts(account_email:, account_password:, contact_info:) ⇒ Object
148 149 150 151 152 153 154 155 156 |
# File 'lib/aws_account_utils.rb', line 148 def set_alternate_contacts(account_email:, account_password:, contact_info:) raise ArgumentError, "contact_info: must be a hash." unless contact_info.is_a?(Hash) resp = alternate_contacts.set account_email, account_password, contact_info logger.info 'Set alternate contacts.' if resp resp ensure browser.close rescue nil end |
#set_challenge_questions(account_email:, account_password:, answers:) ⇒ Object
138 139 140 141 142 143 144 145 146 |
# File 'lib/aws_account_utils.rb', line 138 def set_challenge_questions(account_email:, account_password:, answers:) raise ArgumentError, "answers: must be a hash." unless answers.is_a?(Hash) resp = challenge_questions.create account_email, account_password, answers logger.info 'Security Challenge Questions have been setup' if resp resp ensure browser.close rescue nil end |
#set_company_name(account_email:, account_password:, name:) ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/aws_account_utils.rb', line 158 def set_company_name(account_email:, account_password:, name:) resp = company_name.set account_email, account_password, name logger.info 'Set company name.' if resp resp ensure browser.close rescue nil end |