aws-sdk-glacier 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
@@ -0,0 +1,23 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module Glacier
10
+ module Errors
11
+
12
+ extend Aws::Errors::DynamicErrors
13
+
14
+ # Raised when calling #load or #data on a resource class that can not be
15
+ # loaded. This can happen when:
16
+ #
17
+ # * A resource class has identifiers, but no data attributes.
18
+ # * Resource data is only available when making an API call that
19
+ # enumerates all resources of that type.
20
+ class ResourceNotLoadable < RuntimeError; end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,345 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module Glacier
10
+ class Job
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(account_id, vault_name, id, options = {})
15
+ # @param [String] account_id
16
+ # @param [String] vault_name
17
+ # @param [String] id
18
+ # @option options [Client] :client
19
+ # @overload def initialize(options = {})
20
+ # @option options [required, String] :account_id
21
+ # @option options [required, String] :vault_name
22
+ # @option options [required, String] :id
23
+ # @option options [Client] :client
24
+ def initialize(*args)
25
+ options = Hash === args.last ? args.pop.dup : {}
26
+ @account_id = extract_account_id(args, options)
27
+ @vault_name = extract_vault_name(args, options)
28
+ @id = extract_id(args, options)
29
+ @data = options.delete(:data)
30
+ @client = options.delete(:client) || Client.new(options)
31
+ end
32
+
33
+ # @!group Read-Only Attributes
34
+
35
+ # @return [String]
36
+ def account_id
37
+ @account_id
38
+ end
39
+
40
+ # @return [String]
41
+ def vault_name
42
+ @vault_name
43
+ end
44
+
45
+ # @return [String]
46
+ def id
47
+ @id
48
+ end
49
+ alias :job_id :id
50
+
51
+ # The job description you provided when you initiated the job.
52
+ # @return [String]
53
+ def job_description
54
+ data.job_description
55
+ end
56
+
57
+ # The job type. It is either ArchiveRetrieval or InventoryRetrieval.
58
+ # @return [String]
59
+ def action
60
+ data.action
61
+ end
62
+
63
+ # For an ArchiveRetrieval job, this is the archive ID requested for
64
+ # download. Otherwise, this field is null.
65
+ # @return [String]
66
+ def archive_id
67
+ data.archive_id
68
+ end
69
+
70
+ # The Amazon Resource Name (ARN) of the vault from which the archive
71
+ # retrieval was requested.
72
+ # @return [String]
73
+ def vault_arn
74
+ data.vault_arn
75
+ end
76
+
77
+ # The UTC date when the job was created. A string representation of ISO
78
+ # 8601 date format, for example, "2012-03-20T17:03:43.221Z".
79
+ # @return [Time]
80
+ def creation_date
81
+ data.creation_date
82
+ end
83
+
84
+ # The job status. When a job is completed, you get the job's output.
85
+ # @return [Boolean]
86
+ def completed
87
+ data.completed
88
+ end
89
+
90
+ # The status code can be InProgress, Succeeded, or Failed, and indicates
91
+ # the status of the job.
92
+ # @return [String]
93
+ def status_code
94
+ data.status_code
95
+ end
96
+
97
+ # A friendly message that describes the job status.
98
+ # @return [String]
99
+ def status_message
100
+ data.status_message
101
+ end
102
+
103
+ # For an ArchiveRetrieval job, this is the size in bytes of the archive
104
+ # being requested for download. For the InventoryRetrieval job, the
105
+ # value is null.
106
+ # @return [Integer]
107
+ def archive_size_in_bytes
108
+ data.archive_size_in_bytes
109
+ end
110
+
111
+ # For an InventoryRetrieval job, this is the size in bytes of the
112
+ # inventory requested for download. For the ArchiveRetrieval job, the
113
+ # value is null.
114
+ # @return [Integer]
115
+ def inventory_size_in_bytes
116
+ data.inventory_size_in_bytes
117
+ end
118
+
119
+ # An Amazon Simple Notification Service (Amazon SNS) topic that receives
120
+ # notification.
121
+ # @return [String]
122
+ def sns_topic
123
+ data.sns_topic
124
+ end
125
+
126
+ # The UTC time that the archive retrieval request completed. While the
127
+ # job is in progress, the value will be null.
128
+ # @return [Time]
129
+ def completion_date
130
+ data.completion_date
131
+ end
132
+
133
+ # For an ArchiveRetrieval job, it is the checksum of the archive.
134
+ # Otherwise, the value is null.
135
+ #
136
+ # The SHA256 tree hash value for the requested range of an archive. If
137
+ # the Initiate a Job request for an archive specified a tree-hash
138
+ # aligned range, then this field returns a value.
139
+ #
140
+ # For the specific case when the whole archive is retrieved, this value
141
+ # is the same as the ArchiveSHA256TreeHash value.
142
+ #
143
+ # This field is null in the following situations:
144
+ #
145
+ # * Archive retrieval jobs that specify a range that is not tree-hash
146
+ # aligned.
147
+ #
148
+ # ^
149
+ # ^
150
+ #
151
+ # * Archival jobs that specify a range that is equal to the whole
152
+ # archive and the job status is InProgress.
153
+ #
154
+ # ^
155
+ # ^
156
+ #
157
+ # * Inventory jobs.
158
+ #
159
+ # ^
160
+ # @return [String]
161
+ def sha256_tree_hash
162
+ data.sha256_tree_hash
163
+ end
164
+
165
+ # The SHA256 tree hash of the entire archive for an archive retrieval.
166
+ # For inventory retrieval jobs, this field is null.
167
+ # @return [String]
168
+ def archive_sha256_tree_hash
169
+ data.archive_sha256_tree_hash
170
+ end
171
+
172
+ # The retrieved byte range for archive retrieval jobs in the form
173
+ # "*StartByteValue*-*EndByteValue*" If no range was specified in the
174
+ # archive retrieval, then the whole archive is retrieved and
175
+ # *StartByteValue* equals 0 and *EndByteValue* equals the size of the
176
+ # archive minus 1. For inventory retrieval jobs this field is null.
177
+ # @return [String]
178
+ def retrieval_byte_range
179
+ data.retrieval_byte_range
180
+ end
181
+
182
+ # The retrieval option to use for the archive retrieval. Valid values
183
+ # are `Expedited`, `Standard`, or `Bulk`. `Standard` is the default.
184
+ # @return [String]
185
+ def tier
186
+ data.tier
187
+ end
188
+
189
+ # Parameters used for range inventory retrieval.
190
+ # @return [Types::InventoryRetrievalJobDescription]
191
+ def inventory_retrieval_parameters
192
+ data.inventory_retrieval_parameters
193
+ end
194
+
195
+ # @!endgroup
196
+
197
+ # @return [Client]
198
+ def client
199
+ @client
200
+ end
201
+
202
+ # Loads, or reloads {#data} for the current {Job}.
203
+ # Returns `self` making it possible to chain methods.
204
+ #
205
+ # job.reload.data
206
+ #
207
+ # @return [self]
208
+ def load
209
+ resp = @client.describe_job(
210
+ account_id: @account_id,
211
+ vault_name: @vault_name,
212
+ job_id: @id
213
+ )
214
+ @data = resp.data
215
+ self
216
+ end
217
+ alias :reload :load
218
+
219
+ # @return [Types::GlacierJobDescription]
220
+ # Returns the data for this {Job}. Calls
221
+ # {Client#describe_job} if {#data_loaded?} is `false`.
222
+ def data
223
+ load unless @data
224
+ @data
225
+ end
226
+
227
+ # @return [Boolean]
228
+ # Returns `true` if this resource is loaded. Accessing attributes or
229
+ # {#data} on an unloaded resource will trigger a call to {#load}.
230
+ def data_loaded?
231
+ !!@data
232
+ end
233
+
234
+ # @!group Actions
235
+
236
+ # @example Request syntax with placeholder values
237
+ #
238
+ # job.get_output({
239
+ # range: "string",
240
+ # })
241
+ # @param [Hash] options ({})
242
+ # @option options [String] :range
243
+ # The range of bytes to retrieve from the output. For example, if you
244
+ # want to download the first 1,048,576 bytes, specify the range as
245
+ # `bytes=0-1048575`. By default, this operation downloads the entire
246
+ # output.
247
+ #
248
+ # If the job output is large, then you can use a range to retrieve a
249
+ # portion of the output. This allows you to download the entire output
250
+ # in smaller chunks of bytes. For example, suppose you have 1 GB of job
251
+ # output you want to download and you decide to download 128 MB chunks
252
+ # of data at a time, which is a total of eight Get Job Output requests.
253
+ # You use the following process to download the job output:
254
+ #
255
+ # 1. Download a 128 MB chunk of output by specifying the appropriate
256
+ # byte range. Verify that all 128 MB of data was received.
257
+ #
258
+ # 2. Along with the data, the response includes a SHA256 tree hash of
259
+ # the payload. You compute the checksum of the payload on the client
260
+ # and compare it with the checksum you received in the response to
261
+ # ensure you received all the expected data.
262
+ #
263
+ # 3. Repeat steps 1 and 2 for all the eight 128 MB chunks of output
264
+ # data, each time specifying the appropriate byte range.
265
+ #
266
+ # 4. After downloading all the parts of the job output, you have a list
267
+ # of eight checksum values. Compute the tree hash of these values to
268
+ # find the checksum of the entire output. Using the DescribeJob API,
269
+ # obtain job information of the job that provided you the output.
270
+ # The response includes the checksum of the entire archive stored in
271
+ # Amazon Glacier. You compare this value with the checksum you
272
+ # computed to ensure you have downloaded the entire archive content
273
+ # with no errors.
274
+ # @return [Types::GetJobOutputOutput]
275
+ def get_output(options = {})
276
+ options = options.merge(
277
+ account_id: @account_id,
278
+ vault_name: @vault_name,
279
+ job_id: @id
280
+ )
281
+ resp = @client.get_job_output(options)
282
+ resp.data
283
+ end
284
+
285
+ # @!group Associations
286
+
287
+ # @return [Vault]
288
+ def vault
289
+ Vault.new(
290
+ account_id: @account_id,
291
+ name: @vault_name,
292
+ client: @client
293
+ )
294
+ end
295
+
296
+ # @deprecated
297
+ # @api private
298
+ def identifiers
299
+ {
300
+ account_id: @account_id,
301
+ vault_name: @vault_name,
302
+ id: @id
303
+ }
304
+ end
305
+ deprecated(:identifiers)
306
+
307
+ private
308
+
309
+ def extract_account_id(args, options)
310
+ value = args[0] || options.delete(:account_id)
311
+ case value
312
+ when String then value
313
+ when nil then raise ArgumentError, "missing required option :account_id"
314
+ else
315
+ msg = "expected :account_id to be a String, got #{value.class}"
316
+ raise ArgumentError, msg
317
+ end
318
+ end
319
+
320
+ def extract_vault_name(args, options)
321
+ value = args[1] || options.delete(:vault_name)
322
+ case value
323
+ when String then value
324
+ when nil then raise ArgumentError, "missing required option :vault_name"
325
+ else
326
+ msg = "expected :vault_name to be a String, got #{value.class}"
327
+ raise ArgumentError, msg
328
+ end
329
+ end
330
+
331
+ def extract_id(args, options)
332
+ value = args[2] || options.delete(:id)
333
+ case value
334
+ when String then value
335
+ when nil then raise ArgumentError, "missing required option :id"
336
+ else
337
+ msg = "expected :id to be a String, got #{value.class}"
338
+ raise ArgumentError, msg
339
+ end
340
+ end
341
+
342
+ class Collection < Aws::Resources::Collection; end
343
+ end
344
+ end
345
+ end
@@ -0,0 +1,269 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module Glacier
10
+ class MultipartUpload
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(account_id, vault_name, id, options = {})
15
+ # @param [String] account_id
16
+ # @param [String] vault_name
17
+ # @param [String] id
18
+ # @option options [Client] :client
19
+ # @overload def initialize(options = {})
20
+ # @option options [required, String] :account_id
21
+ # @option options [required, String] :vault_name
22
+ # @option options [required, String] :id
23
+ # @option options [Client] :client
24
+ def initialize(*args)
25
+ options = Hash === args.last ? args.pop.dup : {}
26
+ @account_id = extract_account_id(args, options)
27
+ @vault_name = extract_vault_name(args, options)
28
+ @id = extract_id(args, options)
29
+ @data = options.delete(:data)
30
+ @client = options.delete(:client) || Client.new(options)
31
+ end
32
+
33
+ # @!group Read-Only Attributes
34
+
35
+ # @return [String]
36
+ def account_id
37
+ @account_id
38
+ end
39
+
40
+ # @return [String]
41
+ def vault_name
42
+ @vault_name
43
+ end
44
+
45
+ # @return [String]
46
+ def id
47
+ @id
48
+ end
49
+ alias :multipart_upload_id :id
50
+
51
+ # The Amazon Resource Name (ARN) of the vault that contains the archive.
52
+ # @return [String]
53
+ def vault_arn
54
+ data.vault_arn
55
+ end
56
+
57
+ # The description of the archive that was specified in the Initiate
58
+ # Multipart Upload request.
59
+ # @return [String]
60
+ def archive_description
61
+ data.archive_description
62
+ end
63
+
64
+ # The part size, in bytes, specified in the Initiate Multipart Upload
65
+ # request. This is the size of all the parts in the upload except the
66
+ # last part, which may be smaller than this size.
67
+ # @return [Integer]
68
+ def part_size_in_bytes
69
+ data.part_size_in_bytes
70
+ end
71
+
72
+ # The UTC time at which the multipart upload was initiated.
73
+ # @return [Time]
74
+ def creation_date
75
+ data.creation_date
76
+ end
77
+
78
+ # @!endgroup
79
+
80
+ # @return [Client]
81
+ def client
82
+ @client
83
+ end
84
+
85
+ # @raise [Errors::ResourceNotLoadable]
86
+ # @api private
87
+ def load
88
+ msg = "#load is not implemented, data only available via enumeration"
89
+ raise Errors::ResourceNotLoadable, msg
90
+ end
91
+ alias :reload :load
92
+
93
+ # @raise [Errors::ResourceNotLoadableError] Raises when {#data_loaded?} is `false`.
94
+ # @return [Types::UploadListElement]
95
+ # Returns the data for this {MultipartUpload}.
96
+ def data
97
+ load unless @data
98
+ @data
99
+ end
100
+
101
+ # @return [Boolean]
102
+ # Returns `true` if this resource is loaded. Accessing attributes or
103
+ # {#data} on an unloaded resource will trigger a call to {#load}.
104
+ def data_loaded?
105
+ !!@data
106
+ end
107
+
108
+ # @!group Actions
109
+
110
+ # @example Request syntax with placeholder values
111
+ #
112
+ # multipart_upload.abort()
113
+ # @param [Hash] options ({})
114
+ # @return [EmptyStructure]
115
+ def abort(options = {})
116
+ options = options.merge(
117
+ account_id: @account_id,
118
+ vault_name: @vault_name,
119
+ upload_id: @id
120
+ )
121
+ resp = @client.abort_multipart_upload(options)
122
+ resp.data
123
+ end
124
+
125
+ # @example Request syntax with placeholder values
126
+ #
127
+ # multipart_upload.complete({
128
+ # archive_size: 1,
129
+ # checksum: "string",
130
+ # })
131
+ # @param [Hash] options ({})
132
+ # @option options [Integer] :archive_size
133
+ # The total size, in bytes, of the entire archive. This value should be
134
+ # the sum of all the sizes of the individual parts that you uploaded.
135
+ # @option options [String] :checksum
136
+ # The SHA256 tree hash of the entire archive. It is the tree hash of
137
+ # SHA256 tree hash of the individual parts. If the value you specify in
138
+ # the request does not match the SHA256 tree hash of the final assembled
139
+ # archive as computed by Amazon Glacier, Amazon Glacier returns an error
140
+ # and the request fails.
141
+ # @return [Types::ArchiveCreationOutput]
142
+ def complete(options = {})
143
+ options = options.merge(
144
+ account_id: @account_id,
145
+ vault_name: @vault_name,
146
+ upload_id: @id
147
+ )
148
+ resp = @client.complete_multipart_upload(options)
149
+ resp.data
150
+ end
151
+
152
+ # @example Request syntax with placeholder values
153
+ #
154
+ # multipart_upload.parts({
155
+ # marker: "string",
156
+ # limit: 1,
157
+ # })
158
+ # @param [Hash] options ({})
159
+ # @option options [String] :marker
160
+ # An opaque string used for pagination. This value specifies the part at
161
+ # which the listing of parts should begin. Get the marker value from the
162
+ # response of a previous List Parts response. You need only include the
163
+ # marker if you are continuing the pagination of results started in a
164
+ # previous List Parts request.
165
+ # @option options [Integer] :limit
166
+ # The maximum number of parts to be returned. The default limit is 1000.
167
+ # The number of parts returned might be fewer than the specified limit,
168
+ # but the number of returned parts never exceeds the limit.
169
+ # @return [Types::ListPartsOutput]
170
+ def parts(options = {})
171
+ options = options.merge(
172
+ account_id: @account_id,
173
+ vault_name: @vault_name,
174
+ upload_id: @id
175
+ )
176
+ resp = @client.list_parts(options)
177
+ resp.data
178
+ end
179
+
180
+ # @example Request syntax with placeholder values
181
+ #
182
+ # multipart_upload.upload_part({
183
+ # checksum: "string",
184
+ # range: "string",
185
+ # body: "data",
186
+ # })
187
+ # @param [Hash] options ({})
188
+ # @option options [String] :checksum
189
+ # The SHA256 tree hash of the data being uploaded.
190
+ # @option options [String] :range
191
+ # Identifies the range of bytes in the assembled archive that will be
192
+ # uploaded in this part. Amazon Glacier uses this information to
193
+ # assemble the archive in the proper sequence. The format of this header
194
+ # follows RFC 2616. An example header is Content-Range:bytes
195
+ # 0-4194303/*.
196
+ # @option options [String, IO] :body
197
+ # The data to upload.
198
+ # @return [Types::UploadMultipartPartOutput]
199
+ def upload_part(options = {})
200
+ options = options.merge(
201
+ account_id: @account_id,
202
+ vault_name: @vault_name,
203
+ upload_id: @id
204
+ )
205
+ resp = @client.upload_multipart_part(options)
206
+ resp.data
207
+ end
208
+
209
+ # @!group Associations
210
+
211
+ # @return [Vault]
212
+ def vault
213
+ Vault.new(
214
+ account_id: @account_id,
215
+ name: @vault_name,
216
+ client: @client
217
+ )
218
+ end
219
+
220
+ # @deprecated
221
+ # @api private
222
+ def identifiers
223
+ {
224
+ account_id: @account_id,
225
+ vault_name: @vault_name,
226
+ id: @id
227
+ }
228
+ end
229
+ deprecated(:identifiers)
230
+
231
+ private
232
+
233
+ def extract_account_id(args, options)
234
+ value = args[0] || options.delete(:account_id)
235
+ case value
236
+ when String then value
237
+ when nil then raise ArgumentError, "missing required option :account_id"
238
+ else
239
+ msg = "expected :account_id to be a String, got #{value.class}"
240
+ raise ArgumentError, msg
241
+ end
242
+ end
243
+
244
+ def extract_vault_name(args, options)
245
+ value = args[1] || options.delete(:vault_name)
246
+ case value
247
+ when String then value
248
+ when nil then raise ArgumentError, "missing required option :vault_name"
249
+ else
250
+ msg = "expected :vault_name to be a String, got #{value.class}"
251
+ raise ArgumentError, msg
252
+ end
253
+ end
254
+
255
+ def extract_id(args, options)
256
+ value = args[2] || options.delete(:id)
257
+ case value
258
+ when String then value
259
+ when nil then raise ArgumentError, "missing required option :id"
260
+ else
261
+ msg = "expected :id to be a String, got #{value.class}"
262
+ raise ArgumentError, msg
263
+ end
264
+ end
265
+
266
+ class Collection < Aws::Resources::Collection; end
267
+ end
268
+ end
269
+ end