{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}

module Database.Redis.ManualCommands.Ts where

import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as Char8
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NE

import Database.Redis.Core
import Database.Redis.Protocol
import Database.Redis.Types

data TsSample = TsSample
    { TsSample -> Integer
tsSampleTimestamp :: Integer
    , TsSample -> Double
tsSampleValue :: Double
    } deriving (Int -> TsSample -> ShowS
[TsSample] -> ShowS
TsSample -> String
(Int -> TsSample -> ShowS)
-> (TsSample -> String) -> ([TsSample] -> ShowS) -> Show TsSample
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsSample -> ShowS
showsPrec :: Int -> TsSample -> ShowS
$cshow :: TsSample -> String
show :: TsSample -> String
$cshowList :: [TsSample] -> ShowS
showList :: [TsSample] -> ShowS
Show, TsSample -> TsSample -> Bool
(TsSample -> TsSample -> Bool)
-> (TsSample -> TsSample -> Bool) -> Eq TsSample
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsSample -> TsSample -> Bool
== :: TsSample -> TsSample -> Bool
$c/= :: TsSample -> TsSample -> Bool
/= :: TsSample -> TsSample -> Bool
Eq)

instance RedisResult TsSample where
    decode :: Reply -> Either Reply TsSample
decode (MultiBulk (Just [Reply
timestampReply, Reply
valueReply])) =
        Integer -> Double -> TsSample
TsSample (Integer -> Double -> TsSample)
-> Either Reply Integer -> Either Reply (Double -> TsSample)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply Integer
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
timestampReply Either Reply (Double -> TsSample)
-> Either Reply Double -> Either Reply TsSample
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
valueReply
    decode Reply
response = Reply -> Either Reply TsSample
forall a b. a -> Either a b
Left Reply
response

data TsEncoding
    = TsUncompressed
    | TsCompressed
    deriving (Int -> TsEncoding -> ShowS
[TsEncoding] -> ShowS
TsEncoding -> String
(Int -> TsEncoding -> ShowS)
-> (TsEncoding -> String)
-> ([TsEncoding] -> ShowS)
-> Show TsEncoding
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsEncoding -> ShowS
showsPrec :: Int -> TsEncoding -> ShowS
$cshow :: TsEncoding -> String
show :: TsEncoding -> String
$cshowList :: [TsEncoding] -> ShowS
showList :: [TsEncoding] -> ShowS
Show, TsEncoding -> TsEncoding -> Bool
(TsEncoding -> TsEncoding -> Bool)
-> (TsEncoding -> TsEncoding -> Bool) -> Eq TsEncoding
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsEncoding -> TsEncoding -> Bool
== :: TsEncoding -> TsEncoding -> Bool
$c/= :: TsEncoding -> TsEncoding -> Bool
/= :: TsEncoding -> TsEncoding -> Bool
Eq)

instance RedisArg TsEncoding where
    encode :: TsEncoding -> ByteString
encode TsEncoding
TsUncompressed = ByteString
"UNCOMPRESSED"
    encode TsEncoding
TsCompressed = ByteString
"COMPRESSED"

data TsDuplicatePolicy
    = TsDuplicateBlock
    | TsDuplicateFirst
    | TsDuplicateLast
    | TsDuplicateMin
    | TsDuplicateMax
    | TsDuplicateSum
    deriving (Int -> TsDuplicatePolicy -> ShowS
[TsDuplicatePolicy] -> ShowS
TsDuplicatePolicy -> String
(Int -> TsDuplicatePolicy -> ShowS)
-> (TsDuplicatePolicy -> String)
-> ([TsDuplicatePolicy] -> ShowS)
-> Show TsDuplicatePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsDuplicatePolicy -> ShowS
showsPrec :: Int -> TsDuplicatePolicy -> ShowS
$cshow :: TsDuplicatePolicy -> String
show :: TsDuplicatePolicy -> String
$cshowList :: [TsDuplicatePolicy] -> ShowS
showList :: [TsDuplicatePolicy] -> ShowS
Show, TsDuplicatePolicy -> TsDuplicatePolicy -> Bool
(TsDuplicatePolicy -> TsDuplicatePolicy -> Bool)
-> (TsDuplicatePolicy -> TsDuplicatePolicy -> Bool)
-> Eq TsDuplicatePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsDuplicatePolicy -> TsDuplicatePolicy -> Bool
== :: TsDuplicatePolicy -> TsDuplicatePolicy -> Bool
$c/= :: TsDuplicatePolicy -> TsDuplicatePolicy -> Bool
/= :: TsDuplicatePolicy -> TsDuplicatePolicy -> Bool
Eq)

instance RedisArg TsDuplicatePolicy where
    encode :: TsDuplicatePolicy -> ByteString
encode TsDuplicatePolicy
TsDuplicateBlock = ByteString
"BLOCK"
    encode TsDuplicatePolicy
TsDuplicateFirst = ByteString
"FIRST"
    encode TsDuplicatePolicy
TsDuplicateLast = ByteString
"LAST"
    encode TsDuplicatePolicy
TsDuplicateMin = ByteString
"MIN"
    encode TsDuplicatePolicy
TsDuplicateMax = ByteString
"MAX"
    encode TsDuplicatePolicy
TsDuplicateSum = ByteString
"SUM"

data TsIgnore = TsIgnore
    { TsIgnore -> Integer
tsIgnoreMaxTimeDiff :: Integer
    , TsIgnore -> Double
tsIgnoreMaxValDiff :: Double
    } deriving (Int -> TsIgnore -> ShowS
[TsIgnore] -> ShowS
TsIgnore -> String
(Int -> TsIgnore -> ShowS)
-> (TsIgnore -> String) -> ([TsIgnore] -> ShowS) -> Show TsIgnore
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsIgnore -> ShowS
showsPrec :: Int -> TsIgnore -> ShowS
$cshow :: TsIgnore -> String
show :: TsIgnore -> String
$cshowList :: [TsIgnore] -> ShowS
showList :: [TsIgnore] -> ShowS
Show, TsIgnore -> TsIgnore -> Bool
(TsIgnore -> TsIgnore -> Bool)
-> (TsIgnore -> TsIgnore -> Bool) -> Eq TsIgnore
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsIgnore -> TsIgnore -> Bool
== :: TsIgnore -> TsIgnore -> Bool
$c/= :: TsIgnore -> TsIgnore -> Bool
/= :: TsIgnore -> TsIgnore -> Bool
Eq)

data TsCreateOpts = TsCreateOpts
    { TsCreateOpts -> Maybe Integer
tsCreateRetention :: Maybe Integer
    , TsCreateOpts -> Maybe TsEncoding
tsCreateEncoding :: Maybe TsEncoding
    , TsCreateOpts -> Maybe Integer
tsCreateChunkSize :: Maybe Integer
    , TsCreateOpts -> Maybe TsDuplicatePolicy
tsCreateDuplicatePolicy :: Maybe TsDuplicatePolicy
    , TsCreateOpts -> Maybe TsIgnore
tsCreateIgnore :: Maybe TsIgnore
    , TsCreateOpts -> [(ByteString, ByteString)]
tsCreateLabels :: [(ByteString, ByteString)]
    } deriving (Int -> TsCreateOpts -> ShowS
[TsCreateOpts] -> ShowS
TsCreateOpts -> String
(Int -> TsCreateOpts -> ShowS)
-> (TsCreateOpts -> String)
-> ([TsCreateOpts] -> ShowS)
-> Show TsCreateOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsCreateOpts -> ShowS
showsPrec :: Int -> TsCreateOpts -> ShowS
$cshow :: TsCreateOpts -> String
show :: TsCreateOpts -> String
$cshowList :: [TsCreateOpts] -> ShowS
showList :: [TsCreateOpts] -> ShowS
Show, TsCreateOpts -> TsCreateOpts -> Bool
(TsCreateOpts -> TsCreateOpts -> Bool)
-> (TsCreateOpts -> TsCreateOpts -> Bool) -> Eq TsCreateOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsCreateOpts -> TsCreateOpts -> Bool
== :: TsCreateOpts -> TsCreateOpts -> Bool
$c/= :: TsCreateOpts -> TsCreateOpts -> Bool
/= :: TsCreateOpts -> TsCreateOpts -> Bool
Eq)

defaultTsCreateOpts :: TsCreateOpts
defaultTsCreateOpts :: TsCreateOpts
defaultTsCreateOpts = TsCreateOpts
    { tsCreateRetention :: Maybe Integer
tsCreateRetention = Maybe Integer
forall a. Maybe a
Nothing
    , tsCreateEncoding :: Maybe TsEncoding
tsCreateEncoding = Maybe TsEncoding
forall a. Maybe a
Nothing
    , tsCreateChunkSize :: Maybe Integer
tsCreateChunkSize = Maybe Integer
forall a. Maybe a
Nothing
    , tsCreateDuplicatePolicy :: Maybe TsDuplicatePolicy
tsCreateDuplicatePolicy = Maybe TsDuplicatePolicy
forall a. Maybe a
Nothing
    , tsCreateIgnore :: Maybe TsIgnore
tsCreateIgnore = Maybe TsIgnore
forall a. Maybe a
Nothing
    , tsCreateLabels :: [(ByteString, ByteString)]
tsCreateLabels = []
    }

data TsAlterOpts = TsAlterOpts
    { TsAlterOpts -> Maybe Integer
tsAlterRetention :: Maybe Integer
    , TsAlterOpts -> Maybe Integer
tsAlterChunkSize :: Maybe Integer
    , TsAlterOpts -> Maybe TsDuplicatePolicy
tsAlterDuplicatePolicy :: Maybe TsDuplicatePolicy
    , TsAlterOpts -> [(ByteString, ByteString)]
tsAlterLabels :: [(ByteString, ByteString)]
    } deriving (Int -> TsAlterOpts -> ShowS
[TsAlterOpts] -> ShowS
TsAlterOpts -> String
(Int -> TsAlterOpts -> ShowS)
-> (TsAlterOpts -> String)
-> ([TsAlterOpts] -> ShowS)
-> Show TsAlterOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsAlterOpts -> ShowS
showsPrec :: Int -> TsAlterOpts -> ShowS
$cshow :: TsAlterOpts -> String
show :: TsAlterOpts -> String
$cshowList :: [TsAlterOpts] -> ShowS
showList :: [TsAlterOpts] -> ShowS
Show, TsAlterOpts -> TsAlterOpts -> Bool
(TsAlterOpts -> TsAlterOpts -> Bool)
-> (TsAlterOpts -> TsAlterOpts -> Bool) -> Eq TsAlterOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsAlterOpts -> TsAlterOpts -> Bool
== :: TsAlterOpts -> TsAlterOpts -> Bool
$c/= :: TsAlterOpts -> TsAlterOpts -> Bool
/= :: TsAlterOpts -> TsAlterOpts -> Bool
Eq)

defaultTsAlterOpts :: TsAlterOpts
defaultTsAlterOpts :: TsAlterOpts
defaultTsAlterOpts = TsAlterOpts
    { tsAlterRetention :: Maybe Integer
tsAlterRetention = Maybe Integer
forall a. Maybe a
Nothing
    , tsAlterChunkSize :: Maybe Integer
tsAlterChunkSize = Maybe Integer
forall a. Maybe a
Nothing
    , tsAlterDuplicatePolicy :: Maybe TsDuplicatePolicy
tsAlterDuplicatePolicy = Maybe TsDuplicatePolicy
forall a. Maybe a
Nothing
    , tsAlterLabels :: [(ByteString, ByteString)]
tsAlterLabels = []
    }

data TsAddOpts = TsAddOpts
    { TsAddOpts -> Maybe Integer
tsAddRetention :: Maybe Integer
    , TsAddOpts -> Maybe TsEncoding
tsAddEncoding :: Maybe TsEncoding
    , TsAddOpts -> Maybe Integer
tsAddChunkSize :: Maybe Integer
    , TsAddOpts -> Maybe TsDuplicatePolicy
tsAddOnDuplicate :: Maybe TsDuplicatePolicy
    , TsAddOpts -> Maybe TsIgnore
tsAddIgnore :: Maybe TsIgnore
    , TsAddOpts -> [(ByteString, ByteString)]
tsAddLabels :: [(ByteString, ByteString)]
    } deriving (Int -> TsAddOpts -> ShowS
[TsAddOpts] -> ShowS
TsAddOpts -> String
(Int -> TsAddOpts -> ShowS)
-> (TsAddOpts -> String)
-> ([TsAddOpts] -> ShowS)
-> Show TsAddOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsAddOpts -> ShowS
showsPrec :: Int -> TsAddOpts -> ShowS
$cshow :: TsAddOpts -> String
show :: TsAddOpts -> String
$cshowList :: [TsAddOpts] -> ShowS
showList :: [TsAddOpts] -> ShowS
Show, TsAddOpts -> TsAddOpts -> Bool
(TsAddOpts -> TsAddOpts -> Bool)
-> (TsAddOpts -> TsAddOpts -> Bool) -> Eq TsAddOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsAddOpts -> TsAddOpts -> Bool
== :: TsAddOpts -> TsAddOpts -> Bool
$c/= :: TsAddOpts -> TsAddOpts -> Bool
/= :: TsAddOpts -> TsAddOpts -> Bool
Eq)

defaultTsAddOpts :: TsAddOpts
defaultTsAddOpts :: TsAddOpts
defaultTsAddOpts = TsAddOpts
    { tsAddRetention :: Maybe Integer
tsAddRetention = Maybe Integer
forall a. Maybe a
Nothing
    , tsAddEncoding :: Maybe TsEncoding
tsAddEncoding = Maybe TsEncoding
forall a. Maybe a
Nothing
    , tsAddChunkSize :: Maybe Integer
tsAddChunkSize = Maybe Integer
forall a. Maybe a
Nothing
    , tsAddOnDuplicate :: Maybe TsDuplicatePolicy
tsAddOnDuplicate = Maybe TsDuplicatePolicy
forall a. Maybe a
Nothing
    , tsAddIgnore :: Maybe TsIgnore
tsAddIgnore = Maybe TsIgnore
forall a. Maybe a
Nothing
    , tsAddLabels :: [(ByteString, ByteString)]
tsAddLabels = []
    }

data TsIncrByOpts = TsIncrByOpts
    { TsIncrByOpts -> Maybe ByteString
tsIncrByTimestamp :: Maybe ByteString
    , TsIncrByOpts -> Maybe Integer
tsIncrByRetention :: Maybe Integer
    , TsIncrByOpts -> Bool
tsIncrByUncompressed :: Bool
    , TsIncrByOpts -> Maybe Integer
tsIncrByChunkSize :: Maybe Integer
    , TsIncrByOpts -> Maybe TsDuplicatePolicy
tsIncrByDuplicatePolicy :: Maybe TsDuplicatePolicy
    , TsIncrByOpts -> Maybe TsIgnore
tsIncrByIgnore :: Maybe TsIgnore
    , TsIncrByOpts -> [(ByteString, ByteString)]
tsIncrByLabels :: [(ByteString, ByteString)]
    } deriving (Int -> TsIncrByOpts -> ShowS
[TsIncrByOpts] -> ShowS
TsIncrByOpts -> String
(Int -> TsIncrByOpts -> ShowS)
-> (TsIncrByOpts -> String)
-> ([TsIncrByOpts] -> ShowS)
-> Show TsIncrByOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsIncrByOpts -> ShowS
showsPrec :: Int -> TsIncrByOpts -> ShowS
$cshow :: TsIncrByOpts -> String
show :: TsIncrByOpts -> String
$cshowList :: [TsIncrByOpts] -> ShowS
showList :: [TsIncrByOpts] -> ShowS
Show, TsIncrByOpts -> TsIncrByOpts -> Bool
(TsIncrByOpts -> TsIncrByOpts -> Bool)
-> (TsIncrByOpts -> TsIncrByOpts -> Bool) -> Eq TsIncrByOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsIncrByOpts -> TsIncrByOpts -> Bool
== :: TsIncrByOpts -> TsIncrByOpts -> Bool
$c/= :: TsIncrByOpts -> TsIncrByOpts -> Bool
/= :: TsIncrByOpts -> TsIncrByOpts -> Bool
Eq)

defaultTsIncrByOpts :: TsIncrByOpts
defaultTsIncrByOpts :: TsIncrByOpts
defaultTsIncrByOpts = TsIncrByOpts
    { tsIncrByTimestamp :: Maybe ByteString
tsIncrByTimestamp = Maybe ByteString
forall a. Maybe a
Nothing
    , tsIncrByRetention :: Maybe Integer
tsIncrByRetention = Maybe Integer
forall a. Maybe a
Nothing
    , tsIncrByUncompressed :: Bool
tsIncrByUncompressed = Bool
False
    , tsIncrByChunkSize :: Maybe Integer
tsIncrByChunkSize = Maybe Integer
forall a. Maybe a
Nothing
    , tsIncrByDuplicatePolicy :: Maybe TsDuplicatePolicy
tsIncrByDuplicatePolicy = Maybe TsDuplicatePolicy
forall a. Maybe a
Nothing
    , tsIncrByIgnore :: Maybe TsIgnore
tsIncrByIgnore = Maybe TsIgnore
forall a. Maybe a
Nothing
    , tsIncrByLabels :: [(ByteString, ByteString)]
tsIncrByLabels = []
    }

data TsGetOpts = TsGetOpts
    { TsGetOpts -> Bool
tsGetLatest :: Bool
    } deriving (Int -> TsGetOpts -> ShowS
[TsGetOpts] -> ShowS
TsGetOpts -> String
(Int -> TsGetOpts -> ShowS)
-> (TsGetOpts -> String)
-> ([TsGetOpts] -> ShowS)
-> Show TsGetOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsGetOpts -> ShowS
showsPrec :: Int -> TsGetOpts -> ShowS
$cshow :: TsGetOpts -> String
show :: TsGetOpts -> String
$cshowList :: [TsGetOpts] -> ShowS
showList :: [TsGetOpts] -> ShowS
Show, TsGetOpts -> TsGetOpts -> Bool
(TsGetOpts -> TsGetOpts -> Bool)
-> (TsGetOpts -> TsGetOpts -> Bool) -> Eq TsGetOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsGetOpts -> TsGetOpts -> Bool
== :: TsGetOpts -> TsGetOpts -> Bool
$c/= :: TsGetOpts -> TsGetOpts -> Bool
/= :: TsGetOpts -> TsGetOpts -> Bool
Eq)

defaultTsGetOpts :: TsGetOpts
defaultTsGetOpts :: TsGetOpts
defaultTsGetOpts = TsGetOpts
    { tsGetLatest :: Bool
tsGetLatest = Bool
False
    }

data TsAggregator
    = TsAggAvg
    | TsAggFirst
    | TsAggLast
    | TsAggMin
    | TsAggMax
    | TsAggSum
    | TsAggRange
    | TsAggCount
    | TsAggStdP
    | TsAggStdS
    | TsAggVarP
    | TsAggVarS
    | TsAggTwa
    | TsAggCountNaN
    | TsAggCountAll
    deriving (Int -> TsAggregator -> ShowS
[TsAggregator] -> ShowS
TsAggregator -> String
(Int -> TsAggregator -> ShowS)
-> (TsAggregator -> String)
-> ([TsAggregator] -> ShowS)
-> Show TsAggregator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsAggregator -> ShowS
showsPrec :: Int -> TsAggregator -> ShowS
$cshow :: TsAggregator -> String
show :: TsAggregator -> String
$cshowList :: [TsAggregator] -> ShowS
showList :: [TsAggregator] -> ShowS
Show, TsAggregator -> TsAggregator -> Bool
(TsAggregator -> TsAggregator -> Bool)
-> (TsAggregator -> TsAggregator -> Bool) -> Eq TsAggregator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsAggregator -> TsAggregator -> Bool
== :: TsAggregator -> TsAggregator -> Bool
$c/= :: TsAggregator -> TsAggregator -> Bool
/= :: TsAggregator -> TsAggregator -> Bool
Eq)

instance RedisArg TsAggregator where
    encode :: TsAggregator -> ByteString
encode TsAggregator
TsAggAvg = ByteString
"avg"
    encode TsAggregator
TsAggFirst = ByteString
"first"
    encode TsAggregator
TsAggLast = ByteString
"last"
    encode TsAggregator
TsAggMin = ByteString
"min"
    encode TsAggregator
TsAggMax = ByteString
"max"
    encode TsAggregator
TsAggSum = ByteString
"sum"
    encode TsAggregator
TsAggRange = ByteString
"range"
    encode TsAggregator
TsAggCount = ByteString
"count"
    encode TsAggregator
TsAggStdP = ByteString
"std.p"
    encode TsAggregator
TsAggStdS = ByteString
"std.s"
    encode TsAggregator
TsAggVarP = ByteString
"var.p"
    encode TsAggregator
TsAggVarS = ByteString
"var.s"
    encode TsAggregator
TsAggTwa = ByteString
"twa"
    encode TsAggregator
TsAggCountNaN = ByteString
"countnan"
    encode TsAggregator
TsAggCountAll = ByteString
"countall"

newtype TsAggregators = TsAggregators
    { TsAggregators -> NonEmpty TsAggregator
unTsAggregators :: NonEmpty TsAggregator
    } deriving (Int -> TsAggregators -> ShowS
[TsAggregators] -> ShowS
TsAggregators -> String
(Int -> TsAggregators -> ShowS)
-> (TsAggregators -> String)
-> ([TsAggregators] -> ShowS)
-> Show TsAggregators
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsAggregators -> ShowS
showsPrec :: Int -> TsAggregators -> ShowS
$cshow :: TsAggregators -> String
show :: TsAggregators -> String
$cshowList :: [TsAggregators] -> ShowS
showList :: [TsAggregators] -> ShowS
Show, TsAggregators -> TsAggregators -> Bool
(TsAggregators -> TsAggregators -> Bool)
-> (TsAggregators -> TsAggregators -> Bool) -> Eq TsAggregators
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsAggregators -> TsAggregators -> Bool
== :: TsAggregators -> TsAggregators -> Bool
$c/= :: TsAggregators -> TsAggregators -> Bool
/= :: TsAggregators -> TsAggregators -> Bool
Eq)

instance RedisArg TsAggregators where
    encode :: TsAggregators -> ByteString
encode = ByteString -> [ByteString] -> ByteString
Char8.intercalate ByteString
"," ([ByteString] -> ByteString)
-> (TsAggregators -> [ByteString]) -> TsAggregators -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TsAggregator -> ByteString) -> [TsAggregator] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map TsAggregator -> ByteString
forall a. RedisArg a => a -> ByteString
encode ([TsAggregator] -> [ByteString])
-> (TsAggregators -> [TsAggregator])
-> TsAggregators
-> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty TsAggregator -> [TsAggregator]
forall a. NonEmpty a -> [a]
NE.toList (NonEmpty TsAggregator -> [TsAggregator])
-> (TsAggregators -> NonEmpty TsAggregator)
-> TsAggregators
-> [TsAggregator]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TsAggregators -> NonEmpty TsAggregator
unTsAggregators

data TsBucketTimestamp
    = TsBucketStart
    | TsBucketEnd
    | TsBucketMid
    deriving (Int -> TsBucketTimestamp -> ShowS
[TsBucketTimestamp] -> ShowS
TsBucketTimestamp -> String
(Int -> TsBucketTimestamp -> ShowS)
-> (TsBucketTimestamp -> String)
-> ([TsBucketTimestamp] -> ShowS)
-> Show TsBucketTimestamp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsBucketTimestamp -> ShowS
showsPrec :: Int -> TsBucketTimestamp -> ShowS
$cshow :: TsBucketTimestamp -> String
show :: TsBucketTimestamp -> String
$cshowList :: [TsBucketTimestamp] -> ShowS
showList :: [TsBucketTimestamp] -> ShowS
Show, TsBucketTimestamp -> TsBucketTimestamp -> Bool
(TsBucketTimestamp -> TsBucketTimestamp -> Bool)
-> (TsBucketTimestamp -> TsBucketTimestamp -> Bool)
-> Eq TsBucketTimestamp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsBucketTimestamp -> TsBucketTimestamp -> Bool
== :: TsBucketTimestamp -> TsBucketTimestamp -> Bool
$c/= :: TsBucketTimestamp -> TsBucketTimestamp -> Bool
/= :: TsBucketTimestamp -> TsBucketTimestamp -> Bool
Eq)

instance RedisArg TsBucketTimestamp where
    encode :: TsBucketTimestamp -> ByteString
encode TsBucketTimestamp
TsBucketStart = ByteString
"-"
    encode TsBucketTimestamp
TsBucketEnd = ByteString
"+"
    encode TsBucketTimestamp
TsBucketMid = ByteString
"~"

data TsAggregationOpts = TsAggregationOpts
    { TsAggregationOpts -> Maybe ByteString
tsAggregationAlign :: Maybe ByteString
    , TsAggregationOpts -> TsAggregators
tsAggregationType :: TsAggregators
    , TsAggregationOpts -> Integer
tsAggregationBucketDuration :: Integer
    , TsAggregationOpts -> Maybe TsBucketTimestamp
tsAggregationBucketTimestamp :: Maybe TsBucketTimestamp
    , TsAggregationOpts -> Bool
tsAggregationEmpty :: Bool
    } deriving (Int -> TsAggregationOpts -> ShowS
[TsAggregationOpts] -> ShowS
TsAggregationOpts -> String
(Int -> TsAggregationOpts -> ShowS)
-> (TsAggregationOpts -> String)
-> ([TsAggregationOpts] -> ShowS)
-> Show TsAggregationOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsAggregationOpts -> ShowS
showsPrec :: Int -> TsAggregationOpts -> ShowS
$cshow :: TsAggregationOpts -> String
show :: TsAggregationOpts -> String
$cshowList :: [TsAggregationOpts] -> ShowS
showList :: [TsAggregationOpts] -> ShowS
Show, TsAggregationOpts -> TsAggregationOpts -> Bool
(TsAggregationOpts -> TsAggregationOpts -> Bool)
-> (TsAggregationOpts -> TsAggregationOpts -> Bool)
-> Eq TsAggregationOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsAggregationOpts -> TsAggregationOpts -> Bool
== :: TsAggregationOpts -> TsAggregationOpts -> Bool
$c/= :: TsAggregationOpts -> TsAggregationOpts -> Bool
/= :: TsAggregationOpts -> TsAggregationOpts -> Bool
Eq)

data TsRangeOpts = TsRangeOpts
    { TsRangeOpts -> Bool
tsRangeLatest :: Bool
    , TsRangeOpts -> [Integer]
tsRangeFilterByTs :: [Integer]
    , TsRangeOpts -> Maybe (Double, Double)
tsRangeFilterByValue :: Maybe (Double, Double)
    , TsRangeOpts -> Maybe Integer
tsRangeCount :: Maybe Integer
    , TsRangeOpts -> Maybe TsAggregationOpts
tsRangeAggregation :: Maybe TsAggregationOpts
    } deriving (Int -> TsRangeOpts -> ShowS
[TsRangeOpts] -> ShowS
TsRangeOpts -> String
(Int -> TsRangeOpts -> ShowS)
-> (TsRangeOpts -> String)
-> ([TsRangeOpts] -> ShowS)
-> Show TsRangeOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsRangeOpts -> ShowS
showsPrec :: Int -> TsRangeOpts -> ShowS
$cshow :: TsRangeOpts -> String
show :: TsRangeOpts -> String
$cshowList :: [TsRangeOpts] -> ShowS
showList :: [TsRangeOpts] -> ShowS
Show, TsRangeOpts -> TsRangeOpts -> Bool
(TsRangeOpts -> TsRangeOpts -> Bool)
-> (TsRangeOpts -> TsRangeOpts -> Bool) -> Eq TsRangeOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsRangeOpts -> TsRangeOpts -> Bool
== :: TsRangeOpts -> TsRangeOpts -> Bool
$c/= :: TsRangeOpts -> TsRangeOpts -> Bool
/= :: TsRangeOpts -> TsRangeOpts -> Bool
Eq)

defaultTsRangeOpts :: TsRangeOpts
defaultTsRangeOpts :: TsRangeOpts
defaultTsRangeOpts = TsRangeOpts
    { tsRangeLatest :: Bool
tsRangeLatest = Bool
False
    , tsRangeFilterByTs :: [Integer]
tsRangeFilterByTs = []
    , tsRangeFilterByValue :: Maybe (Double, Double)
tsRangeFilterByValue = Maybe (Double, Double)
forall a. Maybe a
Nothing
    , tsRangeCount :: Maybe Integer
tsRangeCount = Maybe Integer
forall a. Maybe a
Nothing
    , tsRangeAggregation :: Maybe TsAggregationOpts
tsRangeAggregation = Maybe TsAggregationOpts
forall a. Maybe a
Nothing
    }

data TsLabelSelection
    = TsWithLabels
    | TsSelectedLabels (NonEmpty ByteString)
    deriving (Int -> TsLabelSelection -> ShowS
[TsLabelSelection] -> ShowS
TsLabelSelection -> String
(Int -> TsLabelSelection -> ShowS)
-> (TsLabelSelection -> String)
-> ([TsLabelSelection] -> ShowS)
-> Show TsLabelSelection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsLabelSelection -> ShowS
showsPrec :: Int -> TsLabelSelection -> ShowS
$cshow :: TsLabelSelection -> String
show :: TsLabelSelection -> String
$cshowList :: [TsLabelSelection] -> ShowS
showList :: [TsLabelSelection] -> ShowS
Show, TsLabelSelection -> TsLabelSelection -> Bool
(TsLabelSelection -> TsLabelSelection -> Bool)
-> (TsLabelSelection -> TsLabelSelection -> Bool)
-> Eq TsLabelSelection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsLabelSelection -> TsLabelSelection -> Bool
== :: TsLabelSelection -> TsLabelSelection -> Bool
$c/= :: TsLabelSelection -> TsLabelSelection -> Bool
/= :: TsLabelSelection -> TsLabelSelection -> Bool
Eq)

data TsGroupByReduce = TsGroupByReduce
    { TsGroupByReduce -> ByteString
tsGroupByLabel :: ByteString
    , TsGroupByReduce -> TsAggregator
tsGroupByReducer :: TsAggregator
    } deriving (Int -> TsGroupByReduce -> ShowS
[TsGroupByReduce] -> ShowS
TsGroupByReduce -> String
(Int -> TsGroupByReduce -> ShowS)
-> (TsGroupByReduce -> String)
-> ([TsGroupByReduce] -> ShowS)
-> Show TsGroupByReduce
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsGroupByReduce -> ShowS
showsPrec :: Int -> TsGroupByReduce -> ShowS
$cshow :: TsGroupByReduce -> String
show :: TsGroupByReduce -> String
$cshowList :: [TsGroupByReduce] -> ShowS
showList :: [TsGroupByReduce] -> ShowS
Show, TsGroupByReduce -> TsGroupByReduce -> Bool
(TsGroupByReduce -> TsGroupByReduce -> Bool)
-> (TsGroupByReduce -> TsGroupByReduce -> Bool)
-> Eq TsGroupByReduce
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsGroupByReduce -> TsGroupByReduce -> Bool
== :: TsGroupByReduce -> TsGroupByReduce -> Bool
$c/= :: TsGroupByReduce -> TsGroupByReduce -> Bool
/= :: TsGroupByReduce -> TsGroupByReduce -> Bool
Eq)

data TsMGetOpts = TsMGetOpts
    { TsMGetOpts -> Bool
tsMGetLatest :: Bool
    , TsMGetOpts -> Maybe TsLabelSelection
tsMGetLabels :: Maybe TsLabelSelection
    } deriving (Int -> TsMGetOpts -> ShowS
[TsMGetOpts] -> ShowS
TsMGetOpts -> String
(Int -> TsMGetOpts -> ShowS)
-> (TsMGetOpts -> String)
-> ([TsMGetOpts] -> ShowS)
-> Show TsMGetOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsMGetOpts -> ShowS
showsPrec :: Int -> TsMGetOpts -> ShowS
$cshow :: TsMGetOpts -> String
show :: TsMGetOpts -> String
$cshowList :: [TsMGetOpts] -> ShowS
showList :: [TsMGetOpts] -> ShowS
Show, TsMGetOpts -> TsMGetOpts -> Bool
(TsMGetOpts -> TsMGetOpts -> Bool)
-> (TsMGetOpts -> TsMGetOpts -> Bool) -> Eq TsMGetOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsMGetOpts -> TsMGetOpts -> Bool
== :: TsMGetOpts -> TsMGetOpts -> Bool
$c/= :: TsMGetOpts -> TsMGetOpts -> Bool
/= :: TsMGetOpts -> TsMGetOpts -> Bool
Eq)

defaultTsMGetOpts :: TsMGetOpts
defaultTsMGetOpts :: TsMGetOpts
defaultTsMGetOpts = TsMGetOpts
    { tsMGetLatest :: Bool
tsMGetLatest = Bool
False
    , tsMGetLabels :: Maybe TsLabelSelection
tsMGetLabels = Maybe TsLabelSelection
forall a. Maybe a
Nothing
    }

data TsMRangeOpts = TsMRangeOpts
    { TsMRangeOpts -> Bool
tsMRangeLatest :: Bool
    , TsMRangeOpts -> [Integer]
tsMRangeFilterByTs :: [Integer]
    , TsMRangeOpts -> Maybe (Double, Double)
tsMRangeFilterByValue :: Maybe (Double, Double)
    , TsMRangeOpts -> Maybe TsLabelSelection
tsMRangeLabels :: Maybe TsLabelSelection
    , TsMRangeOpts -> Maybe Integer
tsMRangeCount :: Maybe Integer
    , TsMRangeOpts -> Maybe TsAggregationOpts
tsMRangeAggregation :: Maybe TsAggregationOpts
    , TsMRangeOpts -> Maybe TsGroupByReduce
tsMRangeGroupByReduce :: Maybe TsGroupByReduce
    } deriving (Int -> TsMRangeOpts -> ShowS
[TsMRangeOpts] -> ShowS
TsMRangeOpts -> String
(Int -> TsMRangeOpts -> ShowS)
-> (TsMRangeOpts -> String)
-> ([TsMRangeOpts] -> ShowS)
-> Show TsMRangeOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsMRangeOpts -> ShowS
showsPrec :: Int -> TsMRangeOpts -> ShowS
$cshow :: TsMRangeOpts -> String
show :: TsMRangeOpts -> String
$cshowList :: [TsMRangeOpts] -> ShowS
showList :: [TsMRangeOpts] -> ShowS
Show, TsMRangeOpts -> TsMRangeOpts -> Bool
(TsMRangeOpts -> TsMRangeOpts -> Bool)
-> (TsMRangeOpts -> TsMRangeOpts -> Bool) -> Eq TsMRangeOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsMRangeOpts -> TsMRangeOpts -> Bool
== :: TsMRangeOpts -> TsMRangeOpts -> Bool
$c/= :: TsMRangeOpts -> TsMRangeOpts -> Bool
/= :: TsMRangeOpts -> TsMRangeOpts -> Bool
Eq)

defaultTsMRangeOpts :: TsMRangeOpts
defaultTsMRangeOpts :: TsMRangeOpts
defaultTsMRangeOpts = TsMRangeOpts
    { tsMRangeLatest :: Bool
tsMRangeLatest = Bool
False
    , tsMRangeFilterByTs :: [Integer]
tsMRangeFilterByTs = []
    , tsMRangeFilterByValue :: Maybe (Double, Double)
tsMRangeFilterByValue = Maybe (Double, Double)
forall a. Maybe a
Nothing
    , tsMRangeLabels :: Maybe TsLabelSelection
tsMRangeLabels = Maybe TsLabelSelection
forall a. Maybe a
Nothing
    , tsMRangeCount :: Maybe Integer
tsMRangeCount = Maybe Integer
forall a. Maybe a
Nothing
    , tsMRangeAggregation :: Maybe TsAggregationOpts
tsMRangeAggregation = Maybe TsAggregationOpts
forall a. Maybe a
Nothing
    , tsMRangeGroupByReduce :: Maybe TsGroupByReduce
tsMRangeGroupByReduce = Maybe TsGroupByReduce
forall a. Maybe a
Nothing
    }

data TsInfoOpts
    = TsInfoDefault
    | TsInfoDebug
    deriving (Int -> TsInfoOpts -> ShowS
[TsInfoOpts] -> ShowS
TsInfoOpts -> String
(Int -> TsInfoOpts -> ShowS)
-> (TsInfoOpts -> String)
-> ([TsInfoOpts] -> ShowS)
-> Show TsInfoOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsInfoOpts -> ShowS
showsPrec :: Int -> TsInfoOpts -> ShowS
$cshow :: TsInfoOpts -> String
show :: TsInfoOpts -> String
$cshowList :: [TsInfoOpts] -> ShowS
showList :: [TsInfoOpts] -> ShowS
Show, TsInfoOpts -> TsInfoOpts -> Bool
(TsInfoOpts -> TsInfoOpts -> Bool)
-> (TsInfoOpts -> TsInfoOpts -> Bool) -> Eq TsInfoOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsInfoOpts -> TsInfoOpts -> Bool
== :: TsInfoOpts -> TsInfoOpts -> Bool
$c/= :: TsInfoOpts -> TsInfoOpts -> Bool
/= :: TsInfoOpts -> TsInfoOpts -> Bool
Eq)

tsLabelsToArgs :: [(ByteString, ByteString)] -> [ByteString]
tsLabelsToArgs :: [(ByteString, ByteString)] -> [ByteString]
tsLabelsToArgs [] = []
tsLabelsToArgs [(ByteString, ByteString)]
labels = ByteString
"LABELS" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ((ByteString, ByteString) -> [ByteString])
-> [(ByteString, ByteString)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(ByteString
k, ByteString
v) -> [ByteString
k, ByteString
v]) [(ByteString, ByteString)]
labels

tsIgnoreToArgs :: TsIgnore -> [ByteString]
tsIgnoreToArgs :: TsIgnore -> [ByteString]
tsIgnoreToArgs TsIgnore{Double
Integer
tsIgnoreMaxTimeDiff :: TsIgnore -> Integer
tsIgnoreMaxValDiff :: TsIgnore -> Double
tsIgnoreMaxTimeDiff :: Integer
tsIgnoreMaxValDiff :: Double
..} =
    [ByteString
"IGNORE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
tsIgnoreMaxTimeDiff, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
tsIgnoreMaxValDiff]

tsCreateOptsToArgs :: TsCreateOpts -> [ByteString]
tsCreateOptsToArgs :: TsCreateOpts -> [ByteString]
tsCreateOptsToArgs TsCreateOpts{[(ByteString, ByteString)]
Maybe Integer
Maybe TsIgnore
Maybe TsDuplicatePolicy
Maybe TsEncoding
tsCreateRetention :: TsCreateOpts -> Maybe Integer
tsCreateEncoding :: TsCreateOpts -> Maybe TsEncoding
tsCreateChunkSize :: TsCreateOpts -> Maybe Integer
tsCreateDuplicatePolicy :: TsCreateOpts -> Maybe TsDuplicatePolicy
tsCreateIgnore :: TsCreateOpts -> Maybe TsIgnore
tsCreateLabels :: TsCreateOpts -> [(ByteString, ByteString)]
tsCreateRetention :: Maybe Integer
tsCreateEncoding :: Maybe TsEncoding
tsCreateChunkSize :: Maybe Integer
tsCreateDuplicatePolicy :: Maybe TsDuplicatePolicy
tsCreateIgnore :: Maybe TsIgnore
tsCreateLabels :: [(ByteString, ByteString)]
..} =
    [ByteString]
retentionArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
encodingArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
chunkSizeArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
duplicatePolicyArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
ignoreArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [(ByteString, ByteString)] -> [ByteString]
tsLabelsToArgs [(ByteString, ByteString)]
tsCreateLabels
  where
    retentionArg :: [ByteString]
retentionArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
retention -> [ByteString
"RETENTION", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
retention]) Maybe Integer
tsCreateRetention
    encodingArg :: [ByteString]
encodingArg = [ByteString]
-> (TsEncoding -> [ByteString]) -> Maybe TsEncoding -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\TsEncoding
encoding -> [ByteString
"ENCODING", TsEncoding -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsEncoding
encoding]) Maybe TsEncoding
tsCreateEncoding
    chunkSizeArg :: [ByteString]
chunkSizeArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
size -> [ByteString
"CHUNK_SIZE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
size]) Maybe Integer
tsCreateChunkSize
    duplicatePolicyArg :: [ByteString]
duplicatePolicyArg = [ByteString]
-> (TsDuplicatePolicy -> [ByteString])
-> Maybe TsDuplicatePolicy
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\TsDuplicatePolicy
policy -> [ByteString
"DUPLICATE_POLICY", TsDuplicatePolicy -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsDuplicatePolicy
policy]) Maybe TsDuplicatePolicy
tsCreateDuplicatePolicy
    ignoreArg :: [ByteString]
ignoreArg = [ByteString]
-> (TsIgnore -> [ByteString]) -> Maybe TsIgnore -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] TsIgnore -> [ByteString]
tsIgnoreToArgs Maybe TsIgnore
tsCreateIgnore

tsAlterOptsToArgs :: TsAlterOpts -> [ByteString]
tsAlterOptsToArgs :: TsAlterOpts -> [ByteString]
tsAlterOptsToArgs TsAlterOpts{[(ByteString, ByteString)]
Maybe Integer
Maybe TsDuplicatePolicy
tsAlterRetention :: TsAlterOpts -> Maybe Integer
tsAlterChunkSize :: TsAlterOpts -> Maybe Integer
tsAlterDuplicatePolicy :: TsAlterOpts -> Maybe TsDuplicatePolicy
tsAlterLabels :: TsAlterOpts -> [(ByteString, ByteString)]
tsAlterRetention :: Maybe Integer
tsAlterChunkSize :: Maybe Integer
tsAlterDuplicatePolicy :: Maybe TsDuplicatePolicy
tsAlterLabels :: [(ByteString, ByteString)]
..} =
    [ByteString]
retentionArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
chunkSizeArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
duplicatePolicyArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [(ByteString, ByteString)] -> [ByteString]
tsLabelsToArgs [(ByteString, ByteString)]
tsAlterLabels
  where
    retentionArg :: [ByteString]
retentionArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
retention -> [ByteString
"RETENTION", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
retention]) Maybe Integer
tsAlterRetention
    chunkSizeArg :: [ByteString]
chunkSizeArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
size -> [ByteString
"CHUNK_SIZE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
size]) Maybe Integer
tsAlterChunkSize
    duplicatePolicyArg :: [ByteString]
duplicatePolicyArg = [ByteString]
-> (TsDuplicatePolicy -> [ByteString])
-> Maybe TsDuplicatePolicy
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\TsDuplicatePolicy
policy -> [ByteString
"DUPLICATE_POLICY", TsDuplicatePolicy -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsDuplicatePolicy
policy]) Maybe TsDuplicatePolicy
tsAlterDuplicatePolicy

tsAddOptsToArgs :: TsAddOpts -> [ByteString]
tsAddOptsToArgs :: TsAddOpts -> [ByteString]
tsAddOptsToArgs TsAddOpts{[(ByteString, ByteString)]
Maybe Integer
Maybe TsIgnore
Maybe TsDuplicatePolicy
Maybe TsEncoding
tsAddRetention :: TsAddOpts -> Maybe Integer
tsAddEncoding :: TsAddOpts -> Maybe TsEncoding
tsAddChunkSize :: TsAddOpts -> Maybe Integer
tsAddOnDuplicate :: TsAddOpts -> Maybe TsDuplicatePolicy
tsAddIgnore :: TsAddOpts -> Maybe TsIgnore
tsAddLabels :: TsAddOpts -> [(ByteString, ByteString)]
tsAddRetention :: Maybe Integer
tsAddEncoding :: Maybe TsEncoding
tsAddChunkSize :: Maybe Integer
tsAddOnDuplicate :: Maybe TsDuplicatePolicy
tsAddIgnore :: Maybe TsIgnore
tsAddLabels :: [(ByteString, ByteString)]
..} =
    [ByteString]
retentionArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
encodingArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
chunkSizeArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
onDuplicateArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
ignoreArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [(ByteString, ByteString)] -> [ByteString]
tsLabelsToArgs [(ByteString, ByteString)]
tsAddLabels
  where
    retentionArg :: [ByteString]
retentionArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
retention -> [ByteString
"RETENTION", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
retention]) Maybe Integer
tsAddRetention
    encodingArg :: [ByteString]
encodingArg = [ByteString]
-> (TsEncoding -> [ByteString]) -> Maybe TsEncoding -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\TsEncoding
encoding -> [ByteString
"ENCODING", TsEncoding -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsEncoding
encoding]) Maybe TsEncoding
tsAddEncoding
    chunkSizeArg :: [ByteString]
chunkSizeArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
size -> [ByteString
"CHUNK_SIZE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
size]) Maybe Integer
tsAddChunkSize
    onDuplicateArg :: [ByteString]
onDuplicateArg = [ByteString]
-> (TsDuplicatePolicy -> [ByteString])
-> Maybe TsDuplicatePolicy
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\TsDuplicatePolicy
policy -> [ByteString
"ON_DUPLICATE", TsDuplicatePolicy -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsDuplicatePolicy
policy]) Maybe TsDuplicatePolicy
tsAddOnDuplicate
    ignoreArg :: [ByteString]
ignoreArg = [ByteString]
-> (TsIgnore -> [ByteString]) -> Maybe TsIgnore -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] TsIgnore -> [ByteString]
tsIgnoreToArgs Maybe TsIgnore
tsAddIgnore

tsIncrByOptsToArgs :: TsIncrByOpts -> [ByteString]
tsIncrByOptsToArgs :: TsIncrByOpts -> [ByteString]
tsIncrByOptsToArgs TsIncrByOpts{Bool
[(ByteString, ByteString)]
Maybe Integer
Maybe ByteString
Maybe TsIgnore
Maybe TsDuplicatePolicy
tsIncrByTimestamp :: TsIncrByOpts -> Maybe ByteString
tsIncrByRetention :: TsIncrByOpts -> Maybe Integer
tsIncrByUncompressed :: TsIncrByOpts -> Bool
tsIncrByChunkSize :: TsIncrByOpts -> Maybe Integer
tsIncrByDuplicatePolicy :: TsIncrByOpts -> Maybe TsDuplicatePolicy
tsIncrByIgnore :: TsIncrByOpts -> Maybe TsIgnore
tsIncrByLabels :: TsIncrByOpts -> [(ByteString, ByteString)]
tsIncrByTimestamp :: Maybe ByteString
tsIncrByRetention :: Maybe Integer
tsIncrByUncompressed :: Bool
tsIncrByChunkSize :: Maybe Integer
tsIncrByDuplicatePolicy :: Maybe TsDuplicatePolicy
tsIncrByIgnore :: Maybe TsIgnore
tsIncrByLabels :: [(ByteString, ByteString)]
..} =
    [ByteString]
timestampArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
retentionArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
uncompressedArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
chunkSizeArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
duplicatePolicyArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
ignoreArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [(ByteString, ByteString)] -> [ByteString]
tsLabelsToArgs [(ByteString, ByteString)]
tsIncrByLabels
  where
    timestampArg :: [ByteString]
timestampArg = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
timestamp -> [ByteString
"TIMESTAMP", ByteString
timestamp]) Maybe ByteString
tsIncrByTimestamp
    retentionArg :: [ByteString]
retentionArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
retention -> [ByteString
"RETENTION", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
retention]) Maybe Integer
tsIncrByRetention
    uncompressedArg :: [ByteString]
uncompressedArg = [ByteString
"UNCOMPRESSED" | Bool
tsIncrByUncompressed]
    chunkSizeArg :: [ByteString]
chunkSizeArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
size -> [ByteString
"CHUNK_SIZE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
size]) Maybe Integer
tsIncrByChunkSize
    duplicatePolicyArg :: [ByteString]
duplicatePolicyArg = [ByteString]
-> (TsDuplicatePolicy -> [ByteString])
-> Maybe TsDuplicatePolicy
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\TsDuplicatePolicy
policy -> [ByteString
"DUPLICATE_POLICY", TsDuplicatePolicy -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsDuplicatePolicy
policy]) Maybe TsDuplicatePolicy
tsIncrByDuplicatePolicy
    ignoreArg :: [ByteString]
ignoreArg = [ByteString]
-> (TsIgnore -> [ByteString]) -> Maybe TsIgnore -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] TsIgnore -> [ByteString]
tsIgnoreToArgs Maybe TsIgnore
tsIncrByIgnore

tsAggregationToArgs :: TsAggregationOpts -> [ByteString]
tsAggregationToArgs :: TsAggregationOpts -> [ByteString]
tsAggregationToArgs TsAggregationOpts{Bool
Integer
Maybe ByteString
Maybe TsBucketTimestamp
TsAggregators
tsAggregationAlign :: TsAggregationOpts -> Maybe ByteString
tsAggregationType :: TsAggregationOpts -> TsAggregators
tsAggregationBucketDuration :: TsAggregationOpts -> Integer
tsAggregationBucketTimestamp :: TsAggregationOpts -> Maybe TsBucketTimestamp
tsAggregationEmpty :: TsAggregationOpts -> Bool
tsAggregationAlign :: Maybe ByteString
tsAggregationType :: TsAggregators
tsAggregationBucketDuration :: Integer
tsAggregationBucketTimestamp :: Maybe TsBucketTimestamp
tsAggregationEmpty :: Bool
..} =
    [ByteString]
alignArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"AGGREGATION", TsAggregators -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsAggregators
tsAggregationType, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
tsAggregationBucketDuration] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
bucketTimestampArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
emptyArg
  where
    alignArg :: [ByteString]
alignArg = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
align -> [ByteString
"ALIGN", ByteString
align]) Maybe ByteString
tsAggregationAlign
    bucketTimestampArg :: [ByteString]
bucketTimestampArg = [ByteString]
-> (TsBucketTimestamp -> [ByteString])
-> Maybe TsBucketTimestamp
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\TsBucketTimestamp
bt -> [ByteString
"BUCKETTIMESTAMP", TsBucketTimestamp -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsBucketTimestamp
bt]) Maybe TsBucketTimestamp
tsAggregationBucketTimestamp
    emptyArg :: [ByteString]
emptyArg = [ByteString
"EMPTY" | Bool
tsAggregationEmpty]

tsRangeOptsToArgs :: TsRangeOpts -> [ByteString]
tsRangeOptsToArgs :: TsRangeOpts -> [ByteString]
tsRangeOptsToArgs TsRangeOpts{Bool
[Integer]
Maybe Integer
Maybe (Double, Double)
Maybe TsAggregationOpts
tsRangeLatest :: TsRangeOpts -> Bool
tsRangeFilterByTs :: TsRangeOpts -> [Integer]
tsRangeFilterByValue :: TsRangeOpts -> Maybe (Double, Double)
tsRangeCount :: TsRangeOpts -> Maybe Integer
tsRangeAggregation :: TsRangeOpts -> Maybe TsAggregationOpts
tsRangeLatest :: Bool
tsRangeFilterByTs :: [Integer]
tsRangeFilterByValue :: Maybe (Double, Double)
tsRangeCount :: Maybe Integer
tsRangeAggregation :: Maybe TsAggregationOpts
..} =
    [ByteString]
latestArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
filterByTsArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
filterByValueArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
countArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
aggregationArg
  where
    latestArg :: [ByteString]
latestArg = [ByteString
"LATEST" | Bool
tsRangeLatest]
    filterByTsArg :: [ByteString]
filterByTsArg = [ByteString
"FILTER_BY_TS" | Bool -> Bool
not ([Integer] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Integer]
tsRangeFilterByTs)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (Integer -> ByteString) -> [Integer] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode [Integer]
tsRangeFilterByTs
    filterByValueArg :: [ByteString]
filterByValueArg = [ByteString]
-> ((Double, Double) -> [ByteString])
-> Maybe (Double, Double)
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\(Double
minValue, Double
maxValue) -> [ByteString
"FILTER_BY_VALUE", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
minValue, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
maxValue]) Maybe (Double, Double)
tsRangeFilterByValue
    countArg :: [ByteString]
countArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
count -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]) Maybe Integer
tsRangeCount
    aggregationArg :: [ByteString]
aggregationArg = [ByteString]
-> (TsAggregationOpts -> [ByteString])
-> Maybe TsAggregationOpts
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] TsAggregationOpts -> [ByteString]
tsAggregationToArgs Maybe TsAggregationOpts
tsRangeAggregation

tsLabelSelectionToArgs :: TsLabelSelection -> [ByteString]
tsLabelSelectionToArgs :: TsLabelSelection -> [ByteString]
tsLabelSelectionToArgs TsLabelSelection
TsWithLabels = [ByteString
"WITHLABELS"]
tsLabelSelectionToArgs (TsSelectedLabels NonEmpty ByteString
labels) = [ByteString
"SELECTED_LABELS"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
labels

tsMGetOptsToArgs :: TsMGetOpts -> [ByteString]
tsMGetOptsToArgs :: TsMGetOpts -> [ByteString]
tsMGetOptsToArgs TsMGetOpts{Bool
Maybe TsLabelSelection
tsMGetLatest :: TsMGetOpts -> Bool
tsMGetLabels :: TsMGetOpts -> Maybe TsLabelSelection
tsMGetLatest :: Bool
tsMGetLabels :: Maybe TsLabelSelection
..} =
    [ByteString]
latestArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
labelsArg
  where
    latestArg :: [ByteString]
latestArg = [ByteString
"LATEST" | Bool
tsMGetLatest]
    labelsArg :: [ByteString]
labelsArg = [ByteString]
-> (TsLabelSelection -> [ByteString])
-> Maybe TsLabelSelection
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] TsLabelSelection -> [ByteString]
tsLabelSelectionToArgs Maybe TsLabelSelection
tsMGetLabels

tsGroupByReduceToArgs :: TsGroupByReduce -> [ByteString]
tsGroupByReduceToArgs :: TsGroupByReduce -> [ByteString]
tsGroupByReduceToArgs TsGroupByReduce{ByteString
TsAggregator
tsGroupByLabel :: TsGroupByReduce -> ByteString
tsGroupByReducer :: TsGroupByReduce -> TsAggregator
tsGroupByLabel :: ByteString
tsGroupByReducer :: TsAggregator
..} =
    [ByteString
"GROUPBY", ByteString
tsGroupByLabel, ByteString
"REDUCE", TsAggregator -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsAggregator
tsGroupByReducer]

tsMRangeOptsToArgs :: TsMRangeOpts -> [ByteString]
tsMRangeOptsToArgs :: TsMRangeOpts -> [ByteString]
tsMRangeOptsToArgs TsMRangeOpts{Bool
[Integer]
Maybe Integer
Maybe (Double, Double)
Maybe TsGroupByReduce
Maybe TsLabelSelection
Maybe TsAggregationOpts
tsMRangeLatest :: TsMRangeOpts -> Bool
tsMRangeFilterByTs :: TsMRangeOpts -> [Integer]
tsMRangeFilterByValue :: TsMRangeOpts -> Maybe (Double, Double)
tsMRangeLabels :: TsMRangeOpts -> Maybe TsLabelSelection
tsMRangeCount :: TsMRangeOpts -> Maybe Integer
tsMRangeAggregation :: TsMRangeOpts -> Maybe TsAggregationOpts
tsMRangeGroupByReduce :: TsMRangeOpts -> Maybe TsGroupByReduce
tsMRangeLatest :: Bool
tsMRangeFilterByTs :: [Integer]
tsMRangeFilterByValue :: Maybe (Double, Double)
tsMRangeLabels :: Maybe TsLabelSelection
tsMRangeCount :: Maybe Integer
tsMRangeAggregation :: Maybe TsAggregationOpts
tsMRangeGroupByReduce :: Maybe TsGroupByReduce
..} =
    [ByteString]
latestArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
filterByTsArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
filterByValueArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
labelsArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
countArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
aggregationArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
groupByReduceArg
  where
    latestArg :: [ByteString]
latestArg = [ByteString
"LATEST" | Bool
tsMRangeLatest]
    filterByTsArg :: [ByteString]
filterByTsArg = [ByteString
"FILTER_BY_TS" | Bool -> Bool
not ([Integer] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Integer]
tsMRangeFilterByTs)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (Integer -> ByteString) -> [Integer] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode [Integer]
tsMRangeFilterByTs
    filterByValueArg :: [ByteString]
filterByValueArg = [ByteString]
-> ((Double, Double) -> [ByteString])
-> Maybe (Double, Double)
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\(Double
minValue, Double
maxValue) -> [ByteString
"FILTER_BY_VALUE", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
minValue, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
maxValue]) Maybe (Double, Double)
tsMRangeFilterByValue
    labelsArg :: [ByteString]
labelsArg = [ByteString]
-> (TsLabelSelection -> [ByteString])
-> Maybe TsLabelSelection
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] TsLabelSelection -> [ByteString]
tsLabelSelectionToArgs Maybe TsLabelSelection
tsMRangeLabels
    countArg :: [ByteString]
countArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
count -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]) Maybe Integer
tsMRangeCount
    aggregationArg :: [ByteString]
aggregationArg = [ByteString]
-> (TsAggregationOpts -> [ByteString])
-> Maybe TsAggregationOpts
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] TsAggregationOpts -> [ByteString]
tsAggregationToArgs Maybe TsAggregationOpts
tsMRangeAggregation
    groupByReduceArg :: [ByteString]
groupByReduceArg = [ByteString]
-> (TsGroupByReduce -> [ByteString])
-> Maybe TsGroupByReduce
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] TsGroupByReduce -> [ByteString]
tsGroupByReduceToArgs Maybe TsGroupByReduce
tsMRangeGroupByReduce

-- |Appends a sample to a time series (<https://redis.io/commands/ts.add>).
--
-- /O(M)/ when /M/ is the number of compaction rules, or /O(1)/ with no compaction
--
-- Since RedisTimeSeries 1.0.0
tsAdd
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> ByteString -- ^ Timestamp, or @*@ for the current server time.
    -> Double -- ^ Sample value.
    -> m (f Integer)
tsAdd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Double -> m (f Integer)
tsAdd ByteString
key ByteString
timestamp Double
value = ByteString -> ByteString -> Double -> TsAddOpts -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Double -> TsAddOpts -> m (f Integer)
tsAddOpts ByteString
key ByteString
timestamp Double
value TsAddOpts
defaultTsAddOpts

-- |Appends a sample to a time series (<https://redis.io/commands/ts.add>).
--
-- /O(M)/ when /M/ is the number of compaction rules, or /O(1)/ with no compaction
--
-- Since RedisTimeSeries 1.0.0
tsAddOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> ByteString -- ^ Timestamp, or @*@ for the current server time.
    -> Double -- ^ Sample value.
    -> TsAddOpts -- ^ Insertion options.
    -> m (f Integer)
tsAddOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Double -> TsAddOpts -> m (f Integer)
tsAddOpts ByteString
key ByteString
timestamp Double
value TsAddOpts
opts =
    [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.ADD", ByteString
key, ByteString
timestamp, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
value] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsAddOpts -> [ByteString]
tsAddOptsToArgs TsAddOpts
opts

-- |Update the retention, chunk size, duplicate policy, and labels of an existing time series (<https://redis.io/commands/ts.alter>).
--
-- /O(N)/ where /N/ is the number of labels requested to update
--
-- Since RedisTimeSeries 1.0.0
tsAlter
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> TsAlterOpts -- ^ Alteration options.
    -> m (f Status)
tsAlter :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> TsAlterOpts -> m (f Status)
tsAlter ByteString
key TsAlterOpts
opts = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.ALTER", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsAlterOpts -> [ByteString]
tsAlterOptsToArgs TsAlterOpts
opts

-- |Create a new time series (<https://redis.io/commands/ts.create>).
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.0.0
tsCreate
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> m (f Status)
tsCreate :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Status)
tsCreate ByteString
key = ByteString -> TsCreateOpts -> m (f Status)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> TsCreateOpts -> m (f Status)
tsCreateOpts ByteString
key TsCreateOpts
defaultTsCreateOpts

-- |Create a new time series (<https://redis.io/commands/ts.create>).
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.0.0
tsCreateOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> TsCreateOpts -- ^ Creation options.
    -> m (f Status)
tsCreateOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> TsCreateOpts -> m (f Status)
tsCreateOpts ByteString
key TsCreateOpts
opts = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.CREATE", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsCreateOpts -> [ByteString]
tsCreateOptsToArgs TsCreateOpts
opts

-- |Create a compaction rule (<https://redis.io/commands/ts.createrule>).
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.0.0
tsCreaterule
    :: (RedisCtx m f)
    => ByteString -- ^ Source time series key.
    -> ByteString -- ^ Destination time series key.
    -> TsAggregator -- ^ Aggregation function.
    -> Integer -- ^ Bucket duration in milliseconds.
    -> m (f Status)
tsCreaterule :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> TsAggregator -> Integer -> m (f Status)
tsCreaterule ByteString
source ByteString
destination TsAggregator
aggregator Integer
bucketDuration =
    [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"TS.CREATERULE", ByteString
source, ByteString
destination, ByteString
"AGGREGATION", TsAggregator -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsAggregator
aggregator, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
bucketDuration]

-- |Create a compaction rule with an aligned bucket timestamp (<https://redis.io/commands/ts.createrule>).
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.8.0
tsCreateruleAlign
    :: (RedisCtx m f)
    => ByteString -- ^ Source time series key.
    -> ByteString -- ^ Destination time series key.
    -> TsAggregator -- ^ Aggregation function.
    -> Integer -- ^ Bucket duration in milliseconds.
    -> Integer -- ^ Alignment timestamp in milliseconds.
    -> m (f Status)
tsCreateruleAlign :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> TsAggregator -> Integer -> Integer -> m (f Status)
tsCreateruleAlign ByteString
source ByteString
destination TsAggregator
aggregator Integer
bucketDuration Integer
alignTimestamp =
    [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"TS.CREATERULE", ByteString
source, ByteString
destination, ByteString
"AGGREGATION", TsAggregator -> ByteString
forall a. RedisArg a => a -> ByteString
encode TsAggregator
aggregator, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
bucketDuration, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
alignTimestamp]

-- |Decrease the value of the sample with the maximum timestamp, or create a new sample with a decremented value (<https://redis.io/commands/ts.decrby>).
--
-- /O(M)/ when /M/ is the number of compaction rules, or /O(1)/ with no compaction
--
-- Since RedisTimeSeries 1.0.0
tsDecrby
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> Double -- ^ Decrement amount.
    -> m (f Integer)
tsDecrby :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> m (f Integer)
tsDecrby ByteString
key Double
value = ByteString -> Double -> TsIncrByOpts -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> TsIncrByOpts -> m (f Integer)
tsDecrbyOpts ByteString
key Double
value TsIncrByOpts
defaultTsIncrByOpts

-- |Decrease the value of the sample with the maximum timestamp, or create a new sample with a decremented value (<https://redis.io/commands/ts.decrby>).
--
-- /O(M)/ when /M/ is the number of compaction rules, or /O(1)/ with no compaction
--
-- Since RedisTimeSeries 1.0.0
tsDecrbyOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> Double -- ^ Decrement amount.
    -> TsIncrByOpts -- ^ Update options.
    -> m (f Integer)
tsDecrbyOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> TsIncrByOpts -> m (f Integer)
tsDecrbyOpts ByteString
key Double
value TsIncrByOpts
opts =
    [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.DECRBY", ByteString
key, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
value] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsIncrByOpts -> [ByteString]
tsIncrByOptsToArgs TsIncrByOpts
opts

-- |Delete all samples between two timestamps for a given time series (<https://redis.io/commands/ts.del>).
--
-- /O(N)/ where /N/ is the number of data points that will be removed
--
-- Since RedisTimeSeries 1.6.0
tsDel
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> Integer -- ^ Lower timestamp bound.
    -> Integer -- ^ Upper timestamp bound.
    -> m (f Integer)
tsDel :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f Integer)
tsDel ByteString
key Integer
fromTimestamp Integer
toTimestamp =
    [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"TS.DEL", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
fromTimestamp, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
toTimestamp]

-- |Delete a compaction rule (<https://redis.io/commands/ts.delrule>).
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.0.0
tsDelrule
    :: (RedisCtx m f)
    => ByteString -- ^ Source time series key.
    -> ByteString -- ^ Destination time series key.
    -> m (f Status)
tsDelrule :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Status)
tsDelrule ByteString
source ByteString
destination = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"TS.DELRULE", ByteString
source, ByteString
destination]

-- |Get the sample with the highest timestamp from a given time series (<https://redis.io/commands/ts.get>).
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.0.0
tsGet
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> m (f (Maybe TsSample))
tsGet :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe TsSample))
tsGet ByteString
key = ByteString -> TsGetOpts -> m (f (Maybe TsSample))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> TsGetOpts -> m (f (Maybe TsSample))
tsGetOpts ByteString
key TsGetOpts
defaultTsGetOpts

-- |Get the sample with the highest timestamp from a given time series (<https://redis.io/commands/ts.get>).
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.0.0
tsGetOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> TsGetOpts -- ^ Read options.
    -> m (f (Maybe TsSample))
tsGetOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> TsGetOpts -> m (f (Maybe TsSample))
tsGetOpts ByteString
key TsGetOpts{Bool
tsGetLatest :: TsGetOpts -> Bool
tsGetLatest :: Bool
..} =
    [ByteString] -> m (f (Maybe TsSample))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe TsSample)))
-> [ByteString] -> m (f (Maybe TsSample))
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.GET", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"LATEST" | Bool
tsGetLatest]

-- |Increase the value of the sample with the maximum timestamp, or create a new sample with an incremented value (<https://redis.io/commands/ts.incrby>).
--
-- /O(M)/ when /M/ is the number of compaction rules, or /O(1)/ with no compaction
--
-- Since RedisTimeSeries 1.0.0
tsIncrby
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> Double -- ^ Increment amount.
    -> m (f Integer)
tsIncrby :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> m (f Integer)
tsIncrby ByteString
key Double
value = ByteString -> Double -> TsIncrByOpts -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> TsIncrByOpts -> m (f Integer)
tsIncrbyOpts ByteString
key Double
value TsIncrByOpts
defaultTsIncrByOpts

-- |Increase the value of the sample with the maximum timestamp, or create a new sample with an incremented value (<https://redis.io/commands/ts.incrby>).
--
-- /O(M)/ when /M/ is the number of compaction rules, or /O(1)/ with no compaction
--
-- Since RedisTimeSeries 1.0.0
tsIncrbyOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> Double -- ^ Increment amount.
    -> TsIncrByOpts -- ^ Update options.
    -> m (f Integer)
tsIncrbyOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> TsIncrByOpts -> m (f Integer)
tsIncrbyOpts ByteString
key Double
value TsIncrByOpts
opts =
    [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.INCRBY", ByteString
key, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
value] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsIncrByOpts -> [ByteString]
tsIncrByOptsToArgs TsIncrByOpts
opts

-- |Returns information and statistics for a time series (<https://redis.io/commands/ts.info>).
--
-- The reply is a heterogeneous attribute map, so this wrapper returns the raw 'Reply'.
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.0.0
tsInfo
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> m (f Reply)
tsInfo :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Reply)
tsInfo ByteString
key = ByteString -> TsInfoOpts -> m (f Reply)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> TsInfoOpts -> m (f Reply)
tsInfoOpts ByteString
key TsInfoOpts
TsInfoDefault

-- |Returns information and statistics for a time series (<https://redis.io/commands/ts.info>).
--
-- The reply is a heterogeneous attribute map, so this wrapper returns the raw 'Reply'.
--
-- /O(1)/
--
-- Since RedisTimeSeries 1.0.0
tsInfoOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> TsInfoOpts -- ^ Information query options.
    -> m (f Reply)
tsInfoOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> TsInfoOpts -> m (f Reply)
tsInfoOpts ByteString
key TsInfoOpts
infoOpts =
    [ByteString] -> m (f Reply)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Reply)) -> [ByteString] -> m (f Reply)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.INFO", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ case TsInfoOpts
infoOpts of
        TsInfoOpts
TsInfoDefault -> []
        TsInfoOpts
TsInfoDebug -> [ByteString
"DEBUG"]

-- |Append new samples to one or more time series (<https://redis.io/commands/ts.madd>).
--
-- /O(N \cdot M)/ when /N/ is the number of series updated and /M/ is the number of compaction rules, or /O(N)/ with no compaction
--
-- Since RedisTimeSeries 1.0.0
tsMadd
    :: (RedisCtx m f)
    => NonEmpty (ByteString, ByteString, Double) -- ^ Time series key, timestamp, and sample value triplets.
    -> m (f [Integer])
tsMadd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty (ByteString, ByteString, Double) -> m (f [Integer])
tsMadd NonEmpty (ByteString, ByteString, Double)
triples = [ByteString] -> m (f [Integer])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [Integer]))
-> [ByteString] -> m (f [Integer])
forall a b. (a -> b) -> a -> b
$ ByteString
"TS.MADD" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ((ByteString, ByteString, Double) -> [ByteString])
-> [(ByteString, ByteString, Double)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ByteString, ByteString, Double) -> [ByteString]
forall {a}.
RedisArg a =>
(ByteString, ByteString, a) -> [ByteString]
encodeTriple (NonEmpty (ByteString, ByteString, Double)
-> [(ByteString, ByteString, Double)]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty (ByteString, ByteString, Double)
triples)
  where
    encodeTriple :: (ByteString, ByteString, a) -> [ByteString]
encodeTriple (ByteString
key, ByteString
timestamp, a
value) = [ByteString
key, ByteString
timestamp, a -> ByteString
forall a. RedisArg a => a -> ByteString
encode a
value]

-- |Get the sample with the highest timestamp from each time series matching a specific filter (<https://redis.io/commands/ts.mget>).
--
-- The reply is heterogeneous and depends on label options, so this wrapper returns the raw 'Reply'.
--
-- /O(n)/ where /n/ is the number of time-series that match the filters
--
-- Since RedisTimeSeries 1.0.0
tsMget
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ Filter expressions.
    -> m (f Reply)
tsMget :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f Reply)
tsMget NonEmpty ByteString
filters = NonEmpty ByteString -> TsMGetOpts -> m (f Reply)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> TsMGetOpts -> m (f Reply)
tsMgetOpts NonEmpty ByteString
filters TsMGetOpts
defaultTsMGetOpts

-- |Get the sample with the highest timestamp from each time series matching a specific filter (<https://redis.io/commands/ts.mget>).
--
-- The reply is heterogeneous and depends on label options, so this wrapper returns the raw 'Reply'.
--
-- /O(n)/ where /n/ is the number of time-series that match the filters
--
-- Since RedisTimeSeries 1.0.0
tsMgetOpts
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ Filter expressions.
    -> TsMGetOpts -- ^ Read options.
    -> m (f Reply)
tsMgetOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> TsMGetOpts -> m (f Reply)
tsMgetOpts NonEmpty ByteString
filters TsMGetOpts
opts =
    [ByteString] -> m (f Reply)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Reply)) -> [ByteString] -> m (f Reply)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.MGET"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsMGetOpts -> [ByteString]
tsMGetOptsToArgs TsMGetOpts
opts [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"FILTER"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
filters

-- |Query a range across multiple time series by filters in forward direction (<https://redis.io/commands/ts.mrange>).
--
-- The reply is heterogeneous and may include labels or grouped output, so this wrapper returns the raw 'Reply'.
--
-- /O(n\/m+k)/ where /n/ is the number of data points, /m/ is the chunk size, and /k/ is the number of returned samples
--
-- Since RedisTimeSeries 1.0.0
tsMrange
    :: (RedisCtx m f)
    => ByteString -- ^ Lower timestamp bound, or @-@.
    -> ByteString -- ^ Upper timestamp bound, or @+@.
    -> NonEmpty ByteString -- ^ Filter expressions.
    -> m (f Reply)
tsMrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> NonEmpty ByteString -> m (f Reply)
tsMrange ByteString
fromTimestamp ByteString
toTimestamp NonEmpty ByteString
filters =
    ByteString
-> ByteString -> NonEmpty ByteString -> TsMRangeOpts -> m (f Reply)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> NonEmpty ByteString -> TsMRangeOpts -> m (f Reply)
tsMrangeOpts ByteString
fromTimestamp ByteString
toTimestamp NonEmpty ByteString
filters TsMRangeOpts
defaultTsMRangeOpts

-- |Query a range across multiple time series by filters in forward direction (<https://redis.io/commands/ts.mrange>).
--
-- The reply is heterogeneous and may include labels or grouped output, so this wrapper returns the raw 'Reply'.
--
-- /O(n\/m+k)/ where /n/ is the number of data points, /m/ is the chunk size, and /k/ is the number of returned samples
--
-- Since RedisTimeSeries 1.0.0
tsMrangeOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Lower timestamp bound, or @-@.
    -> ByteString -- ^ Upper timestamp bound, or @+@.
    -> NonEmpty ByteString -- ^ Filter expressions.
    -> TsMRangeOpts -- ^ Query options.
    -> m (f Reply)
tsMrangeOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> NonEmpty ByteString -> TsMRangeOpts -> m (f Reply)
tsMrangeOpts ByteString
fromTimestamp ByteString
toTimestamp NonEmpty ByteString
filters TsMRangeOpts
opts =
    [ByteString] -> m (f Reply)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Reply)) -> [ByteString] -> m (f Reply)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.MRANGE", ByteString
fromTimestamp, ByteString
toTimestamp] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsMRangeOpts -> [ByteString]
tsMRangeOptsToArgs TsMRangeOpts
opts [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"FILTER"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
filters

-- |Query a range across multiple time series by filters in reverse direction (<https://redis.io/commands/ts.mrevrange>).
--
-- The reply is heterogeneous and may include labels or grouped output, so this wrapper returns the raw 'Reply'.
--
-- /O(n\/m+k)/ where /n/ is the number of data points, /m/ is the chunk size, and /k/ is the number of returned samples
--
-- Since RedisTimeSeries 1.4.0
tsMrevrange
    :: (RedisCtx m f)
    => ByteString -- ^ Lower timestamp bound, or @-@.
    -> ByteString -- ^ Upper timestamp bound, or @+@.
    -> NonEmpty ByteString -- ^ Filter expressions.
    -> m (f Reply)
tsMrevrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> NonEmpty ByteString -> m (f Reply)
tsMrevrange ByteString
fromTimestamp ByteString
toTimestamp NonEmpty ByteString
filters =
    ByteString
-> ByteString -> NonEmpty ByteString -> TsMRangeOpts -> m (f Reply)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> NonEmpty ByteString -> TsMRangeOpts -> m (f Reply)
tsMrevrangeOpts ByteString
fromTimestamp ByteString
toTimestamp NonEmpty ByteString
filters TsMRangeOpts
defaultTsMRangeOpts

-- |Query a range across multiple time series by filters in reverse direction (<https://redis.io/commands/ts.mrevrange>).
--
-- The reply is heterogeneous and may include labels or grouped output, so this wrapper returns the raw 'Reply'.
--
-- /O(n\/m+k)/ where /n/ is the number of data points, /m/ is the chunk size, and /k/ is the number of returned samples
--
-- Since RedisTimeSeries 1.4.0
tsMrevrangeOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Lower timestamp bound, or @-@.
    -> ByteString -- ^ Upper timestamp bound, or @+@.
    -> NonEmpty ByteString -- ^ Filter expressions.
    -> TsMRangeOpts -- ^ Query options.
    -> m (f Reply)
tsMrevrangeOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> NonEmpty ByteString -> TsMRangeOpts -> m (f Reply)
tsMrevrangeOpts ByteString
fromTimestamp ByteString
toTimestamp NonEmpty ByteString
filters TsMRangeOpts
opts =
    [ByteString] -> m (f Reply)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Reply)) -> [ByteString] -> m (f Reply)
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.MREVRANGE", ByteString
fromTimestamp, ByteString
toTimestamp] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsMRangeOpts -> [ByteString]
tsMRangeOptsToArgs TsMRangeOpts
opts [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"FILTER"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
filters

-- |Get all time series keys matching a filter list (<https://redis.io/commands/ts.queryindex>).
--
-- /O(n)/ where /n/ is the number of time-series that match the filters
--
-- Since RedisTimeSeries 1.0.0
tsQueryindex
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ Filter expressions.
    -> m (f [ByteString])
tsQueryindex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [ByteString])
tsQueryindex NonEmpty ByteString
filters = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [ByteString]))
-> [ByteString] -> m (f [ByteString])
forall a b. (a -> b) -> a -> b
$ ByteString
"TS.QUERYINDEX" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
filters

-- |Query a range in forward direction (<https://redis.io/commands/ts.range>).
--
-- /O(n\/m+k)/ where /n/ is the number of data points, /m/ is the chunk size, and /k/ is the number of returned samples
--
-- Since RedisTimeSeries 1.0.0
tsRange
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> ByteString -- ^ Lower timestamp bound, or @-@.
    -> ByteString -- ^ Upper timestamp bound, or @+@.
    -> m (f [TsSample])
tsRange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f [TsSample])
tsRange ByteString
key ByteString
fromTimestamp ByteString
toTimestamp =
    ByteString
-> ByteString -> ByteString -> TsRangeOpts -> m (f [TsSample])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> TsRangeOpts -> m (f [TsSample])
tsRangeOpts ByteString
key ByteString
fromTimestamp ByteString
toTimestamp TsRangeOpts
defaultTsRangeOpts

-- |Query a range in forward direction (<https://redis.io/commands/ts.range>).
--
-- /O(n\/m+k)/ where /n/ is the number of data points, /m/ is the chunk size, and /k/ is the number of returned samples
--
-- Since RedisTimeSeries 1.0.0
tsRangeOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> ByteString -- ^ Lower timestamp bound, or @-@.
    -> ByteString -- ^ Upper timestamp bound, or @+@.
    -> TsRangeOpts -- ^ Query options.
    -> m (f [TsSample])
tsRangeOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> TsRangeOpts -> m (f [TsSample])
tsRangeOpts ByteString
key ByteString
fromTimestamp ByteString
toTimestamp TsRangeOpts
opts =
    [ByteString] -> m (f [TsSample])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [TsSample]))
-> [ByteString] -> m (f [TsSample])
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.RANGE", ByteString
key, ByteString
fromTimestamp, ByteString
toTimestamp] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsRangeOpts -> [ByteString]
tsRangeOptsToArgs TsRangeOpts
opts

-- |Query a range in reverse direction (<https://redis.io/commands/ts.revrange>).
--
-- /O(n\/m+k)/ where /n/ is the number of data points, /m/ is the chunk size, and /k/ is the number of returned samples
--
-- Since RedisTimeSeries 1.4.0
tsRevrange
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> ByteString -- ^ Lower timestamp bound, or @-@.
    -> ByteString -- ^ Upper timestamp bound, or @+@.
    -> m (f [TsSample])
tsRevrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f [TsSample])
tsRevrange ByteString
key ByteString
fromTimestamp ByteString
toTimestamp =
    ByteString
-> ByteString -> ByteString -> TsRangeOpts -> m (f [TsSample])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> TsRangeOpts -> m (f [TsSample])
tsRevrangeOpts ByteString
key ByteString
fromTimestamp ByteString
toTimestamp TsRangeOpts
defaultTsRangeOpts

-- |Query a range in reverse direction (<https://redis.io/commands/ts.revrange>).
--
-- /O(n\/m+k)/ where /n/ is the number of data points, /m/ is the chunk size, and /k/ is the number of returned samples
--
-- Since RedisTimeSeries 1.4.0
tsRevrangeOpts
    :: (RedisCtx m f)
    => ByteString -- ^ Time series key.
    -> ByteString -- ^ Lower timestamp bound, or @-@.
    -> ByteString -- ^ Upper timestamp bound, or @+@.
    -> TsRangeOpts -- ^ Query options.
    -> m (f [TsSample])
tsRevrangeOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> TsRangeOpts -> m (f [TsSample])
tsRevrangeOpts ByteString
key ByteString
fromTimestamp ByteString
toTimestamp TsRangeOpts
opts =
    [ByteString] -> m (f [TsSample])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [TsSample]))
-> [ByteString] -> m (f [TsSample])
forall a b. (a -> b) -> a -> b
$ [ByteString
"TS.REVRANGE", ByteString
key, ByteString
fromTimestamp, ByteString
toTimestamp] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ TsRangeOpts -> [ByteString]
tsRangeOptsToArgs TsRangeOpts
opts