o
    !d                     @   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)Zmetric_name	timestampunitvalue
dimensionsZstatistic_values)register_promote_argsr   )Zevent_handler r   Gusr/lib/python3.10/site-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.)Z	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PutMetricArgumentZinput_shapemembersmemberdocumentation)Zargument_tableZoperation_modelkwargsr   Z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 )NZ
MetricNamer   r   r   r   r   r   r   _add_param_metric_names      z(PutMetricArgument._add_param_metric_namec                 C   r&   )NZUnitr   r'   r   r   r   _add_param_unitw   r)   z!PutMetricArgument._add_param_unitc                 C   r&   )NZ	Timestampr   r'   r   r   r   _add_param_timestamp{   r)   z&PutMetricArgument._add_param_timestampc                 C   s   t ||d< d S )NValue)decimalDecimalr'   r   r   r   _add_param_value   s   z"PutMetricArgument._add_param_valuec                 C   s<   g }t |D ]}|d\}}|||d q||d< d S )N=)Namer,   Z
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 )Nr0   ZStatisticValues)r   r2   r-   r.   )r   r   r   
statisticsr4   r5   r   r   r   _add_param_statistic_values   s
   z-PutMetricArgument._add_param_statistic_valuesc                 C   s   t ||d< d S )Nr   )intr'   r   r   r   _add_param_storage_resolution   s   z/PutMetricArgument._add_param_storage_resolutionN)__name__
__module____qualname__r%   r   r(   r*   r+   r/   r6   r8   r:   r   r   r   r   r   n   s     






r   )__doc__r-   Zawscli.argumentsr   Zawscli.utilsr   Zawscli.customizations.utilsr   r   r   r   r   r   r   r   r   <module>   s   
1