
    Vha                    V    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	  G d de      Z
y)	    )annotations)AnsibleError)
ActionBase)ArgumentSpecValidator)combine_varsc                  2     e Zd ZdZdZdZd Zd fd	Z xZS )ActionModulez Validate an arg specFc                    i }|j                         D ]  \  }}||v s||   ||<    | j                  j                  |      }|S )aM  
        Get any arguments that may come from `task_vars`.

        Expand templated variables so we can validate the actual values.

        :param argument_spec: A dict of the argument spec.
        :param task_vars: A dict of task variables.

        :returns: A dict of values that can be validated against the arg spec.
        )items_templartemplate)selfargument_spec	task_varsargsargument_nameargument_attrss         ]/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/action/validate_argument_spec.pyget_args_from_task_varsz$ActionModule.get_args_from_task_vars   sX     -:-@-@-B 	?)M>	)&/&>]#	? }}%%d+    c                Z   |
t               }t        t        |   ||      }~| j                  j
                  j                  di       |d<   d| j                  j
                  vr"t        d| j                  j
                  z        | j                  j
                  j                  d      }| j                  j
                  j                  di       }t        |t               st        dt        |      z        t        |t               st        dt        |      z        | j                  ||      }t        |      }|j                  t        ||      d      }|j                  r<d|d	<   d
dj                  |j                        z  |d<   ||d<   |j                  |d<   |S d|d<   d|d<   |S )a  
        Validate an argument specification against a provided set of data.

        The `validate_argument_spec` module expects to receive the arguments:
            - argument_spec: A dict whose keys are the valid argument names, and
                  whose values are dicts of the argument attributes (type, etc).
            - provided_arguments: A dict whose keys are the argument names, and
                  whose values are the argument value.

        :param tmp: Deprecated. Do not use.
        :param task_vars: A dict of task variables.
        :return: An action result dict, including a 'argument_errors' key with a
            list of validation errors found.
        validate_args_contextr   z+"argument_spec" arg is required in args: %sprovided_argumentsz:Incorrect type for argument_spec, expected dict and got %sz?Incorrect type for provided_arguments, expected dict and got %sT)validate_role_argument_specfailedz"Validation of arguments failed:
%s
msgargument_spec_dataargument_errorsFchangedzThe arg spec validation passed)dictsuperr	   run_taskr   getr   
isinstancetyper   r   validater   error_messagesjoin)
r   tmpr   resultr   r   args_from_vars	validatorvalidation_result	__class__s
            r   r#   zActionModule.run%   s    I|T.sI> +/**//*=*=>UWY*Z&'$**//1Ltzz^__ "ZZ__00A "ZZ__001ErJ,d3[^bcu^vvww,d3`cghzc{{||556H)T)*<=	%..|NL^/_  ~B.  C++#F8ADIIN_NnNnDooF5M+=F'((9(H(HF$%M!y8ur   )NN)	__name__
__module____qualname____doc__TRANSFERS_FILES_requires_connectionr   r#   __classcell__)r0   s   @r   r	   r	      s     O &7 7r   r	   N)
__future__r   ansible.errorsr   ansible.plugins.actionr   $ansible.module_utils.common.arg_specr   ansible.utils.varsr   r	    r   r   <module>r>      s$    # ' - F +P: Pr   