Class: Aws::OpsWorks::StackSummary
- Inherits:
-
Object
- Object
- Aws::OpsWorks::StackSummary
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-opsworks/stack_summary.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#apps_count ⇒ Integer
The number of apps.
-
#arn ⇒ String
The stack’s ARN.
-
#instances_count ⇒ Types::InstancesCount
An ‘InstancesCount` object with the number of instances in each status.
-
#layers_count ⇒ Integer
The number of layers.
-
#name ⇒ String
The stack name.
- #stack_id ⇒ String
Associations collapse
- #identifiers ⇒ Object deprecated private Deprecated.
- #stack ⇒ Stack
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::StackSummary
Returns the data for this StackSummary.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ StackSummary
constructor
A new instance of StackSummary.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current StackSummary.
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::OpsWorks::Client] #wait_until instead
Constructor Details
#initialize(stack_id, options = {}) ⇒ StackSummary #initialize(options = {}) ⇒ StackSummary
Returns a new instance of StackSummary.
22 23 24 25 26 27 28 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 22 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @stack_id = extract_stack_id(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#apps_count ⇒ Integer
The number of apps.
57 58 59 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 57 def apps_count data[:apps_count] end |
#arn ⇒ String
The stack’s ARN.
45 46 47 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 45 def arn data[:arn] end |
#client ⇒ Client
71 72 73 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 71 def client @client end |
#data ⇒ Types::StackSummary
Returns the data for this Aws::OpsWorks::StackSummary. Calls Client#describe_stack_summary if #data_loaded? is ‘false`.
93 94 95 96 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 93 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
101 102 103 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 101 def data_loaded? !!@data end |
#identifiers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
216 217 218 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 216 def identifiers { stack_id: @stack_id } end |
#instances_count ⇒ Types::InstancesCount
An ‘InstancesCount` object with the number of instances in each status.
64 65 66 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 64 def instances_count data[:instances_count] end |
#layers_count ⇒ Integer
The number of layers.
51 52 53 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 51 def layers_count data[:layers_count] end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::OpsWorks::StackSummary. Returns ‘self` making it possible to chain methods.
stack_summary.reload.data
81 82 83 84 85 86 87 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 81 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_stack_summary(stack_id: @stack_id) end @data = resp.stack_summary self end |
#name ⇒ String
The stack name.
39 40 41 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 39 def name data[:name] end |
#stack ⇒ Stack
207 208 209 210 211 212 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 207 def stack Stack.new( id: @stack_id, client: @client ) end |
#stack_id ⇒ String
33 34 35 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 33 def stack_id @stack_id end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::OpsWorks::Client] #wait_until instead
The waiting operation is performed on a copy. The original resource remains unchanged.
Waiter polls an API operation until a resource enters a desired state.
## Basic Usage
Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop until condition is true
resource.wait_until() {|resource| condition}
## Example
instance.wait_until(max_attempts:10, delay:5) do |instance|
instance.state.name == 'running'
end
## Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:
# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}
## Callbacks
You can be notified before each polling attempt and before each delay. If you throw ‘:success` or `:failure` from these callbacks, it will terminate the waiter.
started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
# disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}
## Handling Errors
When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.
begin
resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
attempts attempt in seconds invoked before each attempt invoked before each wait
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/aws-sdk-opsworks/stack_summary.rb', line 185 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do Aws::Waiters::Waiter.new().wait({}) end end |