Class: OpenStax::Aws::Stack::Status
- Inherits:
-
Object
- Object
- OpenStax::Aws::Stack::Status
- Defined in:
- lib/openstax/aws/stack_status.rb
Class Method Summary collapse
- .active_status_texts ⇒ Object
- .all_status_texts ⇒ Object
- .does_not_exist_status_text ⇒ Object
- .failure_status_texts ⇒ Object
- .success_status_texts ⇒ Object
Instance Method Summary collapse
- #creating? ⇒ Boolean
- #deleting? ⇒ Boolean
- #exists? ⇒ Boolean
- #failed? ⇒ Boolean
- #failed_events_since_last_user_event ⇒ Object
-
#initialize(stack) ⇒ Status
constructor
A new instance of Status.
- #status_text ⇒ Object
- #succeeded? ⇒ Boolean
- #to_h ⇒ Object
- #to_json ⇒ Object
- #updating? ⇒ Boolean
Constructor Details
#initialize(stack) ⇒ Status
Returns a new instance of Status.
4 5 6 |
# File 'lib/openstax/aws/stack_status.rb', line 4 def initialize(stack) @stack = stack end |
Class Method Details
.active_status_texts ⇒ Object
81 82 83 |
# File 'lib/openstax/aws/stack_status.rb', line 81 def self.active_status_texts all_status_texts - %w(CREATE_FAILED DELETE_COMPLETE) end |
.all_status_texts ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/openstax/aws/stack_status.rb', line 54 def self.all_status_texts %w( CREATE_IN_PROGRESS CREATE_FAILED CREATE_COMPLETE ROLLBACK_IN_PROGRESS ROLLBACK_FAILED ROLLBACK_COMPLETE DELETE_IN_PROGRESS DELETE_FAILED DELETE_COMPLETE UPDATE_IN_PROGRESS UPDATE_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_COMPLETE UPDATE_ROLLBACK_IN_PROGRESS UPDATE_ROLLBACK_FAILED UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_COMPLETE REVIEW_IN_PROGRESS IMPORT_IN_PROGRESS IMPORT_COMPLETE IMPORT_ROLLBACK_IN_PROGRESS IMPORT_ROLLBACK_FAILED IMPORT_ROLLBACK_COMPLETE ) end |
.does_not_exist_status_text ⇒ Object
50 51 52 |
# File 'lib/openstax/aws/stack_status.rb', line 50 def self.does_not_exist_status_text "DOES_NOT_EXIST" end |
.failure_status_texts ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/openstax/aws/stack_status.rb', line 85 def self.failure_status_texts %w( UPDATE_ROLLBACK_COMPLETE ROLLBACK_COMPLETE ROLLBACK_IN_PROGRESS CREATE_FAILED ROLLBACK_FAILED DELETE_FAILED UPDATE_ROLLBACK_FAILED IMPORT_ROLLBACK_FAILED ) end |
.success_status_texts ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/openstax/aws/stack_status.rb', line 98 def self.success_status_texts %w( UPDATE_COMPLETE DELETE_COMPLETE CREATE_COMPLETE ) end |
Instance Method Details
#creating? ⇒ Boolean
38 39 40 |
# File 'lib/openstax/aws/stack_status.rb', line 38 def creating? "CREATE_IN_PROGRESS" == status_text end |
#deleting? ⇒ Boolean
42 43 44 |
# File 'lib/openstax/aws/stack_status.rb', line 42 def deleting? "DELETE_IN_PROGRESS" == status_text end |
#exists? ⇒ Boolean
46 47 48 |
# File 'lib/openstax/aws/stack_status.rb', line 46 def exists? self.class.does_not_exist_status_text != status_text end |
#failed? ⇒ Boolean
21 22 23 |
# File 'lib/openstax/aws/stack_status.rb', line 21 def failed? self.class.failure_status_texts.include?(status_text) end |
#failed_events_since_last_user_event ⇒ Object
106 107 108 109 110 111 |
# File 'lib/openstax/aws/stack_status.rb', line 106 def failed_events_since_last_user_event @stack.events.each_with_object([]) do |event, array| array.push(event) if event.failed? && event.status_reason #if nil, don't push return array if event.user_initiated? end end |
#status_text ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/openstax/aws/stack_status.rb', line 8 def status_text begin @stack.aws_stack.stack_status rescue Aws::CloudFormation::Errors::ValidationError => ee case ee. when /Stack.*does not exist/ self.class.does_not_exist_status_text else raise end end end |
#succeeded? ⇒ Boolean
25 26 27 |
# File 'lib/openstax/aws/stack_status.rb', line 25 def succeeded? self.class.success_status_texts.include?(status_text) end |
#to_h ⇒ Object
113 114 115 116 117 118 |
# File 'lib/openstax/aws/stack_status.rb', line 113 def to_h { status: status_text, failed_events_since_last_user_event: failed? ? failed_events_since_last_user_event : [] } end |
#to_json ⇒ Object
120 121 122 |
# File 'lib/openstax/aws/stack_status.rb', line 120 def to_json to_h.to_json end |
#updating? ⇒ Boolean
29 30 31 32 33 34 35 36 |
# File 'lib/openstax/aws/stack_status.rb', line 29 def updating? %w( UPDATE_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_IN_PROGRESS UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_IN_PROGRESS ).include?(status_text) end |