Class: Fog::AWS::Glacier::Real
- Inherits:
-
Object
- Object
- Fog::AWS::Glacier::Real
- Includes:
- CredentialFetcher::ConnectionMethods
- Defined in:
- lib/fog/aws/glacier.rb,
lib/fog/aws/requests/glacier/list_jobs.rb,
lib/fog/aws/requests/glacier/list_parts.rb,
lib/fog/aws/requests/glacier/list_vaults.rb,
lib/fog/aws/requests/glacier/upload_part.rb,
lib/fog/aws/requests/glacier/create_vault.rb,
lib/fog/aws/requests/glacier/delete_vault.rb,
lib/fog/aws/requests/glacier/describe_job.rb,
lib/fog/aws/requests/glacier/initiate_job.rb,
lib/fog/aws/requests/glacier/create_archive.rb,
lib/fog/aws/requests/glacier/delete_archive.rb,
lib/fog/aws/requests/glacier/describe_vault.rb,
lib/fog/aws/requests/glacier/get_job_output.rb,
lib/fog/aws/requests/glacier/abort_multipart_upload.rb,
lib/fog/aws/requests/glacier/list_multipart_uploads.rb,
lib/fog/aws/requests/glacier/complete_multipart_upload.rb,
lib/fog/aws/requests/glacier/initiate_multipart_upload.rb,
lib/fog/aws/requests/glacier/get_vault_notification_configuration.rb,
lib/fog/aws/requests/glacier/set_vault_notification_configuration.rb,
lib/fog/aws/requests/glacier/delete_vault_notification_configuration.rb
Instance Method Summary collapse
-
#abort_multipart_upload(vault_name, upload_id, options = {}) ⇒ Object
Abort an upload.
-
#complete_multipart_upload(vault_name, upload_id, total_size, tree_hash, options = {}) ⇒ Object
Complete an upload.
-
#create_archive(vault_name, body, options = {}) ⇒ Object
Upload an archive.
-
#create_vault(name, options = {}) ⇒ Object
This operation creates a new vault with the specified name.
-
#delete_archive(name, archive_id, options = {}) ⇒ Object
Delete an archive.
-
#delete_vault(name, options = {}) ⇒ Object
Delete a vault.
-
#delete_vault_notification_configuration(name, options = {}) ⇒ Object
Delete vault’s notification configuration.
-
#describe_job(vault_name, job_id, options = {}) ⇒ Object
Complete an upload.
-
#describe_vault(name, options = {}) ⇒ Object
This operation returns information about a vault.
-
#get_job_output(vault_name, job_id, options = {}) ⇒ Object
Get the output from a job.
-
#get_vault_notification_configuration(name, options = {}) ⇒ Object
Get a vault’s notification configuration.
-
#initialize(options = {}) ⇒ Real
constructor
Initialize connection to Glacier.
-
#initiate_job(name, job_specification, options = {}) ⇒ Object
This operation initiates a multipart upload of an archive to a vault.
-
#initiate_multipart_upload(name, part_size, options = {}) ⇒ Object
This operation initiates a multipart upload of an archive to a vault.
-
#list_jobs(vault_name, options = {}) ⇒ Object
lists in-progress and recently jobs for the specified vault.
-
#list_multipart_uploads(vault_name, options = {}) ⇒ Object
lists in-progress multipart uploads for the specified vault.
-
#list_parts(vault_name, upload_id, options = {}) ⇒ Object
lists the parts of an archive that have been uploaded in a specific multipart upload.
-
#list_vaults(options = {}) ⇒ Object
This operation lists all vaults owned by the calling user’s account.
-
#set_vault_notification_configuration(name, sns_topic, events, options = {}) ⇒ Object
Set a vault’s notification configuration.
-
#upload_part(vault_name, upload_id, body, offset, hash, options = {}) ⇒ Object
Upload an archive.
Methods included from CredentialFetcher::ConnectionMethods
#refresh_credentials_if_expired
Constructor Details
#initialize(options = {}) ⇒ Real
Initialize connection to Glacier
Notes
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
Examples
ses = SES.new(
:aws_access_key_id => your_aws_access_key_id,
:aws_secret_access_key => your_aws_secret_access_key
)
Parameters
-
options<~Hash> - config arguments for connection. Defaults to {}.
-
region<~String> - optional region to use. For instance, ‘us-east-1’ and etc.
-
Returns
-
Glacier object with connection to AWS.
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/fog/aws/glacier.rb', line 179 def initialize(={}) @use_iam_profile = [:use_iam_profile] @region = [:region] || 'us-east-1' setup_credentials() @instrumentor = [:instrumentor] @instrumentor_name = [:instrumentor_name] || 'fog.aws.glacier' @connection_options = [:connection_options] || {} @host = [:host] || "glacier.#{@region}.amazonaws.com" @version = '2012-06-01' @path = [:path] || '/' @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) end |
Instance Method Details
#abort_multipart_upload(vault_name, upload_id, options = {}) ⇒ Object
Abort an upload
Parameters
-
name<~String> Name of the vault to upload to
-
upload_id<~String> The id of the upload to complete
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-multipart-abort-upload.html
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fog/aws/requests/glacier/abort_multipart_upload.rb', line 18 def abort_multipart_upload(vault_name, upload_id, ={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/multipart-uploads/#{upload_id}" request( :expects => 204, :idempotent => true, :headers => {}, :method => :delete, :path => path ) end |
#complete_multipart_upload(vault_name, upload_id, total_size, tree_hash, options = {}) ⇒ Object
Complete an upload
Parameters
-
name<~String> Name of the vault to upload to
-
upload_id<~String> The id of the upload to complete
-
total_size<~Integer> The total archive size
-
tree_hash<~String> the treehash for the archive
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-multipart-complete-upload.html
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fog/aws/requests/glacier/complete_multipart_upload.rb', line 20 def complete_multipart_upload(vault_name, upload_id, total_size, tree_hash, ={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/multipart-uploads/#{upload_id}" headers = { 'x-amz-archive-size' => total_size.to_s, 'x-amz-sha256-tree-hash' => tree_hash } request( :expects => 201, :idempotent => true, :headers => headers, :method => :post, :path => path ) end |
#create_archive(vault_name, body, options = {}) ⇒ Object
Upload an archive
Parameters
-
name<~String> Name of the vault to upload to
-
body<~String> The data to upload
-
options<~Hash>
-
description<~String> - The archive description
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-archive-post.html
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/aws/requests/glacier/create_archive.rb', line 19 def create_archive(vault_name, body, ={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/archives" headers = { 'Content-Length' => body.bytesize.to_s, 'x-amz-content-sha256' => OpenSSL::Digest::SHA256.hexdigest(body), 'x-amz-sha256-tree-hash' => Fog::AWS::Glacier::TreeHash.digest(body) } headers['x-amz-archive-description'] = Fog::AWS.escape(['description']) if ['description'] request( :expects => 201, :headers => headers, :method => :post, :path => path, :body => body ) end |
#create_vault(name, options = {}) ⇒ Object
This operation creates a new vault with the specified name. .
Parameters
-
name<~String> 1-255 characters. must be unique within a region for an AWS account
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-vault-put.html
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fog/aws/requests/glacier/create_vault.rb', line 18 def create_vault(name,={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}" request(.merge({ :expects => 201, :idempotent => true, :headers => {}, :method => :put, :path => path, })) end |
#delete_archive(name, archive_id, options = {}) ⇒ Object
Delete an archive
Parameters
-
name<~String> Name of the vault to delete
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘RequestId’<~String> - Id of the request
-
-
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-vault-delete.html
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fog/aws/requests/glacier/delete_archive.rb', line 19 def delete_archive(name,archive_id,={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}/archives/#{archive_id}" request( :expects => 204, :idempotent => true, :headers => {}, :method => :delete, :path => path ) end |
#delete_vault(name, options = {}) ⇒ Object
Delete a vault. Amazon Glacier will delete a vault only if there are no archives in the vault as per the last inventory and there have been no writes to the vault since the last inventory
Parameters
-
name<~String> Name of the vault to delete
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-vault-delete.html
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fog/aws/requests/glacier/delete_vault.rb', line 18 def delete_vault(name,={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}" request( :expects => 204, :idempotent => true, :headers => {}, :method => :delete, :path => path ) end |
#delete_vault_notification_configuration(name, options = {}) ⇒ Object
Delete vault’s notification configuration
Parameters
-
name<~String> Name of the vault
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-vault-notifications-delete.html
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/aws/requests/glacier/delete_vault_notification_configuration.rb', line 17 def delete_vault_notification_configuration(name,={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}/notification-configuration" request( :expects => 204, :idempotent => true, :headers => {}, :method => :delete, :path => path ) end |
#describe_job(vault_name, job_id, options = {}) ⇒ Object
Complete an upload
Parameters
-
name<~String> Name of the vault
-
job_id<~String> The id of the job
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-describe-job-get.html
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fog/aws/requests/glacier/describe_job.rb', line 18 def describe_job(vault_name, job_id, ={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/jobs/#{job_id}" request( :expects => 200, :idempotent => true, :headers => {}, :method => :get, :path => path ) end |
#describe_vault(name, options = {}) ⇒ Object
This operation returns information about a vault
Parameters
-
name<~String> Vault name
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-vault-get.html
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fog/aws/requests/glacier/describe_vault.rb', line 18 def describe_vault(name,={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}" request( :expects => 200, :idempotent => true, :headers => {}, :method => :get, :path => path ) end |
#get_job_output(vault_name, job_id, options = {}) ⇒ Object
Get the output from a job
Parameters
-
name<~String> Name of the vault
-
job_id<~String> The id of the job
-
options<~Hash>
-
Range<~Range> The range to retrieve
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
response_block<~Proc> Proc to use for streaming the response
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-job-output-get.html
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/aws/requests/glacier/get_job_output.rb', line 20 def get_job_output(vault_name, job_id, ={}) account_id = .delete('account_id') || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/jobs/#{job_id}/output" headers = {} if range = .delete('Range') headers['Range'] = "bytes=#{range.begin}-#{range.end}" end request( .merge( :expects => [200,206], :idempotent => true, :headers => headers, :method => :get, :path => path )) end |
#get_vault_notification_configuration(name, options = {}) ⇒ Object
Get a vault’s notification configuration
Parameters
-
name<~String> Name of the vault
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-vault-notifications-get.html
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fog/aws/requests/glacier/get_vault_notification_configuration.rb', line 18 def get_vault_notification_configuration(name,={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}/notification-configuration" request( :expects => 200, :idempotent => true, :headers => {}, :method => :get, :path => path ) end |
#initiate_job(name, job_specification, options = {}) ⇒ Object
This operation initiates a multipart upload of an archive to a vault
Parameters
-
name<~String> The vault name
-
job_specification<~Hash> A specification of the job
* Type<~String> The job type. Mandatory. Values: archive-retrieval, inventory-retrieval * Description<~String> The job description * ArchiveId<~String> The id of the archive to retrieve (only for Type==archive-retrieval) * Format<~String> The format to return (only for inventory retrieval). Values: CSV, JSON * SNSTopic<String> ARN of a topic to publish to when the job is complete
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-initiate-job-post.html
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/aws/requests/glacier/initiate_job.rb', line 24 def initiate_job(name, job_specification, ={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}/jobs" request({ :expects => 202, :headers => {}, :method => 'POST', :path => path, :body => Fog::JSON.encode(job_specification) }) end |
#initiate_multipart_upload(name, part_size, options = {}) ⇒ Object
This operation initiates a multipart upload of an archive to a vault
Parameters
-
name<~String> The vault name
-
part_size<~Integer> The part size to use. Must be a power of 2 multiple of 1MB (1,2,4,8,16,…)
-
options<~Hash>
-
description<~String> - The archive description
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-multipart-initiate-upload.html
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fog/aws/requests/glacier/initiate_multipart_upload.rb', line 20 def initiate_multipart_upload(name, part_size, ={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}/multipart-uploads" headers = {'x-amz-part-size' => part_size.to_s} headers['x-amz-archive-description'] = Fog::AWS.escape(['description']) if ['description'] request( :expects => 201, :headers => headers, :method => 'POST', :path => path ) end |
#list_jobs(vault_name, options = {}) ⇒ Object
lists in-progress and recently jobs for the specified vault
Parameters
-
name<~String> Name of the vault
-
options<~Hash>
-
completed<~Boolean>Specifies the state of the jobs to return. You can specify true or false
-
statuscode<~String> Filter returned jobs by status (InProgress, Succeeded, or Failed)
-
limit<~Integer> - The maximum number of items returned in the response. (default 1000)
-
marker<~String> - marker used for pagination
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-jobs-get.html
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fog/aws/requests/glacier/list_jobs.rb', line 20 def list_jobs(vault_name, ={}) account_id = .delete('account_id') || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/jobs" request( :expects => 200, :idempotent => true, :headers => {}, :method => :get, :path => path, :query => ) end |
#list_multipart_uploads(vault_name, options = {}) ⇒ Object
lists in-progress multipart uploads for the specified vault
Parameters
-
name<~String> Name of the vault
-
options<~Hash>
-
limit<~Integer> - The maximum number of items returned in the response. (default 1000)
-
marker<~String> - marker used for pagination
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-multipart-list-uploads.html
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fog/aws/requests/glacier/list_multipart_uploads.rb', line 18 def list_multipart_uploads(vault_name, ={}) account_id = .delete('account_id') || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/multipart-uploads" request( :expects => 200, :idempotent => true, :headers => {}, :method => :get, :path => path, :query => ) end |
#list_parts(vault_name, upload_id, options = {}) ⇒ Object
lists the parts of an archive that have been uploaded in a specific multipart upload
Parameters
-
name<~String> Name of the vault
-
upload_id<~String> The id of the upload
-
options<~Hash>
-
limit<~Integer> - The maximum number of items returned in the response. (default 1000)
-
marker<~String> - marker used for pagination
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-multipart-list-parts.html
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/aws/requests/glacier/list_parts.rb', line 19 def list_parts(vault_name, upload_id, ={}) account_id = .delete('account_id') || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/multipart-uploads/#{Fog::AWS.escape(upload_id)}" request( :expects => 200, :idempotent => true, :headers => {}, :method => :get, :path => path, :query => ) end |
#list_vaults(options = {}) ⇒ Object
This operation lists all vaults owned by the calling user’s account.
Parameters
-
options<~Hash>
-
limit<~Integer> - The maximum number of items returned in the response. (default 1000)
-
marker<~String> - marker used for pagination
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-vaults-get.html
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fog/aws/requests/glacier/list_vaults.rb', line 19 def list_vaults(={}) account_id = .delete('account_id') || '-' path = "/#{account_id}/vaults" request( :expects => 200, :idempotent => true, :headers => {}, :method => 'GET', :path => path, :query => ) end |
#set_vault_notification_configuration(name, sns_topic, events, options = {}) ⇒ Object
Set a vault’s notification configuration
Parameters
-
name<~String> Name of the vault
-
SnsTopic<~String> ARN of the topic to notify
-
events<~Array> Events you wish to receive. Valid events are ArchiveRetrievalCompleted, InventoryRetrievalCompleted
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-vault-notifications-put.html
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/aws/requests/glacier/set_vault_notification_configuration.rb', line 20 def set_vault_notification_configuration(name,sns_topic, events, ={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(name)}/notification-configuration" request( :expects => 204, :idempotent => true, :headers => {}, :method => :put, :path => path, :body => Fog::JSON.encode('SNSTopic' => sns_topic, 'Events' => events) ) end |
#upload_part(vault_name, upload_id, body, offset, hash, options = {}) ⇒ Object
Upload an archive
Parameters
-
name<~String> Name of the vault to upload to
-
uploadId<~String> Id of the upload
-
body<~String> The data to upload
-
offset<~Integer> The offset of the data within the archive
-
hash<~String> The tree hash for this part
-
options<~Hash>
-
account_id<~String> - The AWS account id. Defaults to the account owning the credentials making the request
-
Returns
-
response<~Excon::Response>:
See Also
docs.amazonwebservices.com/amazonglacier/latest/dev/api-upload-part.html
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fog/aws/requests/glacier/upload_part.rb', line 21 def upload_part(vault_name, upload_id, body, offset, hash, ={}) account_id = ['account_id'] || '-' path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/multipart-uploads/#{Fog::AWS.escape(upload_id)}" headers = { 'Content-Length' => body.bytesize.to_s, 'Content-Range' => "bytes #{offset}-#{offset+body.bytesize-1}/*", 'x-amz-content-sha256' => OpenSSL::Digest::SHA256.hexdigest(body), 'x-amz-sha256-tree-hash' => hash } request( :expects => 204, :idempotent => true, :headers => headers, :method => :put, :path => path, :body => body ) end |