
    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  e       Zej%                   e ed	       ed	       ed
	                   g Zg Zg Zg Z G d de      Zy# e$ r dZ
Y aw xY w)    )absolute_importdivisionprint_function)
ActionBase)AnsibleArgSpecValidatorTF)AnsibleActionFail)ISESDKise_argument_specint)typestr)pagesizeclientIDc                   6     e Zd Z fdZ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'FT)ANSIBLE_UTILS_IS_INSTALLEDr   superr   __init___supports_async_supports_check_mode_result)selfargskwargs	__class__s      m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ise/plugins/action/reservation_info.pyr   zActionModule.__init__,   sC    )#k  	lD*D;F;$$(!    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_conditionalsname)r   _taskr   dictr!   r#   r$   r%   r&   actionvalidater   )r   aavvaliderrorss       r   _check_argspeczActionModule._check_argspec7   sr    %m4# $' /#5"3	! ""
 *-&vtzz#F++ r   c                 |    t        |j                  d      |j                  d      |j                  d            }|S )Nr   r   r   )r   r   	client_id)r-   get)r   params
new_objects      r   
get_objectzActionModule.get_objectH   s8    F#F#jj,


 r   c                    d| j                   _        t        t        |   ||      | _        d| j
                  d<   | j                          | j
                  j                  t        g              t        | j                   j                        }| j                   j                  j                  d      }| j                   j                  j                  d      }|r|j                  dd| j                  | j                   j                        	      j                  d
   }| j
                  j                  t        |             | j
                  j                  |j                                | j
                  S |s|sg }|j                  dd| j                  | j                   j                        	      }	 |D ]8  }	|	j                  d
   }
t!        |
t"              r||
z  }(|j%                  |
       : |}| j
                  j                  t                     | j
                  j                  |j                                | j
                  S y y # t&        t(        f$ r,}|j+                  dj-                  |             Y d }~d }~wt.        $ r,}|j+                  dj-                  |             Y d }~d }~ww xY w)NFchanged)ise_response)r7   r   r+   sgt_range_reservationget_sgt_reserved_range)familyfunctionr7   response!get_sgt_reserved_ranges_generatora'  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)msgzxAn error occured when executing operation. The error was: {error} You may want to enable the (ise_debug: True) argument.)r,   diffr   r   runr   r3   updater-   r	   r   r6   execr9   rA   	exit_json
isinstancelistappend	TypeErrorAttributeError	fail_jsonformat	Exception)r   tmp	task_varsiseidr+   rA   	responses	generatoritemtmp_responseer   s               r   rF   zActionModule.runP   sG   

\44S)D"'YDb12DJJOO,ZZ__  ,zz""6*xx.1tzz7    hz	#H
 LL( ;<LL0<<BI.<tzz7 ! I
% 7D#'==#<L!,5!\1	!((67 %( LL( ;<LL0<<I t ~. 	2
 f1fo     R f1fo   s$   8?I K""J		K"J<<K)NN)__name__
__module____qualname__r   r3   r9   rF   __classcell__)r   s   @r   r   r   +   s    ,"9  9 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!   rG   r-   r#   r$   r%   r&   r    r   r   <module>rg      s    A @ -& "& , "#   uu5!   ^ : ^ 7  '!&'s   A4 4A>=A>