o
    `®f“  ã                   @   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|v r[|d | _| jd | _d|v rd|d | _d|v r||d | _t| jƒtkr~| j ¡ | _dS dS 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Ú	sourceKeyÚ
chunkCountÚmemoryUsageÚtotalSamplesÚlabelsÚretentionTimeÚlastTimestampÚfirstTimestampÚmaxSamplesPerChunké   Ú	chunkSizeÚduplicatePolicy)ÚdictÚzipÚmapr   Úgetr   Ú
source_keyÚchunk_countÚmemory_usageÚtotal_samplesr   r   Úretention_msecsÚlast_timestampÚfirst_timestampÚmax_samples_per_chunkÚ
chunk_sizeÚduplicate_policyÚtypeÚbytesÚdecode)ÚselfÚargsÚresponse© r'   úW/home/ubuntu/webapp/venv/lib/python3.10/site-packages/redis/commands/timeseries/info.pyÚ__init__   s,   ($
ÿ

ýzTSInfo.__init__c                 C   s"   z|   |¡W S  ty   Y d S w ©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   Úlast_time_stampÚfirst_time_stampr   r   r    r)   r   r+   r'   r'   r'   r(   r      s"    :r   N)Úhelpersr   Úutilsr   r   r'   r'   r'   r(   Ú<module>   s    