
    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  e       Zej)                   ed(i d ed	d
d
dg      d ed      d ed      d ed      d ed      d ed	      d ed      d ed      d ed	      d ed      d ed	      d ed      d ed	      d ed      d ed      d ed      d ed      d  ed	      d! ed	      d" ed             dd
d!gdfdd
d dgdf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statestrpresentabsent)typedefaultchoicesadminbool)r   $allowPortalTagTransferForSameSubject allowReplacementOfPortalGroupTagallowRoleTransferForSameSubjectdescriptioneapexpirationTTLPeriodintexpirationTTLUnitsimsnameportalportalGroupTagpxgridradiusrenewSelfSignedCertificatesamlidhostNameallowWildcardDeletec                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	SystemCertificatec                    || _         t        di d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d	|j                  d	      d
|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      | _        y )Nr   *allow_portal_tag_transfer_for_same_subjectr   %allow_replacement_of_portal_group_tagr   $allow_role_transfer_for_same_subjectr   r   r   expiration_ttl_periodr   expiration_ttl_unitsr   r   r   r    portal_group_tagr!   r"   r#   renew_self_signed_certificater$   r%   r&   	host_namer'   allow_wildcard_deleter(    )isedictget
new_object)selfparamsr6   s      o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ise/plugins/action/system_certificate.py__init__zSystemCertificate.__init__D   s    
**W%
7=zz68

 39**23
 2812
 

=1
 

5!
 #)**-B"C
 "(,@!A
 

5!
  F#!
" ::h'#
$ $ZZ(89%
& ::h''
( ::h')
* +1**5Q*R+
, F#-
. zz$/
0 jj,1
2 #)**-B"C3
    c                 n   d }| j                   j                  ddd|i      }	 |D ]5  }|j                  j                  dg       xs g }t	        |d|      }|s3|c S  	 |S # t
        t        f$ r7}| j                   j                  dj                  |      	       Y d }~|S d }~wt        $ r d }Y |S w xY w)
Ncertificates!get_system_certificates_generatorr3   familyfunctionr;   responsefriendlyNamea'  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)
r6   execrE   r8   r   	TypeErrorAttributeError	fail_jsonformat	Exception)r:   r   r3   resultgen_items_responsesitems_responseitemses           r<   get_object_by_namez$SystemCertificate.get_object_by_nameb   s    "hhmm!8+ , 

	"5 "&//33JCIr(E!M	""  >* 		HH.
 &q&/      	F	s)   4A! A! A! !B40,B""B43B4c                     	 | j                   j                  dd||dd      j                  d   }|S # t        $ r}d }Y d }~|S d }~ww xY w)Nr@   get_system_certificate_by_id)r&   r3   F)rC   rD   r;   handle_func_exceptionrE   )r6   rI   rE   rN   )r:   r&   r3   rO   rS   s        r<   get_object_by_idz"SystemCertificate.get_object_by_id}   s`    	XX]]%7 y9&+	 # 
 hz#F   	F	s   /3 	A	AA	c                 d   d }d}| j                   j                  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   r3   )r9   r8   rX   
isinstancer7   rT   )r:   prev_objrO   r&   r   r3   s         r<   existszSystemCertificate.exists   s    __  &""6*OO''4	,,R;HT)Hj4.HF !! ..tY?HT)Hj4.HF!!r>   c                 n   | j                   j                  d      }||j                         dk(  rdd<   dd<   dd<   dd<   nTd|j                         v d<   d|j                         v d<   d|j                         v d<   d|j                         v d<   g d}t        fd	|D              S )
NusedByz
not in useFr   r"   r#   r   ))r   r   )r   r,   )r   r-   )r   r.   )r   r   )r   r   )r   r/   )r   r0   )r   r   )rF   r   )r    r    )r!   r1   )r"   r"   )r#   r#   )r$   r2   )r%   r%   )r&   r&   )r'   r3   )r(   r4   c              3   z   K   | ]2  \  }}t        j                  |      j                  |              4 y w)N)r   r8   ).0	ise_paramansible_paramcurrent_objrequested_objs      r<   	<genexpr>z4SystemCertificate.requires_update.<locals>.<genexpr>   sB      
 +M %	*M,=,=m,L 
s   8;)r9   r8   lowerany)r:   rc   used_by_value
obj_paramsrd   s    `  @r<   requires_updatez!SystemCertificate.requires_update   s    #1 M$7$7$9\$I!&K$)K!$)K!!&K!&-*=*=*?!?K$,0C0C0E$EK!$,0C0C0E$EK!!&-*=*=*?!?K

:  
 /9	
 
 	
r>   c                    | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }d }|sF| j                  ||      j                  d      }| j                   j                  t	        |             | j
                  j                  dd| j                         j                  }|S )Nr&   r   r3   r&   r@   update_system_certificaterB   r9   r8   rT   updater7   r6   rI   rE   r:   r&   r   r3   rO   id_s         r<   ro   zSystemCertificate.update   s    __  &""6*OO''4	))$	:>>tDCOO""43<0!0??  
 (	 	
 r>   c                    | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }d }|sF| j                  ||      j                  d      }| j                   j                  t	        |             | j
                  j                  dd| j                         j                  }|S )Nr&   r   r3   rl   r@   delete_system_certificate_by_idrB   rn   rp   s         r<   deletezSystemCertificate.delete   s    __  &""6*OO''4	))$	:>>tDCOO""43<0!6??  
 (	 	
 r>   N)
__name__
__module____qualname__r=   rT   rX   r\   rj   ro   rt   r5   r>   r<   r*   r*   C   s&    
<6
"1
f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   superry   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   _taskr   r7   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                    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                          nr|}|j!                          n_|j#                  d       nM|dk(  rH|j                         \  }}|r#|j%                          |}|j'                          n|j)                          | j
                  j                  t        |	             | j
                  j                  |j+                                | j
                  S )
NFchanged)r;   r   r   )ise_update_responsez.Object does not exists, plugin only has updater   )ise_response)r   diffr|   ry   runr   r   r	   r   r*   r8   r\   rj   ro   r7   object_updatedobject_already_presentrL   rt   object_deletedobject_already_absent	exit_json)r:   tmp	task_varsr6   objr   rE   
obj_existsr[   r   updated_objr   s              r<   r   zActionModule.run  s   

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

5

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

-Z*H&&('H..0NOh%(ZZ\"Z

#""$))+Dh78CMMO,||r>   )NN)ru   rv   rw   r=   r   r   __classcell__)r   s   @r<   ry   ry      s    ,"% %r>   ry   Nr5   )
__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   r   ro   r7   r   r   r   r   objectr*   ry   r5   r>   r<   <module>r      s   A @ -& "& ,  "#    y9h:OP .2v-> *.6):	
 )-&(9 e$ f !e,  U+ f u   '      $(V#4!" v#$ U%& 5!'( !f-)4 i*t,i$.i*t,hv-	   c cLB: Bs  '!&'s   E EE