Class: Aws::Glacier::Vault
- Inherits:
-
Object
- Object
- Aws::Glacier::Vault
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-glacier/vault.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
- #account_id ⇒ String
-
#creation_date ⇒ Time
The Universal Coordinated Time (UTC) date when the vault was created.
-
#last_inventory_date ⇒ Time
The Universal Coordinated Time (UTC) date when Amazon S3 Glacier completed the last vault inventory.
- #name ⇒ String (also: #vault_name)
-
#number_of_archives ⇒ Integer
The number of archives in the vault as of the last inventory date.
-
#size_in_bytes ⇒ Integer
Total size, in bytes, of the archives in the vault as of the last inventory date.
-
#vault_arn ⇒ String
The Amazon Resource Name (ARN) of the vault.
Actions collapse
- #create(options = {}) ⇒ Types::CreateVaultOutput
- #delete(options = {}) ⇒ EmptyStructure
- #initiate_inventory_retrieval(options = {}) ⇒ Job
- #initiate_multipart_upload(options = {}) ⇒ MultipartUpload
- #upload_archive(options = {}) ⇒ Archive
Associations collapse
- #account ⇒ Account
- #archive(id) ⇒ Archive
- #completed_jobs(options = {}) ⇒ Job::Collection
- #failed_jobs(options = {}) ⇒ Job::Collection
- #identifiers ⇒ Object deprecated private Deprecated.
- #job(id) ⇒ Job
- #jobs(options = {}) ⇒ Job::Collection
- #jobs_in_progress(options = {}) ⇒ Job::Collection
- #multipart_uplaods(options = {}) ⇒ MultipartUpload::Collection
- #multipart_upload(id) ⇒ MultipartUpload
- #notification ⇒ Notification
- #succeeded_jobs(options = {}) ⇒ Job::Collection
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::DescribeVaultOutput
Returns the data for this Vault.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ Vault
constructor
A new instance of Vault.
- #load ⇒ self (also: #reload)
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::Glacier::Client] #wait_until instead
Constructor Details
#initialize(account_id, name, options = {}) ⇒ Vault #initialize(options = {}) ⇒ Vault
Returns a new instance of Vault.
24 25 26 27 28 29 30 31 |
# File 'lib/aws-sdk-glacier/vault.rb', line 24 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @account_id = extract_account_id(args, ) @name = extract_name(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#account ⇒ Account
349 350 351 352 353 354 |
# File 'lib/aws-sdk-glacier/vault.rb', line 349 def account Account.new( id: @account_id, client: @client ) end |
#account_id ⇒ String
36 37 38 |
# File 'lib/aws-sdk-glacier/vault.rb', line 36 def account_id @account_id end |
#archive(id) ⇒ Archive
358 359 360 361 362 363 364 365 |
# File 'lib/aws-sdk-glacier/vault.rb', line 358 def archive(id) Archive.new( account_id: @account_id, vault_name: @name, id: id, client: @client ) end |
#completed_jobs(options = {}) ⇒ Job::Collection
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/aws-sdk-glacier/vault.rb', line 377 def completed_jobs( = {}) batches = Enumerator.new do |y| = .merge( account_id: @account_id, vault_name: @name, completed: "true" ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_jobs() end resp.each_page do |page| batch = [] page.data.job_list.each do |j| batch << Job.new( account_id: @account_id, vault_name: @name, id: j.job_id, data: j, client: @client ) end y.yield(batch) end end Job::Collection.new(batches) end |
#create(options = {}) ⇒ Types::CreateVaultOutput
230 231 232 233 234 235 236 237 238 239 |
# File 'lib/aws-sdk-glacier/vault.rb', line 230 def create( = {}) = .merge( vault_name: @name, account_id: @account_id ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_vault() end resp.data end |
#creation_date ⇒ Time
The Universal Coordinated Time (UTC) date when the vault was created. This value should be a string in the ISO 8601 date format, for example ‘2012-03-20T17:03:43.221Z`.
56 57 58 |
# File 'lib/aws-sdk-glacier/vault.rb', line 56 def creation_date data[:creation_date] end |
#data ⇒ Types::DescribeVaultOutput
Returns the data for this Aws::Glacier::Vault. Calls Client#describe_vault if #data_loaded? is ‘false`.
112 113 114 115 |
# File 'lib/aws-sdk-glacier/vault.rb', line 112 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
120 121 122 |
# File 'lib/aws-sdk-glacier/vault.rb', line 120 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
246 247 248 249 250 251 252 253 254 255 |
# File 'lib/aws-sdk-glacier/vault.rb', line 246 def delete( = {}) = .merge( vault_name: @name, account_id: @account_id ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.delete_vault() end resp.data end |
#failed_jobs(options = {}) ⇒ Job::Collection
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/aws-sdk-glacier/vault.rb', line 413 def failed_jobs( = {}) batches = Enumerator.new do |y| = .merge( account_id: @account_id, vault_name: @name, statuscode: "Failed" ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_jobs() end resp.each_page do |page| batch = [] page.data.job_list.each do |j| batch << Job.new( account_id: @account_id, vault_name: @name, id: j.job_id, data: j, client: @client ) end y.yield(batch) end end Job::Collection.new(batches) 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.
615 616 617 618 619 620 |
# File 'lib/aws-sdk-glacier/vault.rb', line 615 def identifiers { account_id: @account_id, name: @name } end |
#initiate_inventory_retrieval(options = {}) ⇒ Job
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/aws-sdk-glacier/vault.rb', line 262 def initiate_inventory_retrieval( = {}) = Aws::Util.deep_merge(, vault_name: @name, account_id: @account_id, job_parameters: { type: "inventory-retrieval" } ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.initiate_job() end Job.new( id: resp.data.job_id, account_id: @account_id, vault_name: @name, client: @client ) end |
#initiate_multipart_upload(options = {}) ⇒ MultipartUpload
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/aws-sdk-glacier/vault.rb', line 299 def initiate_multipart_upload( = {}) = .merge( vault_name: @name, account_id: @account_id ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.initiate_multipart_upload() end MultipartUpload.new( id: resp.data.upload_id, account_id: @account_id, vault_name: @name, client: @client ) end |
#job(id) ⇒ Job
442 443 444 445 446 447 448 449 |
# File 'lib/aws-sdk-glacier/vault.rb', line 442 def job(id) Job.new( account_id: @account_id, vault_name: @name, id: id, client: @client ) end |
#jobs(options = {}) ⇒ Job::Collection
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/aws-sdk-glacier/vault.rb', line 464 def jobs( = {}) batches = Enumerator.new do |y| = .merge( account_id: @account_id, vault_name: @name ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_jobs() end resp.each_page do |page| batch = [] page.data.job_list.each do |j| batch << Job.new( account_id: @account_id, vault_name: @name, id: j.job_id, data: j, client: @client ) end y.yield(batch) end end Job::Collection.new(batches) end |
#jobs_in_progress(options = {}) ⇒ Job::Collection
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/aws-sdk-glacier/vault.rb', line 499 def jobs_in_progress( = {}) batches = Enumerator.new do |y| = .merge( account_id: @account_id, vault_name: @name, statuscode: "InProgress" ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_jobs() end resp.each_page do |page| batch = [] page.data.job_list.each do |j| batch << Job.new( account_id: @account_id, vault_name: @name, id: j.job_id, data: j, client: @client ) end y.yield(batch) end end Job::Collection.new(batches) end |
#last_inventory_date ⇒ Time
The Universal Coordinated Time (UTC) date when Amazon S3 Glacier completed the last vault inventory. This value should be a string in the ISO 8601 date format, for example ‘2012-03-20T17:03:43.221Z`.
64 65 66 |
# File 'lib/aws-sdk-glacier/vault.rb', line 64 def last_inventory_date data[:last_inventory_date] end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::Glacier::Vault. Returns ‘self` making it possible to chain methods.
vault.reload.data
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/aws-sdk-glacier/vault.rb', line 97 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_vault( vault_name: @name, account_id: @account_id ) end @data = resp.data self end |
#multipart_uplaods(options = {}) ⇒ MultipartUpload::Collection
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'lib/aws-sdk-glacier/vault.rb', line 531 def multipart_uplaods( = {}) batches = Enumerator.new do |y| = .merge( vault_name: @name, account_id: @account_id ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_multipart_uploads() end resp.each_page do |page| batch = [] page.data.uploads_list.each do |u| batch << MultipartUpload.new( account_id: @account_id, vault_name: @name, id: u.multipart_upload_id, data: u, client: @client ) end y.yield(batch) end end MultipartUpload::Collection.new(batches) end |
#multipart_upload(id) ⇒ MultipartUpload
559 560 561 562 563 564 565 566 |
# File 'lib/aws-sdk-glacier/vault.rb', line 559 def multipart_upload(id) MultipartUpload.new( account_id: @account_id, vault_name: @name, id: id, client: @client ) end |
#name ⇒ String Also known as: vault_name
41 42 43 |
# File 'lib/aws-sdk-glacier/vault.rb', line 41 def name @name end |
#notification ⇒ Notification
569 570 571 572 573 574 575 |
# File 'lib/aws-sdk-glacier/vault.rb', line 569 def notification Notification.new( account_id: @account_id, vault_name: @name, client: @client ) end |
#number_of_archives ⇒ Integer
The number of archives in the vault as of the last inventory date. This field will return ‘null` if an inventory has not yet run on the vault, for example if you just created the vault.
72 73 74 |
# File 'lib/aws-sdk-glacier/vault.rb', line 72 def number_of_archives data[:number_of_archives] end |
#size_in_bytes ⇒ Integer
Total size, in bytes, of the archives in the vault as of the last inventory date. This field will return null if an inventory has not yet run on the vault, for example if you just created the vault.
80 81 82 |
# File 'lib/aws-sdk-glacier/vault.rb', line 80 def size_in_bytes data[:size_in_bytes] end |
#succeeded_jobs(options = {}) ⇒ Job::Collection
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'lib/aws-sdk-glacier/vault.rb', line 586 def succeeded_jobs( = {}) batches = Enumerator.new do |y| = .merge( account_id: @account_id, vault_name: @name, statuscode: "Succeeded" ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_jobs() end resp.each_page do |page| batch = [] page.data.job_list.each do |j| batch << Job.new( account_id: @account_id, vault_name: @name, id: j.job_id, data: j, client: @client ) end y.yield(batch) end end Job::Collection.new(batches) end |
#upload_archive(options = {}) ⇒ Archive
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/aws-sdk-glacier/vault.rb', line 330 def upload_archive( = {}) = .merge( vault_name: @name, account_id: @account_id ) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.upload_archive() end Archive.new( id: resp.data.archive_id, account_id: @account_id, vault_name: @name, client: @client ) end |
#vault_arn ⇒ String
The Amazon Resource Name (ARN) of the vault.
48 49 50 |
# File 'lib/aws-sdk-glacier/vault.rb', line 48 def vault_arn data[:vault_arn] end |
#wait_until(options = {}) {|resource| ... } ⇒ 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) 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
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/aws-sdk-glacier/vault.rb', line 204 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 |