o
    Ü!d+  ã                   @   sT   d dl Z d dlmZmZ d dlmZ d dlmZ dd„ Zdd„ Z	G d	d
„ d
eƒZ
dS )é    N)Úget_paramfileÚLOCAL_PREFIX_MAP)Ú
ParamError)ÚOverrideRequiredArgsArgumentc                 C   s   |   dt¡ d S )Nzbuilding-argument-table)ÚregisterÚadd_cli_input_json)Úcli© r	   úFusr/lib/python3.10/site-packages/awscli/customizations/cliinputjson.pyÚregister_cli_input_json   s   r   c                 K   s"   d|vrt | ƒ}| |¡ d S d S )NÚoutfile)ÚCliInputJSONArgumentZadd_to_arg_table)ÚsessionZargument_tableÚkwargsZcli_input_json_argumentr	   r	   r
   r      s   þr   c                       sF   e Zd ZdZdddœZ‡ fdd„Z‡ fdd„Zd	d
„ Zdd„ Z‡  Z	S )r   a#  This argument inputs a JSON string as the entire input for a command.

    Ideally, the value to this argument should be a filled out JSON file
    generated by ``--generate-cli-skeleton``. The items in the JSON string
    will not clobber other arguments entered into the command line.
    zcli-input-jsonak  Performs service operation based on the JSON string provided. The JSON string follows the format provided by ``--generate-cli-skeleton``. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.)ÚnameZ	help_textc                    s   t t| ƒ |¡ d S ©N)Úsuperr   Ú__init__)Úselfr   ©Ú	__class__r	   r
   r   2   s   zCliInputJSONArgument.__init__c                    s"   | j  d| j¡ tt| ƒ ¡  d S )Nzcalling-command.*)Z_sessionr   Úadd_to_call_parametersr   r   Ú_register_argument_action)r   r   r	   r
   r   5   s   ÿz.CliInputJSONArgument._register_argument_actionc           	   
   K   sz   t |dd ƒ}|d ur;t|tƒ}|d u r|}zt |¡}W n ty2 } z
t| jd||f ƒ‚d }~ww |  ||¡ d S d S )NZcli_input_jsonz"Invalid JSON: %s
JSON received: %s)	Úgetattrr   r   ÚjsonÚloadsÚ
ValueErrorr   r   Ú_update_call_parameters)	r   Úcall_parametersZparsed_argsZparsed_globalsr   Z
input_jsonZretrieved_jsonÚ
input_dataÚer	   r	   r
   r   :   s"   
ÿÿ€ÿñz+CliInputJSONArgument.add_to_call_parametersc                 C   s&   |  ¡ D ]}||vr|| ||< qd S r   )Úkeys)r   r   r   Z	input_keyr	   r	   r
   r   P   s
   €üz,CliInputJSONArgument._update_call_parameters)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ZARG_DATAr   r   r   r   Ú__classcell__r	   r	   r   r
   r       s    þr   )r   Zawscli.paramfiler   r   Zawscli.argprocessr   Zawscli.customizations.argumentsr   r   r   r   r	   r	   r	   r
   Ú<module>   s   