o ckF[*@s`ddlmZGdddeZGdddeZGdddeZGdd d eZGd d d eZd S) )sixc@s>eZdZdZ  d ddZddZddZd d Zd d ZdS)RuleaH A Lifecycle rule for an S3 bucket. :ivar id: Unique identifier for the rule. The value cannot be longer than 255 characters. This value is optional. The server will generate a unique value for the rule if no value is provided. :ivar prefix: Prefix identifying one or more objects to which the rule applies. If prefix is not provided, Boto generates a default prefix which will match all objects. :ivar status: If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being applied. :ivar expiration: An instance of `Expiration`. This indicates the lifetime of the objects that are subject to the rule. :ivar transition: An instance of `Transition`. This indicates when to transition to a different storage class. NcCsz||_|dur dn||_||_t|tjrt|d|_n||_t|tr0t |_ |j |dS|r7||_ dSt |_ dS)N)days) idprefixstatus isinstancer integer_types Expiration expiration Transition Transitions transitionappend)selfrrrr rr3/usr/lib/python3/dist-packages/boto/s3/lifecycle.py__init__.s    z Rule.__init__cCs d|jS)Nz )rrrrr__repr__Cs z Rule.__repr__cCs(|dkr|jS|dkrt|_|jSdS)Nr r )rr r rnameattrs connectionrrr startElementFs zRule.startElementcCsF|dkr ||_dS|dkr||_dS|dkr||_dSt|||dS)NIDPrefixStatus)rrrsetattrrrvaluerrrr endElementNs   zRule.endElementcCstd}|jdur|d|j7}|d|j7}|d|j7}|jdur(||j7}|jdur4||j7}|d7}|S)Nzz %sz%sz%sz)rrrr to_xmlrrsrrrr#Xs   z Rule.to_xml)NNNNN) __name__ __module__ __qualname____doc__rrrr"r#rrrrrs  rc@s:eZdZdZd ddZddZddZd d Zd d ZdS)r z When an object will expire. :ivar days: The number of days until the object expires :ivar date: The date when the object will expire. Must be in ISO 8601 format. NcCs||_||_dSNrdate)rrr,rrrrns zExpiration.__init__cCdSr*rrrrrrrzExpiration.startElementcCs,|dkr t||_dS|dkr||_dSdS)NDaysDate)intrr,r rrrr"us  zExpiration.endElementcCs.|jdurd|j}d|Sd|j}d|S)Non: %s in: %s dayszr+rhow_longrrrr{s   zExpiration.__repr__cCsBd}|jdur|d|j7}n |jdur|d|j7}|d7}|S)Nz %s%sz r+r$rrrr#s  zExpiration.to_xml)NN) r&r'r(r)rrr"rr#rrrrr es  r c@s*eZdZdZd ddZddZddZdS) r aJ A transition to a different storage class. :ivar days: The number of days until the object should be moved. :ivar date: The date when the object should be moved. Should be in ISO 8601 format. :ivar storage_class: The storage class to transition to. Valid values are GLACIER, STANDARD_IA. NcCs||_||_||_dSr*rr, storage_class)rrr,r9rrrrs zTransition.__init__cCs.|jdur d|j}nd|j}d||jfS)Nr2r3zr8r4rrrrs   zTransition.__repr__cCsPd}|d|j7}|jdur|d|j7}n |jdur"|d|j7}|d7}|S)Nz z%sr6r7z )r9rr,r$rrrr#s  zTransition.to_xmlNNN)r&r'r(r)rrr#rrrrr s   r c@sfeZdZdZddZddZddZdd Zdd d Zd dZ e ddZ e ddZ e ddZ d S)rz[ A container for the transitions associated with a Lifecycle's Rule configuration. cCs"d|_d|_d|_d|_d|_dS)N)transition_propertiescurrent_transition_property temp_days temp_datetemp_storage_classrrrrrs  zTransitions.__init__cCr-r*rrrrrrr.zTransitions.startElementcCs|dkr t||_n|dkr||_n|dkr||_|j|jkr9|t|j|j|jd|_|_|_d|_dS|jd7_dS)Nr/r0 StorageClassr<)r1r?r@rAr>r=rr r rrrr"s   zTransitions.endElementcCsd}|D]}||7}q|S)v Returns a string containing the XML version of the Lifecycle configuration as defined by S3. rr#)rr%rrrrr#szTransitions.to_xmlNcCst|||}||dS)aB Add a transition to this Lifecycle configuration. This only adds the rule to the local copy. To install the new rule(s) on the bucket, you need to pass this Lifecycle config object to the configure_lifecycle method of the Bucket object. :ivar days: The number of days until the object should be moved. :ivar date: The date when the object should be moved. Should be in ISO 8601 format. :ivar storage_class: The storage class to transition to. Valid values are GLACIER, STANDARD_IA. N)r r)rrr,r9rrrradd_transitions zTransitions.add_transitioncCs|D]}t||SdSr*)getattr)rproprrrr__first_or_defaultszTransitions.__first_or_defaultcC |dS)Nr_Transitions__first_or_defaultrrrrr zTransitions.dayscCrI)Nr,rJrrrrr,rLzTransitions.datecCrI)Nr9rJrrrrr9rLzTransitions.storage_classr:)r&r'r(r)rrr"r#rErKpropertyrr,r9rrrrrs   rc@s6eZdZdZddZddZddZ d d d ZdS) LifecyclezN A container for the rules associated with a Lifecycle configuration. cCs |dkrt}|||SdS)Nrrr)rrrrrulerrrrs  zLifecycle.startElementcCst|||dSr*)rr rrrr" szLifecycle.endElementcCs.d}|d7}|D]}||7}q|d7}|S)rCz&zzrD)rr%rPrrrr# s zLifecycle.to_xmlNrEnabledcCst|||||}||dS)a Add a rule to this Lifecycle configuration. This only adds the rule to the local copy. To install the new rule(s) on the bucket, you need to pass this Lifecycle config object to the configure_lifecycle method of the Bucket object. :type id: str :param id: Unique identifier for the rule. The value cannot be longer than 255 characters. This value is optional. The server will generate a unique value for the rule if no value is provided. :type prefix: str :iparam prefix: Prefix identifying one or more objects to which the rule applies. :type status: str :param status: If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being applied. :type expiration: int :param expiration: Indicates the lifetime, in days, of the objects that are subject to the rule. The value must be a non-zero positive integer. A Expiration object instance is also perfect. :type transition: Transitions :param transition: Indicates when an object transitions to a different storage class. NrO)rrrrr rrPrrradd_ruleszLifecycle.add_rule)NrrQNN)r&r'r(r)rr"r#rRrrrrrNs rNN) boto.compatrobjectrr r listrrNrrrrs M&"P