Class: AwsAccountUtils::AwsAccountUtils
- Inherits:
-
Object
- Object
- AwsAccountUtils::AwsAccountUtils
- Defined in:
- lib/aws_account_utils.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#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
- #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(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
Constructor Details
#initialize(logger: nil, browser: nil, screenshots: nil) ⇒ AwsAccountUtils
Returns a new instance of AwsAccountUtils.
21 22 23 24 25 26 27 |
# File 'lib/aws_account_utils.rb', line 21 def initialize(logger: nil, browser: nil, screenshots: nil) @browser = browser @logger = logger @screenshots = screenshots Settings.set_screenshot_dir screenshots if screenshots end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'lib/aws_account_utils.rb', line 19 def @options end |
#screenshots ⇒ Object (readonly)
Returns the value of attribute screenshots.
19 20 21 |
# File 'lib/aws_account_utils.rb', line 19 def screenshots @screenshots end |
Instance Method Details
#change_root_password(account_email:, account_password:, new_password:) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/aws_account_utils.rb', line 47 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
39 40 41 42 43 44 45 |
# File 'lib/aws_account_utils.rb', line 39 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 |
#confirm_consolidated_billing(account_email:, account_password:, confirmation_link:) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/aws_account_utils.rb', line 55 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
29 30 31 32 33 34 35 36 37 |
# File 'lib/aws_account_utils.rb', line 29 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
63 64 65 66 67 68 69 |
# File 'lib/aws_account_utils.rb', line 63 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
71 72 73 74 75 76 77 |
# File 'lib/aws_account_utils.rb', line 71 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
79 80 81 82 83 84 85 |
# File 'lib/aws_account_utils.rb', line 79 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
87 88 89 90 91 92 93 |
# File 'lib/aws_account_utils.rb', line 87 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
95 96 97 98 99 100 101 |
# File 'lib/aws_account_utils.rb', line 95 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
103 104 105 106 107 108 109 |
# File 'lib/aws_account_utils.rb', line 103 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
111 112 113 114 115 116 117 |
# File 'lib/aws_account_utils.rb', line 111 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
119 120 121 122 123 124 125 |
# File 'lib/aws_account_utils.rb', line 119 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
137 138 139 140 141 142 143 144 145 |
# File 'lib/aws_account_utils.rb', line 137 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 alterante contacts.' if resp resp ensure browser.close rescue nil end |
#set_challenge_questions(account_email:, account_password:, answers:) ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/aws_account_utils.rb', line 127 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 |