
    Pf                         d dl mZmZmZmZmZ d dlmZ d dlm	Z	m
Z
 dZdZdZdZdZd	Zd
ZdZdZdZdZdZdZdZdZdZdZ G d d          ZdS )    )DictListOptionalTupleUnion)	DataError)KeyTNumberzTS.ADDzTS.ALTERzTS.CREATERULEz	TS.CREATEz	TS.DECRBYzTS.DELETERULEzTS.DELzTS.GETz	TS.INCRBYzTS.INFOzTS.MADDzTS.MGETz	TS.MRANGEzTS.MREVRANGEzTS.QUERYINDEXzTS.RANGEzTS.REVRANGEc            $       4   e Zd ZdZ	 	 	 	 	 	 	 dOdedee         dee         deee	e	f                  dee         d	ee	         d
ee         dee
         fdZ	 	 	 	 	 	 dPdedee         deee	e	f                  dee         d	ee	         d
ee         dee
         fdZ	 	 	 	 	 	 	 	 dQdedeee	f         de
dee         dee         deee	e	f                  dee         d	ee	         d
ee         dee
         dee	         fdZdeeeeee	f         e
f                  fdZ	 	 	 	 	 	 	 	 dRdede
deeee	f                  dee         dee         deee	e	f                  dee         d	ee	         d
ee         dee
         fdZ	 	 	 	 	 	 	 	 dRdede
deeee	f                  dee         dee         deee	e	f                  dee         d	ee	         d
ee         dee
         fdZdededefdZ	 dSdedede	dedee         f
dZdedefdZdedeee	f         deee	f         d ee         dee	         dee         d!eee                  d"ee         d#ee         d$eeee	f                  d%ee         d&ee	         d'ee         fd(Z	 	 	 	 	 	 	 	 	 	 dTdedeee	f         deee	f         d ee         dee	         dee         d!eee                  d"ee         d#ee         d$eeee	f                  d%ee         d&ee	         d'ee         fd*Z	 	 	 	 	 	 	 	 	 	 dTdedeee	f         deee	f         d ee         dee	         dee         d!eee                  d"ee         d#ee         d$eeee	f                  d%ee         d&ee	         d'ee         fd+Zdee	         dee         d ee         d,ee	         deee	f         deee	f         d-ee         d!eee                  d"ee         d#ee         d.ee	         d/ee	         d0eee	                  d$eeee	f                  d%ee         d&ee	         d'ee         f"d1Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 dUdeee	f         deee	f         d,ee	         d ee         dee	         dee         d-ee         d!eee                  d"ee         d#ee         d.ee	         d/ee	         d0eee	                  d$eeee	f                  d%ee         d&ee	         d'ee         f"d2Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 dUdeee	f         deee	f         d,ee	         d ee         dee	         dee         d-ee         d!eee                  d"ee         d#ee         d.ee	         d/ee	         d0eee	                  d$eeee	f                  d%ee         d&ee	         d'ee         f"d3ZdVded%ee         fd4Z	 	 	 dWd,ee	         d-ee         d0eee	                  d%ee         fd5Zdefd6Zd,ee	         fd7Z e!d8ee	         dee         fd9            Z"e!d8ee	         d-ee         d0eee	                  fd:            Z#e!d8ee	         d.ee	         d/ee	         fd;            Z$e!d8ee	         d<ee         fd=            Z%e!d8ee	         deee	                  fd>            Z&e!d8ee	         d ee         fd?            Z'e!d8ee	         dee         fd@            Z(e!d8ee	         d$eeee	f                  fdA            Z)e!d8ee	         dee	         dee         fdB            Z*e!d8ee	         dee         fdC            Z+e!d8ee	         d	ee	         fdD            Z,e!d8ee	         dee	         fdE            Z-e!d8ee	         dFeee                  fdG            Z.e!d8ee	         dHee         dIee         fdJ            Z/e!d8ee	         d%ee         fdK            Z0e!d8ee	         d&ee	         fdL            Z1e!d8ee	         d'ee         fdM            Z2e!	 	 dXd8ee	         d
ee         dee
         fdN            Z3dS )YTimeSeriesCommandszRedisTimeSeries Commands.NFkeyretention_msecsuncompressedlabels
chunk_sizeduplicate_policyignore_max_time_diffignore_max_val_diffc	                 8   |g}	|                      |	|           |                     |	|           |                     |	|           |                     |	|           |                     |	|           |                     |	||            | j        t          g|	R  S )a
  
        Create a new time-series.

        For more information see https://redis.io/commands/ts.create/

        Args:
            key:
                The time-series key.
            retention_msecs:
                Maximum age for samples, compared to the highest reported timestamp in
                milliseconds. If `None` or `0` is passed, the series is not trimmed at
                all.
            uncompressed:
                Changes data storage from compressed (default) to uncompressed.
            labels:
                A dictionary of label-value pairs that represent metadata labels of the
                key.
            chunk_size:
                Memory size, in bytes, allocated for each data chunk. Must be a multiple
                of 8 in the range `[48..1048576]`. In earlier versions of the module the
                minimum value was different.
            duplicate_policy:
                Policy for handling multiple samples with identical timestamps. Can be
                one of:
                    - 'block': An error will occur and the new value will be ignored.
                    - 'first': Ignore the new value.
                    - 'last': Override with the latest value.
                    - 'min': Only override if the value is lower than the existing
                      value.
                    - 'max': Only override if the value is higher than the existing
                      value.
                    - 'sum': If a previous sample exists, add the new sample to it so
                      that the updated value is equal to (previous + new). If no
                      previous sample exists, set the updated value equal to the new
                      value.
            ignore_max_time_diff:
                A non-negative integer value, in milliseconds, that sets an ignore
                threshold for added timestamps. If the difference between the last
                timestamp and the new timestamp is lower than this threshold, the new
                entry is ignored. Only applicable if `duplicate_policy` is set to
                `last`, and if `ignore_max_val_diff` is also set. Available since
                RedisTimeSeries version 1.12.0.
            ignore_max_val_diff:
                A non-negative floating point value, that sets an ignore threshold for
                added values. If the difference between the last value and the new value
                is lower than this threshold, the new entry is ignored. Only applicable
                if `duplicate_policy` is set to `last`, and if `ignore_max_time_diff` is
                also set. Available since RedisTimeSeries version 1.12.0.
        )_append_retention_append_uncompressed_append_chunk_size_append_duplicate_policy_append_labels_append_insertion_filtersexecute_command
CREATE_CMD)
selfr   r   r   r   r   r   r   r   paramss
             T/var/www/html/env/lib/python3.11/site-packages/redis/commands/timeseries/commands.pycreatezTimeSeriesCommands.create   s    x v777!!&,777
333%%f.>???FF+++&&(*=	
 	
 	
 $t#J88888    c                    |g}|                      ||           |                     ||           |                     ||           |                     ||           |                     |||            | j        t          g|R  S )ag
  
        Update an existing time series.

        For more information see https://redis.io/commands/ts.alter/

        Args:
            key:
                The time-series key.
            retention_msecs:
                Maximum age for samples, compared to the highest reported timestamp in
                milliseconds. If `None` or `0` is passed, the series is not trimmed at
                all.
            labels:
                A dictionary of label-value pairs that represent metadata labels of the
                key.
            chunk_size:
                Memory size, in bytes, allocated for each data chunk. Must be a multiple
                of 8 in the range `[48..1048576]`. In earlier versions of the module the
                minimum value was different. Changing this value does not affect
                existing chunks.
            duplicate_policy:
                Policy for handling multiple samples with identical timestamps. Can be
                one of:
                    - 'block': An error will occur and the new value will be ignored.
                    - 'first': Ignore the new value.
                    - 'last': Override with the latest value.
                    - 'min': Only override if the value is lower than the existing
                      value.
                    - 'max': Only override if the value is higher than the existing
                      value.
                    - 'sum': If a previous sample exists, add the new sample to it so
                      that the updated value is equal to (previous + new). If no
                      previous sample exists, set the updated value equal to the new
                      value.
            ignore_max_time_diff:
                A non-negative integer value, in milliseconds, that sets an ignore
                threshold for added timestamps. If the difference between the last
                timestamp and the new timestamp is lower than this threshold, the new
                entry is ignored. Only applicable if `duplicate_policy` is set to
                `last`, and if `ignore_max_val_diff` is also set. Available since
                RedisTimeSeries version 1.12.0.
            ignore_max_val_diff:
                A non-negative floating point value, that sets an ignore threshold for
                added values. If the difference between the last value and the new value
                is lower than this threshold, the new entry is ignored. Only applicable
                if `duplicate_policy` is set to `last`, and if `ignore_max_time_diff` is
                also set. Available since RedisTimeSeries version 1.12.0.
        )r   r   r   r   r   r   	ALTER_CMD)	r   r   r   r   r   r   r   r   r   s	            r    alterzTimeSeriesCommands.alterd   s    t v777
333%%f.>???FF+++&&(*=	
 	
 	
 $t#I77777r"   	timestampvalueon_duplicatec                 h   |||g}|                      ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||	|
           |                     ||            | j        t          g|R  S )aa  
        Append a sample to a time series. When the specified key does not exist, a new
        time series is created.

        For more information see https://redis.io/commands/ts.add/

        Args:
            key:
                The time-series key.
            timestamp:
                Timestamp of the sample. `*` can be used for automatic timestamp (using
                the system clock).
            value:
                Numeric data value of the sample.
            retention_msecs:
                Maximum age for samples, compared to the highest reported timestamp in
                milliseconds. If `None` or `0` is passed, the series is not trimmed at
                all.
            uncompressed:
                Changes data storage from compressed (default) to uncompressed.
            labels:
                A dictionary of label-value pairs that represent metadata labels of the
                key.
            chunk_size:
                Memory size, in bytes, allocated for each data chunk. Must be a multiple
                of 8 in the range `[48..1048576]`. In earlier versions of the module the
                minimum value was different.
            duplicate_policy:
                Policy for handling multiple samples with identical timestamps. Can be
                one of:
                    - 'block': An error will occur and the new value will be ignored.
                    - 'first': Ignore the new value.
                    - 'last': Override with the latest value.
                    - 'min': Only override if the value is lower than the existing
                      value.
                    - 'max': Only override if the value is higher than the existing
                      value.
                    - 'sum': If a previous sample exists, add the new sample to it so
                      that the updated value is equal to (previous + new). If no
                      previous sample exists, set the updated value equal to the new
                      value.
            ignore_max_time_diff:
                A non-negative integer value, in milliseconds, that sets an ignore
                threshold for added timestamps. If the difference between the last
                timestamp and the new timestamp is lower than this threshold, the new
                entry is ignored. Only applicable if `duplicate_policy` is set to
                `last`, and if `ignore_max_val_diff` is also set. Available since
                RedisTimeSeries version 1.12.0.
            ignore_max_val_diff:
                A non-negative floating point value, that sets an ignore threshold for
                added values. If the difference between the last value and the new value
                is lower than this threshold, the new entry is ignored. Only applicable
                if `duplicate_policy` is set to `last`, and if `ignore_max_time_diff` is
                also set. Available since RedisTimeSeries version 1.12.0.
            on_duplicate:
                Use a specific duplicate policy for the specified timestamp. Overrides
                the duplicate policy set by `duplicate_policy`.
        )	r   r   r   r   r   r   _append_on_duplicater   ADD_CMD)r   r   r&   r'   r   r   r   r   r   r   r   r(   r   s                r    addzTimeSeriesCommands.add   s    P y%(v777!!&,777
333%%f.>???FF+++&&(*=	
 	
 	
 	!!&,777#t#G5f5555r"   
ktv_tuplesc                 `    g }|D ]}|                     |            | j        t          g|R  S )ay  
        Append new samples to one or more time series.

        Each time series must already exist.

        The method expects a list of tuples. Each tuple should contain three elements:
        (`key`, `timestamp`, `value`). The `value` will be appended to the time series
        identified by 'key', at the given 'timestamp'.

        For more information see https://redis.io/commands/ts.madd/

        Args:
            ktv_tuples:
                A list of tuples, where each tuple contains:
                    - `key`: The key of the time series.
                    - `timestamp`: The timestamp at which the value should be appended.
                    - `value`: The value to append to the time series.

        Returns:
            A list that contains, for each sample, either the timestamp that was used,
            or an error, if the sample could not be added.
        )extendr   MADD_CMD)r   r-   r   ktvs       r    maddzTimeSeriesCommands.madd   sH    .  	 	CMM##t#H6v6666r"   c                 f   ||g}|                      ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||	|
            | j        t          g|R  S )a9  
        Increment the latest sample's of a series. When the specified key does not
        exist, a new time series is created.

        This command can be used as a counter or gauge that automatically gets history
        as a time series.

        For more information see https://redis.io/commands/ts.incrby/

        Args:
            key:
                The time-series key.
            value:
                Numeric value to be added (addend).
            timestamp:
                Timestamp of the sample. `*` can be used for automatic timestamp (using
                the system clock). `timestamp` must be equal to or higher than the
                maximum existing timestamp in the series. When equal, the value of the
                sample with the maximum existing timestamp is increased. If it is
                higher, a new sample with a timestamp set to `timestamp` is created, and
                its value is set to the value of the sample with the maximum existing
                timestamp plus the addend.
            retention_msecs:
                Maximum age for samples, compared to the highest reported timestamp in
                milliseconds. If `None` or `0` is passed, the series is not trimmed at
                all.
            uncompressed:
                Changes data storage from compressed (default) to uncompressed.
            labels:
                A dictionary of label-value pairs that represent metadata labels of the
                key.
            chunk_size:
                Memory size, in bytes, allocated for each data chunk. Must be a multiple
                of 8 in the range `[48..1048576]`. In earlier versions of the module the
                minimum value was different.
            duplicate_policy:
                Policy for handling multiple samples with identical timestamps. Can be
                one of:
                    - 'block': An error will occur and the new value will be ignored.
                    - 'first': Ignore the new value.
                    - 'last': Override with the latest value.
                    - 'min': Only override if the value is lower than the existing
                      value.
                    - 'max': Only override if the value is higher than the existing
                      value.
                    - 'sum': If a previous sample exists, add the new sample to it so
                      that the updated value is equal to (previous + new). If no
                      previous sample exists, set the updated value equal to the new
                      value.
            ignore_max_time_diff:
                A non-negative integer value, in milliseconds, that sets an ignore
                threshold for added timestamps. If the difference between the last
                timestamp and the new timestamp is lower than this threshold, the new
                entry is ignored. Only applicable if `duplicate_policy` is set to
                `last`, and if `ignore_max_val_diff` is also set. Available since
                RedisTimeSeries version 1.12.0.
            ignore_max_val_diff:
                A non-negative floating point value, that sets an ignore threshold for
                added values. If the difference between the last value and the new value
                is lower than this threshold, the new entry is ignored. Only applicable
                if `duplicate_policy` is set to `last`, and if `ignore_max_time_diff` is
                also set. Available since RedisTimeSeries version 1.12.0.

        Returns:
            The timestamp of the sample that was modified or added.
        )	_append_timestampr   r   r   r   r   r   r   
INCRBY_CMDr   r   r'   r&   r   r   r   r   r   r   r   r   s               r    incrbyzTimeSeriesCommands.incrby      ^ uvy111v777!!&,777
333%%f.>???FF+++&&(*=	
 	
 	
 $t#J88888r"   c                 f   ||g}|                      ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||	|
            | j        t          g|R  S )a>  
        Decrement the latest sample's of a series. When the specified key does not
        exist, a new time series is created.

        This command can be used as a counter or gauge that automatically gets history
        as a time series.

        For more information see https://redis.io/commands/ts.decrby/

        Args:
            key:
                The time-series key.
            value:
                Numeric value to subtract (subtrahend).
            timestamp:
                Timestamp of the sample. `*` can be used for automatic timestamp (using
                the system clock). `timestamp` must be equal to or higher than the
                maximum existing timestamp in the series. When equal, the value of the
                sample with the maximum existing timestamp is decreased. If it is
                higher, a new sample with a timestamp set to `timestamp` is created, and
                its value is set to the value of the sample with the maximum existing
                timestamp minus subtrahend.
            retention_msecs:
                Maximum age for samples, compared to the highest reported timestamp in
                milliseconds. If `None` or `0` is passed, the series is not trimmed at
                all.
            uncompressed:
                Changes data storage from compressed (default) to uncompressed.
            labels:
                A dictionary of label-value pairs that represent metadata labels of the
                key.
            chunk_size:
                Memory size, in bytes, allocated for each data chunk. Must be a multiple
                of 8 in the range `[48..1048576]`. In earlier versions of the module the
                minimum value was different.
            duplicate_policy:
                Policy for handling multiple samples with identical timestamps. Can be
                one of:
                    - 'block': An error will occur and the new value will be ignored.
                    - 'first': Ignore the new value.
                    - 'last': Override with the latest value.
                    - 'min': Only override if the value is lower than the existing
                      value.
                    - 'max': Only override if the value is higher than the existing
                      value.
                    - 'sum': If a previous sample exists, add the new sample to it so
                      that the updated value is equal to (previous + new). If no
                      previous sample exists, set the updated value equal to the new
                      value.
            ignore_max_time_diff:
                A non-negative integer value, in milliseconds, that sets an ignore
                threshold for added timestamps. If the difference between the last
                timestamp and the new timestamp is lower than this threshold, the new
                entry is ignored. Only applicable if `duplicate_policy` is set to
                `last`, and if `ignore_max_val_diff` is also set. Available since
                RedisTimeSeries version 1.12.0.
            ignore_max_val_diff:
                A non-negative floating point value, that sets an ignore threshold for
                added values. If the difference between the last value and the new value
                is lower than this threshold, the new entry is ignored. Only applicable
                if `duplicate_policy` is set to `last`, and if `ignore_max_time_diff` is
                also set. Available since RedisTimeSeries version 1.12.0.

        Returns:
            The timestamp of the sample that was modified or added.
        )	r4   r   r   r   r   r   r   r   
DECRBY_CMDr6   s               r    decrbyzTimeSeriesCommands.decrbyw  r8   r"   	from_timeto_timec                 <    |                      t          |||          S )aP  
        Delete all samples between two timestamps for a given time series.

        The given timestamp interval is closed (inclusive), meaning that samples whose
        timestamp equals `from_time` or `to_time` are also deleted.

        For more information see https://redis.io/commands/ts.del/

        Args:
            key:
                The time-series key.
            from_time:
                Start timestamp for the range deletion.
            to_time:
                End timestamp for the range deletion.

        Returns:
            The number of samples deleted.
        )r   DEL_CMD)r   r   r<   r=   s       r    deletezTimeSeriesCommands.delete  s    ( ##GS)WEEEr"   
source_keydest_keyaggregation_typebucket_size_msecalign_timestampc                     ||g}|                      |||           ||                    |            | j        t          g|R  S )a<  
        Create a compaction rule from values added to `source_key` into `dest_key`.

        For more information see https://redis.io/commands/ts.createrule/

        Args:
            source_key:
                Key name for source time series.
            dest_key:
                Key name for destination (compacted) time series.
            aggregation_type:
                Aggregation type: One of the following:
                [`avg`, `sum`, `min`, `max`, `range`, `count`, `first`, `last`, `std.p`,
                `std.s`, `var.p`, `var.s`, `twa`]
            bucket_size_msec:
                Duration of each bucket, in milliseconds.
            align_timestamp:
                Assure that there is a bucket that starts at exactly align_timestamp and
                align all other buckets accordingly.
        )_append_aggregationappendr   CREATERULE_CMD)r   rA   rB   rC   rD   rE   r   s          r    
createrulezTimeSeriesCommands.createrule  s[    8 h'  )9;KLLL&MM/***#t#N<V<<<<r"   c                 :    |                      t          ||          S )z
        Delete a compaction rule from `source_key` to `dest_key`.

        For more information see https://redis.io/commands/ts.deleterule/
        )r   DELETERULE_CMD)r   rA   rB   s      r    
deleterulezTimeSeriesCommands.deleterule  s     ##NJIIIr"   countfilter_by_tsfilter_by_min_valuefilter_by_max_valuealignlatestbucket_timestampemptyc                 t   |||g}|                      ||           |                     ||           |                     |||	           |                     ||           |                     ||
           |                     |||           |                     ||           |                     ||           |S )z*Create TS.RANGE and TS.REVRANGE arguments.)_append_latest_append_filer_by_ts_append_filer_by_value_append_count_append_alignrG   _append_bucket_timestamp_append_emptyr   r   r<   r=   rN   rC   rD   rO   rP   rQ   rR   rS   rT   rU   r   s                  r    __range_paramsz!TimeSeriesCommands.__range_params  s    " y'*FF+++  666##F,?ATUUU65)))65)))  )9;KLLL%%f.>???65)))r"   r   c                 j    |                      |||||||||	|
|||          } | j        t          g|R  S )a  
        Query a range in forward direction for a specific time-series.

        For more information see https://redis.io/commands/ts.range/

        Args:
            key:
                Key name for timeseries.
            from_time:
                Start timestamp for the range query. `-` can be used to express the
                minimum possible timestamp (0).
            to_time:
                End timestamp for range query, `+` can be used to express the maximum
                possible timestamp.
            count:
                Limits the number of returned samples.
            aggregation_type:
                Optional aggregation type. Can be one of [`avg`, `sum`, `min`, `max`,
                `range`, `count`, `first`, `last`, `std.p`, `std.s`, `var.p`, `var.s`,
                `twa`]
            bucket_size_msec:
                Time bucket for aggregation in milliseconds.
            filter_by_ts:
                List of timestamps to filter the result by specific timestamps.
            filter_by_min_value:
                Filter result by minimum value (must mention also
                `filter by_max_value`).
            filter_by_max_value:
                Filter result by maximum value (must mention also
                `filter by_min_value`).
            align:
                Timestamp for alignment control for aggregation.
            latest:
                Used when a time series is a compaction, reports the compacted value of
                the latest possibly partial bucket.
            bucket_timestamp:
                Controls how bucket timestamps are reported. Can be one of [`-`, `low`,
                `+`, `high`, `~`, `mid`].
            empty:
                Reports aggregations for empty buckets.
        )!_TimeSeriesCommands__range_paramsr   	RANGE_CMDr^   s                  r    rangezTimeSeriesCommands.range1  s^    r $$
 
 $t#I77777r"   c                 j    |                      |||||||||	|
|||          } | j        t          g|R  S )aB  
        Query a range in reverse direction for a specific time-series.

        **Note**: This command is only available since RedisTimeSeries >= v1.4

        For more information see https://redis.io/commands/ts.revrange/

        Args:
            key:
                Key name for timeseries.
            from_time:
                Start timestamp for the range query. `-` can be used to express the
                minimum possible timestamp (0).
            to_time:
                End timestamp for range query, `+` can be used to express the maximum
                possible timestamp.
            count:
                Limits the number of returned samples.
            aggregation_type:
                Optional aggregation type. Can be one of [`avg`, `sum`, `min`, `max`,
                `range`, `count`, `first`, `last`, `std.p`, `std.s`, `var.p`, `var.s`,
                `twa`]
            bucket_size_msec:
                Time bucket for aggregation in milliseconds.
            filter_by_ts:
                List of timestamps to filter the result by specific timestamps.
            filter_by_min_value:
                Filter result by minimum value (must mention also
                `filter_by_max_value`).
            filter_by_max_value:
                Filter result by maximum value (must mention also
                `filter_by_min_value`).
            align:
                Timestamp for alignment control for aggregation.
            latest:
                Used when a time series is a compaction, reports the compacted value of
                the latest possibly partial bucket.
            bucket_timestamp:
                Controls how bucket timestamps are reported. Can be one of [`-`, `low`,
                `+`, `high`, `~`, `mid`].
            empty:
                Reports aggregations for empty buckets.
        )ra   r   REVRANGE_CMDr^   s                  r    revrangezTimeSeriesCommands.revrange{  s^    v $$
 
 $t#L:6::::r"   filterswith_labelsgroupbyreduceselect_labelsc                    ||g}|                      ||           |                     ||           |                     ||	|
           |                     |||           |                     ||           |                     ||           |                     |||           |                     ||           |                     ||           |	                    dg           ||z  }| 
                    |||           |S )z,Create TS.MRANGE and TS.MREVRANGE arguments.FILTER)rW   rX   rY   _append_with_labelsrZ   r[   rG   r\   r]   r/   _append_groupby_reduce)r   rC   rD   rN   rg   r<   r=   rh   rO   rP   rQ   ri   rj   rk   rR   rS   rT   rU   r   s                      r    __mrange_paramsz"TimeSeriesCommands.__mrange_params  s   * W%FF+++  666##F,?ATUUU  mDDD65)))65)))  )9;KLLL%%f.>???65)))xj!!!'##FGV<<<r"   c                 r    |                      |||||||||	|
|||||||          } | j        t          g|R  S )aM	  
        Query a range across multiple time-series by filters in forward direction.

        For more information see https://redis.io/commands/ts.mrange/

        Args:
            from_time:
                Start timestamp for the range query. `-` can be used to express the
                minimum possible timestamp (0).
            to_time:
                End timestamp for range query, `+` can be used to express the maximum
                possible timestamp.
            filters:
                Filter to match the time-series labels.
            count:
                Limits the number of returned samples.
            aggregation_type:
                Optional aggregation type. Can be one of [`avg`, `sum`, `min`, `max`,
                `range`, `count`, `first`, `last`, `std.p`, `std.s`, `var.p`, `var.s`,
                `twa`]
            bucket_size_msec:
                Time bucket for aggregation in milliseconds.
            with_labels:
                Include in the reply all label-value pairs representing metadata labels
                of the time series.
            filter_by_ts:
                List of timestamps to filter the result by specific timestamps.
            filter_by_min_value:
                Filter result by minimum value (must mention also
                `filter_by_max_value`).
            filter_by_max_value:
                Filter result by maximum value (must mention also
                `filter_by_min_value`).
            groupby:
                Grouping by fields the results (must mention also `reduce`).
            reduce:
                Applying reducer functions on each group. Can be one of [`avg` `sum`,
                `min`, `max`, `range`, `count`, `std.p`, `std.s`, `var.p`, `var.s`].
            select_labels:
                Include in the reply only a subset of the key-value pair labels of a
                series.
            align:
                Timestamp for alignment control for aggregation.
            latest:
                Used when a time series is a compaction, reports the compacted value of
                the latest possibly partial bucket.
            bucket_timestamp:
                Controls how bucket timestamps are reported. Can be one of [`-`, `low`,
                `+`, `high`, `~`, `mid`].
            empty:
                Reports aggregations for empty buckets.
        )"_TimeSeriesCommands__mrange_paramsr   
MRANGE_CMDr   r<   r=   rg   rN   rC   rD   rh   rO   rP   rQ   ri   rj   rk   rR   rS   rT   rU   r   s                      r    mrangezTimeSeriesCommands.mrange  sj    P %%#
 
( $t#J88888r"   c                 r    |                      |||||||||	|
|||||||          } | j        t          g|R  S )aQ	  
        Query a range across multiple time-series by filters in reverse direction.

        For more information see https://redis.io/commands/ts.mrevrange/

        Args:
            from_time:
                Start timestamp for the range query. '-' can be used to express the
                minimum possible timestamp (0).
            to_time:
                End timestamp for range query, '+' can be used to express the maximum
                possible timestamp.
            filters:
                Filter to match the time-series labels.
            count:
                Limits the number of returned samples.
            aggregation_type:
                Optional aggregation type. Can be one of [`avg`, `sum`, `min`, `max`,
                `range`, `count`, `first`, `last`, `std.p`, `std.s`, `var.p`, `var.s`,
                `twa`].
            bucket_size_msec:
                Time bucket for aggregation in milliseconds.
            with_labels:
                Include in the reply all label-value pairs representing metadata labels
                of the time series.
            filter_by_ts:
                List of timestamps to filter the result by specific timestamps.
            filter_by_min_value:
                Filter result by minimum value (must mention also
                `filter_by_max_value`).
            filter_by_max_value:
                Filter result by maximum value (must mention also
                `filter_by_min_value`).
            groupby:
                Grouping by fields the results (must mention also `reduce`).
            reduce:
                Applying reducer functions on each group. Can be one of [`avg` `sum`,
                `min`, `max`, `range`, `count`, `std.p`, `std.s`, `var.p`, `var.s`].
            select_labels:
                Include in the reply only a subset of the key-value pair labels of a
                series.
            align:
                Timestamp for alignment control for aggregation.
            latest:
                Used when a time series is a compaction, reports the compacted value of
                the latest possibly partial bucket.
            bucket_timestamp:
                Controls how bucket timestamps are reported. Can be one of [`-`, `low`,
                `+`, `high`, `~`, `mid`].
            empty:
                Reports aggregations for empty buckets.
        )rr   r   MREVRANGE_CMDrt   s                      r    	mrevrangezTimeSeriesCommands.mrevrangeI  sj    P %%#
 
( $t#M;F;;;;r"   c                 Z    |g}|                      ||            | j        t          g|R  S )a$  
        Get the last sample of `key`.

        For more information see https://redis.io/commands/ts.get/

        Args:
            latest:
                Used when a time series is a compaction, reports the compacted value of
                the latest (possibly partial) bucket.
        )rW   r   GET_CMD)r   r   rS   r   s       r    getzTimeSeriesCommands.get  s<     FF+++#t#G5f5555r"   c                     g }|                      ||           |                     |||           |                    dg           ||z  } | j        t          g|R  S )a  
        Get the last samples matching the specific `filter`.

        For more information see https://redis.io/commands/ts.mget/

        Args:
            filters:
                Filter to match the time-series labels.
            with_labels:
                Include in the reply all label-value pairs representing metadata labels
                of the time series.
            select_labels:
                Include in the reply only a subset of the key-value pair labels o the
                time series.
            latest:
                Used when a time series is a compaction, reports the compacted value of
                the latest possibly partial bucket.
        rm   )rW   rn   r/   r   MGET_CMD)r   rg   rh   rk   rS   r   s         r    mgetzTimeSeriesCommands.mget  sp    2 FF+++  mDDDxj!!!'#t#H6v6666r"   c                 8    |                      t          |          S )zp
        Get information of `key`.

        For more information see https://redis.io/commands/ts.info/
        )r   INFO_CMD)r   r   s     r    infozTimeSeriesCommands.info  s     ##Hc222r"   c                 (     | j         t          g|R  S )z
        Get all time series keys matching the `filter` list.

        For more information see https://redis.io/commands/ts.queryindex/
        )r   QUERYINDEX_CMD)r   rg   s     r    
queryindexzTimeSeriesCommands.queryindex  s     $t#N=W====r"   r   c                 <    |r|                      ddg           dS dS )z"Append UNCOMPRESSED tag to params.ENCODINGUNCOMPRESSEDNr/   )r   r   s     r    r   z'TimeSeriesCommands._append_uncompressed  s3      	8MM:~677777	8 	8r"   c                     |r|rt          d          |r|                     dg           |r|                     dg|           dS dS )z!Append labels behavior to params.z:with_labels and select_labels cannot be provided together.
WITHLABELSSELECTED_LABELSN)r   r/   )r   rh   rk   s      r    rn   z&TimeSeriesCommands._append_with_labels  sy      	= 	L    	*MM<.))) 	?MM,=}=>>>>>	? 	?r"   c                 l    |/|/|                      d|d|                                g           dS dS dS )z)Append GROUPBY REDUCE property to params.NGROUPBYREDUCE)r/   upper)r   ri   rj   s      r    ro   z)TimeSeriesCommands._append_groupby_reduce  sF    
 6#5MM9gxHIIIII #5#5r"   	retentionc                 <    ||                      d|g           dS dS )z$Append RETENTION property to params.N	RETENTIONr   )r   r   s     r    r   z$TimeSeriesCommands._append_retention  /      MM;	233333 ! r"   c                     |rF|                      d           |                                D ]\  }}|                     ||g           dS dS )z!Append LABELS property to params.LABELSN)rH   itemsr/   )r   r   kvs       r    r   z!TimeSeriesCommands._append_labels  sf      	&MM(### & &1q!f%%%%	& 	&& &r"   c                 <    ||                      d|g           dS dS )z Append COUNT property to params.NCOUNTr   )r   rN   s     r    rZ   z TimeSeriesCommands._append_count  /     MM7E*+++++ r"   c                 <    ||                      d|g           dS dS )z$Append TIMESTAMP property to params.N	TIMESTAMPr   )r   r&   s     r    r4   z$TimeSeriesCommands._append_timestamp  r   r"   c                 <    ||                      d|g           dS dS )z Append ALIGN property to params.NALIGNr   )r   rR   s     r    r[   z TimeSeriesCommands._append_align  r   r"   c                 >    ||                      d||g           dS dS )z&Append AGGREGATION property to params.NAGGREGATIONr   )r   rC   rD   s      r    rG   z&TimeSeriesCommands._append_aggregation%  s3     'MM=*:<LMNNNNN ('r"   c                 <    ||                      d|g           dS dS )z%Append CHUNK_SIZE property to params.N
CHUNK_SIZEr   )r   r   s     r    r   z%TimeSeriesCommands._append_chunk_size/  s/     !MM<455555 "!r"   c                 <    ||                      d|g           dS dS )z+Append DUPLICATE_POLICY property to params.NDUPLICATE_POLICYr   )r   r   s     r    r   z+TimeSeriesCommands._append_duplicate_policy5  s1     'MM-/?@AAAAA ('r"   c                 <    ||                      d|g           dS dS )z'Append ON_DUPLICATE property to params.NON_DUPLICATEr   )r   r(   s     r    r*   z'TimeSeriesCommands._append_on_duplicate;  s/     #MM><899999 $#r"   ts_listc                 >    ||                      dg|           dS dS )z'Append FILTER_BY_TS property to params.NFILTER_BY_TSr   )r   r   s     r    rX   z&TimeSeriesCommands._append_filer_by_tsA  s2     MM>4G455555 r"   	min_value	max_valuec                 F    |||                      d||g           dS dS dS )z*Append FILTER_BY_VALUE property to params.NFILTER_BY_VALUEr   )r   r   r   s      r    rY   z)TimeSeriesCommands._append_filer_by_valueG  s=    
  Y%:MM,iCDDDDD ! %:%:r"   c                 8    |r|                      d           dS dS )z!Append LATEST property to params.LATESTNrH   )r   rS   s     r    rW   z!TimeSeriesCommands._append_latestO  s.      	$MM(#####	$ 	$r"   c                 <    ||                      d|g           dS dS )z+Append BUCKET_TIMESTAMP property to params.NBUCKETTIMESTAMPr   )r   rT   s     r    r\   z+TimeSeriesCommands._append_bucket_timestampU  s1     'MM,.>?@@@@@ ('r"   c                 8    |r|                      d           dS dS )z Append EMPTY property to params.EMPTYNr   )r   rU   s     r    r]   z TimeSeriesCommands._append_empty[  s.      	#MM'"""""	# 	#r"   c                     |du |du k    rt          d          |6|6|                     dt          |          t          |          g           dS dS dS )z#Append insertion filters to params.Nz>Both ignore_max_time_diff and ignore_max_val_diff must be set.IGNORE)
ValueErrorr/   str)r   r   r   s      r    r   z,TimeSeriesCommands._append_insertion_filtersa  s     !D(.AT.IJJP    +0C0OMM3344c:M6N6NO     ,+0O0Or"   )NFNNNNN)NNNNNN)NFNNNNNN)NNFNNNNN)N)
NNr   NNNNFNF)NNr   FNNNNNNNFNF)F)FNF)NN)4__name__
__module____qualname____doc__r	   r   intboolr   r   r
   r!   r%   r   r,   r   r   r2   r7   r;   r@   rJ   rM   ra   rc   rf   rr   ru   rx   r{   r~   r   r   staticmethodr   rn   ro   r   r   rZ   r4   r[   rG   r   r   r*   rX   rY   rW   r\   r]   r    r"   r    r   r      s       ##
 *.',+/$(*..204F9 F9F9 "#F9 tn	F9
 c3h(F9 SMF9 #3-F9 'smF9 &f-F9 F9 F9 F9V *.+/$(*..204C8 C8C8 "#C8 c3h(	C8
 SMC8 #3-C8 'smC8 &f-C8 C8 C8 C8T *.',+/$(*..204&*S6 S6S6 c?S6 	S6
 "#S6 tnS6 c3h(S6 SMS6 #3-S6 'smS6 &f-S6 smS6 S6 S6 S6j7tE$c3h*G$HI 7 7 7 7B 04)-',+/$(*..204Z9 Z9Z9 Z9 E#s(O,	Z9
 "#Z9 tnZ9 c3h(Z9 SMZ9 #3-Z9 'smZ9 &f-Z9 Z9 Z9 Z9@ 04)-',+/$(*..204Z9 Z9Z9 Z9 E#s(O,	Z9
 "#Z9 tnZ9 c3h(Z9 SMZ9 #3-Z9 'smZ9 &f-Z9 Z9 Z9 Z9xF$ F3 F F F F F8 *.!= !=!= != 	!=
 != "#!= != != !=FJT JT J J J J c? sCx	
 } #3- #3- tCy) &c] &c] c3h(  #3- ~   D  $*.*+,0-1-1+/!&*. %H8 H8H8 c?H8 sCx	H8
 }H8 #3-H8 #3-H8 tCy)H8 &c]H8 &c]H8 c3h(H8 H8 #3-H8 ~H8 H8 H8 H8^  $*.*+,0-1-1+/!&*. %J; J;J; c?J; sCx	J;
 }J; #3-J; #3-J; tCy)J; &c]J; &c]J; c3h(J; J; #3-J; ~J; J; J; J;X""3-" #3-" }	"
 c" c?" sCx" d^" tCy)" &c]" &c]" #" "  S	*" c3h("  !"" #3-#"$ ~%" " " "R  $*.*+&+,0-1-1!% $-1+/!&*. %%\9 \9c?\9 sCx\9 c	\9
 }\9 #3-\9 #3-\9 d^\9 tCy)\9 &c]\9 &c]\9 #\9 \9  S	*\9 c3h(\9  !\9" #3-#\9$ ~%\9 \9 \9 \9F  $*.*+&+,0-1-1!% $-1+/!&*. %%\< \<c?\< sCx\< c	\<
 }\< #3-\< #3-\< d^\< tCy)\< &c]\< &c]\< #\< \<  S	*\< c3h(\<  !\<" #3-#\<$ ~%\< \< \< \<|6 6t 6Xd^ 6 6 6 6$ ',-1!&7 7c7 d^7  S	*	7
 7 7 7 7@3 3 3 3 3>$s) > > > > 8T#Y 8htn 8 8 8 \8
 ?S	?d^?  S	*? ? ? \?  JS	J$,SMJ;CC=J J J \J 4$s) 4 4 4 4 \4
 &tCy &(492E & & & \& ,d3i , , , , \,
 4$s) 4 4 4 4 \4
 ,d3i ,sCx0I , , , \,
 OS	O"3-O #3-O O O \O 649 6(3- 6 6 6 \6
 Bc Bhsm B B B \B
 :T#Y :hsm : : : \:
 6DI 6c8K 6 6 6 \6
 ES	E&.smE@HE E E \E $tCy $(4. $ $ $ \$
 Ac Ahsm A A A \A
 #d3i # # # # \#
  /304 S	&sm &f-   \  r"   r   N)typingr   r   r   r   r   redis.exceptionsr   redis.typingr	   r
   r+   r$   rI   r   r:   rL   r?   rz   r5   r   r0   r}   rs   rw   r   rb   re   r   r   r"   r    <module>r      s    5 5 5 5 5 5 5 5 5 5 5 5 5 5 & & & & & & % % % % % % % %
	 

 



 	W W W W W W W W W Wr"   