o
    .&ßa  ã                   @   s\   d Z ddlZddlmZ ddlmZ ddlmZ dd„ Zdd	„ Z	d
d„ Z
G dd„ deƒZdS )zÔ
This customization adds the following scalar parameters to the
cloudwatch put-metric-data operation:

* --metric-name
* --dimensions
* --timestamp
* --value
* --statistic-values
* --unit
* --storage-resolution

é    N)ÚCustomArgument)Úsplit_on_commas)Ú#validate_mutually_exclusive_handlerc                 C   s(   |   dt¡ |   dtdgg d¢ƒ¡ d S )Nz2building-argument-table.cloudwatch.put-metric-dataz0operation-args-parsed.cloudwatch.put-metric-dataÚmetric_data)Úmetric_nameÚ	timestampÚunitÚvalueÚ
dimensionsÚstatistic_values)ÚregisterÚ_promote_argsr   )Úevent_handler© r   úE/usr/lib/python3/dist-packages/awscli/customizations/putmetricdata.pyÚregister_put_metric_data!   s   ÿ
ÿþr   c                 K   s˜   d| d _ tddd�| d< tddd�| d< tdd	d�| d< td
dd�| d
< tddd�| d< tddd�| d< |jjd j}|jd }td|jd�| d< d S )NFzmetric-datazmetric-namezThe name of the metric.)Ú	help_textr   zyThe time stamp used for the metric.  If not specified, the default value is set to the time the metric data was received.r   zThe unit of metric.r	   a=  The value for the metric.  Although the --value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents.  Values with base-10 exponents greater than 126 (1 x 10^126) are truncated.  Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated.r
   aÌ  The --dimensions argument further expands on the identity of a metric using a Name=Value pair, separated by commas, for example: <code>--dimensions InstanceID=1-23456789,InstanceType=m1.small</code>. Note that the <code>--dimensions</code> argument has a different format when used in <code>get-metric-data</code>, where for the same example you would use the format <code>--dimensions Name=InstanceID,Value=i-aaba32d4 Name=InstanceType,value=m1.small </code>.zstatistic-valuesz2A set of statistical values describing the metric.Ú
MetricDataÚStorageResolutionzstorage-resolution)ÚrequiredÚPutMetricArgumentÚinput_shapeÚmembersÚmemberÚdocumentation)Úargument_tableÚoperation_modelÚkwargsr   Ústorage_resolutionr   r   r   r   +   s2   

ÿ
ÿ
ÿ
ÿ	
þ
ÿ
ÿr   c                    s   ‡ fdd„}|S )Nc                    s   ‡ ‡fdd„}|S )Nc                    s6   |d u rd S ˆ|vri g|ˆ< |ˆ d }ˆ | ||ƒS )Nr   r   )ÚselfÚ
parametersr	   Úfirst_element)ÚfuncÚnamer   r   Ú_add_to_params^   s   
zIinsert_first_element.<locals>._wrap_add_to_params.<locals>._add_to_paramsr   )r"   r$   ©r#   )r"   r   Ú_wrap_add_to_params]   s   z1insert_first_element.<locals>._wrap_add_to_paramsr   )r#   r&   r   r%   r   Úinsert_first_element\   s   r'   c                   @   s„   e Zd Zdd„ Zedƒdd„ ƒZedƒdd„ ƒZedƒdd	„ ƒZedƒd
d„ ƒZedƒdd„ ƒZ	edƒdd„ ƒZ
edƒdd„ ƒZdS )r   c                 C   s"   d| j  dd¡ }t| |ƒ||ƒS )Nz_add_param_%sú-Ú_)r#   ÚreplaceÚgetattr)r   r    r	   Úmethod_namer   r   r   Úadd_to_paramso   s   zPutMetricArgument.add_to_paramsr   c                 C   ó   ||d< d S )NÚ
MetricNamer   ©r   r!   r	   r   r   r   Ú_add_param_metric_names   ó   z(PutMetricArgument._add_param_metric_namec                 C   r.   )NÚUnitr   r0   r   r   r   Ú_add_param_unitw   r2   z!PutMetricArgument._add_param_unitc                 C   r.   )NÚ	Timestampr   r0   r   r   r   Ú_add_param_timestamp{   r2   z&PutMetricArgument._add_param_timestampc                 C   s   t  |¡|d< d S )NÚValue)ÚdecimalÚDecimalr0   r   r   r   Ú_add_param_value   s   z"PutMetricArgument._add_param_valuec                 C   s<   g }t |ƒD ]}| d¡\}}| ||dœ¡ q||d< d S )Nú=)ÚNamer7   Ú
Dimensions)r   ÚsplitÚappend)r   r!   r	   r
   ÚpairÚkeyr   r   r   Ú_add_param_dimensions„   s
   z'PutMetricArgument._add_param_dimensionsc                 C   s:   i }t |ƒD ]}| d¡\}}t |¡||< q||d< d S )Nr;   ÚStatisticValues)r   r>   r8   r9   )r   r!   r	   Ú
statisticsr@   rA   r   r   r   Ú_add_param_statistic_values�   s
   z-PutMetricArgument._add_param_statistic_valuesc                 C   s   t |ƒ|d< d S )Nr   )Úintr0   r   r   r   Ú_add_param_storage_resolutionœ   s   z/PutMetricArgument._add_param_storage_resolutionN)Ú__name__Ú
__module__Ú__qualname__r-   r'   r1   r4   r6   r:   rB   rE   rG   r   r   r   r   r   n   s     






r   )Ú__doc__r8   Úawscli.argumentsr   Úawscli.utilsr   Úawscli.customizations.utilsr   r   r   r'   r   r   r   r   r   Ú<module>   s   
1