You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::Glacier::Resource

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Resource

Returns a new instance of Resource

Parameters:

  • options ({}) (defaults to: {})

Options Hash (options):



13
14
15
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 13

def initialize(options = {})
  @client = options[:client] || Client.new(options)
end

Instance Method Details

#account(id) ⇒ Account

Parameters:

  • id (String)

Returns:



47
48
49
50
51
52
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 47

def (id)
  Account.new(
    id: id,
    client: @client
  )
end

#clientClient

Returns:



18
19
20
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 18

def client
  @client
end

#create_vault(options = {}) ⇒ Vault

Examples:

Request syntax with placeholder values


vault = glacier.create_vault({
  vault_name: "string", # required
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :vault_name (required, String)

    The name of the vault.

Returns:



33
34
35
36
37
38
39
40
41
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 33

def create_vault(options = {})
  options = options.merge(account_id: "-")
  resp = @client.create_vault(options)
  Vault.new(
    account_id: options[:account_id],
    name: options[:vault_name],
    client: @client
  )
end

#vaults(options = {}) ⇒ Vault::Collection

Examples:

Request syntax with placeholder values


glacier.vaults()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 59

def vaults(options = {})
  batches = Enumerator.new do |y|
    options = options.merge(account_id: "-")
    resp = @client.list_vaults(options)
    resp.each_page do |page|
      batch = []
      page.data.vault_list.each do |v|
        batch << Vault.new(
          account_id: options[:account_id],
          name: v.vault_name,
          data: v,
          client: @client
        )
      end
      y.yield(batch)
    end
  end
  Vault::Collection.new(batches)
end