Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/boto/glacier/layer2.py @ 0:d30785e31577 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:18:57 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d30785e31577 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 # Copyright (c) 2012 Thomas Parslow http://almostobsolete.net/ | |
3 # | |
4 # Permission is hereby granted, free of charge, to any person obtaining a | |
5 # copy of this software and associated documentation files (the | |
6 # "Software"), to deal in the Software without restriction, including | |
7 # without limitation the rights to use, copy, modify, merge, publish, dis- | |
8 # tribute, sublicense, and/or sell copies of the Software, and to permit | |
9 # persons to whom the Software is furnished to do so, subject to the fol- | |
10 # lowing conditions: | |
11 # | |
12 # The above copyright notice and this permission notice shall be included | |
13 # in all copies or substantial portions of the Software. | |
14 # | |
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | |
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | |
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
21 # IN THE SOFTWARE. | |
22 # | |
23 | |
24 from boto.glacier.layer1 import Layer1 | |
25 from boto.glacier.vault import Vault | |
26 | |
27 | |
28 class Layer2(object): | |
29 """ | |
30 Provides a more pythonic and friendly interface to Glacier based on Layer1 | |
31 """ | |
32 | |
33 def __init__(self, *args, **kwargs): | |
34 # Accept a passed in layer1, mainly to allow easier testing | |
35 if "layer1" in kwargs: | |
36 self.layer1 = kwargs["layer1"] | |
37 else: | |
38 self.layer1 = Layer1(*args, **kwargs) | |
39 | |
40 def create_vault(self, name): | |
41 """Creates a vault. | |
42 | |
43 :type name: str | |
44 :param name: The name of the vault | |
45 | |
46 :rtype: :class:`boto.glacier.vault.Vault` | |
47 :return: A Vault object representing the vault. | |
48 """ | |
49 self.layer1.create_vault(name) | |
50 return self.get_vault(name) | |
51 | |
52 def delete_vault(self, name): | |
53 """Delete a vault. | |
54 | |
55 This operation deletes a vault. Amazon Glacier will delete a | |
56 vault only if there are no archives in the vault as per the | |
57 last inventory and there have been no writes to the vault | |
58 since the last inventory. If either of these conditions is not | |
59 satisfied, the vault deletion fails (that is, the vault is not | |
60 removed) and Amazon Glacier returns an error. | |
61 | |
62 This operation is idempotent, you can send the same request | |
63 multiple times and it has no further effect after the first | |
64 time Amazon Glacier delete the specified vault. | |
65 | |
66 :type vault_name: str | |
67 :param vault_name: The name of the vault to delete. | |
68 """ | |
69 return self.layer1.delete_vault(name) | |
70 | |
71 def get_vault(self, name): | |
72 """ | |
73 Get an object representing a named vault from Glacier. This | |
74 operation does not check if the vault actually exists. | |
75 | |
76 :type name: str | |
77 :param name: The name of the vault | |
78 | |
79 :rtype: :class:`boto.glacier.vault.Vault` | |
80 :return: A Vault object representing the vault. | |
81 """ | |
82 response_data = self.layer1.describe_vault(name) | |
83 return Vault(self.layer1, response_data) | |
84 | |
85 def list_vaults(self): | |
86 """ | |
87 Return a list of all vaults associated with the account ID. | |
88 | |
89 :rtype: List of :class:`boto.glacier.vault.Vault` | |
90 :return: A list of Vault objects. | |
91 """ | |
92 vaults = [] | |
93 marker = None | |
94 while True: | |
95 response_data = self.layer1.list_vaults(marker=marker, limit=1000) | |
96 vaults.extend([Vault(self.layer1, rd) for rd in response_data['VaultList']]) | |
97 marker = response_data.get('Marker') | |
98 if not marker: | |
99 break | |
100 | |
101 return vaults |