Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyo

�
�Udac@sfyddlZeZWnek
r/eZnXyBddlZddlZddlm	Z	ddl
mZeZWnek
r�eZnXddl
mZmZddlmZddlmZmZddlZddlZddlZdd�Zdefd	��YZd
�Zd�Zdefd
��YZdefd��YZ defd��YZ!dS(i����N(tservice_account(tAuthorizedSession(t
AnsibleModuletenv_fallback(tstring_types(tto_textt	to_nativecCsV|s
dS|d}|d}||kr.|S||}|rNt|||�S|SdS(Nii(tNonet
navigate_hash(tsourcetpathtdefaulttkeytresult((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRs


tGcpRequestExceptioncBseZRS((t__name__t
__module__(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR*scCs`i}xI|D]A}||}|dk	r
|ikr
|gkr
|||<q
q
W|s\dS|S(N(R(tobjtnew_objRtvalue((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pytremove_nones_from_dict.s

$cCs[t|t�r@g}x$|D]}|jt||��qW|S|sJ|S|j|�SdS(N(t
isinstancetlisttappendtreplace_resource_dicttget(titemRtitemsti((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR<s
t
GcpSessioncBs�eZd�Zdd�Zddd�Zddd�Zdd�Zdd�Zdd�Z	dddd	�Z
dd
�Zddd�Zdd�Z
dd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs ||_||_|j�dS(N(tmoduletproductt	_validate(tselfRR((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyt__init__Ks		cKs$|ji|d6�|j||�S(sD
        This method should be avoided in favor of full_get
        tjson(tupdatetfull_get(R!turltbodytkwargs((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRPscKs+|ji|d6|d6�|j||�S(sE
        This method should be avoided in favor of full_post
        R#theaders(R$t	full_post(R!R&R'R)R(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pytpostWscKs+|ji|d6|d6�|j||�S(sE
        This method should be avoided in favor of full_post
        tdataR)(R$R*(R!R&t
file_contentsR)R(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyt
post_contents^scCsi|d6}|j||�S(sG
        This method should be avoided in favor of full_delete
        R#(tfull_delete(R!R&R'R(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pytdeletees
cCsi|d6}|j||�S(sD
        This method should be avoided in favor of full_put
        R#(tfull_put(R!R&R'R(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pytputls
cKs$|ji|d6�|j||�S(sF
        This method should be avoided in favor of full_patch
        R#(R$t
full_patch(R!R&R'R(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pytpatchssRt
nextPageTokenc	Ks�||j|j|||��}|j|�r?|j|�ng}x�|j|�r�|rs|j|�|d<ni||d6}||j|j|||��}|j|�rH||j|�}qHqHW|S(s|
        This should be used for calling the GCP list APIs. It will return
        an array of items

        This takes a callback to a `return_if_object(module, response)`
        function that will decode the response + return a dictionary. Some
        modules handle the decode + error processing differently, so we should
        defer to the module to handle this.
        t	pageToken(RR%R(	R!R&tcallbacktparamst
array_nameR6R(trespR((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRzs!$!cKsx|j|jd��|d<y |j�j|d||�SWn5ttjd�k
rs}|jjd|j�nXdS(NR)R8tRequestExceptiontmsg(	t_set_headersRtsessiontgetattrtrequestst
exceptionsRt	fail_jsontmessage(R!R&R8R(tinst((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR%�s
 cKs~|j|jd��|d<y&|j�j|d|d||�SWn5ttjd�k
ry}|jjd|j	�nXdS(NR)R,R#R;R<(
R=RR>R+R?R@RARRBRC(R!R&R,R#R(RD((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR*�s
&cKsx|j|jd��|d<y |j�j|d||�SWn5ttjd�k
rs}|jjd|j	�nXdS(NR)R,R;R<(
R=RR>R2R?R@RARRBRC(R!R&R,R(RD((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR1�s
 cKsx|j|jd��|d<y |j�j|d||�SWn5ttjd�k
rs}|jjd|j	�nXdS(NR)R,R;R<(
R=RR>R4R?R@RARRBRC(R!R&R,R(RD((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR3�s
 cKsr|j|jd��|d<y|j�j||�SWn5ttjd�k
rm}|jjd|j	�nXdS(NR)R;R<(
R=RR>R0R?R@RARRBRC(R!R&R(RD((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR/�s
cCs*|r|j||j��S|j�SdS(N(t_merge_dictionariest_headers(R!R)((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR=�scCst|j��S(N(Rt_credentials(R!((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR>�scCs�ts|jjdd�nts8|jjdd�n|jjjd�dk	r|jjddkr|jjdd�n|jjjd�dk	s�|jjjd	�dk	r�|jjdd
kr�|jjdd�ndS(NR<s#Please install the requests librarys&Please install the google-auth librarytservice_account_emailt	auth_kindtmachineaccountsJService Account Email only works with Machine Account-based authenticationtservice_account_filetservice_account_contentstserviceaccountsIService Account File only works with Service Account-based authentication(tHAS_REQUESTSRRBtHAS_GOOGLE_LIBRARIESR8RR(R!((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR �s1
1cCs�|jjd}|dkrEtjjd|jjd�\}}|S|dkr�|jjjd�r�tjjtjj	|jjd��}t
jj|�j
|jjd�S|dkrF|jjjd�rFy"tj|jjjd��}Wn,tjjk
r"}|jjdd�nXt
jj|�j
|jjd�S|d	krotjjj|jjd
�S|jjdd|�dS(NRItapplicationtscopesRMRKRLR<s1Unable to decode service_account_contents as JSONRJRHs$Credential type '%s' not implemented(RR8tgoogletauthRRtosR
trealpatht
expanduserRtCredentialstfrom_service_account_filetwith_scopesR#tloadstdecodertJSONDecodeErrorRBtfrom_service_account_infotcompute_engine(R!t	cred_typetcredentialst
project_idR
tcredte((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRG�s$%!(#!"#cCsY|jjjd�r>idj|j|jjjd��d6Sidj|j�d6SdS(Ntenv_typesGoogle-Ansible-MM-{0}-{1}s
User-AgentsGoogle-Ansible-MM-{0}(RR8RtformatR(R!((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRF�s
&cCs|j�}|j|�|S(N(tcopyR$(R!tatbtnew((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRE�s
N(RRR"RRR+R.R0R2R4RR%R*R1R3R/R=R>R RGRFRE(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRJs(							
t	GcpModulecBs#eZd�Zd�Zd�ZRS(cOs�i}d|kr|d}n|j|tdtdtdddtdgf�dtdtdtd	gfd
ddd
gdd�dtdtdtdgfdd�dtdtdtdgfdd�dtdtdtdgfdtdd�dtdtdtdgfdd�dtdtdtdgfdd���|d<g}d|krh|d}n|jdddg�|d<tj|||�dS(Nt
argument_spectprojecttrequiredttypetstrtfallbacktGCP_PROJECTRIt
GCP_AUTH_KINDtchoicesRJRMRPRHtGCP_SERVICE_ACCOUNT_EMAILRKtGCP_SERVICE_ACCOUNT_FILER
RLtGCP_SERVICE_ACCOUNT_CONTENTStno_logtjsonargRQt
GCP_SCOPESRRdtGCP_ENV_TYPEtmutually_exclusive(REtdicttFalseRtTrueRRR"(R!targsR(targ_spectmutual((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR"�sT
					
cCsNy|j�Wn9ttjd�k
rI}|jdd|j��nXdS(NR;R<sGCP returned error: %s(traise_for_statusR?R@RARBR#(R!tresponseRD((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR�1scCs|j�}|j|�|S(N(RfR$(R!RgRhRi((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRE7s
(RRR"R�RE(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyRj�s	3	t
GcpRequestcBsYeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	cCs
||_dS(N(trequest(R!R�((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR"HscCs|j|�S(N(t
difference(R!tother((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyt__eq__KscCs|j|�S(N(R�(R!R�((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyt__ne__NscCs|j|j|j�S(N(t_compare_valueR�(R!R�((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR�TscCs�i}xH|D]@}|j|�r
|j|j|�|j|��||<q
q
Wi}x)|D]!}||r^||||<q^q^W|S(N(RR�(R!treq_dictt	resp_dictR�Rtsanitized_difference((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyt_compare_dictsWs
/

cCs�g}|j|�}|j|�}xV|D]N}t}x)|D]!}|j||�s>t}q>q>W|s+|j|�q+q+Wg}	x$|D]}
|
r�|	j|
�q�q�W|	S(N(t_convert_valueR}R�R~R(R!treq_listt	resp_listR�tnew_req_listt
new_resp_listtreq_itemt
found_itemt	resp_itemtdifference2R((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyt_compare_listsgs



cCs�d}|sdSy�t|t�r7|j||�}nit|t�r[|j||�}nEt|t�r|j||�}n!t|�t|�kr�|}nWnt	k
r�nX|S(N(
RRRR�R|R�tboolt_compare_booleanRtUnicodeError(R!t	req_valuet
resp_valuetdiff((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR��s

cCs�y�|r"t|t�r"|r"dS|r>t|�dkr>dS|r_t|t�r_|r_dS|r|t|�dkr|dS|SWntk
r�dSXdS(Nttruetfalse(RR�RRR�(R!R�R�((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR��s
cCs�t|t�r@g}x$|D]}|j|j|��qW|St|t�r�i}x%|D]}|j||�||<q\W|St|�SdS(N(RRRR�R|R(R!Rtnew_listRtnew_dictR((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR��s

(RRR"R�R�R�R�R�R�R�R�(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyR�Gs								("R@R~RNtImportErrorR}tgoogle.authRRtgoogle.auth.compute_enginet
google.oauth2Rtgoogle.auth.transport.requestsRROtansible.module_utils.basicRRtansible.module_utils.sixRtansible.module_utils._textRRtastRTR#RRt	ExceptionRRRtobjectRRjR�(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/gcp_utils.pyt<module>s2





		�J

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]