o ckF[o)@s|ddZGdddeZGdddeZGdddeZGdd d eZGd d d eZGd d d eZGdddeZ dS)cCsd|}d|}d|||fS)Nz<%s>zz%s%s%s)keyvaluestartendrr1/usr/lib/python3/dist-packages/boto/s3/website.pytagsrc@s6eZdZdZ  d ddZddZddZd d ZdS) WebsiteConfigurationa Website configuration for a bucket. :ivar suffix: Suffix that is appended to a request that is for a "directory" on the website endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/ the data that is returned will be for the object with the key name images/index.html). The suffix must not be empty and must not include a slash character. :ivar error_key: The object key name to use when a 4xx class error occurs. This key identifies the page that is returned when such an error occurs. :ivar redirect_all_requests_to: Describes the redirect behavior for every request to this bucket's website endpoint. If this value is non None, no other values are considered when configuring the website configuration for the bucket. This is an instance of ``RedirectLocation``. :ivar routing_rules: ``RoutingRules`` object which specifies conditions and redirects that apply when the conditions are met. NcCs0||_||_||_|dur||_dSt|_dSN)suffix error_keyredirect_all_requests_to routing_rules RoutingRules)selfr r r r rrr__init__7s   zWebsiteConfiguration.__init__cCsF|dkr t|_|jS|dkrtdg|dS|dkr!tdg|dSdS)Nr IndexDocument)Suffixr ) container ErrorDocument)Keyr )rr _XMLKeyValuernameattrs connectionrrr startElementAsz!WebsiteConfiguration.startElementcCdSr rrrrrrrr endElementJzWebsiteConfiguration.endElementcCsddg}|jdur|tdtd|j|jdur&|tdtd|j|jdur3||j|jr>||j|dd|S) Nz&zFrrrrz)r appendrr r to_xmlr joinrpartsrrrr"Ms     zWebsiteConfiguration.to_xml)NNNN)__name__ __module__ __qualname____doc__rrrr"rrrrrs   rc@s.eZdZd ddZddZddZdd ZdS) rNcCs||_|r ||_dS||_dSr ) translatorr)rr*rrrrr]s  z_XMLKeyValue.__init__cCrr rrrrrrdrz_XMLKeyValue.startElementcCs*|jD]\}}||krt|j||qdSr )r*setattrr)rrrrxml_key attr_namerrrrgs z_XMLKeyValue.endElementcCsBg}|jD]\}}t|j|}|dur|t||qd|S)Nr )r*getattrrr!rr#)rr%r,r-contentrrrr"ls  z_XMLKeyValue.to_xmlr )r&r'r(rrrr"rrrrr\s   rc6eZdZdZddgZd fdd ZfddZZS) RedirectLocationa*Specify redirect behavior for every request to a bucket's endpoint. :ivar hostname: Name of the host where requests will be redirected. :ivar protocol: Protocol to use (http, https) when redirecting requests. The default is the protocol that is used in the original request. HostNamehostnameProtocolprotocolNc"||_||_tt||jdSr )r4r7superr1r TRANSLATOR)rr4r7 __class__rrrzRedirectLocation.__init__ctdtt|S)NRedirectAllRequestsTo)rr9r1r"rr;rrr"s zRedirectLocation.to_xmlNNr&r'r(r)r:rr" __classcell__rrr;rr1usr1cs<eZdZddZddZddZfddZd d ZZS) rcCs|||S)z :type rule: :class:`boto.s3.website.RoutingRule` :param rule: A routing rule. :return: This ``RoutingRules`` object is returned, so that it can chain subsequent calls. )r!)rrulerrradd_rules zRoutingRules.add_rulecCs(|dkrttt}|||SdS)N RoutingRule)rF ConditionRedirectrE)rrrrrDrrrrs  zRoutingRules.startElementcCrr rrrrrrrzRoutingRules.endElementcsdtt|S)NzRoutingRules(%s))r9r__repr__r@r;rrrIszRoutingRules.__repr__cCs,g}|D] }||qtdd|S)Nr )r!r"rr#)r inner_textrDrrrr"szRoutingRules.to_xml) r&r'r(rErrrIr"rCrrr;rrs   rc@sNeZdZdZdddZddZddZd d Zedd d Z  dd dZ dS)rFaRepresents a single routing rule. There are convenience methods to making creating rules more concise:: rule = RoutingRule.when(key_prefix='foo/').then_redirect('example.com') :ivar condition: Describes condition that must be met for the specified redirect to apply. :ivar redirect: Specifies redirect behavior. You can redirect requests to another host, to another page, or with another protocol. In the event of an error, you can can specify a different error code to return. NcCs||_||_dSr  conditionredirect)rrMrNrrrrs zRoutingRule.__init__cCs |dkr|jS|dkr|jSdS)NrGrHrLrrrrrs zRoutingRule.startElementcCrr rrrrrrrzRoutingRule.endElementcCs@g}|jr ||j|jr||jtdd|S)NrFrJ)rMr!r"rNrr#r$rrrr"s zRoutingRule.to_xmlcCs|t||ddS)N) key_prefixhttp_error_code)rG)clsrOrPrrrwhens zRoutingRule.whencCst|||||d|_|S)N)r4r7 replace_keyreplace_key_prefixhttp_redirect_code)rHrNrr4r7rSrTrUrrr then_redirectszRoutingRule.then_redirectrANNNNN) r&r'r(r)rrrr" classmethodrRrWrrrrrFs  rFcr0) rGa$ :ivar key_prefix: The object key name prefix when the redirect is applied. For example, to redirect requests for ExamplePage.html, the key prefix will be ExamplePage.html. To redirect request for all pages with the prefix docs/, the key prefix will be /docs, which identifies all objects in the docs/ folder. :ivar http_error_code: The HTTP error code when the redirect is applied. In the event of an error, if the error code equals this value, then the specified redirect is applied. )KeyPrefixEqualsrO)HttpErrorCodeReturnedEqualsrPNcr8r )rOrPr9rGrr:)rrOrPr;rrrr=zCondition.__init__cr>)NrG)rr9rGr"r@r;rrr"zCondition.to_xmlrArBrrr;rrGs rGcs:eZdZdZgdZ  dfdd ZfddZZS) rHa :ivar hostname: The host name to use in the redirect request. :ivar protocol: The protocol to use in the redirect request. Can be either 'http' or 'https'. :ivar replace_key: The specific object key to use in the redirect request. For example, redirect request to error.html. :ivar replace_key_prefix: The object key prefix to use in the redirect request. For example, to redirect requests for all pages with prefix docs/ (objects in the docs/ folder) to documents/, you can set a condition block with KeyPrefixEquals set to docs/ and in the Redirect set ReplaceKeyPrefixWith to /documents. :ivar http_redirect_code: The HTTP redirect code to use on the response. )r5r2)ReplaceKeyWithrS)ReplaceKeyPrefixWithrT)HttpRedirectCoderUNcs4||_||_||_||_||_tt||jdSr ) r4r7rSrTrUr9rHrr:rVr;rrrs zRedirect.__init__cr>)NrH)rr9rHr"r@r;rrr""r\zRedirect.to_xmlrXrBrrr;rrHs rHN) robjectrrr1listrrFrGrHrrrrs?"4