1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[AWS|Glacier] Jobs requests

This commit is contained in:
Frederick Cheung 2012-09-01 23:40:51 +01:00
parent 17c8e44a31
commit 42b84b54c9
5 changed files with 160 additions and 0 deletions

View file

@ -17,9 +17,13 @@ module Fog
request :delete_archive
request :delete_vault
request :delete_vault_notification_configuration
request :describe_job
request :describe_vault
request :get_job_output
request :get_vault_notification_configuration
request :initiate_job
request :initiate_multipart_upload
request :list_jobs
request :list_multipart_uploads
request :list_parts
request :list_vaults

View file

@ -0,0 +1,35 @@
module Fog
module AWS
class Glacier
class Real
# 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
# http://docs.amazonwebservices.com/amazonglacier/latest/dev/api-describe-job-get.html
#
def describe_job(vault_name, job_id, options={})
account_id = options['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
end
end
end
end

View file

@ -0,0 +1,41 @@
module Fog
module AWS
class Glacier
class Real
# 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
# http://docs.amazonwebservices.com/amazonglacier/latest/dev/api-job-output-get.html
#
def get_job_output(vault_name, job_id, options={})
account_id = options.delete('account_id') || '-'
path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/jobs/#{job_id}/output"
headers = {}
if range = options.delete('Range')
headers['Range'] = "bytes=#{range.begin}-#{range.end}"
end
request(
options.merge(
:expects => [200,206],
:idempotent => true,
:headers => headers,
:method => :get,
:path => path,
))
end
end
end
end
end

View file

@ -0,0 +1,41 @@
module Fog
module AWS
class Glacier
class Real
# This operation initates 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
# http://docs.amazonwebservices.com/amazonglacier/latest/dev/api-initiate-job-post.html
#
def initiate_job(name, job_specification, options={})
account_id = options['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
end
end
end
end

View file

@ -0,0 +1,39 @@
module Fog
module AWS
class Glacier
class Real
# 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
#http://docs.amazonwebservices.com/amazonglacier/latest/dev/api-jobs-get.html
#
def list_jobs(vault_name, options={})
account_id = options.delete('account_id') || '-'
path = "/#{account_id}/vaults/#{Fog::AWS.escape(vault_name)}/jobs"
request(
:expects => 200,
:idempotent => true,
:headers => {},
:method => :get,
:path => path,
:query => options
)
end
end
end
end
end