%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pyc

�
���^c@@s?dZddlmZmZmZddlZddljjZddl	m
Z
ddlZy;ddl
Z
ddlZejd�jej�eZWnek
r�eZnXeje�Zd�Zdddddd�Zddddd�Zddddd	�Zdddddd
�Zdddddd�ZdS(u�
Connection module for Amazon CloudFront

.. versionadded:: 2018.3.0

:depends: boto3

:configuration: This module accepts explicit AWS credentials but can also
    utilize IAM roles assigned to the instance through Instance Profiles or
    it can read them from the ~/.aws/credentials file or from these
    environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY.
    Dynamic credentials are then automatically obtained from AWS API and no
    further configuration is necessary. More information available at:

    .. code-block:: text

        http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/
            iam-roles-for-amazon-ec2.html

        http://boto3.readthedocs.io/en/latest/guide/
            configuration.html#guide-configuration

    If IAM roles are not used you need to specify them either in a pillar or
    in the minion's config file:

    .. code-block:: yaml

        cloudfront.keyid: GKTADJGHEIQSXMKKRBJ08H
        cloudfront.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    A region may also be specified in the configuration:

    .. code-block:: yaml

        cloudfront.region: us-east-1

    If a region is not specified, the default is us-east-1.

    It's also possible to specify key, keyid and region via a profile, either
    as a passed in dict, or as a string to pull from pillars or minion config:

    .. code-block:: yaml

        myprofile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
            region: us-east-1
i(tabsolute_importtprint_functiontunicode_literalsN(tOrderedDictuboto3cC@s6tjjj�}|tkr2tdtd�n|S(u-
    Only load if boto3 libraries exist.
    uboto3.assign_funcsu
cloudfront(tsalttutilstversionstcheck_boto_reqstTruet	__utils__t__name__(t
has_boto_reqs((s@/usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pyt__virtual__Lscc@s�x�|jd�j�D]v}|d}d|kr8qnxQ|dD]E}|jd|d�}	td�|	ddD��}	|d}
d	|	kr�tjd
|
�qCn|	jd	d�}|dk	r�||kr�qCntdd|d
|d|d|d|�}|r||fVqCn|j	d|
�}
i|
dd6|
dd6|	d6}tdd|d|d
|d|d|d|�||fVqCWqWdS(u�
    Private function that returns an iterator over all CloudFront distributions.
    The caller is responsible for all boto-related error handling.

    name
        (Optional) Only yield the distribution with the given name
    ulist_distributionsuDistributionListuItemstResourceuARNcs@s#|]}|d|dfVqdS(uKeyuValueN((t.0tkv((s@/usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pys	<genexpr>msuTagsuIduNameu+CloudFront distribution %s has no Name tag.u
cloudfronttsub_resourcetregiontkeytkeyidtprofiletIduDistributionudistributionuETaguetagutagstresource_idN(
t
get_paginatortpaginatetlist_tags_for_resourcetdicttlogtwarningtpoptNonet	_cache_idtget_distribution(tconntnameRRRRtdl_tdistribution_listtpartial_distttagstid_tdistribution_nametdistributiontdist_with_etag((s@/usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pyt_list_distributionsVsN


	
cC@s?tdd|d|d|d|d|�}|r;i|d6Std|d|d|d|�}ykxdt|d|d|d|d|d|�D]8\}}|d
k	r�d	}	i|	j|�d
6S|}q�WWn+tjjk
r�}
itd|
�d
6SX|sid
d6Stdd|d|d|d|d|d|�i|d6S(u

    Get information about a CloudFront distribution (configuration, tags) with a given name.

    name
        Name of the CloudFront distribution

    region
        Region to connect to

    key
        Secret key to use

    keyid
        Access key to use

    profile
        A dict with region, key, and keyid,
        or a pillar key (string) that contains such a dict.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudfront.get_distribution name=mydistribution profile=awsprofile

    u
cloudfrontRRRRRuresultR"u.More than one distribution found with name {0}uerroruboto3.get_errorRN(	Rt	_get_connR+Rtformattbotocoret
exceptionstClientErrorR	(R"RRRRR)R!t_tdisttmsgterr((s@/usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pyR �sF	!c

C@st�}td|d|d|d|�}y�x�t|d|d|d|d|�D]b\}}|dd}|d}	i|d6i|d	6i|	d6g}
i|
d
6|dj|�<qRWWntjjk
r�}|�nXtdd
�}td|dtd|�S(u 
    Get details of all CloudFront distributions.
    Produces results that can be used to create an SLS file.

    CLI Example:

    .. code-block:: bash

        salt-call boto_cloudfront.export_distributions --out=txt |            sed "s/local: //" > cloudfront_distributions.sls

    RRRRudistributionuDistributionConfigutagsunameuconfiguboto_cloudfront.presentu"Manage CloudFront distribution {0}uyaml.get_dumperuIndentedSafeOrderedDumperu	yaml.dumptdefault_flow_styletDumper(	RR,R+R-R.R/R0R	tFalse(
RRRRtresultsR!R"R)tconfigR&tdistribution_sls_dataR4tdumper((s@/usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pytexport_distributions�s.
	!



cC@s0|dkri}nd|kr?|d|kr?idd6Sn||d<igtj|�D] \}}i|d6|d6^q\d6}td|d|d	|d
|�}	yP|	jdi|d6|d
6�tdd|dtd|d|d	|d
|�Wn+tjj	k
r$}
it
d|
�d6SXitd6S(u�
    Create a CloudFront distribution with the given name, config, and (optionally) tags.

    name
        Name for the CloudFront distribution

    config
        Configuration for the distribution

    tags
        Tags to associate with the distribution

    region
        Region to connect to

    key
        Secret key to use

    keyid
        Access key to use

    profile
        A dict with region, key, and keyid,
        or a pillar key (string) that contains such a dict.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudfront.create_distribution name=mydistribution profile=awsprofile             config='{"Comment":"partial configuration","Enabled":true}'
    uNameu,Must not pass `Name` in `tags` but as `name`uerroruKeyuValueuItemsRRRRtDistributionConfigWithTagsuDistributionConfiguTagsu
cloudfrontRt
invalidateuboto3.get_erroruresultN(Rtsixt	iteritemsR,tcreate_distribution_with_tagsRRR.R/R0R	(R"R9R&RRRRtktvR!R4((s@/usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pytcreate_distributions2)	
:!	cC@st|d|d|d|d|�}d|kr4|S|d}|d}	|	d}
|d	}|d
}td|
|�}
|r�td||�}ntd|d|d|d|�}z,y�d|
ks�d
|
kr�|jd|d|	dd|�n|r�|	d}d
|krmigtj|d
�D] \}}i|d6|d6^q*d6}|jd|d|�nd|kr�it|dj��d6}|j	d|d|�q�nWn+t
jjk
r�}itd|�d6SXWdt
dd|dtd|d|d|d|�Xitd6S(u�
    Update the config (and optionally tags) for the CloudFront distribution with the given name.

    name
        Name of the CloudFront distribution

    config
        Configuration for the distribution

    tags
        Tags to associate with the distribution

    region
        Region to connect to

    key
        Secret key to use

    keyid
        Access key to use

    profile
        A dict with region, key, and keyid,
        or a pillar key (string) that contains such a dict.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudfront.update_distribution name=mydistribution profile=awsprofile             config='{"Comment":"partial configuration","Enabled":true}'
    RRRRuerroruresultudistributionuDistributionConfigutagsuetagudictdiffer.deep_diffuoldunewtDistributionConfigRuIdtIfMatchuARNuKeyuValueuItemsR
tTagstTagKeysuboto3.get_errorNu
cloudfrontRR>(R R	R,tupdate_distributionR?R@ttag_resourcetlisttkeystuntag_resourceR.R/R0RR(R"R9R&RRRRtdistribution_rettdist_with_tagstcurrent_distributiontcurrent_configtcurrent_tagstetagtconfig_difft	tags_diffR!tarnRBRCttags_to_addttags_to_removeR4((s@/usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pyRIcsd)	




!	


;	
	(t__doc__t
__future__RRRtloggingtsalt.ext.sixtextR?tsalt.utils.odictRtsalt.utils.versionsRtboto3R.t	getLoggertsetLeveltCRITICALRtHAS_BOTOtImportErrorR7R
RRRR+R R<RDRI(((s@/usr/lib/python2.7/site-packages/salt/modules/boto_cloudfront.pyt<module>1s>


	BK2G

Zerion Mini Shell 1.0