
    Vh                     8    d dl mZmZmZ eZd dlZd ZddZd Z	y)    )absolute_importdivisionprint_functionNc                     |s| S dj                  | dj                  |j                         D cg c]  \  }}dj                  ||       c}}            S c c}}w )a=  
    Generates an API endpoint with query strings based on the provided keyword arguments.

    :param path: The base URL of the API endpoint. -> Str
    :param kwargs: Keyword arguments representing query parameters. -> Dict
    :return: A string representing the full API endpoint with query parameters. -> Str
    z{0}?{1}&z{0}={1})formatjoinitems)pathkwargskeyvalues       h/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/mso/plugins/module_utils/utils.pygenerate_api_endpointr      sq     4  E9#3#3D#((syss  tB  DCeoehjoIDTDTUXZ_D`  DC  ;D  $E  E  DCs   Ac           	      L     fd fd|rQt        |t              st        d      |j                         D ]#  \  }} ||t        |t              r|n|f|       % |r@t        |t
              st        d      |D ]  } ||t        |t              r|n|f       ! yy)a
  
    Append Update ops payload data.
    :param ops: Variable which contains the PATCH replace actions for the update operation -> List
    :param existing_data: Variable which contains the existing data -> Dict
    :param update_path: The object path is used to update an existing object -> Str
    :param replace_data: Defaults to None when not specified, expected a dictionary object. Which contains the attribute to be updated and its new value -> Dict
    :param remove_data: Defaults to None when not specified, expected a list of string or tuple, value used to clear the existing configuration -> List
    :return: None
                If attributes is not empty then the ops and existing_data are updated with the input value.

    Sample Existing Data:
    ---------------------
    existing_data = {
        "name": "name",
        "description": "description",
        "bfdMultiHopPol": {
            "adminState": "enabled",
            "minRxInterval": 250,
            "ifControl": {"adminState": "enabled"},
        },
        "bfdPol": {
            "adminState": "enabled",
            "detectionMultiplier": 3,
        }
    }

    ops = []
    update_path = "/tenantPolicyTemplate/template/l3OutIntfPolGroups/0"
    replace_data = {
        ("name"): "new_name",
        "description": "new_description",
        ("ospfIntfPol"): dict(ifControl=dict(adminState="disabled"), cost=0)),
    }
    remove_data = [("bfdMultiHopPol", "ifControl", "adminState"), "bfdPol"]

    append_update_ops_data(ops, existing_data, update_path, replace_data, remove_data)

    Standard Output Data:
    ---------------------
    {
        "bfdMultiHopPol": {
            "adminState": "enabled",
            "minRxInterval": 250,
            "ifControl": {},
        },
        "name": "new_name",
        "description": "new_description",
        "ospfIntfPol": {
            "ifControl": {
                "adminState": "disabled",
            },
            "cost": 0,
        },
    }

    API Input Data:
    ---------------
    [
        {"op": "replace", "path": "/tenantPolicyTemplate/template/l3OutIntfPolGroups/1/name", "value": "new_name"},
        {"op": "replace", "path": "/tenantPolicyTemplate/template/l3OutIntfPolGroups/1/description", "value": "new_description"},
        {
            "op": "replace",
            "path": "/tenantPolicyTemplate/template/l3OutIntfPolGroups/1/ospfIntfPol",
            "value": {"ifControl": {"adminState": "disabled"}, "cost": 0},
        },
        {"op": "remove", "path": "/tenantPolicyTemplate/template/l3OutIntfPolGroups/1/bfdPol"},
        {"op": "remove", "path": "/tenantPolicyTemplate/template/l3OutIntfPolGroups/1/bfdMultiHopPol/ifControl/adminState"},
    ]
    c           	      4   |d   }t        |      dk(  r^|[| j                  |      |k7  rF|| |<   j                  t        ddj	                  ||      t        j                  |                   y y y || v r" | |   dj	                  ||      |dd  |       y y )Nr      replace{}/{})opr   r   )lengetappenddictr   copydeepcopy)datar   keys	new_valuer   opsrecursive_replaces        r   r!   z1append_update_ops_data.<locals>.recursive_replace_   s    1gt9>$#))C%S	

$$^^D#6"mmI6 *D$ D[d3ic)BDHiX     c           	          |d   }t        |      dk(  rC|| v r>| j                  |       j                  t        ddj	                  ||                   y y || v r! | |   dj	                  ||      |dd         y y )Nr   r   remover   )r   r   )r   popr   r   r   )r   r   r   r   r    recursive_deletes       r   r&   z0append_update_ops_data.<locals>.recursive_deleteo   s    1gt9>d{

#$^^D#6  D[T#YtS(A48L r"   zreplace_data must be a dictz.remove_data must be a list of string or tuplesN)
isinstancer   	TypeErrorr
   tuplelist)	r    existing_dataupdate_pathreplace_dataremove_datar   r   r&   r!   s	   `      @@r   append_update_ops_datar/      s    NY M ,-9::&,,. 	lJCm[CQVAW#^a]cejk	l +t,LMM 	dC]K
3PU@V]`\bc	d	 r"   c                 &    t        d | D              S )z
    Checks if all the elements in the provided list are None.

    :param values: List of values to check. -> List
    :return: True if all elements are None, False otherwise. -> bool
    c              3   $   K   | ]  }|d u  
 y w)N ).0r   s     r   	<genexpr>z1check_if_all_elements_are_none.<locals>.<genexpr>   s     1u}1s   )all)valuess    r   check_if_all_elements_are_noner7      s     1&111r"   )NN)

__future__r   r   r   type__metaclass__r   r   r/   r7   r2   r"   r   <module>r;      s)    A @ Erdj2r"   