o
    h                     @   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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
isinstancebytesdecode)selfargsresponse r'   `/var/www/html/optinet_system/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    