Mercurial > repos > shellac > guppy_basecaller
annotate env/lib/python3.7/site-packages/boto/s3/lifecycle.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac | 
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 1 # Copyright (c) 2012 Mitch Garnaat http://garnaat.org/ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 3 # | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 4 # Permission is hereby granted, free of charge, to any person obtaining a | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 5 # copy of this software and associated documentation files (the | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 6 # "Software"), to deal in the Software without restriction, including | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 7 # without limitation the rights to use, copy, modify, merge, publish, dis- | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 8 # tribute, sublicense, and/or sell copies of the Software, and to permit | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 9 # persons to whom the Software is furnished to do so, subject to the fol- | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 10 # lowing conditions: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 11 # | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 12 # The above copyright notice and this permission notice shall be included | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 13 # in all copies or substantial portions of the Software. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 14 # | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 21 # IN THE SOFTWARE. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 22 from boto.compat import six | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 23 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 24 class Rule(object): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 25 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 26 A Lifecycle rule for an S3 bucket. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 27 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 28 :ivar id: Unique identifier for the rule. The value cannot be longer | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 29 than 255 characters. This value is optional. The server will | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 30 generate a unique value for the rule if no value is provided. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 31 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 32 :ivar prefix: Prefix identifying one or more objects to which the | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 33 rule applies. If prefix is not provided, Boto generates a default | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 34 prefix which will match all objects. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 35 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 36 :ivar status: If 'Enabled', the rule is currently being applied. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 37 If 'Disabled', the rule is not currently being applied. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 38 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 39 :ivar expiration: An instance of `Expiration`. This indicates | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 40 the lifetime of the objects that are subject to the rule. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 41 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 42 :ivar transition: An instance of `Transition`. This indicates | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 43 when to transition to a different storage class. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 44 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 45 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 46 def __init__(self, id=None, prefix=None, status=None, expiration=None, | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 47 transition=None): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 48 self.id = id | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 49 self.prefix = '' if prefix is None else prefix | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 50 self.status = status | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 51 if isinstance(expiration, six.integer_types): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 52 # retain backwards compatibility??? | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 53 self.expiration = Expiration(days=expiration) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 54 else: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 55 # None or object | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 56 self.expiration = expiration | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 57 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 58 # retain backwards compatibility | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 59 if isinstance(transition, Transition): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 60 self.transition = Transitions() | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 61 self.transition.append(transition) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 62 elif transition: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 63 self.transition = transition | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 64 else: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 65 self.transition = Transitions() | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 66 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 67 def __repr__(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 68 return '<Rule: %s>' % self.id | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 69 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 70 def startElement(self, name, attrs, connection): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 71 if name == 'Transition': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 72 return self.transition | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 73 elif name == 'Expiration': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 74 self.expiration = Expiration() | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 75 return self.expiration | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 76 return None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 77 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 78 def endElement(self, name, value, connection): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 79 if name == 'ID': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 80 self.id = value | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 81 elif name == 'Prefix': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 82 self.prefix = value | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 83 elif name == 'Status': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 84 self.status = value | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 85 else: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 86 setattr(self, name, value) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 87 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 88 def to_xml(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 89 s = '<Rule>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 90 if self.id is not None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 91 s += '<ID>%s</ID>' % self.id | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 92 s += '<Prefix>%s</Prefix>' % self.prefix | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 93 s += '<Status>%s</Status>' % self.status | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 94 if self.expiration is not None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 95 s += self.expiration.to_xml() | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 96 if self.transition is not None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 97 s += self.transition.to_xml() | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 98 s += '</Rule>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 99 return s | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 100 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 101 class Expiration(object): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 102 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 103 When an object will expire. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 104 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 105 :ivar days: The number of days until the object expires | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 106 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 107 :ivar date: The date when the object will expire. Must be | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 108 in ISO 8601 format. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 109 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 110 def __init__(self, days=None, date=None): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 111 self.days = days | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 112 self.date = date | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 113 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 114 def startElement(self, name, attrs, connection): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 115 return None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 116 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 117 def endElement(self, name, value, connection): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 118 if name == 'Days': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 119 self.days = int(value) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 120 elif name == 'Date': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 121 self.date = value | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 122 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 123 def __repr__(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 124 if self.days is None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 125 how_long = "on: %s" % self.date | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 126 else: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 127 how_long = "in: %s days" % self.days | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 128 return '<Expiration: %s>' % how_long | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 129 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 130 def to_xml(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 131 s = '<Expiration>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 132 if self.days is not None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 133 s += '<Days>%s</Days>' % self.days | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 134 elif self.date is not None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 135 s += '<Date>%s</Date>' % self.date | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 136 s += '</Expiration>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 137 return s | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 138 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 139 class Transition(object): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 140 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 141 A transition to a different storage class. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 142 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 143 :ivar days: The number of days until the object should be moved. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 144 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 145 :ivar date: The date when the object should be moved. Should be | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 146 in ISO 8601 format. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 147 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 148 :ivar storage_class: The storage class to transition to. Valid | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 149 values are GLACIER, STANDARD_IA. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 150 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 151 def __init__(self, days=None, date=None, storage_class=None): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 152 self.days = days | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 153 self.date = date | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 154 self.storage_class = storage_class | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 155 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 156 def __repr__(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 157 if self.days is None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 158 how_long = "on: %s" % self.date | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 159 else: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 160 how_long = "in: %s days" % self.days | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 161 return '<Transition: %s, %s>' % (how_long, self.storage_class) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 162 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 163 def to_xml(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 164 s = '<Transition>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 165 s += '<StorageClass>%s</StorageClass>' % self.storage_class | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 166 if self.days is not None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 167 s += '<Days>%s</Days>' % self.days | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 168 elif self.date is not None: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 169 s += '<Date>%s</Date>' % self.date | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 170 s += '</Transition>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 171 return s | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 172 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 173 class Transitions(list): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 174 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 175 A container for the transitions associated with a Lifecycle's Rule configuration. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 176 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 177 def __init__(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 178 self.transition_properties = 3 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 179 self.current_transition_property = 1 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 180 self.temp_days = None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 181 self.temp_date = None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 182 self.temp_storage_class = None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 183 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 184 def startElement(self, name, attrs, connection): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 185 return None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 186 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 187 def endElement(self, name, value, connection): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 188 if name == 'Days': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 189 self.temp_days = int(value) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 190 elif name == 'Date': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 191 self.temp_date = value | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 192 elif name == 'StorageClass': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 193 self.temp_storage_class = value | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 194 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 195 # the XML does not contain a <Transitions> tag | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 196 # but rather N number of <Transition> tags not | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 197 # structured in any sort of hierarchy. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 198 if self.current_transition_property == self.transition_properties: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 199 self.append(Transition(self.temp_days, self.temp_date, self.temp_storage_class)) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 200 self.temp_days = self.temp_date = self.temp_storage_class = None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 201 self.current_transition_property = 1 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 202 else: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 203 self.current_transition_property += 1 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 204 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 205 def to_xml(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 206 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 207 Returns a string containing the XML version of the Lifecycle | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 208 configuration as defined by S3. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 209 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 210 s = '' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 211 for transition in self: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 212 s += transition.to_xml() | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 213 return s | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 214 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 215 def add_transition(self, days=None, date=None, storage_class=None): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 216 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 217 Add a transition to this Lifecycle configuration. This only adds | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 218 the rule to the local copy. To install the new rule(s) on | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 219 the bucket, you need to pass this Lifecycle config object | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 220 to the configure_lifecycle method of the Bucket object. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 221 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 222 :ivar days: The number of days until the object should be moved. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 223 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 224 :ivar date: The date when the object should be moved. Should be | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 225 in ISO 8601 format. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 226 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 227 :ivar storage_class: The storage class to transition to. Valid | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 228 values are GLACIER, STANDARD_IA. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 229 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 230 transition = Transition(days, date, storage_class) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 231 self.append(transition) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 232 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 233 def __first_or_default(self, prop): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 234 for transition in self: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 235 return getattr(transition, prop) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 236 return None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 237 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 238 # maintain backwards compatibility so that we can continue utilizing | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 239 # 'rule.transition.days' syntax | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 240 @property | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 241 def days(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 242 return self.__first_or_default('days') | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 243 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 244 @property | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 245 def date(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 246 return self.__first_or_default('date') | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 247 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 248 @property | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 249 def storage_class(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 250 return self.__first_or_default('storage_class') | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 251 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 252 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 253 class Lifecycle(list): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 254 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 255 A container for the rules associated with a Lifecycle configuration. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 256 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 257 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 258 def startElement(self, name, attrs, connection): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 259 if name == 'Rule': | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 260 rule = Rule() | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 261 self.append(rule) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 262 return rule | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 263 return None | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 264 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 265 def endElement(self, name, value, connection): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 266 setattr(self, name, value) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 267 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 268 def to_xml(self): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 269 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 270 Returns a string containing the XML version of the Lifecycle | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 271 configuration as defined by S3. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 272 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 273 s = '<?xml version="1.0" encoding="UTF-8"?>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 274 s += '<LifecycleConfiguration>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 275 for rule in self: | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 276 s += rule.to_xml() | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 277 s += '</LifecycleConfiguration>' | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 278 return s | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 279 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 280 def add_rule(self, id=None, prefix='', status='Enabled', | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 281 expiration=None, transition=None): | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 282 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 283 Add a rule to this Lifecycle configuration. This only adds | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 284 the rule to the local copy. To install the new rule(s) on | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 285 the bucket, you need to pass this Lifecycle config object | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 286 to the configure_lifecycle method of the Bucket object. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 287 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 288 :type id: str | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 289 :param id: Unique identifier for the rule. The value cannot be longer | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 290 than 255 characters. This value is optional. The server will | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 291 generate a unique value for the rule if no value is provided. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 292 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 293 :type prefix: str | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 294 :iparam prefix: Prefix identifying one or more objects to which the | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 295 rule applies. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 296 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 297 :type status: str | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 298 :param status: If 'Enabled', the rule is currently being applied. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 299 If 'Disabled', the rule is not currently being applied. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 300 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 301 :type expiration: int | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 302 :param expiration: Indicates the lifetime, in days, of the objects | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 303 that are subject to the rule. The value must be a non-zero | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 304 positive integer. A Expiration object instance is also perfect. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 305 | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 306 :type transition: Transitions | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 307 :param transition: Indicates when an object transitions to a | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 308 different storage class. | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 309 """ | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 310 rule = Rule(id, prefix, status, expiration, transition) | 
| 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 shellac parents: diff
changeset | 311 self.append(rule) | 
