
    Vh                     x   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 d dl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
g df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)InconsistentParametersstrpresentabsent)typedefaultchoicesbool)r   int)state	isEnabledprimaryHealthCheckNodesecondaryHealthCheckNodepollingIntervalfailedAttemptsr   c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	PanHac           	          || _         t        |j                  d      |j                  d      |j                  d      |j                  d      |j                  d            | _        y )Nr   r   r   r   r   )
is_enabledprimary_health_check_nodesecondary_health_check_nodepolling_intervalfailed_attempts)isedictget
new_object)selfparamsr$   s      c/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ise/plugins/action/pan_ha.py__init__zPanHa.__init__7   sU    zz+.&,jj1I&J(.

3M(N#ZZ(9:"JJ'78
    c                 x    d }| j                   j                  dd      j                  d   }t        |d|      }|S )Npan_haget_pan_ha_status)familyfunctionresponsename)r$   execr2   r   )r(   r3   resultitemss       r*   get_object_by_namezPanHa.get_object_by_nameA   sA    X8KLUU
 !5r,   c                 
    d }|S N )r(   idr5   s      r*   get_object_by_idzPanHa.get_object_by_idJ   s    r,   c                    d }d}d}| j                   j                  d      }| j                   j                  d      }|r'| j                  |      }|d uxr t        |t              }|s)|r'| j                  |      }|d uxr t        |t              }|r%|j                  d      }|r|r||k7  rt        d      |d uxr t        |t              }||fS )NFr;   r3   z9The 'id' and 'name' params don't refer to the same object)r'   r&   r<   
isinstancer%   r7   r   )r(   prev_obj	id_existsname_existso_idr3   _id	it_existss           r*   existszPanHa.existsO   s    	""4(""6*,,T2H ,KHd1KIT..t4H"$.M:h3MK,,t$C[TS[,O  D(GZ$-G	8$$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r9   )r   r&   ).0	ise_paramansible_paramcurrent_objrequested_objs      r*   	<genexpr>z(PanHa.requires_update.<locals>.<genexpr>p   sB      
 +M %	*M,=,=m,L 
s   8;)r'   any)r(   rK   
obj_paramsrL   s    ` @r*   requires_updatezPanHa.requires_updated   s1    

  
 /9	
 
 	
r,   c                 j    | j                   j                  dd| j                        j                  }|S )Nr.   enable_pan_har0   r1   r)   )r$   r4   r'   r2   )r(   r5   s     r*   createzPanHa.createw   s7    $??  
 (	 	
 r,   c                     | j                   j                  d      }| j                   j                  d      }d }| j                  j                  dd| j                         j                  }|S )Nr;   r3   r.   disable_pan_harS   )r'   r&   r$   r4   r2   )r(   r;   r3   r5   s       r*   deletezPanHa.delete   sa    __  &""6*&6t  

( 	 r,   N)
__name__
__module____qualname__r+   r7   r<   rE   rP   rT   rW   r:   r,   r*   r   r   6   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   superr\   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_conditionalsr3   )r   _taskrc   r%   rg   ri   rj   rk   rl   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 oldValuerz   r   )ise_response)rq   diffr_   r\   runrb   rw   r	   rc   r   r&   rE   rP   updater%   lenpopobject_already_presentobject_updatedrT   object_createdrW   object_deletedobject_already_absent	exit_json)r(   tmp	task_varsr$   objr   r2   
obj_existsr?   rz   updated_objhas_changedise_create_responsecreated_objre   s                 r*   r   zActionModule.run   s<   

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

##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)rX   rY   rZ   r+   rw   r   __classcell__)re   s   @r*   r\   r\      s    ,"5 5r,   r\   N)
__future__r   r   r   r   __metaclass__ansible.plugins.actionr   Nansible_collections.ansible.utils.plugins.module_utils.common.argspec_validater   r^   ImportErroransible.errorsr   6ansible_collections.cisco.ise.plugins.plugin_utils.iser	   r
   r   r   =ansible_collections.cisco.ise.plugins.plugin_utils.exceptionsr   rg   r   r%   ri   rj   rk   rl   objectr   r\   r:   r,   r*   <module>r      s    A @ -& "& , 
 "#   y9h:OPF##/!%5!1%('	 iT"hD!   PF PfR: Rs  '!&'s   B/ /B98B9