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/fdm_swagger_client.pyc

�
�Udac@sddlmZddlmZmZmZdZdZdZddd��YZ	ddd	��YZ
d
dd��YZddd
��YZdd d��YZ
dd!d��YZd�Zdefd��YZdefd��YZdd"d��YZdd#d��YZdS($i����(t
HTTPMethod(t
integer_typeststring_typest	iteritemst_Filet200tdeletetOperationFieldcBs2eZdZdZdZdZdZdZdZRS(turltmethodt
parameterst	modelNametdescriptiontreturnMultipleItemsttags(	t__name__t
__module__tURLtMETHODt
PARAMETERSt
MODEL_NAMEtDESCRIPTIONtRETURN_MULTIPLE_ITEMStTAGS(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRstSpecPropcBs eZdZdZdZdZRS(tdefinitionst
operationstmodelstmodel_operations(RRtDEFINITIONSt
OPERATIONStMODELStMODEL_OPERATIONS(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR%stPropNamecBsbeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZRS(tenumttypetrequiredtinvalid_types$reftallOftbasePathtpathstoperationIdtschematitemst
propertiest	responsestnameR(RRtENUMtTYPEtREQUIREDtINVALID_TYPEtREFtALL_OFt	BASE_PATHtPATHStOPERATION_IDtSCHEMAtITEMSt
PROPERTIESt	RESPONSEStNAMER(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR!,stPropTypecBs2eZdZdZdZdZdZdZdZRS(tstringtbooleantintegertnumbertobjecttarraytfile(	RRtSTRINGtBOOLEANtINTEGERtNUMBERtOBJECTtARRAYtFILE(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR=>stOperationParamscBseZdZdZRS(tpathtquery(RRtPATHtQUERY(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRLHstQueryParamscBseZdZRS(tfilter(RRtFILTER(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRQMscCs!|jd�}|t|�dS(Nt/i(tsplittlen(t
schema_refRM((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyt_get_model_name_from_urlQstIllegalArgumentExceptioncBseZdZRS(s}
    Exception raised when the function parameters:
        - not all passed
        - empty string
        - wrong type
    (RRt__doc__(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRYVstValidationErrorcBseZRS((RR(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR[`stFdmSwaggerParsercBs�eZdZdZdd�Zed��Zd�Zd�Z	d�Z
d�Zd�Ze
d��Zd�Zd	�Ze
d
��Zd�Zd�Ze
d
��Zd�ZRS(cCs�|tj|_|tj|_|j|�}|rb|j||�}|j|j|�|_ni|jtj	6|tj
6|j|�tj6S(sj

        This method simplifies a swagger format, resolves a model name for each operation, and adds documentation for
        each operation and model if it is provided.

        :param spec: An API specification in the swagger format, see
            <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md>
        :type spec: dict
        :param spec: A documentation map containing descriptions for models, operations and operation parameters.
        :type docs: dict
        :rtype: dict
        :return:
        Ex.
            The models field contains model definition from swagger see
            <#https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#definitions>
            {
                'models':{
                    'model_name':{...},
                    ...
                },
                'operations':{
                    'operation_name':{
                        'method': 'get', #post, put, delete
                        'url': '/api/fdm/v2/object/networks', #url already contains a value from `basePath`
                        'modelName': 'NetworkObject', # it is a link to the model from 'models'
                                                      # None - for a delete operation or we don't have information
                                                      # '_File' - if an endpoint works with files
                        'returnMultipleItems': False, # shows if the operation returns a single item or an item list
                        'parameters': {
                            'path':{
                                'param_name':{
                                    'type': 'string'#integer, boolean, number
                                    'required' True #False
                                }
                                ...
                                },
                            'query':{
                                'param_name':{
                                    'type': 'string'#integer, boolean, number
                                    'required' True #False
                                }
                                ...
                            }
                        }
                    },
                    ...
                },
                'model_operations':{
                    'model_name':{ # a list of operations available for the current model
                        'operation_name':{
                            ... # the same as in the operations section
                        },
                        ...
                    },
                    ...
                }
            }
        (
RRt_definitionsR!R5t
_base_patht_get_operationst_enrich_operations_with_docst_enrich_definitions_with_docsRRt_get_model_operationsR (tselftspectdocsR((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyt
parse_spechs:

cCs|jS(N(R^(Rc((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyt	base_path�scCsJi}x=t|�D]/\}}|tj}||j|i�|<qW|S(N(RRRt
setdefault(RcRRtoperations_nametparamst
model_name((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRb�s

c
Cs�|tj}i}x�t|�D]�\}}x�t|�D]�\}}i|tj6|j|tj6|j||�tj6|j	|�tj
6|jtjg�tj6}tj
|kr�|j|tj
�|tj
<n|tj}	|||	<q9Wq W|S(N(R!R6RRRR^Rt_get_model_nameRt_return_multiple_itemsRtgetRRt_get_rest_paramsR7(
RcRdt
paths_dicttoperations_dictRtoperation_paramsR	Rjt	operationtoperation_id((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR_�s

 
c	s��fd�}x�|j�D]�}||�}|jtjd�|tj<tj|krtd�|jtji�D��}xA|tjtjj	�D]%\}}|j|d�|tj<q�WxD|tjtj
j	�D]%\}}|j|d�|tj<q�WqqW|S(NcsD|tjt�j�}�tjj|i�j|tji�S(N(RRRVR^R!R6RnR(toptop_url(ReRc(sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pytget_operation_docs�stcss)|]}|tj|tjfVqdS(N(R!R<R(t.0tp((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pys	<genexpr>�s(tvaluesRnR!RRRtdictRLROR+RP(	RcRReRwRstoperation_docstparam_descriptionst
param_nametparams_spec((ReRcsW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR`�s''$cCs�x�|j�D]�\}}|tjj|i�}|jtjd�|tj<xs|jtji�j�D]V\}}|jtji�j|d�|tj<||jtjg�k|tj<qjWq
W|S(NRx(R+RRRnR!RR:R1(RcRReRkt	model_deft
model_docst	prop_namet	prop_spec((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRa�s((*cCsk|tjkr|j|�S|tjks:|tjkrG|j|�S|tjkrc|j|�SdSdS(N(	RtGETt_get_model_name_from_responsestPOSTtPUTt%_get_model_name_for_post_put_requeststDELETEt%_get_model_name_from_delete_operationtNone(RcR	Rj((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRl�s


cCsIy0|tjttj}tj|tjkSWntk
rDtSXdS(s�
        Defines if the operation returns one item or a list of items.

        :param op_params: operation specification
        :return: True if the operation returns a list of items, otherwise False
        N(R!R;tSUCCESS_RESPONSE_CODER8R9R:tKeyErrortFalse(t	op_paramsR*((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRm�s

cCsF|tj}|jt�rB|tt�}||jkrB|SndS(N(R!R7t
startswitht
DELETE_PREFIXRVR]R�(RcRjRtRk((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�s
cCs|d}tj|krZ|j|tj�}|rZ|tjtj}|j|�}qZn|dkrx|j|�}n|S(N(	R�RRt_get_body_param_from_parametersR!R8R3t_get_model_name_byschema_refR�(RcRjRktbody_param_dictRW((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�scCstd�|D�d�S(Ncss%|]}|ddkr|VqdS(tintbodyN((Rytparam((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pys	<genexpr>s(tnextR�(Rj((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�scCs�|tj}t|kr�|ttj}tj|krM|j|tj�Stj|kr�|tjtjtjtj}|j|�Stj|kr�|tjt	j
kr�tSndSdS(N(
R!R;R�R8R3R�R:R9R0R=RKtFILE_MODEL_NAMER�(RcRjR-tresponsetref((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�s
"
%cCs�i}i}i|tj6|tj6}xp|D]h}|d}|tjkri|j|�||tj<q-|tjkr-|j|�||tj<q-q-W|S(NR�(RLRORPt_simplify_param_defR!R<(RcRjRMRNtoperation_paramR�tin_param((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyRo+s



!cCs&i|tjtj6|tjtj6S(N(R!R0R1(R�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�:scCsOt|�}|j|}tj|krG|j|tjdtj�S|SdS(Ni(RXR]R!R4R�R3(RcRWRkR�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�As

N(RRR�R]R^RftpropertyRgRbR_R`RaRltstaticmethodRmR�R�R�R�RoR�R�(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR\ds"H						
				tFdmSwaggerValidatorcBseZd�Zdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zeed��Zed��Zed��Zed��Zeddd��Zed��ZRS(cCs$|tj|_|tj|_dS(sa
        :param spec: dict
                    data from FdmSwaggerParser().parse_spec()
        N(RRt_operationsRt_models(RcRd((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyt__init__KscCs�|dkri}n|j||�|j|}|j|tj}|j�}|j|||d�t|t	j
�dks�t|t	j�dkr�t|j
|�fStdfS(s�
        Validate data for the post|put requests
        :param operation_name: string
                            The value must be non empty string.
                            The operation name is used to get a model specification
        :param data: dict
                    The value must be in the format that the model(from operation) expects
        :rtype: (bool, string|dict)
        :return:
            (True, None) - if data valid
            Invalid:
            (False, {
                'required': [ #list of the fields that are required but were not present in the data
                    'field_name',
                    'patent.field_name',# when the nested field is omitted
                    'patent.list[2].field_name' # if data is array and one of the field is omitted
                ],
                'invalid_type':[ #list of the fields with invalid data
                        {
                           'path': 'objId', #field name or path to the field. Ex. objects[3].id, parent.name
                           'expected_type': 'string',# expected type. Ex. 'object', 'array', 'string', 'integer',
                                                     # 'boolean', 'number'
                           'actually_value': 1 # the value that user passed
                       }
                ]
            })
        :raises IllegalArgumentException
            'The operation_name parameter must be a non-empty string' if operation_name is not valid
            'The data parameter must be a dict' if data neither dict or None
            '{operation_name} operation does not support' if the spec does not contain the operation
        RxiN(R�t_check_validate_data_paramsR�R�RRt_init_reportt_validate_objectRVR!R1R2R�t_delete_empty_field_from_reporttTrue(Rctoperation_nametdataRstmodeltstatus((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyt
validate_dataSs 	
2cCso|st|t�r&td��nt|t�sDtd��n||jkrktdj|���ndS(Ns7The operation_name parameter must be a non-empty strings!The data parameter must be a dicts{0} operation does not support(t
isinstanceRRYR|R�tformat(RcR�R�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR��scCs|j||dtj�S(s�
           Validate params for the get requests. Use this method for validating the query part of the url.
           :param operation_name: string
                               The value must be non empty string.
                               The operation name is used to get a params specification
           :param params: dict
                        should be in the format that the specification(from operation) expects
                    Ex.
                    {
                        'objId': "string_value",
                        'p_integer': 1,
                        'p_boolean': True,
                        'p_number': 2.3
                    }
           :rtype:(Boolean, msg)
           :return:
               (True, None) - if params valid
               Invalid:
               (False, {
                   'required': [ #list of the fields that are required but are not present in the params
                       'field_name'
                   ],
                   'invalid_type':[ #list of the fields with invalid data and expected type of the params
                            {
                              'path': 'objId', #field name
                              'expected_type': 'string',#expected type. Ex. 'string', 'integer', 'boolean', 'number'
                              'actually_value': 1 # the value that user passed
                            }
                   ]
               })
            :raises IllegalArgumentException
               'The operation_name parameter must be a non-empty string' if operation_name is not valid
               'The params parameter must be a dict' if params neither dict or None
               '{operation_name} operation does not support' if the spec does not contain the operation
           tresource(t_validate_url_paramsRLRP(RcR�Rj((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pytvalidate_query_params�s$cCs|j||dtj�S(s�
        Validate params for the get requests. Use this method for validating the path part of the url.
           :param operation_name: string
                               The value must be non empty string.
                               The operation name is used to get a params specification
           :param params: dict
                        should be in the format that the specification(from operation) expects

                 Ex.
                 {
                     'objId': "string_value",
                     'p_integer': 1,
                     'p_boolean': True,
                     'p_number': 2.3
                 }
        :rtype:(Boolean, msg)
        :return:
            (True, None) - if params valid
            Invalid:
            (False, {
                'required': [ #list of the fields that are required but are not present in the params
                    'field_name'
                ],
                'invalid_type':[ #list of the fields with invalid data and expected type of the params
                         {
                           'path': 'objId', #field name
                           'expected_type': 'string',#expected type. Ex. 'string', 'integer', 'boolean', 'number'
                           'actually_value': 1 # the value that user passed
                         }
                ]
            })
        :raises IllegalArgumentException
            'The operation_name parameter must be a non-empty string' if operation_name is not valid
            'The params parameter must be a dict' if params neither dict or None
            '{operation_name} operation does not support' if the spec does not contain the operation
        R�(R�RLRO(RcR�Rj((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pytvalidate_path_params�s%cCs�|dkri}n|j||�|j|}tj|kr�||tjkr�|tj|}|j�}|j|||�t|tj	�dks�t|tj
�dkr�t|j|�fSt
dfSt
dfSdS(Ni(R�t_check_validate_url_paramsR�RRR�t_check_url_paramsRVR!R1R2R�R�R�(RcRsRjR�RdR�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR��s	
"2
cCso|st|t�r&td��nt|t�sDtd��n||jkrktdj|���ndS(Ns7The operation_name parameter must be a non-empty strings#The params parameter must be a dicts{0} operation does not support(R�RRYR|R�R�(RcRsRj((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR��sc	Cs�x�|j�D]�}||}|tjrP||krP|tjj|�q
n||kr
|tj}||}||kr�|j||dt�r�|j|d|||�q�q
q
WdS(Nt
allow_nullRx(tkeysR!R1tappendR0t_is_correct_simple_typesR�t_add_invalid_type_report(RcR�RdRjR�tpropt
expected_typetvalue((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR��s


%cCsT|j|�r(|j||||�n(|j|�rP|j||||�ndS(N(t_is_enumt_check_enumt
_is_objectt
_check_object(RcR�R�R�RM((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR��scCs|j|�otj|kS(N(t_is_string_typeR!R/(RcR�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�scCsB|dk	r>||tjkr>|j||dtj|�ndS(NRx(R�R!R/R�(RcR�R�R�RM((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�scCs9|tjji|j||�d6|d6|d6�dS(NRMR�tactually_value(R!R2R�t_create_path_to_field(RcR�RMR�R�R�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�
sc
Cs�|dkrdSt|t�s?|j||dtj|�dStj|krn|j||tj||�n|tj	}x`|j
�D]R}||kr�||}|tj}||}	|j||	||||�q�q�WdS(NRx(
R�R�R|R�R=RIR!R1t_check_required_fieldsR:R�R0t_check_types(
RcR�R�R�RMtmodel_propertiesR�tmodel_prop_valR�R�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�s 



cCs�|tjkrF|j|�}|j|||d|j||��ne|tjkr}|j|||d|j||��n.|j||�s�|j|||||�ndS(NRM(	R=RIt_get_model_by_refR�R�RJt_check_arrayR�R�(RcR�R�R�R�RMR�t	ref_model((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�$scCst|tj�}|j|S(N(RXR!R3R�(RcR�R�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�0scCssg|D]:}||j�ks/||dkr|j||�^q}t|�dkro|tjc|7<ndS(Ni(R�R�R�RVR!R1(RcR�trequired_fieldsR�RMtfieldtmissed_required_fields((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�4sDc	Cs�|dkrdSt|t�s>|j||dtj|�nY|tj}xIt|�D];\}}|j	|||tj
|dj||�d�qXWdS(NRxs{0}[{1}](R�R�tlistR�R=RJR!R9t	enumerateR�R0R�(RcR�R�R�RMt
item_modeltit	item_data((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�:s
(cCsd�}|dkr|rtS|tjkr;t|t�S|tjkrWt|t�S|tjkr�t|t	�o�t|t�}t|t�o�|j
�}|p�|S|tjkrt|t	tf�o�t|t�}t|t�o�||�}|p|St
S(NcSs+yt|�tSWntk
r&tSXdS(N(tfloatR�t
ValueErrorR�(ts((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pytis_numeric_stringGs


(R�R�R=RER�RRFtboolRGRtisdigitRHR�R�(R�R�R�R�t
is_integertis_digit_stringt	is_number((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�Es 	


%
cCs#tj|ko"|tjtjkS(N(R!R0R=RE(R�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�^scCsigtj6gtj6S(N(R!R1R2(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�bs
cCs8|tjs|tj=n|tjs4|tj=n|S(N(R!R1R2(R�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�is




RxcCs.d}|r|rd}ndj|||�S(NRxt.s	{0}{1}{2}(R�(RMR�t	separator((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�qs	cCs#tj|ko"|tjtjkS(N(R!R0R=RI(R�((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�xsN(RRR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyR�Js2	/		&	'												N(((((((((t'ansible.module_utils.network.ftd.commonRtansible.module_utils.sixRRRR�R�R�RRR!R=RLRQRXR�RYR[R\R�(((sW/usr/lib/python2.7/site-packages/ansible/module_utils/network/ftd/fdm_swagger_client.pyt<module>s

	
�

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