
    Vh%$                     t   d dl mZmZmZ eZd dlmZ 	 d dlm	Z	 dZ
d dlmZ d dlmZmZmZmZ  e       Zej)                   e edd	d	d
g       ed       ed       ed       ed       ed                   dd	ddgdfdd
ddgdfgZg Zg Zg Z G d de      Z G d de      Zy# e$ r dZ
Y w xY w)    )absolute_importdivisionprint_function)
ActionBase)AnsibleArgSpecValidatorTF)AnsibleActionFail)ISESDKise_argument_specise_compare_equalityget_dict_resultstrpresentabsent)typedefaultchoices)r   bool)statenamedescriptionsystemDefinedidparentIDr   r   r   c                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
EndpointGroupc           	          || _         t        |j                  d      |j                  d      |j                  d      |j                  d      |j                  d            | _        y )Nr   r   r   r   r   )r   r   system_definedr   	parent_id)isedictget
new_object)selfparamsr   s      k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ise/plugins/action/endpoint_group.py__init__zEndpointGroup.__init__4   sQ    F#

=1!::o6zz$jj,
    c                 *   	 | j                   j                  ddd|id      j                  d   }t        |d|      }|S # t        t
        f$ r7}| j                   j                  dj                  |      	       Y d }~S d }~wt        $ r d }Y |S w xY w)
Nendpoint_identity_groupget_endpoint_group_by_namer   F)familyfunctionr$   handle_func_exceptionEndPointGroup'  An error occured when executing operation. Check the configuration of your API Settings and API Gateway settings on your ISE server. This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled. You may want to enable the (ise_debug: True) argument. The error was: {error}errormsg)	r   execresponser   	TypeErrorAttributeError	fail_jsonformat	Exception)r#   r   resultes       r%   get_object_by_namez EndpointGroup.get_object_by_name>   s    	XX]]05~&+	 # 
 h(F %VVT:F  >* 		HH.
 &q&/      	F	s   ;? B,B  BBc                    	 | j                   j                  dddd|i      j                  d   }|S # t        t        f$ r7}| j                   j                  dj                  |      	       Y d }~S d }~wt        $ r d }Y |S w xY w)
Nr)   get_endpoint_group_by_idFr   )r+   r,   r-   r$   r.   r/   r0   r2   )r   r4   r5   r6   r7   r8   r9   r:   )r#   r   r;   r<   s       r%   get_object_by_idzEndpointGroup.get_object_by_idU   s    	XX]]03&+bz	 # 
 h(F$  >* 		HH.
 &q&/      	F	s   .2 B,A33BBc                 *   d}d }| j                   j                  d      }| j                   j                  d      }|r+| j                  |      }|d uxr t        |t              }||fS |r'| j                  |      }|d uxr t        |t              }||fS )NFr   r   )r"   r!   r@   
isinstancer    r=   )r#   r;   prev_objr   r   s        r%   existszEndpointGroup.existsk   s    __  &""6*,,R0HT)Hj4.HF !! ..t4HT)Hj4.HF!!r'   c                 P    | j                   g d}t        fd|D              S )N))r   r   )r   r   )r   r   )r   r   )r   r   c              3   z   K   | ]2  \  }}t        j                  |      j                  |              4 y w)N)r   r!   ).0	ise_paramansible_paramcurrent_objrequested_objs      r%   	<genexpr>z0EndpointGroup.requires_update.<locals>.<genexpr>   sB      
 +M %	*M,=,=m,L 
s   8;)r"   any)r#   rJ   
obj_paramsrK   s    ` @r%   requires_updatezEndpointGroup.requires_updatex   s1    

  
 /9	
 
 	
r'   c                 j    | j                   j                  dd| j                        j                  }|S )Nr)   create_endpoint_groupr+   r,   r$   )r   r4   r"   r5   )r#   r;   s     r%   createzEndpointGroup.create   s7    ,,??  
 (	 	
 r'   c                 h   | j                   j                  d      }| j                   j                  d      }d }|sE| j                  |      j                  d      }| j                   j                  t	        |             | j
                  j                  dd| j                         j                  }|S )Nr   r   r   r)   update_endpoint_group_by_idrR   r"   r!   r=   updater    r   r4   r5   r#   r   r   r;   id_s        r%   rX   zEndpointGroup.update       __  &""6*))$/33D9COO""43<0,2??  
 (	 	
 r'   c                 h   | j                   j                  d      }| j                   j                  d      }d }|sE| j                  |      j                  d      }| j                   j                  t	        |             | j
                  j                  dd| j                         j                  }|S )Nr   r   rU   r)   delete_endpoint_group_by_idrR   rW   rY   s        r%   deletezEndpointGroup.delete   r[   r'   N)__name__
__module____qualname__r&   r=   r@   rD   rO   rS   rX   r^    r'   r%   r   r   3   s*    
.,"
&r'   r   c                   0     e Zd Z fdZd Zd fd	Z xZS )ActionModulec                 x    t         st        d      t        t        |   |i | d| _        d| _        d | _        y )NzYansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'F)ANSIBLE_UTILS_IS_INSTALLEDr   superrd   r&   _supports_async_supports_check_mode_result)r#   argskwargs	__class__s      r%   r&   zActionModule.__init__   sC    )#k  	lD*D;F;$$)!r'   c                 *   t        | j                  j                  t        t              dt        t
        t        t        t              | j                  j                        }|j                         \  }}| j                  _        |st        |      y )N)argument_specargspec)required_ifrequired_one_ofmutually_exclusiverequired_together)dataschemaschema_formatschema_conditionalsr   )r   _taskrk   r    ro   rq   rr   rs   rt   actionvalidater   )r#   aavvaliderrorss       r%   _check_argspeczActionModule._check_argspec   sr    %m4# $' /#5"3	! ""
 *-&vtzz#F++ r'   c                    d| j                   _        t        t        |   ||      | _        d| j
                  d<   | j                          t        | j                   j                        }t        | j                   j                  |      }| j                   j                  j                  d      }d }|dk(  rh|j                         \  }}|r|j                  |      r|j                         }	| j
                  j                  t        |	             |j                         \  }}
|
}d }|	j                  d      j                  d      }t        |      d	k(  s@|d	   j                  d
      dk(  rV|d	   j                  d
      |d	   j                  d      k(  r-| j
                  j!                  dd        |j#                          n|j%                          n|}|j#                          n|j'                         }|j                         \  }}|}|j)                          nM|dk(  rH|j                         \  }}|r#|j+                          |}|j-                          n|j/                          | j
                  j                  t        |             | j
                  j                  |j1                                | j
                  S )NFchanged)r$   r   r   )ise_update_responseUpdatedFieldsListupdatedFieldr   newValue oldValuer   r   )ise_response)ry   diffrg   rd   runrj   r   r	   rk   r   r!   rD   rO   rX   r    lenpopobject_already_presentobject_updatedrS   object_createdr^   object_deletedobject_already_absent	exit_json)r#   tmp	task_varsr   objr   r5   
obj_existsrC   r   updated_objhas_changedise_create_responsecreated_objrm   s                 r%   r   zActionModule.run   s<   

\44S)D"'YDJJOO,DJJOOS1

##G,I%(ZZ\"Z&&x0*-**,'LL''AT(UV03

-Z*H"&K"5"9"9:M"N"R"R&#K K(A-&q>--j9R?'N..z:&q>--j9: (()>E224**,'H..0&)jjl#,/JJL)[&""$h%(ZZ\"Z

#""$))+Dh78CMMO,||r'   )NN)r_   r`   ra   r&   r   r   __classcell__)rm   s   @r%   rd   rd      s    ,"7 7r'   rd   N)
__future__r   r   r   r   __metaclass__ansible.plugins.actionr   Nansible_collections.ansible.utils.plugins.module_utils.common.argspec_validater   rf   ImportErroransible.errorsr   6ansible_collections.cisco.ise.plugins.plugin_utils.iser	   r
   r   r   ro   rX   r    rq   rr   rs   rt   objectr   rd   rb   r'   r%   <module>r      s    A @ -& "& ,  "#   y9h:OPue$'U5!	 i$.hv-   zF zzT: TA  '!&'s   B- -B76B7