U
    Œàôg—  ã                   @   s*   d dl mZ ddlmZ G dd„ dƒZdS )é   )Ú	nativestré   )Úlist_to_dictc                   @   sX   e Zd ZdZg Zg ZdZdZdZdZ	dZ
dZdZdZdZdZdd„ Zdd„ Zdd„ ZdS )	ÚTSInfozœ
    Hold information and statistics on the time-series.
    Can be created using ``tsinfo`` command
    https://redis.io/docs/latest/commands/ts.info/
    Nc                 C   sö   t ttt|ddd… ƒ|ddd… ƒƒ}| d¡| _| d¡| _| d¡| _| d¡| _| d¡| _	t
| d	¡ƒ| _| d
¡| _| d¡| _| d¡| _d|kr¶|d | _| jd | _d|krÈ|d | _d|krò|d | _t| jtƒrò| j ¡ | _dS )a  
        Hold information and statistics on the time-series.

        The supported params that can be passed as args:

        rules:
            A list of compaction rules of the time series.
        sourceKey:
            Key name for source time series in case the current series
            is a target of a rule.
        chunkCount:
            Number of Memory Chunks used for the time series.
        memoryUsage:
            Total number of bytes allocated for the time series.
        totalSamples:
            Total number of samples in the time series.
        labels:
            A list of label-value pairs that represent the metadata
            labels of the time series.
        retentionTime:
            Retention time, in milliseconds, for the time series.
        lastTimestamp:
            Last timestamp present in the time series.
        firstTimestamp:
            First timestamp present in the time series.
        maxSamplesPerChunk:
            Deprecated.
        chunkSize:
            Amount of memory, in bytes, allocated for data.
        duplicatePolicy:
            Policy that will define handling of duplicate samples.

        Can read more about on
        https://redis.io/docs/latest/develop/data-types/timeseries/configuration/#duplicate_policy
        Nr   r   ÚrulesÚ	sourceKeyZ
chunkCountZmemoryUsageZtotalSamplesÚlabelsZretentionTimeZlastTimestampZfirstTimestampZmaxSamplesPerChunké   Ú	chunkSizeZduplicatePolicy)ÚdictÚzipÚmapr   Úgetr   Z
source_keyÚchunk_countÚmemory_usageÚtotal_samplesr   r   Úretention_msecsZlast_timestampZfirst_timestampÚmax_samples_per_chunkÚ
chunk_sizeÚduplicate_policyÚ
isinstanceÚbytesÚdecode)ÚselfÚargsÚresponse© r   úB/tmp/pip-unpacked-wheel-f3sx1i9r/redis/commands/timeseries/info.pyÚ__init__   s(    $(
ÿ

zTSInfo.__init__c                 C   s(   z|   |¡W S  tk
r"   Y d S X d S ©N)Ú__getitem__ÚAttributeError©r   Úitemr   r   r   r   T   s    z
TSInfo.getc                 C   s
   t | |ƒS r   )Úgetattrr"   r   r   r   r    Z   s    zTSInfo.__getitem__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   Zlast_time_stampZfirst_time_stampr   r   r   r   r   r    r   r   r   r   r      s    :r   N)Zhelpersr   Úutilsr   r   r   r   r   r   Ú<module>   s   