Class: AwsAccountUtils::ConsolidatedBilling

Inherits:
Base
  • Object
show all
Defined in:
lib/aws_account_utils/consolidated_billing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#screenshot

Constructor Details

#initialize(logger, browser) ⇒ ConsolidatedBilling

Returns a new instance of ConsolidatedBilling.



7
8
9
10
# File 'lib/aws_account_utils/consolidated_billing.rb', line 7

def initialize(logger, browser)
  @logger = logger
  @browser = browser
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



5
6
7
# File 'lib/aws_account_utils/consolidated_billing.rb', line 5

def browser
  @browser
end

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/aws_account_utils/consolidated_billing.rb', line 5

def logger
  @logger
end

Instance Method Details

#confirm(account_email, account_password, confirmation_link) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/aws_account_utils/consolidated_billing.rb', line 27

def confirm(, , confirmation_link)
  logger.debug "Confirming consolidated billing"

  Login.new(logger, browser).execute confirmation_link,
                                     ,
                                     

  browser.button(:class => "btn btn-primary").when_present.click
  screenshot(browser, "1")
  browser.span(:text => /Accepting Request/).wait_while_present(timeout = 120)
  screenshot(browser, "2")
  true
rescue Watir::Wait::TimeoutError, Net::ReadTimeout, StandardError => e
  screenshot(browser, "error")
  page_error?
  raise StandardError, "#{self.class.name} - #{e}"
end

#existing?(account_email, account_password) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/aws_account_utils/consolidated_billing.rb', line 45

def existing?(, )
  logger.debug "Checking to see if Consolidated Billing is already setup"

  Login.new(logger, browser).execute billing_established_url,
                                     ,
                                     
  browser.h2(:text => /Consolidated Billing/).wait_until_present
  screenshot(browser, "1")
  billing_setup?
rescue Watir::Wait::TimeoutError, Net::ReadTimeout => e
  screenshot(browser, "error")
  raise StandardError, "#{self.class.name} - #{e}"
end

#request(master_account_email, master_account_password, account_email) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aws_account_utils/consolidated_billing.rb', line 12

def request(, , )
  logger.debug "Submitting consolidated billing request from master account #{} to #{}"
  Login.new(logger, browser).execute billing_request_url,
                                     ,
                                     

  browser.text_field(:name => "emailaddresses").when_present.set 
  screenshot(browser, "1")
  browser.button(:class => "btn btn-primary margin-left-10").when_present.click
  browser.h2(:text => /Manage Requests and Accounts/).wait_until_present
rescue Watir::Wait::TimeoutError, Net::ReadTimeout => e
  screenshot(browser, "error")
  raise StandardError, "#{self.class.name} - #{e}"
end