o .&aT)@sddlZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z ddZdd d Zd d ZGddde ZGddde ZGdddeZGdddeZGdddeZddZGddde ZGdddeZdS)N)parse_to_aware_datetime)CloudFrontSigner)CustomArgument)#validate_mutually_exclusive_handler) BasicCommandcs|dt|dt|dtdgdg|dtddgd g|d d d |d d d i|jdjdd|dtdgd g|dfdd dS)Nz!building-command-table.cloudfrontz6building-argument-table.cloudfront.create-invalidationz4operation-args-parsed.cloudfront.create-invalidationinvalidation_batchpathsz4operation-args-parsed.cloudfront.create-distributiondefault_root_objectorigin_domain_namedistribution_configz6building-argument-table.cloudfront.create-distributionc[|dt|S)Norigin-domain-name) __setitem__OriginDomainNameargument_tablekwargsrB/usr/lib/python3/dist-packages/awscli/customizations/cloudfront.py+zregister..c[r )Ndefault-root-object)rCreateDefaultRootObjectrrrrr/rztop-level-args-parsed cloudfront) unique_idz4operation-args-parsed.cloudfront.update-distributionz6building-argument-table.cloudfront.update-distributioncs|dt|dS)Nr)contextr)rUpdateDefaultRootObjectrrrrr;s )register _add_sign _add_pathsrupdate) event_handlerrrrrsJ   rclicCsd|tttddfS)Nz%s-%s-%si@B)inttimerandomrandintprefixrrr unique_string@sr+cKsd|d_t|d<dS)NFzinvalidation-batchr)required PathsArgumentrrrrr Ds r c$eZdZfddZddZZS)r-csd}tt|jdd|ddS)NzlThe space-separated paths to be invalidated. Note: --invalidation-batch and --paths are mututally exclusive.r+)nargs help_text)superr-__init__)selfdoc __class__rrr3KszPathsArgument.__init__cCs*|durtt||dd|d<dSdS)NQuantityItems)CallerReferencePathsInvalidationBatch)r+lenr4 parametersvaluerrr add_to_paramsRs  zPathsArgument.add_to_params__name__ __module__ __qualname__r3rB __classcell__rrr6rr-Is r-cs,eZdZdZ dfdd ZddZZS) ExclusiveArgumentz2%s This argument and --%s are mututally exclusive.distribution-configcs,d||_tt|j||j||fddS)NFr1)r,r2rHr3DOC)r4namer exclusive_tor1r6rrr3]s   zExclusiveArgument.__init__cCs4tdgdddddiddddd dd d d d S)Nrr8 placeholderFForwardnone) QueryStringCookies)Enabledr9z allow-all)TargetOriginIdForwardedValuesTrustedSignersViewerProtocolPolicyMinTTLTrJ)r;OriginsDefaultCacheBehaviorrTComment)r+)r4rrrdistribution_config_templatecs z.ExclusiveArgument.distribution_config_template)rIrJ)rDrErFrLr3r]rGrrr6rrHZs rHcr.)rcstt|jd|dddS)Nr z The domain name for your origin.rK)r2rr3)r4rr6rrr3zs  zOriginDomainName.__init__cCs|durdS|d|t|d}||dd}|ddr'ddi|d<nd d d d |d <d|gd|dd<||ddd<dS)NDistributionConfigr)rJ)Id DomainName OriginPathr`z.s3.amazonaws.comOriginAccessIdentityS3OriginConfigPiz http-only)HTTPPort HTTPSPortOriginProtocolPolicyCustomOriginConfigr$r8rZr[rU) setdefaultr]r+endswith)r4r@rA origin_iditemrrrrBs$    zOriginDomainName.add_to_paramsrCrrr6rrys rcs&eZdZdfdd ZddZZS)rrJcstt|jd||p dddS)NrzvThe object that you want CloudFront to return (for example, index.html) when a viewer request points to your root URL.rK)r2rr3)r4rr1r6rrr3s  z CreateDefaultRootObject.__init__cCs,|dur|d|||dd<dSdS)Nr^DefaultRootObject)rir]r?rrrrBs z%CreateDefaultRootObject.add_to_params)rJrCrrr6rrsrcr.)rcstt|j|dd||_dS)NzThe object that you want CloudFront to return (for example, index.html) when a viewer request points to your root URL. CLI will automatically make a get-distribution-config call to load and preserve your other settings.rK)r2rr3r)r4rrr6rrr3s  z UpdateDefaultRootObject.__init__cCst|dur8|jdjd|jdj|jdj|jdjd}|j|dd}|d|d<|d |d <||d d <dSdS) Nsessionr parsed_args) region_name endpoint_urlverifyr_)r_ETagIfMatchr^rm)r create_clientregionrq verify_sslget_distribution_config)r4r@rAclientresponserrrrBs      z%UpdateDefaultRootObject.add_to_paramsrCrrr6rrs  rcKst||d<dS)Nsign) SignCommand) command_tablernrrrrrrc@sfeZdZdZdZdZdddddddd d d dd d d dded ddeddddgZddZdS)r|r{zSign a given url.aOSupported formats include: YYYY-MM-DD (which means 0AM UTC of that day), YYYY-MM-DDThh:mm:ss (with default timezone as UTC), YYYY-MM-DDThh:mm:ss+hh:mm or YYYY-MM-DDThh:mm:ss-hh:mm (with offset), or EpochTime (which always means UTC). Do NOT use YYYYMMDD, because it will be treated as EpochTime.urlTzThe URL to be signed)rM no_paramfiler,r1z key-pair-idz_The active CloudFront key pair Id for the key pair that you're using to generate the signature.)rMr,r1z private-keyz#file://path/to/your/private-key.pemzdate-less-thanz*The expiration date and time for the URL. zdate-greater-thanz-An optional start date and time for the URL. )rMr1z ip-addressztAn optional IP address or IP address range to allow client making the GET request from. Format: x.x.x.x/x or x.x.x.xcCst|jt|jj}t|j}|j}|durt|}|dus#|jdur<|j |j |||jd}t j |j|j |ddSt j |j|j |ddS)N)date_greater_than ip_address)policy)date_less_thanr)r key_pair_id RSASigner private_keyr{rrrr build_policyrsysstdoutwritegenerate_presigned_url)r4argsparsed_globalssignerrrrrrr _run_mains(   zSignCommand._run_mainN)rDrErFNAME DESCRIPTION DATE_FORMAT ARG_TABLErrrrrr|s8 %r|c@seZdZddZddZdS)rcCstj|d|_dS)Nutf8)rsa PrivateKey load_pkcs1encodepriv_key)r4rrrrr3szRSASigner.__init__cCst||jdS)NzSHA-1)rr{r)r4messagerrrr{r~zRSASigner.signN)rDrErFr3r{rrrrrs r)r#)rr&r'rbotocore.utilsrbotocore.signersrawscli.argumentsrawscli.customizations.utilsrawscli.customizations.commandsrrr+r r-rHrrrrr|objectrrrrrs(       &A