Anons79 Mini Shell

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

�
�Udac@suddlZddlmZddlmZmZmZmZmZm	Z	m
Z
ddlmZm
Z
ddlmZdZdZdZd	Zd
ZdZdZd
Zidd6Zdfd��YZdfd��YZdfd��YZdefd��YZdefd��YZdefd��YZ defd��YZ!d�Z"d�Z#d �Z$d!�Z%d"�Z&dS(#i����N(tpartial(t
HTTPMethodt
equal_objectstFtdConfigurationErrortFtdServerErrortResponseParamstcopy_identity_propertiestFtdUnexpectedResponse(tOperationFieldtValidationError(t	iteritemsi
ii�s(Validation failed due to an invalid UUIDs)Validation failed due to a duplicate namesyMultiple objects matching specified filters are found. Please, define filters more precisely to match one object exactly.s^Cannot add a new object. An object with the same name but different parameters already exists.soCannot add a new object while executing an upsert request. Creation of objects with this type is not supported.tdefaulttobjIdtOperationNamePrefixcBs&eZdZdZdZdZdZRS(taddtedittgettdeletetupsert(t__name__t
__module__tADDtEDITtGETtDELETEtUPSERT(((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR
1s
tQueryParamscBseZdZRS(tfilter(RRtFILTER(((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR9st	ParamNamecBs eZdZdZdZdZRS(tquery_paramstpath_paramstdatatfilters(RRtQUERY_PARAMStPATH_PARAMStDATAtFILTERS(((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR=stCheckModeExceptioncBseZRS((RR(((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR&DstFtdInvalidOperationNameErrorcBseZd�ZRS(cCs#tt|�j|�||_dS(N(tsuperR't__init__toperation_name(tselfR*((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR)Is(RRR)(((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR'HstOperationCheckercBs�eZed��Zed��Zed��Zed��Zed��Zed��Zed��Z	ed��Z
RS(cCs|jtj�ot|�S(s�
        Check if operation defined with 'operation_name' is add object operation according to 'operation_spec'.

        :param operation_name: name of the operation being called by the user
        :type operation_name: str
        :param operation_spec: specification of the operation being called by the user
        :type operation_spec: dict
        :return: True if the called operation is add object operation, otherwise False
        :rtype: bool
        (t
startswithR
Rtis_post_request(tclsR*toperation_spec((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_add_operationPs
cCs|jtj�ot|�S(s�
        Check if operation defined with 'operation_name' is edit object operation according to 'operation_spec'.

        :param operation_name: name of the operation being called by the user
        :type operation_name: str
        :param operation_spec: specification of the operation being called by the user
        :type operation_spec: dict
        :return: True if the called operation is edit object operation, otherwise False
        :rtype: bool
        (R-R
Rtis_put_request(R/R*R0((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_edit_operation_s
cCs&|jtj�o%|tjtjkS(s�
        Check if operation defined with 'operation_name' is delete object operation according to 'operation_spec'.

        :param operation_name: name of the operation being called by the user
        :type operation_name: str
        :param operation_spec: specification of the operation being called by the user
        :type operation_spec: dict
        :return: True if the called operation is delete object operation, otherwise False
        :rtype: bool
        (R-R
RRtMETHODR(R/R*R0((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_delete_operationns
cCs!|tjtjko |tjS(s�
        Check if operation defined with 'operation_name' is get list of objects operation according to 'operation_spec'.

        :param operation_name: name of the operation being called by the user
        :type operation_name: str
        :param operation_spec: specification of the operation being called by the user
        :type operation_spec: dict
        :return: True if the called operation is get a list of objects operation, otherwise False
        :rtype: bool
        (RR4RRtRETURN_MULTIPLE_ITEMS(R/R*R0((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_get_list_operation~scCs"|tjtjko!|tjS(s�
        Check if operation defined with 'operation_name' is get objects operation according to 'operation_spec'.

        :param operation_name: name of the operation being called by the user
        :type operation_name: str
        :param operation_spec: specification of the operation being called by the user
        :type operation_spec: dict
        :return: True if the called operation is get object operation, otherwise False
        :rtype: bool
        (RR4RRR6(R/R*R0((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_get_operation�scCs|jtj�S(s]
        Check if operation defined with 'operation_name' is upsert objects operation according to 'operation_name'.

        :param operation_name: name of the operation being called by the user
        :type operation_name: str
        :return: True if the called operation is upsert object operation, otherwise False
        :rtype: bool
        (R-R
R(R/R*((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_upsert_operation�s
cCs2|j||�}|o1tj|ko1|tjS(s�
        Checks whether the called operation is 'find by filter'. This operation fetches all objects and finds
        the matching ones by the given filter. As filtering is done on the client side, this operation should be used
        only when selected filters are not implemented on the server side.

        :param operation_name: name of the operation being called by the user
        :type operation_name: str
        :param operation_spec: specification of the operation being called by the user
        :type operation_spec: dict
        :param params: params - params should contain 'filters'
        :return: True if the called operation is find by filter, otherwise False
        :rtype: bool
        (R7RR%(R/R*tparamsR0tis_get_list((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_find_by_filter_operation�scsTt�fd�t|�D�d�}t�fd�t|�D�d�}|oS|S(sc
        Checks if all operations required for upsert object operation are defined in 'operations'.

        :param operations: specification of the operations supported by model
        :type operations: dict
        :return: True if all criteria required to provide requested called operation are satisfied, otherwise False
        :rtype: bool
        c3s-|]#\}}�j||�r|VqdS(N(R3(t.0tnametspec(R/(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pys	<genexpr>�sc3s-|]#\}}�j||�r|VqdS(N(R7(R=R>R?(R/(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pys	<genexpr>�s	N(tnextR
tNone(R/t
operationsthas_edit_opthas_get_list_op((R/sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_upsert_operation_supported�s
%	(RRtclassmethodR1R3R5R7R8R9R<RE(((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR,NstBaseConfigurationResourcecBs�eZed�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zdddd�Zd�Zed��Zd�Zd�Zd�ZRS(cCs:||_t|_i|_i|_||_t|_dS(N(t_conntFalsetconfig_changedt_operation_spec_cachet_models_operations_specs_cachet_check_modeR,t_operation_checker(R+tconnt
check_mode((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR)�s					cCs6|jj|�r"|j||�S|j||�SdS(s�
        Allow user request execution of simple operations(natively supported by API provider) as well as complex
        operations(operations that are implemented as a set of simple operations).

        :param op_name: name of the operation being called by the user
        :type op_name: str
        :param params: definition of the params that operation should be executed with
        :type params: dict
        :return: Result of the operation being executed
        :rtype: dict
        N(RNR9t
upsert_objecttcrud_operation(R+top_nameR:((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytexecute_operation�scCs�|j|�}|dkr*t|��n|jj||�rT|j||�}n�|jj||�r~|j||�}no|jj||�r�|j	||�}nE|jj
|||�r�t|j||��}n|j
||�}|S(s�
        Allow user request execution of simple operations(natively supported by API provider) only.

        :param op_name: name of the operation being called by the user
        :type op_name: str
        :param params: definition of the params that operation should be executed with
        :type params: dict
        :return: Result of the operation being executed
        :rtype: dict
        N(tget_operation_specRAR'RNR1t
add_objectR3tedit_objectR5t
delete_objectR<tlisttget_objects_by_filtertsend_general_request(R+RSR:top_spectresp((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRR�scCs6||jkr+|jj|�|j|<n|j|S(N(RKRHRU(R+R*((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRUscCsl||jkra|jj|�}||j|<x0t|�D]\}}|jj||�q;Wn|j|S(N(RLRHt!get_operation_specs_by_model_nameR
RKt
setdefault(R+t
model_nametmodel_op_specsRSR\((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR^s
cs�d��t|�\}}}it|�tj6t|�tj6}|jtj�pYi�tj|tjkr�d�kr�d�d|tjtj<nt	t
|jd|�|�}��fd�|D�S(NcSsAx:t|�D],\}}||ks5|||kr
tSq
WtS(N(R
RItTrue(t
filter_paramstobjtktv((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyt
match_filterssR>sname:%sR*c3s$|]}��|�r|VqdS(N((R=ti(R!Rg(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pys	<genexpr>!s(t_get_user_paramstdictRR"R#RR%RRtiterate_over_pageable_resourceRR[(R+R*R:tdummyRRt
url_paramstitem_generator((R!RgsR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRZ
s	&"cCs\d�}y|j||�SWn8tk
rW}||�rN|j|||�S|�nXdS(NcSs|jtkott|�kS(N(tcodetUNPROCESSABLE_ENTITY_STATUStDUPLICATE_NAME_ERROR_MESSAGEtstr(terr((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_duplicate_name_error$s(R[Rt$_check_equality_with_existing_object(R+R*R:Rtte((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRV#s	cCsj|j|�tj}|j||�}|dk	r`t||tj�rN|Stt	|��n|�dS(s�
        Looks for an existing object that caused "object duplicate" error and
        checks whether it corresponds to the one specified in `params`.

        In case a single object is found and it is equal to one we are trying
        to create, the existing object is returned.

        When the existing object is not equal to the object being created or
        several objects are returned, an exception is raised.
        N(
RURt
MODEL_NAMEt_find_object_matching_paramsRARRR$RtDUPLICATE_ERROR(R+R*R:RvR`texisting_obj((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRu/scCs�|j|�}|sdS|tj}|jtj�sSi|dd6|tj<nd}|j||�}x;t|�D]-\}}|dkr�tt	��n|}qxW|S(NR>i(
t_find_get_list_operationRARR$RR%RZt	enumerateRtMULTIPLE_DUPLICATES_FOUND_ERROR(R+R`R:tget_list_operationR Rdt
filtered_objsRh((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRxEs

cs8�j|�pi}t�fd�|j�D�d�S(Nc3s0|]&\}}�jj||�r|VqdS(N(RNR7(R=topR\(R+(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pys	<genexpr>[s	(R^R@titemsRA(R+R`RB((R+sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR{Xscs8�j|�pi}t�fd�|j�D�d�S(Nc3s0|]&\}}�jj||�r|VqdS(N(RNR8(R=R�R\(R+(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pys	<genexpr>as	(R^R@R�RA(R+R`RB((R+sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyt_find_get_operation^scCsTd�}y|j||�SWn0tk
rO}||�rFidd6S|�nXdS(NcSs|jtkott|�kS(N(RoRptINVALID_UUID_ERROR_MESSAGERr(Rs((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytis_invalid_uuid_erroress Referenced object does not existtstatus(R[R(R+R*R:R�Rv((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRXds	c	Cs�t|�\}}}|j|�tj}|j|�}|r�|j|i|tj6�}|sqtd��q�t	||�r�|Sn|j||�S(Ns Referenced object does not exist(
RiRURRwR�R[RR#RR(	R+R*R:R RlRR`t
get_operationtexisting_object((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRWpsc
s~�fd�}�j||�|�t|�\}}}�j|�}|tj|tj}}	�j||	|||�S(Ncs�jrt��ndS(N(RMR&((R+(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytstop_if_check_mode�s	(tvalidate_paramsRiRURtURLR4t
_send_request(
R+R*R:R�R RRR\turltmethod((R+sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR[scCsfd�}|jjd|d|d|d|d|�}||�|tjkr[t|_n|tjS(NcSs1|tjs-t|tj|tj��ndS(N(RtSUCCESSRtRESPONSEtSTATUS_CODE(R]((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytraise_for_failure�s
turl_paththttp_methodtbody_paramsRR(RHtsend_requestRRRbRJRR�(R+R�R�R�RRR�tresponse((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR��s	
cs�i�|j��}t|�\}}}��fd�}||jjtj|�||jjtj|�t|�s�t	|�r�||jj
tj|�n�r�t���ndS(Ncs`d|}y,|�|�\}}|s5|�|<nWn#tk
r[}t|��|<nX�S(NsInvalid %s provided(t	ExceptionRr(tvalidation_methodt
field_nametuser_paramstkeytis_validtvalidation_reportRv(R*treport(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytvalidate�s
(
RURiRHtvalidate_query_paramsRR"tvalidate_path_paramsR#R.R2t
validate_dataR$R	(R+R*R:R\R RRR�((R*R�sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR��s
cs#t�fd�t|�D�d�S(Nc3s*|] \}}�||�r|VqdS(N((R=RSR\(tchecker(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pys	<genexpr>�s(R@R
RA(R�RB((R�sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyt_get_operation_name�scCs=|j|jj|�}|s-tt��n|j||�S(N(R�RNR1Rt!ADD_OPERATION_NOT_SUPPORTED_ERRORRV(R+tmodel_operationsR:tadd_op_name((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyt_add_upserted_object�scCsk|j|jj|�}t|di�t|di�|d|dd<t||d�|j||�S(NRR tidR(R�RNR3t_set_defaultRRW(R+R�R�R:tedit_op_name((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyt_edit_upserted_object�scs���fd�}|�}�j|�}�jj|�sKt���n�j||�}|r�t||tj�}|r�|S�j|||�S�j	||�SdS(s�
        Updates an object if it already exists, or tries to create a new one if there is no
        such object. If multiple objects match filter criteria, or add operation is not supported,
        the exception is raised.

        :param op_name: upsert operation name
        :type op_name: str
        :param params: params that upsert operation should be executed with
        :type params: dict
        :return: upserted object representation
        :rtype: dict
        cs8�ttj�}�jj|�s4t���n|S(N(tlenR
RRHtget_model_specR'(tmodel(RSR+(sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pytextract_and_validate_model�sN(
R^RNRER'RxRRR$R�R�(R+RSR:R�R`R�Rztequal_to_existing_obj((RSR+sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRQ�s	
N(RRRIR)RTRRRUR^RZRVRuRxR{R�RXRWR[RAR�R�tstaticmethodR�R�R�RQ(((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRG�s(																	cCs-||ks||dkr)|||<ndS(N(RA(R:R�tvalue((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR��scCs|tjtjkS(N(RR4RtPOST(R0((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR.�scCs|tjtjkS(N(RR4RtPUT(R0((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyR2�scCsC|jtj�pi|jtj�p*i|jtj�p?ifS(N(RRR$R"R#(R:((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRi�s0ccs�tj|�}|tjjdt�|tjjdt�t|tjd�}d�}x�tr�|d|�}x|dD]}|Vq�W|t	|d�|�r�Pntj|�}|tj}t|d�||d<q`WdS(s
    A generator function that iterates over a resource that supports pagination and lazily returns present items
    one by one.

    :param resource_func: function that receives `params` argument and returns a page of objects
    :type resource_func: callable
    :param params: initial dictionary of parameters that will be passed to the resource_func.
                   Should contain `query_params` inside.
    :type params: dict
    :return: an iterator containing returned items
    :rtype: iterator of dict
    tlimittoffsetcSs<||krtS||kr tStdj||���dS(Ns�Get List of Objects Response from the server contains more objects than requested. There are {0} item(s) in the response while {1} was(ere) requested(RIRbRtformat(titems_in_responsetitems_expected((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyt"received_less_items_than_requestedsR:R�N(
tcopytdeepcopyRR"R_tDEFAULT_PAGE_SIZEtDEFAULT_OFFSETtintRbR�(t
resource_funcR:R�R�tresulttitemR((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyRk�s			
('R�t	functoolsRt'ansible.module_utils.network.ftd.commonRRRRRRRt3ansible.module_utils.network.ftd.fdm_swagger_clientRR	tansible.module_utils.sixR
R�R�RpR�RqR}RyR�tPATH_PARAMS_FOR_DEFAULT_OBJR
RRR�R&R'tobjectR,RGR�R.R2RiRk(((sR/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/configuration.pyt<module>s44
|�				

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