1# -*- coding: utf-8 -*- 2# Copyright (c) 2012 Mitch Garnaat http://garnaat.org/ 3# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved 4# 5# Permission is hereby granted, free of charge, to any person obtaining a 6# copy of this software and associated documentation files (the 7# "Software"), to deal in the Software without restriction, including 8# without limitation the rights to use, copy, modify, merge, publish, dis- 9# tribute, sublicense, and/or sell copies of the Software, and to permit 10# persons to whom the Software is furnished to do so, subject to the fol- 11# lowing conditions: 12# 13# The above copyright notice and this permission notice shall be included 14# in all copies or substantial portions of the Software. 15# 16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 18# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22# IN THE SOFTWARE. 23# 24 25import os 26 27import boto.glacier 28from boto.compat import json 29from boto.connection import AWSAuthConnection 30from boto.glacier.exceptions import UnexpectedHTTPResponseError 31from boto.glacier.response import GlacierResponse 32from boto.glacier.utils import ResettingFileSender 33 34 35class Layer1(AWSAuthConnection): 36 """ 37 Amazon Glacier is a storage solution for "cold data." 38 39 Amazon Glacier is an extremely low-cost storage service that 40 provides secure, durable and easy-to-use storage for data backup 41 and archival. With Amazon Glacier, customers can store their data 42 cost effectively for months, years, or decades. Amazon Glacier 43 also enables customers to offload the administrative burdens of 44 operating and scaling storage to AWS, so they don't have to worry 45 about capacity planning, hardware provisioning, data replication, 46 hardware failure and recovery, or time-consuming hardware 47 migrations. 48 49 Amazon Glacier is a great storage choice when low storage cost is 50 paramount, your data is rarely retrieved, and retrieval latency of 51 several hours is acceptable. If your application requires fast or 52 frequent access to your data, consider using Amazon S3. For more 53 information, go to `Amazon Simple Storage Service (Amazon S3)`_. 54 55 You can store any kind of data in any format. There is no maximum 56 limit on the total amount of data you can store in Amazon Glacier. 57 58 If you are a first-time user of Amazon Glacier, we recommend that 59 you begin by reading the following sections in the Amazon Glacier 60 Developer Guide : 61 62 63 + `What is Amazon Glacier`_ - This section of the Developer Guide 64 describes the underlying data model, the operations it supports, 65 and the AWS SDKs that you can use to interact with the service. 66 + `Getting Started with Amazon Glacier`_ - The Getting Started 67 section walks you through the process of creating a vault, 68 uploading archives, creating jobs to download archives, retrieving 69 the job output, and deleting archives. 70 """ 71 Version = '2012-06-01' 72 73 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, 74 account_id='-', is_secure=True, port=None, 75 proxy=None, proxy_port=None, 76 proxy_user=None, proxy_pass=None, debug=0, 77 https_connection_factory=None, path='/', 78 provider='aws', security_token=None, 79 suppress_consec_slashes=True, 80 region=None, region_name='us-east-1', 81 profile_name=None): 82 83 if not region: 84 for reg in boto.glacier.regions(): 85 if reg.name == region_name: 86 region = reg 87 break 88 89 self.region = region 90 self.account_id = account_id 91 super(Layer1, self).__init__(region.endpoint, 92 aws_access_key_id, aws_secret_access_key, 93 is_secure, port, proxy, proxy_port, 94 proxy_user, proxy_pass, debug, 95 https_connection_factory, 96 path, provider, security_token, 97 suppress_consec_slashes, 98 profile_name=profile_name) 99 100 def _required_auth_capability(self): 101 return ['hmac-v4'] 102 103 def make_request(self, verb, resource, headers=None, 104 data='', ok_responses=(200,), params=None, 105 sender=None, response_headers=None): 106 if headers is None: 107 headers = {} 108 headers['x-amz-glacier-version'] = self.Version 109 uri = '/%s/%s' % (self.account_id, resource) 110 response = super(Layer1, self).make_request(verb, uri, 111 params=params, 112 headers=headers, 113 sender=sender, 114 data=data) 115 if response.status in ok_responses: 116 return GlacierResponse(response, response_headers) 117 else: 118 # create glacier-specific exceptions 119 raise UnexpectedHTTPResponseError(ok_responses, response) 120 121 # Vaults 122 123 def list_vaults(self, limit=None, marker=None): 124 """ 125 This operation lists all vaults owned by the calling user's 126 account. The list returned in the response is ASCII-sorted by 127 vault name. 128 129 By default, this operation returns up to 1,000 items. If there 130 are more vaults to list, the response `marker` field contains 131 the vault Amazon Resource Name (ARN) at which to continue the 132 list with a new List Vaults request; otherwise, the `marker` 133 field is `null`. To return a list of vaults that begins at a 134 specific vault, set the `marker` request parameter to the 135 vault ARN you obtained from a previous List Vaults request. 136 You can also limit the number of vaults returned in the 137 response by specifying the `limit` parameter in the request. 138 139 An AWS account has full permission to perform all operations 140 (actions). However, AWS Identity and Access Management (IAM) 141 users don't have any permissions by default. You must grant 142 them explicit permission to perform specific actions. For more 143 information, see `Access Control Using AWS Identity and Access 144 Management (IAM)`_. 145 146 For conceptual information and underlying REST API, go to 147 `Retrieving Vault Metadata in Amazon Glacier`_ and `List 148 Vaults `_ in the Amazon Glacier Developer Guide . 149 150 :type marker: string 151 :param marker: A string used for pagination. The marker specifies the 152 vault ARN after which the listing of vaults should begin. 153 154 :type limit: string 155 :param limit: The maximum number of items returned in the response. If 156 you don't specify a value, the List Vaults operation returns up to 157 1,000 items. 158 """ 159 params = {} 160 if limit: 161 params['limit'] = limit 162 if marker: 163 params['marker'] = marker 164 return self.make_request('GET', 'vaults', params=params) 165 166 def describe_vault(self, vault_name): 167 """ 168 This operation returns information about a vault, including 169 the vault's Amazon Resource Name (ARN), the date the vault was 170 created, the number of archives it contains, and the total 171 size of all the archives in the vault. The number of archives 172 and their total size are as of the last inventory generation. 173 This means that if you add or remove an archive from a vault, 174 and then immediately use Describe Vault, the change in 175 contents will not be immediately reflected. If you want to 176 retrieve the latest inventory of the vault, use InitiateJob. 177 Amazon Glacier generates vault inventories approximately 178 daily. For more information, see `Downloading a Vault 179 Inventory in Amazon Glacier`_. 180 181 An AWS account has full permission to perform all operations 182 (actions). However, AWS Identity and Access Management (IAM) 183 users don't have any permissions by default. You must grant 184 them explicit permission to perform specific actions. For more 185 information, see `Access Control Using AWS Identity and Access 186 Management (IAM)`_. 187 188 For conceptual information and underlying REST API, go to 189 `Retrieving Vault Metadata in Amazon Glacier`_ and `Describe 190 Vault `_ in the Amazon Glacier Developer Guide . 191 192 :type vault_name: string 193 :param vault_name: The name of the vault. 194 """ 195 uri = 'vaults/%s' % vault_name 196 return self.make_request('GET', uri) 197 198 def create_vault(self, vault_name): 199 """ 200 This operation creates a new vault with the specified name. 201 The name of the vault must be unique within a region for an 202 AWS account. You can create up to 1,000 vaults per account. If 203 you need to create more vaults, contact Amazon Glacier. 204 205 You must use the following guidelines when naming a vault. 206 207 208 209 + Names can be between 1 and 255 characters long. 210 + Allowed characters are a-z, A-Z, 0-9, '_' (underscore), '-' 211 (hyphen), and '.' (period). 212 213 214 215 This operation is idempotent. 216 217 An AWS account has full permission to perform all operations 218 (actions). However, AWS Identity and Access Management (IAM) 219 users don't have any permissions by default. You must grant 220 them explicit permission to perform specific actions. For more 221 information, see `Access Control Using AWS Identity and Access 222 Management (IAM)`_. 223 224 For conceptual information and underlying REST API, go to 225 `Creating a Vault in Amazon Glacier`_ and `Create Vault `_ in 226 the Amazon Glacier Developer Guide . 227 228 :type vault_name: string 229 :param vault_name: The name of the vault. 230 """ 231 uri = 'vaults/%s' % vault_name 232 return self.make_request('PUT', uri, ok_responses=(201,), 233 response_headers=[('Location', 'Location')]) 234 235 def delete_vault(self, vault_name): 236 """ 237 This operation deletes a vault. Amazon Glacier will delete a 238 vault only if there are no archives in the vault as of the 239 last inventory and there have been no writes to the vault 240 since the last inventory. If either of these conditions is not 241 satisfied, the vault deletion fails (that is, the vault is not 242 removed) and Amazon Glacier returns an error. You can use 243 DescribeVault to return the number of archives in a vault, and 244 you can use `Initiate a Job (POST jobs)`_ to initiate a new 245 inventory retrieval for a vault. The inventory contains the 246 archive IDs you use to delete archives using `Delete Archive 247 (DELETE archive)`_. 248 249 This operation is idempotent. 250 251 An AWS account has full permission to perform all operations 252 (actions). However, AWS Identity and Access Management (IAM) 253 users don't have any permissions by default. You must grant 254 them explicit permission to perform specific actions. For more 255 information, see `Access Control Using AWS Identity and Access 256 Management (IAM)`_. 257 258 For conceptual information and underlying REST API, go to 259 `Deleting a Vault in Amazon Glacier`_ and `Delete Vault `_ in 260 the Amazon Glacier Developer Guide . 261 262 :type vault_name: string 263 :param vault_name: The name of the vault. 264 """ 265 uri = 'vaults/%s' % vault_name 266 return self.make_request('DELETE', uri, ok_responses=(204,)) 267 268 def get_vault_notifications(self, vault_name): 269 """ 270 This operation retrieves the `notification-configuration` 271 subresource of the specified vault. 272 273 For information about setting a notification configuration on 274 a vault, see SetVaultNotifications. If a notification 275 configuration for a vault is not set, the operation returns a 276 `404 Not Found` error. For more information about vault 277 notifications, see `Configuring Vault Notifications in Amazon 278 Glacier`_. 279 280 An AWS account has full permission to perform all operations 281 (actions). However, AWS Identity and Access Management (IAM) 282 users don't have any permissions by default. You must grant 283 them explicit permission to perform specific actions. For more 284 information, see `Access Control Using AWS Identity and Access 285 Management (IAM)`_. 286 287 For conceptual information and underlying REST API, go to 288 `Configuring Vault Notifications in Amazon Glacier`_ and `Get 289 Vault Notification Configuration `_ in the Amazon Glacier 290 Developer Guide . 291 292 :type vault_name: string 293 :param vault_name: The name of the vault. 294 """ 295 uri = 'vaults/%s/notification-configuration' % vault_name 296 return self.make_request('GET', uri) 297 298 def set_vault_notifications(self, vault_name, notification_config): 299 """ 300 This operation configures notifications that will be sent when 301 specific events happen to a vault. By default, you don't get 302 any notifications. 303 304 To configure vault notifications, send a PUT request to the 305 `notification-configuration` subresource of the vault. The 306 request should include a JSON document that provides an Amazon 307 SNS topic and specific events for which you want Amazon 308 Glacier to send notifications to the topic. 309 310 Amazon SNS topics must grant permission to the vault to be 311 allowed to publish notifications to the topic. You can 312 configure a vault to publish a notification for the following 313 vault events: 314 315 316 + **ArchiveRetrievalCompleted** This event occurs when a job 317 that was initiated for an archive retrieval is completed 318 (InitiateJob). The status of the completed job can be 319 "Succeeded" or "Failed". The notification sent to the SNS 320 topic is the same output as returned from DescribeJob. 321 + **InventoryRetrievalCompleted** This event occurs when a job 322 that was initiated for an inventory retrieval is completed 323 (InitiateJob). The status of the completed job can be 324 "Succeeded" or "Failed". The notification sent to the SNS 325 topic is the same output as returned from DescribeJob. 326 327 328 An AWS account has full permission to perform all operations 329 (actions). However, AWS Identity and Access Management (IAM) 330 users don't have any permissions by default. You must grant 331 them explicit permission to perform specific actions. For more 332 information, see `Access Control Using AWS Identity and Access 333 Management (IAM)`_. 334 335 For conceptual information and underlying REST API, go to 336 `Configuring Vault Notifications in Amazon Glacier`_ and `Set 337 Vault Notification Configuration `_ in the Amazon Glacier 338 Developer Guide . 339 340 :type vault_name: string 341 :param vault_name: The name of the vault. 342 343 :type vault_notification_config: dict 344 :param vault_notification_config: Provides options for specifying 345 notification configuration. 346 347 The format of the dictionary is: 348 349 {'SNSTopic': 'mytopic', 350 'Events': [event1,...]} 351 """ 352 uri = 'vaults/%s/notification-configuration' % vault_name 353 json_config = json.dumps(notification_config) 354 return self.make_request('PUT', uri, data=json_config, 355 ok_responses=(204,)) 356 357 def delete_vault_notifications(self, vault_name): 358 """ 359 This operation deletes the notification configuration set for 360 a vault. The operation is eventually consistent;that is, it 361 might take some time for Amazon Glacier to completely disable 362 the notifications and you might still receive some 363 notifications for a short time after you send the delete 364 request. 365 366 An AWS account has full permission to perform all operations 367 (actions). However, AWS Identity and Access Management (IAM) 368 users don't have any permissions by default. You must grant 369 them explicit permission to perform specific actions. For more 370 information, see `Access Control Using AWS Identity and Access 371 Management (IAM)`_. 372 373 For conceptual information and underlying REST API, go to 374 `Configuring Vault Notifications in Amazon Glacier`_ and 375 `Delete Vault Notification Configuration `_ in the Amazon 376 Glacier Developer Guide. 377 378 :type vault_name: string 379 :param vault_name: The name of the vault. 380 """ 381 uri = 'vaults/%s/notification-configuration' % vault_name 382 return self.make_request('DELETE', uri, ok_responses=(204,)) 383 384 # Jobs 385 386 def list_jobs(self, vault_name, completed=None, status_code=None, 387 limit=None, marker=None): 388 """ 389 This operation lists jobs for a vault, including jobs that are 390 in-progress and jobs that have recently finished. 391 392 393 Amazon Glacier retains recently completed jobs for a period 394 before deleting them; however, it eventually removes completed 395 jobs. The output of completed jobs can be retrieved. Retaining 396 completed jobs for a period of time after they have completed 397 enables you to get a job output in the event you miss the job 398 completion notification or your first attempt to download it 399 fails. For example, suppose you start an archive retrieval job 400 to download an archive. After the job completes, you start to 401 download the archive but encounter a network error. In this 402 scenario, you can retry and download the archive while the job 403 exists. 404 405 406 To retrieve an archive or retrieve a vault inventory from 407 Amazon Glacier, you first initiate a job, and after the job 408 completes, you download the data. For an archive retrieval, 409 the output is the archive data, and for an inventory 410 retrieval, it is the inventory list. The List Job operation 411 returns a list of these jobs sorted by job initiation time. 412 413 This List Jobs operation supports pagination. By default, this 414 operation returns up to 1,000 jobs in the response. You should 415 always check the response for a `marker` at which to continue 416 the list; if there are no more items the `marker` is `null`. 417 To return a list of jobs that begins at a specific job, set 418 the `marker` request parameter to the value you obtained from 419 a previous List Jobs request. You can also limit the number of 420 jobs returned in the response by specifying the `limit` 421 parameter in the request. 422 423 Additionally, you can filter the jobs list returned by 424 specifying an optional `statuscode` (InProgress, Succeeded, or 425 Failed) and `completed` (true, false) parameter. The 426 `statuscode` allows you to specify that only jobs that match a 427 specified status are returned. The `completed` parameter 428 allows you to specify that only jobs in a specific completion 429 state are returned. 430 431 An AWS account has full permission to perform all operations 432 (actions). However, AWS Identity and Access Management (IAM) 433 users don't have any permissions by default. You must grant 434 them explicit permission to perform specific actions. For more 435 information, see `Access Control Using AWS Identity and Access 436 Management (IAM)`_. 437 438 For the underlying REST API, go to `List Jobs `_ 439 440 :type vault_name: string 441 :param vault_name: The name of the vault. 442 443 :type limit: string 444 :param limit: Specifies that the response be limited to the specified 445 number of items or fewer. If not specified, the List Jobs operation 446 returns up to 1,000 jobs. 447 448 :type marker: string 449 :param marker: An opaque string used for pagination. This value 450 specifies the job at which the listing of jobs should begin. Get 451 the marker value from a previous List Jobs response. You need only 452 include the marker if you are continuing the pagination of results 453 started in a previous List Jobs request. 454 455 :type statuscode: string 456 :param statuscode: Specifies the type of job status to return. You can 457 specify the following values: "InProgress", "Succeeded", or 458 "Failed". 459 460 :type completed: string 461 :param completed: Specifies the state of the jobs to return. You can 462 specify `True` or `False`. 463 464 """ 465 params = {} 466 if limit: 467 params['limit'] = limit 468 if marker: 469 params['marker'] = marker 470 if status_code: 471 params['statuscode'] = status_code 472 if completed is not None: 473 params['completed'] = 'true' if completed else 'false' 474 uri = 'vaults/%s/jobs' % vault_name 475 return self.make_request('GET', uri, params=params) 476 477 def describe_job(self, vault_name, job_id): 478 """ 479 This operation returns information about a job you previously 480 initiated, including the job initiation date, the user who 481 initiated the job, the job status code/message and the Amazon 482 SNS topic to notify after Amazon Glacier completes the job. 483 For more information about initiating a job, see InitiateJob. 484 485 486 This operation enables you to check the status of your job. 487 However, it is strongly recommended that you set up an Amazon 488 SNS topic and specify it in your initiate job request so that 489 Amazon Glacier can notify the topic after it completes the 490 job. 491 492 493 A job ID will not expire for at least 24 hours after Amazon 494 Glacier completes the job. 495 496 An AWS account has full permission to perform all operations 497 (actions). However, AWS Identity and Access Management (IAM) 498 users don't have any permissions by default. You must grant 499 them explicit permission to perform specific actions. For more 500 information, see `Access Control Using AWS Identity and Access 501 Management (IAM)`_. 502 503 For information about the underlying REST API, go to `Working 504 with Archives in Amazon Glacier`_ in the Amazon Glacier 505 Developer Guide . 506 507 :type vault_name: string 508 :param vault_name: The name of the vault. 509 510 :type job_id: string 511 :param job_id: The ID of the job to describe. 512 """ 513 uri = 'vaults/%s/jobs/%s' % (vault_name, job_id) 514 return self.make_request('GET', uri, ok_responses=(200,)) 515 516 def initiate_job(self, vault_name, job_data): 517 """ 518 This operation initiates a job of the specified type. In this 519 release, you can initiate a job to retrieve either an archive 520 or a vault inventory (a list of archives in a vault). 521 522 Retrieving data from Amazon Glacier is a two-step process: 523 524 525 #. Initiate a retrieval job. 526 #. After the job completes, download the bytes. 527 528 529 The retrieval request is executed asynchronously. When you 530 initiate a retrieval job, Amazon Glacier creates a job and 531 returns a job ID in the response. When Amazon Glacier 532 completes the job, you can get the job output (archive or 533 inventory data). For information about getting job output, see 534 GetJobOutput operation. 535 536 The job must complete before you can get its output. To 537 determine when a job is complete, you have the following 538 options: 539 540 541 + **Use Amazon SNS Notification** You can specify an Amazon 542 Simple Notification Service (Amazon SNS) topic to which Amazon 543 Glacier can post a notification after the job is completed. 544 You can specify an SNS topic per job request. The notification 545 is sent only after Amazon Glacier completes the job. In 546 addition to specifying an SNS topic per job request, you can 547 configure vault notifications for a vault so that job 548 notifications are always sent. For more information, see 549 SetVaultNotifications. 550 + **Get job details** You can make a DescribeJob request to 551 obtain job status information while a job is in progress. 552 However, it is more efficient to use an Amazon SNS 553 notification to determine when a job is complete. 554 555 556 557 The information you get via notification is same that you get 558 by calling DescribeJob. 559 560 561 If for a specific event, you add both the notification 562 configuration on the vault and also specify an SNS topic in 563 your initiate job request, Amazon Glacier sends both 564 notifications. For more information, see 565 SetVaultNotifications. 566 567 An AWS account has full permission to perform all operations 568 (actions). However, AWS Identity and Access Management (IAM) 569 users don't have any permissions by default. You must grant 570 them explicit permission to perform specific actions. For more 571 information, see `Access Control Using AWS Identity and Access 572 Management (IAM)`_. 573 574 **About the Vault Inventory** 575 576 Amazon Glacier prepares an inventory for each vault 577 periodically, every 24 hours. When you initiate a job for a 578 vault inventory, Amazon Glacier returns the last inventory for 579 the vault. The inventory data you get might be up to a day or 580 two days old. Also, the initiate inventory job might take some 581 time to complete before you can download the vault inventory. 582 So you do not want to retrieve a vault inventory for each 583 vault operation. However, in some scenarios, you might find 584 the vault inventory useful. For example, when you upload an 585 archive, you can provide an archive description but not an 586 archive name. Amazon Glacier provides you a unique archive ID, 587 an opaque string of characters. So, you might maintain your 588 own database that maps archive names to their corresponding 589 Amazon Glacier assigned archive IDs. You might find the vault 590 inventory useful in the event you need to reconcile 591 information in your database with the actual vault inventory. 592 593 **About Ranged Archive Retrieval** 594 595 You can initiate an archive retrieval for the whole archive or 596 a range of the archive. In the case of ranged archive 597 retrieval, you specify a byte range to return or the whole 598 archive. The range specified must be megabyte (MB) aligned, 599 that is the range start value must be divisible by 1 MB and 600 range end value plus 1 must be divisible by 1 MB or equal the 601 end of the archive. If the ranged archive retrieval is not 602 megabyte aligned, this operation returns a 400 response. 603 Furthermore, to ensure you get checksum values for data you 604 download using Get Job Output API, the range must be tree hash 605 aligned. 606 607 An AWS account has full permission to perform all operations 608 (actions). However, AWS Identity and Access Management (IAM) 609 users don't have any permissions by default. You must grant 610 them explicit permission to perform specific actions. For more 611 information, see `Access Control Using AWS Identity and Access 612 Management (IAM)`_. 613 614 For conceptual information and the underlying REST API, go to 615 `Initiate a Job`_ and `Downloading a Vault Inventory`_ 616 617 :type account_id: string 618 :param account_id: The `AccountId` is the AWS Account ID. You can 619 specify either the AWS Account ID or optionally a '-', in which 620 case Amazon Glacier uses the AWS Account ID associated with the 621 credentials used to sign the request. If you specify your Account 622 ID, do not include hyphens in it. 623 624 :type vault_name: string 625 :param vault_name: The name of the vault. 626 627 :type job_parameters: dict 628 :param job_parameters: Provides options for specifying job information. 629 The dictionary can contain the following attributes: 630 631 * ArchiveId - The ID of the archive you want to retrieve. 632 This field is required only if the Type is set to 633 archive-retrieval. 634 * Description - The optional description for the job. 635 * Format - When initiating a job to retrieve a vault 636 inventory, you can optionally add this parameter to 637 specify the output format. Valid values are: CSV|JSON. 638 * SNSTopic - The Amazon SNS topic ARN where Amazon Glacier 639 sends a notification when the job is completed and the 640 output is ready for you to download. 641 * Type - The job type. Valid values are: 642 archive-retrieval|inventory-retrieval 643 * RetrievalByteRange - Optionally specify the range of 644 bytes to retrieve. 645 * InventoryRetrievalParameters: Optional job parameters 646 * Format - The output format, like "JSON" 647 * StartDate - ISO8601 starting date string 648 * EndDate - ISO8601 ending date string 649 * Limit - Maximum number of entries 650 * Marker - A unique string used for pagination 651 652 """ 653 uri = 'vaults/%s/jobs' % vault_name 654 response_headers = [('x-amz-job-id', u'JobId'), 655 ('Location', u'Location')] 656 json_job_data = json.dumps(job_data) 657 return self.make_request('POST', uri, data=json_job_data, 658 ok_responses=(202,), 659 response_headers=response_headers) 660 661 def get_job_output(self, vault_name, job_id, byte_range=None): 662 """ 663 This operation downloads the output of the job you initiated 664 using InitiateJob. Depending on the job type you specified 665 when you initiated the job, the output will be either the 666 content of an archive or a vault inventory. 667 668 A job ID will not expire for at least 24 hours after Amazon 669 Glacier completes the job. That is, you can download the job 670 output within the 24 hours period after Amazon Glacier 671 completes the job. 672 673 If the job output is large, then you can use the `Range` 674 request header to retrieve a portion of the output. This 675 allows you to download the entire output in smaller chunks of 676 bytes. For example, suppose you have 1 GB of job output you 677 want to download and you decide to download 128 MB chunks of 678 data at a time, which is a total of eight Get Job Output 679 requests. You use the following process to download the job 680 output: 681 682 683 #. Download a 128 MB chunk of output by specifying the 684 appropriate byte range using the `Range` header. 685 #. Along with the data, the response includes a checksum of 686 the payload. You compute the checksum of the payload on the 687 client and compare it with the checksum you received in the 688 response to ensure you received all the expected data. 689 #. Repeat steps 1 and 2 for all the eight 128 MB chunks of 690 output data, each time specifying the appropriate byte range. 691 #. After downloading all the parts of the job output, you have 692 a list of eight checksum values. Compute the tree hash of 693 these values to find the checksum of the entire output. Using 694 the Describe Job API, obtain job information of the job that 695 provided you the output. The response includes the checksum of 696 the entire archive stored in Amazon Glacier. You compare this 697 value with the checksum you computed to ensure you have 698 downloaded the entire archive content with no errors. 699 700 701 An AWS account has full permission to perform all operations 702 (actions). However, AWS Identity and Access Management (IAM) 703 users don't have any permissions by default. You must grant 704 them explicit permission to perform specific actions. For more 705 information, see `Access Control Using AWS Identity and Access 706 Management (IAM)`_. 707 708 For conceptual information and the underlying REST API, go to 709 `Downloading a Vault Inventory`_, `Downloading an Archive`_, 710 and `Get Job Output `_ 711 712 :type account_id: string 713 :param account_id: The `AccountId` is the AWS Account ID. You can 714 specify either the AWS Account ID or optionally a '-', in which 715 case Amazon Glacier uses the AWS Account ID associated with the 716 credentials used to sign the request. If you specify your Account 717 ID, do not include hyphens in it. 718 719 :type vault_name: string 720 :param vault_name: The name of the vault. 721 722 :type job_id: string 723 :param job_id: The job ID whose data is downloaded. 724 725 :type byte_range: string 726 :param byte_range: The range of bytes to retrieve from the output. For 727 example, if you want to download the first 1,048,576 bytes, specify 728 "Range: bytes=0-1048575". By default, this operation downloads the 729 entire output. 730 """ 731 response_headers = [('x-amz-sha256-tree-hash', u'TreeHash'), 732 ('Content-Range', u'ContentRange'), 733 ('Content-Type', u'ContentType')] 734 headers = None 735 if byte_range: 736 headers = {'Range': 'bytes=%d-%d' % byte_range} 737 uri = 'vaults/%s/jobs/%s/output' % (vault_name, job_id) 738 response = self.make_request('GET', uri, headers=headers, 739 ok_responses=(200, 206), 740 response_headers=response_headers) 741 return response 742 743 # Archives 744 745 def upload_archive(self, vault_name, archive, 746 linear_hash, tree_hash, description=None): 747 """ 748 This operation adds an archive to a vault. This is a 749 synchronous operation, and for a successful upload, your data 750 is durably persisted. Amazon Glacier returns the archive ID in 751 the `x-amz-archive-id` header of the response. 752 753 You must use the archive ID to access your data in Amazon 754 Glacier. After you upload an archive, you should save the 755 archive ID returned so that you can retrieve or delete the 756 archive later. Besides saving the archive ID, you can also 757 index it and give it a friendly name to allow for better 758 searching. You can also use the optional archive description 759 field to specify how the archive is referred to in an external 760 index of archives, such as you might create in Amazon 761 DynamoDB. You can also get the vault inventory to obtain a 762 list of archive IDs in a vault. For more information, see 763 InitiateJob. 764 765 You must provide a SHA256 tree hash of the data you are 766 uploading. For information about computing a SHA256 tree hash, 767 see `Computing Checksums`_. 768 769 You can optionally specify an archive description of up to 770 1,024 printable ASCII characters. You can get the archive 771 description when you either retrieve the archive or get the 772 vault inventory. For more information, see InitiateJob. Amazon 773 Glacier does not interpret the description in any way. An 774 archive description does not need to be unique. You cannot use 775 the description to retrieve or sort the archive list. 776 777 Archives are immutable. After you upload an archive, you 778 cannot edit the archive or its description. 779 780 An AWS account has full permission to perform all operations 781 (actions). However, AWS Identity and Access Management (IAM) 782 users don't have any permissions by default. You must grant 783 them explicit permission to perform specific actions. For more 784 information, see `Access Control Using AWS Identity and Access 785 Management (IAM)`_. 786 787 For conceptual information and underlying REST API, go to 788 `Uploading an Archive in Amazon Glacier`_ and `Upload 789 Archive`_ in the Amazon Glacier Developer Guide . 790 791 :type vault_name: str 792 :param vault_name: The name of the vault 793 794 :type archive: bytes 795 :param archive: The data to upload. 796 797 :type linear_hash: str 798 :param linear_hash: The SHA256 checksum (a linear hash) of the 799 payload. 800 801 :type tree_hash: str 802 :param tree_hash: The user-computed SHA256 tree hash of the 803 payload. For more information on computing the 804 tree hash, see http://goo.gl/u7chF. 805 806 :type description: str 807 :param description: The optional description of the archive you 808 are uploading. 809 """ 810 response_headers = [('x-amz-archive-id', u'ArchiveId'), 811 ('Location', u'Location'), 812 ('x-amz-sha256-tree-hash', u'TreeHash')] 813 uri = 'vaults/%s/archives' % vault_name 814 try: 815 content_length = str(len(archive)) 816 except (TypeError, AttributeError): 817 # If a file like object is provided, try to retrieve 818 # the file size via fstat. 819 content_length = str(os.fstat(archive.fileno()).st_size) 820 headers = {'x-amz-content-sha256': linear_hash, 821 'x-amz-sha256-tree-hash': tree_hash, 822 'Content-Length': content_length} 823 if description: 824 headers['x-amz-archive-description'] = description 825 if self._is_file_like(archive): 826 sender = ResettingFileSender(archive) 827 else: 828 sender = None 829 return self.make_request('POST', uri, headers=headers, 830 sender=sender, 831 data=archive, ok_responses=(201,), 832 response_headers=response_headers) 833 834 def _is_file_like(self, archive): 835 return hasattr(archive, 'seek') and hasattr(archive, 'tell') 836 837 def delete_archive(self, vault_name, archive_id): 838 """ 839 This operation deletes an archive from a vault. Subsequent 840 requests to initiate a retrieval of this archive will fail. 841 Archive retrievals that are in progress for this archive ID 842 may or may not succeed according to the following scenarios: 843 844 845 + If the archive retrieval job is actively preparing the data 846 for download when Amazon Glacier receives the delete archive 847 request, the archival retrieval operation might fail. 848 + If the archive retrieval job has successfully prepared the 849 archive for download when Amazon Glacier receives the delete 850 archive request, you will be able to download the output. 851 852 853 This operation is idempotent. Attempting to delete an already- 854 deleted archive does not result in an error. 855 856 An AWS account has full permission to perform all operations 857 (actions). However, AWS Identity and Access Management (IAM) 858 users don't have any permissions by default. You must grant 859 them explicit permission to perform specific actions. For more 860 information, see `Access Control Using AWS Identity and Access 861 Management (IAM)`_. 862 863 For conceptual information and underlying REST API, go to 864 `Deleting an Archive in Amazon Glacier`_ and `Delete Archive`_ 865 in the Amazon Glacier Developer Guide . 866 867 :type vault_name: string 868 :param vault_name: The name of the vault. 869 870 :type archive_id: string 871 :param archive_id: The ID of the archive to delete. 872 """ 873 uri = 'vaults/%s/archives/%s' % (vault_name, archive_id) 874 return self.make_request('DELETE', uri, ok_responses=(204,)) 875 876 # Multipart 877 878 def initiate_multipart_upload(self, vault_name, part_size, 879 description=None): 880 """ 881 This operation initiates a multipart upload. Amazon Glacier 882 creates a multipart upload resource and returns its ID in the 883 response. The multipart upload ID is used in subsequent 884 requests to upload parts of an archive (see 885 UploadMultipartPart). 886 887 When you initiate a multipart upload, you specify the part 888 size in number of bytes. The part size must be a megabyte 889 (1024 KB) multiplied by a power of 2-for example, 1048576 (1 890 MB), 2097152 (2 MB), 4194304 (4 MB), 8388608 (8 MB), and so 891 on. The minimum allowable part size is 1 MB, and the maximum 892 is 4 GB. 893 894 Every part you upload to this resource (see 895 UploadMultipartPart), except the last one, must have the same 896 size. The last one can be the same size or smaller. For 897 example, suppose you want to upload a 16.2 MB file. If you 898 initiate the multipart upload with a part size of 4 MB, you 899 will upload four parts of 4 MB each and one part of 0.2 MB. 900 901 902 You don't need to know the size of the archive when you start 903 a multipart upload because Amazon Glacier does not require you 904 to specify the overall archive size. 905 906 907 After you complete the multipart upload, Amazon Glacier 908 removes the multipart upload resource referenced by the ID. 909 Amazon Glacier also removes the multipart upload resource if 910 you cancel the multipart upload or it may be removed if there 911 is no activity for a period of 24 hours. 912 913 An AWS account has full permission to perform all operations 914 (actions). However, AWS Identity and Access Management (IAM) 915 users don't have any permissions by default. You must grant 916 them explicit permission to perform specific actions. For more 917 information, see `Access Control Using AWS Identity and Access 918 Management (IAM)`_. 919 920 For conceptual information and underlying REST API, go to 921 `Uploading Large Archives in Parts (Multipart Upload)`_ and 922 `Initiate Multipart Upload`_ in the Amazon Glacier Developer 923 Guide . 924 925 The part size must be a megabyte (1024 KB) multiplied by a power of 926 2, for example, 1048576 (1 MB), 2097152 (2 MB), 4194304 (4 MB), 927 8388608 (8 MB), and so on. The minimum allowable part size is 1 MB, 928 and the maximum is 4 GB (4096 MB). 929 930 :type vault_name: str 931 :param vault_name: The name of the vault. 932 933 :type description: str 934 :param description: The archive description that you are uploading in 935 parts. 936 937 :type part_size: int 938 :param part_size: The size of each part except the last, in bytes. The 939 last part can be smaller than this part size. 940 """ 941 response_headers = [('x-amz-multipart-upload-id', u'UploadId'), 942 ('Location', u'Location')] 943 headers = {'x-amz-part-size': str(part_size)} 944 if description: 945 headers['x-amz-archive-description'] = description 946 uri = 'vaults/%s/multipart-uploads' % vault_name 947 response = self.make_request('POST', uri, headers=headers, 948 ok_responses=(201,), 949 response_headers=response_headers) 950 return response 951 952 def complete_multipart_upload(self, vault_name, upload_id, 953 sha256_treehash, archive_size): 954 """ 955 You call this operation to inform Amazon Glacier that all the 956 archive parts have been uploaded and that Amazon Glacier can 957 now assemble the archive from the uploaded parts. After 958 assembling and saving the archive to the vault, Amazon Glacier 959 returns the URI path of the newly created archive resource. 960 Using the URI path, you can then access the archive. After you 961 upload an archive, you should save the archive ID returned to 962 retrieve the archive at a later point. You can also get the 963 vault inventory to obtain a list of archive IDs in a vault. 964 For more information, see InitiateJob. 965 966 In the request, you must include the computed SHA256 tree hash 967 of the entire archive you have uploaded. For information about 968 computing a SHA256 tree hash, see `Computing Checksums`_. On 969 the server side, Amazon Glacier also constructs the SHA256 970 tree hash of the assembled archive. If the values match, 971 Amazon Glacier saves the archive to the vault; otherwise, it 972 returns an error, and the operation fails. The ListParts 973 operation returns a list of parts uploaded for a specific 974 multipart upload. It includes checksum information for each 975 uploaded part that can be used to debug a bad checksum issue. 976 977 Additionally, Amazon Glacier also checks for any missing 978 content ranges when assembling the archive, if missing content 979 ranges are found, Amazon Glacier returns an error and the 980 operation fails. 981 982 Complete Multipart Upload is an idempotent operation. After 983 your first successful complete multipart upload, if you call 984 the operation again within a short period, the operation will 985 succeed and return the same archive ID. This is useful in the 986 event you experience a network issue that causes an aborted 987 connection or receive a 500 server error, in which case you 988 can repeat your Complete Multipart Upload request and get the 989 same archive ID without creating duplicate archives. Note, 990 however, that after the multipart upload completes, you cannot 991 call the List Parts operation and the multipart upload will 992 not appear in List Multipart Uploads response, even if 993 idempotent complete is possible. 994 995 An AWS account has full permission to perform all operations 996 (actions). However, AWS Identity and Access Management (IAM) 997 users don't have any permissions by default. You must grant 998 them explicit permission to perform specific actions. For more 999 information, see `Access Control Using AWS Identity and Access 1000 Management (IAM)`_. 1001 1002 For conceptual information and underlying REST API, go to 1003 `Uploading Large Archives in Parts (Multipart Upload)`_ and 1004 `Complete Multipart Upload`_ in the Amazon Glacier Developer 1005 Guide . 1006 1007 :type checksum: string 1008 :param checksum: The SHA256 tree hash of the entire archive. It is the 1009 tree hash of SHA256 tree hash of the individual parts. If the value 1010 you specify in the request does not match the SHA256 tree hash of 1011 the final assembled archive as computed by Amazon Glacier, Amazon 1012 Glacier returns an error and the request fails. 1013 1014 :type vault_name: str 1015 :param vault_name: The name of the vault. 1016 1017 :type upload_id: str 1018 :param upload_id: The upload ID of the multipart upload. 1019 1020 :type sha256_treehash: str 1021 :param sha256_treehash: The SHA256 tree hash of the entire archive. 1022 It is the tree hash of SHA256 tree hash of the individual parts. 1023 If the value you specify in the request does not match the SHA256 1024 tree hash of the final assembled archive as computed by Amazon 1025 Glacier, Amazon Glacier returns an error and the request fails. 1026 1027 :type archive_size: int 1028 :param archive_size: The total size, in bytes, of the entire 1029 archive. This value should be the sum of all the sizes of 1030 the individual parts that you uploaded. 1031 """ 1032 response_headers = [('x-amz-archive-id', u'ArchiveId'), 1033 ('Location', u'Location')] 1034 headers = {'x-amz-sha256-tree-hash': sha256_treehash, 1035 'x-amz-archive-size': str(archive_size)} 1036 uri = 'vaults/%s/multipart-uploads/%s' % (vault_name, upload_id) 1037 response = self.make_request('POST', uri, headers=headers, 1038 ok_responses=(201,), 1039 response_headers=response_headers) 1040 return response 1041 1042 def abort_multipart_upload(self, vault_name, upload_id): 1043 """ 1044 This operation aborts a multipart upload identified by the 1045 upload ID. 1046 1047 After the Abort Multipart Upload request succeeds, you cannot 1048 upload any more parts to the multipart upload or complete the 1049 multipart upload. Aborting a completed upload fails. However, 1050 aborting an already-aborted upload will succeed, for a short 1051 time. For more information about uploading a part and 1052 completing a multipart upload, see UploadMultipartPart and 1053 CompleteMultipartUpload. 1054 1055 This operation is idempotent. 1056 1057 An AWS account has full permission to perform all operations 1058 (actions). However, AWS Identity and Access Management (IAM) 1059 users don't have any permissions by default. You must grant 1060 them explicit permission to perform specific actions. For more 1061 information, see `Access Control Using AWS Identity and Access 1062 Management (IAM)`_. 1063 1064 For conceptual information and underlying REST API, go to 1065 `Working with Archives in Amazon Glacier`_ and `Abort 1066 Multipart Upload`_ in the Amazon Glacier Developer Guide . 1067 1068 :type vault_name: string 1069 :param vault_name: The name of the vault. 1070 1071 :type upload_id: string 1072 :param upload_id: The upload ID of the multipart upload to delete. 1073 """ 1074 uri = 'vaults/%s/multipart-uploads/%s' % (vault_name, upload_id) 1075 return self.make_request('DELETE', uri, ok_responses=(204,)) 1076 1077 def list_multipart_uploads(self, vault_name, limit=None, marker=None): 1078 """ 1079 This operation lists in-progress multipart uploads for the 1080 specified vault. An in-progress multipart upload is a 1081 multipart upload that has been initiated by an 1082 InitiateMultipartUpload request, but has not yet been 1083 completed or aborted. The list returned in the List Multipart 1084 Upload response has no guaranteed order. 1085 1086 The List Multipart Uploads operation supports pagination. By 1087 default, this operation returns up to 1,000 multipart uploads 1088 in the response. You should always check the response for a 1089 `marker` at which to continue the list; if there are no more 1090 items the `marker` is `null`. To return a list of multipart 1091 uploads that begins at a specific upload, set the `marker` 1092 request parameter to the value you obtained from a previous 1093 List Multipart Upload request. You can also limit the number 1094 of uploads returned in the response by specifying the `limit` 1095 parameter in the request. 1096 1097 Note the difference between this operation and listing parts 1098 (ListParts). The List Multipart Uploads operation lists all 1099 multipart uploads for a vault and does not require a multipart 1100 upload ID. The List Parts operation requires a multipart 1101 upload ID since parts are associated with a single upload. 1102 1103 An AWS account has full permission to perform all operations 1104 (actions). However, AWS Identity and Access Management (IAM) 1105 users don't have any permissions by default. You must grant 1106 them explicit permission to perform specific actions. For more 1107 information, see `Access Control Using AWS Identity and Access 1108 Management (IAM)`_. 1109 1110 For conceptual information and the underlying REST API, go to 1111 `Working with Archives in Amazon Glacier`_ and `List Multipart 1112 Uploads `_ in the Amazon Glacier Developer Guide . 1113 1114 :type vault_name: string 1115 :param vault_name: The name of the vault. 1116 1117 :type limit: string 1118 :param limit: Specifies the maximum number of uploads returned in the 1119 response body. If this value is not specified, the List Uploads 1120 operation returns up to 1,000 uploads. 1121 1122 :type marker: string 1123 :param marker: An opaque string used for pagination. This value 1124 specifies the upload at which the listing of uploads should begin. 1125 Get the marker value from a previous List Uploads response. You 1126 need only include the marker if you are continuing the pagination 1127 of results started in a previous List Uploads request. 1128 """ 1129 params = {} 1130 if limit: 1131 params['limit'] = limit 1132 if marker: 1133 params['marker'] = marker 1134 uri = 'vaults/%s/multipart-uploads' % vault_name 1135 return self.make_request('GET', uri, params=params) 1136 1137 def list_parts(self, vault_name, upload_id, limit=None, marker=None): 1138 """ 1139 This operation lists the parts of an archive that have been 1140 uploaded in a specific multipart upload. You can make this 1141 request at any time during an in-progress multipart upload 1142 before you complete the upload (see CompleteMultipartUpload. 1143 List Parts returns an error for completed uploads. The list 1144 returned in the List Parts response is sorted by part range. 1145 1146 The List Parts operation supports pagination. By default, this 1147 operation returns up to 1,000 uploaded parts in the response. 1148 You should always check the response for a `marker` at which 1149 to continue the list; if there are no more items the `marker` 1150 is `null`. To return a list of parts that begins at a specific 1151 part, set the `marker` request parameter to the value you 1152 obtained from a previous List Parts request. You can also 1153 limit the number of parts returned in the response by 1154 specifying the `limit` parameter in the request. 1155 1156 An AWS account has full permission to perform all operations 1157 (actions). However, AWS Identity and Access Management (IAM) 1158 users don't have any permissions by default. You must grant 1159 them explicit permission to perform specific actions. For more 1160 information, see `Access Control Using AWS Identity and Access 1161 Management (IAM)`_. 1162 1163 For conceptual information and the underlying REST API, go to 1164 `Working with Archives in Amazon Glacier`_ and `List Parts`_ 1165 in the Amazon Glacier Developer Guide . 1166 1167 :type vault_name: string 1168 :param vault_name: The name of the vault. 1169 1170 :type upload_id: string 1171 :param upload_id: The upload ID of the multipart upload. 1172 1173 :type marker: string 1174 :param marker: An opaque string used for pagination. This value 1175 specifies the part at which the listing of parts should begin. Get 1176 the marker value from the response of a previous List Parts 1177 response. You need only include the marker if you are continuing 1178 the pagination of results started in a previous List Parts request. 1179 1180 :type limit: string 1181 :param limit: Specifies the maximum number of parts returned in the 1182 response body. If this value is not specified, the List Parts 1183 operation returns up to 1,000 uploads. 1184 """ 1185 params = {} 1186 if limit: 1187 params['limit'] = limit 1188 if marker: 1189 params['marker'] = marker 1190 uri = 'vaults/%s/multipart-uploads/%s' % (vault_name, upload_id) 1191 return self.make_request('GET', uri, params=params) 1192 1193 def upload_part(self, vault_name, upload_id, linear_hash, 1194 tree_hash, byte_range, part_data): 1195 """ 1196 This operation uploads a part of an archive. You can upload 1197 archive parts in any order. You can also upload them in 1198 parallel. You can upload up to 10,000 parts for a multipart 1199 upload. 1200 1201 Amazon Glacier rejects your upload part request if any of the 1202 following conditions is true: 1203 1204 1205 + **SHA256 tree hash does not match**To ensure that part data 1206 is not corrupted in transmission, you compute a SHA256 tree 1207 hash of the part and include it in your request. Upon 1208 receiving the part data, Amazon Glacier also computes a SHA256 1209 tree hash. If these hash values don't match, the operation 1210 fails. For information about computing a SHA256 tree hash, see 1211 `Computing Checksums`_. 1212 + **Part size does not match**The size of each part except the 1213 last must match the size specified in the corresponding 1214 InitiateMultipartUpload request. The size of the last part 1215 must be the same size as, or smaller than, the specified size. 1216 If you upload a part whose size is smaller than the part size 1217 you specified in your initiate multipart upload request and 1218 that part is not the last part, then the upload part request 1219 will succeed. However, the subsequent Complete Multipart 1220 Upload request will fail. 1221 + **Range does not align**The byte range value in the request 1222 does not align with the part size specified in the 1223 corresponding initiate request. For example, if you specify a 1224 part size of 4194304 bytes (4 MB), then 0 to 4194303 bytes (4 1225 MB - 1) and 4194304 (4 MB) to 8388607 (8 MB - 1) are valid 1226 part ranges. However, if you set a range value of 2 MB to 6 1227 MB, the range does not align with the part size and the upload 1228 will fail. 1229 1230 1231 This operation is idempotent. If you upload the same part 1232 multiple times, the data included in the most recent request 1233 overwrites the previously uploaded data. 1234 1235 An AWS account has full permission to perform all operations 1236 (actions). However, AWS Identity and Access Management (IAM) 1237 users don't have any permissions by default. You must grant 1238 them explicit permission to perform specific actions. For more 1239 information, see `Access Control Using AWS Identity and Access 1240 Management (IAM)`_. 1241 1242 For conceptual information and underlying REST API, go to 1243 `Uploading Large Archives in Parts (Multipart Upload)`_ and 1244 `Upload Part `_ in the Amazon Glacier Developer Guide . 1245 1246 :type vault_name: str 1247 :param vault_name: The name of the vault. 1248 1249 :type linear_hash: str 1250 :param linear_hash: The SHA256 checksum (a linear hash) of the 1251 payload. 1252 1253 :type tree_hash: str 1254 :param tree_hash: The user-computed SHA256 tree hash of the 1255 payload. For more information on computing the 1256 tree hash, see http://goo.gl/u7chF. 1257 1258 :type upload_id: str 1259 :param upload_id: The unique ID associated with this upload 1260 operation. 1261 1262 :type byte_range: tuple of ints 1263 :param byte_range: Identifies the range of bytes in the assembled 1264 archive that will be uploaded in this part. Amazon Glacier uses 1265 this information to assemble the archive in the proper sequence. 1266 The format of this header follows RFC 2616. An example header is 1267 Content-Range:bytes 0-4194303/*. 1268 1269 :type part_data: bytes 1270 :param part_data: The data to be uploaded for the part 1271 """ 1272 headers = {'x-amz-content-sha256': linear_hash, 1273 'x-amz-sha256-tree-hash': tree_hash, 1274 'Content-Range': 'bytes %d-%d/*' % byte_range} 1275 response_headers = [('x-amz-sha256-tree-hash', u'TreeHash')] 1276 uri = 'vaults/%s/multipart-uploads/%s' % (vault_name, upload_id) 1277 return self.make_request('PUT', uri, headers=headers, 1278 data=part_data, ok_responses=(204,), 1279 response_headers=response_headers) 1280