Class: Aws::Glacier::Notification
- Inherits:
-
Object
- Object
- Aws::Glacier::Notification
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-glacier/notification.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
- #account_id ⇒ String
-
#events ⇒ Array<String>
A list of one or more events for which Amazon Glacier will send a notification to the specified Amazon SNS topic.
-
#sns_topic ⇒ String
The Amazon Simple Notification Service (Amazon SNS) topic Amazon Resource Name (ARN).
- #vault_name ⇒ String
Actions collapse
Associations collapse
- #identifiers ⇒ Object deprecated private Deprecated.
- #vault ⇒ Vault
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::VaultNotificationConfig
Returns the data for this Notification.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ Notification
constructor
A new instance of Notification.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current Notification.
-
#wait_until(options = {}, &block) ⇒ Resource
deprecated
Deprecated.
Use [Aws::Glacier::Client] #wait_until instead
Constructor Details
#initialize(account_id, vault_name, options = {}) ⇒ Notification #initialize(options = {}) ⇒ Notification
Returns a new instance of Notification.
21 22 23 24 25 26 27 |
# File 'lib/aws-sdk-glacier/notification.rb', line 21 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @account_id = extract_account_id(args, ) @vault_name = extract_vault_name(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() end |
Instance Method Details
#account_id ⇒ String
32 33 34 |
# File 'lib/aws-sdk-glacier/notification.rb', line 32 def account_id @account_id end |
#client ⇒ Client
58 59 60 |
# File 'lib/aws-sdk-glacier/notification.rb', line 58 def client @client end |
#data ⇒ Types::VaultNotificationConfig
Returns the data for this Aws::Glacier::Notification. Calls Client#get_vault_notifications if #data_loaded? is ‘false`.
81 82 83 84 |
# File 'lib/aws-sdk-glacier/notification.rb', line 81 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
89 90 91 |
# File 'lib/aws-sdk-glacier/notification.rb', line 89 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
195 196 197 198 199 200 201 202 |
# File 'lib/aws-sdk-glacier/notification.rb', line 195 def delete( = {}) = .merge( account_id: @account_id, vault_name: @vault_name ) resp = @client.delete_vault_notifications() resp.data end |
#events ⇒ Array<String>
A list of one or more events for which Amazon Glacier will send a notification to the specified Amazon SNS topic.
51 52 53 |
# File 'lib/aws-sdk-glacier/notification.rb', line 51 def events data[:events] 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.
238 239 240 241 242 243 |
# File 'lib/aws-sdk-glacier/notification.rb', line 238 def identifiers { account_id: @account_id, vault_name: @vault_name } end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::Glacier::Notification. Returns ‘self` making it possible to chain methods.
notification.reload.data
68 69 70 71 72 73 74 75 |
# File 'lib/aws-sdk-glacier/notification.rb', line 68 def load resp = @client.get_vault_notifications( account_id: @account_id, vault_name: @vault_name ) @data = resp.vault_notification_config self end |
#set(options = {}) ⇒ EmptyStructure
216 217 218 219 220 221 222 223 |
# File 'lib/aws-sdk-glacier/notification.rb', line 216 def set( = {}) = .merge( account_id: @account_id, vault_name: @vault_name ) resp = @client.set_vault_notifications() resp.data end |
#sns_topic ⇒ String
The Amazon Simple Notification Service (Amazon SNS) topic Amazon Resource Name (ARN).
44 45 46 |
# File 'lib/aws-sdk-glacier/notification.rb', line 44 def sns_topic data[:sns_topic] end |
#vault ⇒ Vault
228 229 230 231 232 233 234 |
# File 'lib/aws-sdk-glacier/notification.rb', line 228 def vault Vault.new( account_id: @account_id, name: @vault_name, client: @client ) end |
#vault_name ⇒ String
37 38 39 |
# File 'lib/aws-sdk-glacier/notification.rb', line 37 def vault_name @vault_name end |
#wait_until(options = {}, &block) ⇒ Resource
Use [Aws::Glacier::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) {|instance| instance.state.name == 'running' }
## 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
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/aws-sdk-glacier/notification.rb', line 171 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::Waiters::Waiter.new().wait({}) end |