
    Vh              	       ,   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
g       e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 vw xY w)    )absolute_importdivisionprint_function)
ActionBase)AnsibleArgSpecValidatorTF)AnsibleActionFail)ISESDKise_argument_specise_compare_equalityget_dict_result)InconsistentParametersstrpresent)typedefaultchoicesbool)r   )state	isEnabledr   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)StopReplicationc                 R    || _         t        |j                  d            | _        y )Nr   )
is_enabled)isedictget
new_object)selfparamsr   s      m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ise/plugins/action/stop_replication.py__init__zStopReplication.__init__2   s!    zz+.
    c                 x    d }| j                   j                  dd      j                  d   }t        |d|      }|S )N!endpoint_stop_replication_serviceget_stop_replication_status)familyfunctionresponsename)r   execr(   r   )r   r)   resultitemss       r    get_object_by_namez"StopReplication.get_object_by_name8   sG    62  
 (: !5r"   c                 
    d }|S N )r   idr+   s      r    get_object_by_idz StopReplication.get_object_by_idB   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 )NFr1   r)   z9The 'id' and 'name' params don't refer to the same object)r   r   r2   
isinstancer   r-   r   )r   prev_obj	id_existsname_existso_idr)   _id	it_existss           r    existszStopReplication.existsG   s    	""4(""6*,,T2H ,KHd1KIT..t4H"$.M:h3MK,,t$C[TS[,O  D(GZ$-G	8$$r"   c                 N    | j                   dg}t        fd|D              S )N)r   r   c              3   z   K   | ]2  \  }}t        j                  |      j                  |              4 y wr/   )r   r   ).0	ise_paramansible_paramcurrent_objrequested_objs      r    	<genexpr>z2StopReplication.requires_update.<locals>.<genexpr>d   sB      
 +M %	*M,=,=m,L 
s   8;)r   any)r   rA   
obj_paramsrB   s    ` @r    requires_updatezStopReplication.requires_update\   s6     (


  
 /9	
 
 	
r"   c                     | j                   j                  d      }| j                   j                  d      }d }| j                  j                  dd| j                         j                  }|S )Nr1   r)   r$   set_stop_replication_service)r&   r'   r   )r   r   r   r*   r(   )r   r1   r)   r+   s       r    updatezStopReplication.updatek   sd    __  &""6*63??  
 (	 	
 r"   N)	__name__
__module____qualname__r!   r-   r2   r;   rF   rI   r0   r"   r    r   r   1   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   superrN   r!   _supports_async_supports_check_mode_result)r   argskwargs	__class__s      r    r!   zActionModule.__init__x   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   _taskrU   r   rY   r[   r\   r]   r^   actionvalidater   )r   aavvaliderrorss       r    _check_argspeczActionModule._check_argspec   sr    %m4# $' /#5"3	! ""
 *-&vtzz#F++ r"   c                 l   d| j                   _        t        t        |   ||      | _        d| j
                  d<   | j                          t        | j                   j                        }t        | j                   j                  |      }| j                   j                  j                  d      }d }|dk(  r|j                         \  }}|r|j                  |      r[|j                         }	| j
                  j                  t        |	             |j                         \  }}
|
}|j                          n$|}|j!                          n|j#                  d       | j
                  j                  t        |             | j
                  j                  |j%                                | j
                  S )	NFchanged)r   r   r   )ise_update_responsez.Object does not exists, plugin only has update)ise_response)rc   diffrQ   rN   runrT   ri   r	   rU   r   r   r;   rF   rI   r   object_updatedobject_already_present	fail_json	exit_json)r   tmp	task_varsr   objr   r(   
obj_existsr5   rl   updated_objrW   s              r    ro   zActionModule.run   sE   

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

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

-Z*H&&('H..0NODh78CMMO,||r"   )NN)rJ   rK   rL   r!   ri   ro   __classcell__)rW   s   @r    rN   rN   w   s    ," r"   rN   N)
__future__r   r   r   r   __metaclass__ansible.plugins.actionr   Nansible_collections.ansible.utils.plugins.module_utils.common.argspec_validater   rP   ImportErroransible.errorsr   6ansible_collections.cisco.ise.plugins.plugin_utils.iser	   r
   r   r   =ansible_collections.cisco.ise.plugins.plugin_utils.exceptionsr   rY   rI   r   r[   r\   r]   r^   objectr   rN   r0   r"   r    <module>r      s    A @ -& "& , 
 "#   y9+FF# iT"   Cf CL:: :O  '!&'s   B	 	BB