
    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       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 ~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)typedefaultchoicesbool)r   )state	enableEPO	enableRCMr   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)Configurationc                 r    || _         t        |j                  d      |j                  d            | _        y )Nr   r   )
enable_epo
enable_rcm)isedictget
new_object)selfparamsr   s      j/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ise/plugins/action/configuration.py__init__zConfiguration.__init__3   s-    zz+.zz+.
    c                 r    d }| j                   j                  dd      j                  }t        |d|      }|S )Nconfigurationget_configuration)familyfunctionname)r   execresponser   )r    r*   resultitemss       r"   get_object_by_namez Configuration.get_object_by_name:   sA    "-@  

( 	 !5r$   c                 
    d }|S N )r    idr-   s      r"   get_object_by_idzConfiguration.get_object_by_idC   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 )NFr3   r*   z9The 'id' and 'name' params don't refer to the same object)r   r   r4   
isinstancer   r/   r   )r    prev_obj	id_existsname_existso_idr*   _id	it_existss           r"   existszConfiguration.existsH   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                   ddg}t        fd|D              S )N)r   r   )r   r   c              3   z   K   | ]2  \  }}t        j                  |      j                  |              4 y wr1   )r   r   ).0	ise_paramansible_paramcurrent_objrequested_objs      r"   	<genexpr>z0Configuration.requires_update.<locals>.<genexpr>f   sB      
 +M %	*M,=,=m,L 
s   8;)r   any)r    rC   
obj_paramsrD   s    ` @r"   requires_updatezConfiguration.requires_update]   s9     ('

  
 /9	
 
 	
r$   c                     | j                   j                  d      }| j                   j                  d      }d }| j                  j                  dd| j                         j                  }|S )Nr3   r*   r&   update_configuration)r(   r)   r!   )r   r   r   r+   r,   )r    r3   r*   r-   s       r"   updatezConfiguration.updatem   sd    __  &""6*"+??  
 (	 	
 r$   N)	__name__
__module____qualname__r#   r/   r4   r=   rH   rK   r2   r$   r"   r   r   2   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   superrP   r#   _supports_async_supports_check_mode_result)r    argskwargs	__class__s      r"   r#   zActionModule.__init__z   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   _taskrW   r   r[   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)re   diffrS   rP   runrV   rk   r	   rW   r   r   r=   rH   rK   r   object_updatedobject_already_present	fail_json	exit_json)r    tmp	task_varsr   objr   r,   
obj_existsr7   rn   updated_objrY   s              r"   rq   zActionModule.run   sE   

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

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

-Z*H&&('H..0NODh78CMMO,||r$   )NN)rL   rM   rN   r#   rk   rq   __classcell__)rY   s   @r"   rP   rP   y   s    ," r$   rP   N)
__future__r   r   r   r   __metaclass__ansible.plugins.actionr   Nansible_collections.ansible.utils.plugins.module_utils.common.argspec_validater   rR   ImportErroransible.errorsr   6ansible_collections.cisco.ise.plugins.plugin_utils.iser	   r
   r   r   =ansible_collections.cisco.ise.plugins.plugin_utils.exceptionsr   r[   rK   r   r]   r^   r_   r`   objectr   rP   r2   r$   r"   <module>r      s    A @ -& "& , 
 "#   y9+FF#F# iT"   DF DN:: :S  '!&'s   B BB