Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZddlZddlmZddl	m
Z
ddlmZde
fd��YZde
fd	��YZd
dd��YZdS(
i(tabsolute_importtdivisiontprint_functionN(t	to_native(t
AnsibleModule(t	fetch_urltUTMModuleConfigurationErrorcB`seZd�Zd�ZRS(cK`s/tt|�j||�||_||_dS(N(tsuperRt__init__tmsgtmodule_fail_args(tselfR	targs((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyR)s	cC`s |jd|jd|j�dS(NR	tother(t	fail_jsonR	R
(Rtmodule((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pytdo_fail.s(t__name__t
__module__RR(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyR's	t	UTMModulec
B`s;eZdZeeddddeedd�	Zd�ZRS(s�
    This is a helper class to construct any UTM Module. This will automatically add the utm host, port, token,
    protocol, validate_certs and state field to the module. If you want to implement your own sophos utm module
    just initialize this UTMModule class and define the Payload fields that are needed for your module.
    See the other modules like utm_aaa_group for example.
    cC`stdtdddtdi�dtdddt�dtdd	dd
�dtdddtdt�d
tdddtdddddg�dtdddtdt�dtdddddg��}tt|�j|j||�||||||||	|
�
dS(Ntheadersttypetdicttrequiredtdefaulttutm_hosttstrtutm_porttinti\t	utm_tokentno_logtutm_protocolthttpstchoicesthttptvalidate_certstbooltstatetpresenttabsent(RtFalsetTrueRRRt_merge_specs(Rt
argument_spect
bypass_checksRtcheck_invalid_argumentstmutually_exclusivetrequired_togethertrequired_one_oftadd_file_common_argstsupports_check_modetrequired_ift
default_specs((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyR:s'$cC`s|j�}|j|�|S(N(tcopytupdate(RR4tcustom_specstresult((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyR*Js
N(RRt__doc__R(tNoneRR*(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyR2s
	tUTMcB`s\eZed�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�ZRS(	c`s�|�_|�_|jjd�d|jjd�dt|jjd��d|d�_|�_d�jjd	<|jjd
��jjd<t�fd�|jj�D��r�t	d
t�j�dt|jj����ndS(s[
        Initialize UTM Class
        :param module: The Ansible module
        :param endpoint: The corresponding endpoint to the module
        :param change_relevant_keys: The keys of the object to check for changes
        :param info_only: When implementing an info module, set this to true. Will allow access to the info method only
        Rs://Rt:Rs
/api/objects/t/ttokenturl_usernameRturl_passwordc3`s|]}|�jkVqdS(N(tchange_relevant_keys(t.0telem(R(sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pys	<genexpr>ess	The keys s' to check are not in the modules keys:
N(
t	info_onlyRtparamstgetRtrequest_urlRAtalltkeysR(RRtendpointRARD((RsB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyRRs		O	%cC`s�yj|js_|jjjd�dkr4|j�qi|jjjd�dkri|j�qin
|j�Wn,tk
r�}|jjdt	|��nXdS(NR%R&R'R	(
RDRRERFt_addt_removet_infot	ExceptionRR(Rte((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pytexecuteks	
cC`s�|j|j|j�\}}|ddkrM|jjdtj|��n;|dkro|jjdt�n|jjd|dt�dS(s7
        returns the info for an object in utm
        tstatusi�R8tchangedN(	t
_lookup_entryRRGRtjsontloadsR:t	exit_jsonR((RtinfoR8((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyRMwsc	C`s�|j�}t}|j|j|j�\}}|ddkr_|jjdtj|��nn|jj|jj	�}|d
kr
t|j|jddd|d|�\}}|ddkr�|jjdtj|d	��nt}|j
tj|j���}n�|j|j|j|�r�t|j|j|d
ddd|d|�\}}|ddkr�|jjdtj|d	��nt}|j
tj|j���}n|jjd|d|�d
S(s6
        adds or updates a host object on utm
        RQi�R8tmethodtPOSTRtdataR	tbodyt_reftPUTRRN(t_combine_headersR(RSRRGRRTRUtjsonifyRER:RR)t
_clean_resulttreadt_is_object_changedRARV(Rtcombined_headerst
is_changedRWR8tdata_as_json_stringtresponse((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyRK�s.#! #!cC`sdidd6dd6}|jjjd�dk	rZ|j�}|j|jjjd��n|}|S(s�
        This will combine a header default with headers that come from the module declaration
        :return: A combined headers dict
        sapplication/jsontAcceptsContent-typeRN(RRERFR:R5R6(Rtdefault_headersR8((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyR^�sc
C`s�t}|j|j|j�\}}|dk	r�t|j|j|ddddidd6dd6d	|jj|jj��\}}|d
dkr�|jjdt	j
|d
��q�t}n|jjd|�dS(s,
        removes an object from utm
        R\RXtDELETERsapplication/jsonRgRHsX-Restd-Err-AckRZRQi�R	R[RRN(
R(RSRRGR:RR_RERRTRUR)RV(RRdRWR8Rf((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyRL�s !#	c	`s�t�|dddidd6�\}}d}|dk	rytj|j��}ttt�fd�|��d�}n||fS(so
        Lookup for existing entry
        :param module:
        :param request_url:
        :return:
        RXtGETRsapplication/jsonRgc`s|d�jjd�kS(Ntname(RERF(td(R(sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyt<lambda>�sN(RR:RTRURatnexttitertfilter(RRRGRfRWR8tresults((RsB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyRS�s(*cC`s<|d=|d=|d=|d=|d=|d=|d=|d=|S(	s�
        Will clean the result from irrelevant fields
        :param result: The result from the query
        :return: The modified result
        RRRRR#R?R@R%((RR8((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyR`�scC`s5x.|D]&}|jj|�||krtSqWtS(s�
        Check if my object is changed
        :param keys: The keys that will determine if an object is changed
        :param module: The module
        :param result: The result from the query
        :return:
        (RERFR)R((RRIRR8tkey((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyRb�s
(RRR(RRPRMRKR^RLRSR`Rb(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyR;Ps		
	 	
			((t
__future__RRRRt
__metaclass__RTtansible.module_utils._textRtansible.module_utils.basicRtansible.module_utils.urlsRRNRRR;(((sB/usr/lib/python2.7/site-packages/ansible/module_utils/utm_utils.pyt<module>s

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