Class: Aws::Glacier::Resource

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

Overview

This class provides a resource oriented interface for Glacier. To create a resource object:

resource = Aws::Glacier::Resource.new(region: 'us-west-2')

You can supply a client object with custom configuration that will be used for all resource operations. If you do not pass :client, a default client will be constructed.

client = Aws::Glacier::Client.new(region: 'us-west-2')
resource = Aws::Glacier::Resource.new(client: client)

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):



27
28
29
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 27

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

Instance Method Details

#account(id) ⇒ Account

Parameters:

  • id (String)

Returns:



63
64
65
66
67
68
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 63

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

#clientClient

Returns:



32
33
34
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 32

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:



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

def create_vault(options = {})
  options = options.merge(account_id: "-")
  Aws::Plugins::UserAgent.feature('resource') do
    @client.create_vault(options)
  end
  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:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'gems/aws-sdk-glacier/lib/aws-sdk-glacier/resource.rb', line 75

def vaults(options = {})
  batches = Enumerator.new do |y|
    options = options.merge(account_id: "-")
    resp = Aws::Plugins::UserAgent.feature('resource') do
      @client.list_vaults(options)
    end
    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