o
    ‰L‘j‘  ã                   @   sD   d dl mZ ddlmZ dddddd	d
ddddœ
ZG dd„ dƒZdS )é   )Ú	nativestré   )Úlist_to_dictÚ
source_keyÚchunk_countÚmemory_usageÚtotal_samplesÚretention_msecsÚlast_timestampÚfirst_timestampÚmax_samples_per_chunkÚ
chunk_sizeÚduplicate_policy)
Ú	sourceKeyÚ
chunkCountÚmemoryUsageÚtotalSamplesÚretentionTimeÚlastTimestampÚfirstTimestampÚmaxSamplesPerChunkÚ	chunkSizeÚduplicatePolicyc                   @   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/

    Handles both RESP2 (flat list) and RESP3 (dict) responses.
    Nc                 C   s.  t |tƒr|}| d¡pi | _| d¡pi | _n"tttt|ddd… ƒ|ddd… ƒƒ}| d¡| _t| d¡ƒ| _| d¡| _	| d¡| _
| d¡| _| d	¡| _| d
¡| _| d¡| _| d¡| _d|v rs|d | _| jd | _d|v r||d | _d|v r“|d | _t | jtƒ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
        ÚrulesÚlabelsNr   r   r   r   r   r   r   r   r   r   é   r   r   )Ú
isinstanceÚdictÚgetr   r   ÚzipÚmapr   r   r   r   r   r   r	   r
   r   r   r   r   ÚbytesÚdecode)ÚselfÚargsÚresponse© r'   ú\/home/djax/ivt_ai_plugin/venv/lib/python3.10/site-packages/redis/commands/timeseries/info.pyÚ__init__,   s4   
$(
ÿ

ýzTSInfo.__init__c                 C   s"   z|   |¡W S  ty   Y d S w ©N)Ú__getitem__ÚAttributeError©r$   Úitemr'   r'   r(   r   m   s
   ÿz
TSInfo.getc                 C   s   t | t ||¡ƒS r*   )ÚgetattrÚ_FIELD_ALIASESr   r-   r'   r'   r(   r+   s   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"    Ar   N)Úhelpersr   Úutilsr   r0   r   r'   r'   r'   r(   Ú<module>   s    ö