bvnhddlmZdZdZdZdZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZGddZy)) DataErrorTS.ADDzTS.ALTERz TS.CREATERULEz TS.CREATEz TS.DECRBYz TS.DELETERULEzTS.DELzTS.GETz TS.INCRBYzTS.INFOzTS.MADDzTS.MGETz TS.MRANGEz TS.MREVRANGEz TS.QUERYINDEXzTS.RANGEz TS.REVRANGEceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d#d Z d#dZdZ d$dZ d$dZdZd%dZdZdZedZed&dZedZedZedZedZedZedZedZ edZ!ed Z"ed!Z#ed"Z$y )'TimeSeriesCommandszRedisTimeSeries Commands.c |jdd}|jdd}|jdi}|jdd}|jdd}|g}|j|||j|||j|||j |t ||j |||jt g|S)af Create a new time-series. Args: key: time-series key retention_msecs: Maximum age for samples compared to last event time (in milliseconds). If None or 0 is passed then the series is not trimmed at all. uncompressed: Since RedisTimeSeries v1.2, both timestamps and values are compressed by default. Adding this flag will keep data in an uncompressed form. Compression not only saves memory but usually improve performance due to lower number of memory accesses. labels: Set of label-value pairs that represent metadata labels of the key. chunk_size: Each time-serie uses chunks of memory of fixed size for time series samples. You can alter the default TSDB chunk size by passing the chunk_size argument (in Bytes). duplicate_policy: Since RedisTimeSeries v1.4 you can specify the duplicate sample policy ( Configure what to do on duplicate sample. ) Can be one of: - 'block': an error will occur for any out of order sample. - 'first': ignore the new value. - 'last': override with 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. When this is not set, the server-wide default will be used. For more information: https://oss.redis.com/redistimeseries/commands/#tscreate retention_msecsN uncompressedFlabels chunk_sizeduplicate_policy)get_append_retention_append_uncompressed_append_chunk_size_append_duplicate_policy CREATE_CMD_append_labelsexecute_command) selfkeykwargsrr r r r paramss D/usr/lib/python3/dist-packages/redis/commands/timeseries/commands.pycreatezTimeSeriesCommands.createsL!**%6=zz.%8 Hb)ZZ d3 !::&8$? v7 !!&,7  3 %%fj:JK FF+#t##J888c |jdd}|jdi}|jdd}|g}|j|||j|t||j |||j tg|S)z Update the retention, labels of an existing key. For more information see The parameters are the same as TS.CREATE. For more information: https://oss.redis.com/redistimeseries/commands/#tsalter rNr r )r rr ALTER_CMDrr)rrrrr r rs ralterzTimeSeriesCommands.alterMs!**%6=Hb)!::&8$? v7 %%fi9IJ FF+#t##I777rc |jdd}|jdd}|jdi}|jdd}|jdd} |||g} |j| ||j| ||j| ||j | t | |j | ||jt g| S)a! Append (or create and append) a new sample to the series. For more information see Args: key: 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 last event time (in milliseconds). If None or 0 is passed then the series is not trimmed at all. uncompressed: Since RedisTimeSeries v1.2, both timestamps and values are compressed by default. Adding this flag will keep data in an uncompressed form. Compression not only saves memory but usually improve performance due to lower number of memory accesses. labels: Set of label-value pairs that represent metadata labels of the key. chunk_size: Each time-serie uses chunks of memory of fixed size for time series samples. You can alter the default TSDB chunk size by passing the chunk_size argument (in Bytes). duplicate_policy: Since RedisTimeSeries v1.4 you can specify the duplicate sample policy (Configure what to do on duplicate sample). Can be one of: - 'block': an error will occur for any out of order sample. - 'first': ignore the new value. - 'last': override with 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. When this is not set, the server-wide default will be used. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsadd rNr Fr r r )r rrrrADD_CMDrr) rr timestampvaluerrr r r r rs raddzTimeSeriesCommands.add`sL!**%6=zz.%8 Hb)ZZ d3 !::&8$?y%( v7 !!&,7  3 %%fg7GH FF+#t##G5f55rcrg}|D]}|D]}|j||jtg|S)aH Append (or create and append) a new `value` to series `key` with `timestamp`. Expects a list of `tuples` as (`key`,`timestamp`, `value`). Return value is an array with timestamps of insertions. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsmadd )appendrMADD_CMD)r ktv_tuplesrktvitems rmaddzTimeSeriesCommands.maddsM $C $ d# $ $$t##H6v66rc |jdd}|jdd}|jdd}|jdi}|jdd}||g} |j| ||j| ||j| ||j | ||j | ||j tg| S)aN Increment (or create an time-series and increment) the latest sample's of a series. This command can be used as a counter or gauge that automatically gets history as a time series. Args: key: time-series key value: Numeric data value of the sample timestamp: Timestamp of the sample. None can be used for automatic timestamp (using the system clock). retention_msecs: Maximum age for samples compared to last event time (in milliseconds). If None or 0 is passed then the series is not trimmed at all. uncompressed: Since RedisTimeSeries v1.2, both timestamps and values are compressed by default. Adding this flag will keep data in an uncompressed form. Compression not only saves memory but usually improve performance due to lower number of memory accesses. labels: Set of label-value pairs that represent metadata labels of the key. chunk_size: Each time-series uses chunks of memory of fixed size for time series samples. You can alter the default TSDB chunk size by passing the chunk_size argument (in Bytes). For more information: https://oss.redis.com/redistimeseries/master/commands/#tsincrbytsdecrby r!Nrr Fr r )r _append_timestamprrrrr INCRBY_CMD rrr"rr!rr r r rs rincrbyzTimeSeriesCommands.incrbys<JJ{D1  **%6=zz.%8 Hb)ZZ d3 u vy1 v7 !!&,7  3 FF+#t##J888rc |jdd}|jdd}|jdd}|jdi}|jdd}||g} |j| ||j| ||j| ||j | ||j | ||j tg| S)a~ Decrement (or create an time-series and decrement) the latest sample's of a series. This command can be used as a counter or gauge that automatically gets history as a time series. Args: key: time-series key value: Numeric data value of the sample timestamp: Timestamp of the sample. None can be used for automatic timestamp (using the system clock). retention_msecs: Maximum age for samples compared to last event time (in milliseconds). If None or 0 is passed then the series is not trimmed at all. uncompressed: Since RedisTimeSeries v1.2, both timestamps and values are compressed by default. Adding this flag will keep data in an uncompressed form. Compression not only saves memory but usually improve performance due to lower number of memory accesses. labels: Set of label-value pairs that represent metadata labels of the key. chunk_size: Each time-series uses chunks of memory of fixed size for time series samples. You can alter the default TSDB chunk size by passing the chunk_size argument (in Bytes). For more information: https://oss.redis.com/redistimeseries/master/commands/#tsincrbytsdecrby r!Nrr Fr r )r r,rrrrr DECRBY_CMDr.s rdecrbyzTimeSeriesCommands.decrbysDJJ{D1  **%6=zz.%8 Hb)ZZ d3 u vy1 v7 !!&,7  3 FF+#t##J888rc2|jt|||S)ao Delete data points for a given timeseries and interval range in the form of start and end delete timestamps. The given timestamp interval is closed (inclusive), meaning start and end data points will also be deleted. Return the count for deleted items. For more information see Args: key: time-series key. from_time: Start timestamp for the range deletion. to_time: End timestamp for the range deletion. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsdel )rDEL_CMD)rr from_timeto_times rdeletezTimeSeriesCommands.deletes(##GS)WEErc^||g}|j||||jtg|S)a Create a compaction rule from values added to `source_key` into `dest_key`. Aggregating for `bucket_size_msec` where an `aggregation_type` can be [`avg`, `sum`, `min`, `max`, `range`, `count`, `first`, `last`, `std.p`, `std.s`, `var.p`, `var.s`] For more information: https://oss.redis.com/redistimeseries/master/commands/#tscreaterule )_append_aggregationrCREATERULE_CMD)r source_keydest_keyaggregation_typebucket_size_msecrs r createrulezTimeSeriesCommands.createrules:h'   )9;KL#t##N filter_by_tsfilter_by_min_valuefilter_by_max_valuealignrs r__range_paramsz!TimeSeriesCommands.__range_params-smy'*   6 ##F,?ATU 65) 65)   )9;KL rNc d|j||||||||| | } |jtg| S)a Query a range in forward direction for a specific time-serie. 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: Optional maximum number of returned results. 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`] 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. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsrangetsrevrange )!_TimeSeriesCommands__range_paramsr RANGE_CMDrHs rrangezTimeSeriesCommands.rangeDsM^$$            $t##I777rc d|j||||||||| | } |jtg| S)a* Query a range in reverse direction for a specific time-series. **Note**: This command is only available since RedisTimeSeries >= v1.4 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: Optional maximum number of returned results. 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`] 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. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsrangetsrevrange )rPr REVRANGE_CMDrHs rrevrangezTimeSeriesCommands.revrangesMX$$            $t##L:6::rc@||g}|j|||j|| | |j|||j|||j ||||j ||| |j dg||z }|j|| | |S)z,Create TS.MRANGE and TS.MREVRANGE arguments.FILTER)rDrErFrGr9_append_with_labelsextend_append_groupby_reduce)rr=r>rIfiltersr5r6 with_labelsrJrKrLgroupbyreduce select_labelsrMrs r__mrange_paramsz"TimeSeriesCommands.__mrange_paramss$W%   6 ##F,?ATU 65) 65)   )9;KL   mD xj!' ##FGV< rcl|j||||||||| | | | | |}|jtg|S)a Query a range across multiple time-series by filters in forward direction. 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: Optional maximum number of returned results. 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`] bucket_size_msec: Time bucket for aggregation in milliseconds. with_labels: Include in the reply the label-value pairs that represent metadata labels of the time-series. If this argument is not set, by default, an empty Array will be replied on the labels array position. 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 [`sum`, `min`, `max`]. 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. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsmrangetsmrevrange )"_TimeSeriesCommands__mrange_paramsr MRANGE_CMDrr5r6r[rIr=r>r\rJrKrLr]r^r_rMrs rmrangezTimeSeriesCommands.mrangesY@%%               "$t##J888rcl|j||||||||| | | | | |}|jtg|S)a Query a range across multiple time-series by filters in reverse direction. 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: Optional maximum number of returned results. 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`] bucket_size_msec: Time bucket for aggregation in milliseconds. with_labels: Include in the reply the label-value pairs that represent metadata labels of the time-series. If this argument is not set, by default, an empty Array will be replied on the labels array position. 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 [`sum`, `min`, `max`]. 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. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsmrangetsmrevrange )rbr MREVRANGE_CMDrds r mrevrangezTimeSeriesCommands.mrevrange,sYD%%               "$t##M;F;;rc.|jt|S)z# noqa Get the last sample of `key`. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsget )rGET_CMDrrs rr zTimeSeriesCommands.gets ##GS11rcg}|j|||jdg||z }|jtg|S)z# noqa Get the last samples matching the specific `filter`. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsmget rW)rXrYrMGET_CMD)rr[r\rs rmgetzTimeSeriesCommands.mgetsI    5 xj!'#t##H6v66rc.|jt|S)z# noqa Get information of `key`. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsinfo )rINFO_CMDrks rinfozTimeSeriesCommands.infos ##Hc22rc0|jtg|S)z# noqa Get all the keys matching the `filter` list. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsqueryindex )rQUERYINDEX_CMD)rr[s r queryindexzTimeSeriesCommands.queryindexs $t##N=W==rc.|r|jdgyy)z"Append UNCOMPRESSED tag to params. UNCOMPRESSEDNrY)rr s rrz'TimeSeriesCommands._append_uncompresseds  MM>* + rcx|r |r td|r|jdg|r|jdg|yy)z!Append labels behavior to params.z:with_labels and select_labels cannot be provided together. WITHLABELSSELECTED_LABELSN)rrY)rr\r_s rrXz&TimeSeriesCommands._append_with_labelssI =L   MM<. )  MM,=}= > rcV|'|$|jd|d|jgyyy)z)Append GROUPBY REDUCE property to params.NGROUPBYREDUCE)rYupper)rr]r^s rrZz)TimeSeriesCommands._append_groupby_reduces2  6#5 MM9gxH I$6 rc0||jd|gyy)z$Append RETENTION property to params.N RETENTIONrw)r retentions rrz$TimeSeriesCommands._append_retention   MM; 2 3 !rc|r=|jd|jD]\}}|j||gyy)z!Append LABELS property to params.LABELSN)r%itemsrY)rr kvs rrz!TimeSeriesCommands._append_labelssA  MM( #  &1 q!f% & rc0||jd|gyy)z Append COUNT property to params.NCOUNTrw)rrIs rrFz TimeSeriesCommands._append_count    MM7E* + rc0||jd|gyy)z$Append TIMESTAMP property to params.N TIMESTAMPrw)rr!s rr,z$TimeSeriesCommands._append_timestamprrc0||jd|gyy)z Append ALIGN property to params.NALIGNrw)rrMs rrGz TimeSeriesCommands._append_alignrrcR|%|jd|j||gyy)z&Append AGGREGATION property to params.N AGGREGATION)r%rY)rr=r>s rr9z&TimeSeriesCommands._append_aggregations.  ' MM- ( MM+-=> ? (rc0||jd|gyy)z%Append CHUNK_SIZE property to params.N CHUNK_SIZErw)rr s rrz%TimeSeriesCommands._append_chunk_sizes   ! MM<4 5 "rcb|-|dk(r|jd|gy|jd|gyy)z^Append DUPLICATE_POLICY property to params on CREATE and ON_DUPLICATE on ADD. Nr ON_DUPLICATEDUPLICATE_POLICYrw)rcommandr s rrz+TimeSeriesCommands._append_duplicate_policys<  '(" ~/?@A 13CDE (rc2||jdg|yy)z'Append FILTER_BY_TS property to params.N FILTER_BY_TSrw)rts_lists rrDz&TimeSeriesCommands._append_filer_by_tss#   MM>4G4 5 rc8|||jd||gyyy)z*Append FILTER_BY_VALUE property to params.NFILTER_BY_VALUErw)r min_value max_values rrEz)TimeSeriesCommands._append_filer_by_values+  Y%: MM,iC D&; r)NNrNNNN) NNrFNNNNNNN)F)N)%__name__ __module__ __qualname____doc__rrr#r*r/r2r7r?rBrPrRrUrbrerhr rnrqrt staticmethodrrXrZrrrFr,rGr9rrrDrErrrrs#29h8&26h7 *9X.9`F, =J8  ;8D  8;tF  Q9p  S,,  ? ?JJ 44 &&,, 44 ,, @@ 66 FF66 EErrN)redis.exceptionsrr rr:rr1rAr4rjr-rpr&rmrcrgrsrQrTrrrrrsk&                     j Ej Er