{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Database.Bloodhound.Internal.Versions.Common.Types.Reindex where
import Data.Aeson
import Data.List.NonEmpty
import Data.Text (Text)
import Database.Bloodhound.Internal.Utils.Imports (omitNulls)
import Database.Bloodhound.Internal.Versions.Common.Types.Newtypes (IndexName)
import Database.Bloodhound.Internal.Versions.Common.Types.Query (Query)
import Database.Bloodhound.Internal.Versions.Common.Types.Script (ScriptLanguage)
import GHC.Generics
import Optics.Lens
data ReindexRequest = ReindexRequest
{ ReindexRequest -> Maybe ReindexConflicts
reindexConflicts :: Maybe ReindexConflicts,
ReindexRequest -> ReindexSource
reindexSource :: ReindexSource,
ReindexRequest -> ReindexDest
reindexDest :: ReindexDest,
ReindexRequest -> Maybe ReindexScript
reindexScript :: Maybe ReindexScript
}
deriving stock (ReindexRequest -> ReindexRequest -> Bool
(ReindexRequest -> ReindexRequest -> Bool)
-> (ReindexRequest -> ReindexRequest -> Bool) -> Eq ReindexRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReindexRequest -> ReindexRequest -> Bool
== :: ReindexRequest -> ReindexRequest -> Bool
$c/= :: ReindexRequest -> ReindexRequest -> Bool
/= :: ReindexRequest -> ReindexRequest -> Bool
Eq, Int -> ReindexRequest -> ShowS
[ReindexRequest] -> ShowS
ReindexRequest -> String
(Int -> ReindexRequest -> ShowS)
-> (ReindexRequest -> String)
-> ([ReindexRequest] -> ShowS)
-> Show ReindexRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReindexRequest -> ShowS
showsPrec :: Int -> ReindexRequest -> ShowS
$cshow :: ReindexRequest -> String
show :: ReindexRequest -> String
$cshowList :: [ReindexRequest] -> ShowS
showList :: [ReindexRequest] -> ShowS
Show, (forall x. ReindexRequest -> Rep ReindexRequest x)
-> (forall x. Rep ReindexRequest x -> ReindexRequest)
-> Generic ReindexRequest
forall x. Rep ReindexRequest x -> ReindexRequest
forall x. ReindexRequest -> Rep ReindexRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReindexRequest -> Rep ReindexRequest x
from :: forall x. ReindexRequest -> Rep ReindexRequest x
$cto :: forall x. Rep ReindexRequest x -> ReindexRequest
to :: forall x. Rep ReindexRequest x -> ReindexRequest
Generic)
instance ToJSON ReindexRequest where
toJSON :: ReindexRequest -> Value
toJSON ReindexRequest {Maybe ReindexScript
Maybe ReindexConflicts
ReindexDest
ReindexSource
reindexConflicts :: ReindexRequest -> Maybe ReindexConflicts
reindexSource :: ReindexRequest -> ReindexSource
reindexDest :: ReindexRequest -> ReindexDest
reindexScript :: ReindexRequest -> Maybe ReindexScript
reindexConflicts :: Maybe ReindexConflicts
reindexSource :: ReindexSource
reindexDest :: ReindexDest
reindexScript :: Maybe ReindexScript
..} =
[(Key, Value)] -> Value
omitNulls
[ Key
"conflicts" Key -> Maybe ReindexConflicts -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe ReindexConflicts
reindexConflicts,
Key
"source" Key -> ReindexSource -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ReindexSource
reindexSource,
Key
"dest" Key -> ReindexDest -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ReindexDest
reindexDest,
Key
"script" Key -> Maybe ReindexScript -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe ReindexScript
reindexScript
]
instance FromJSON ReindexRequest where
parseJSON :: Value -> Parser ReindexRequest
parseJSON = String
-> (Object -> Parser ReindexRequest)
-> Value
-> Parser ReindexRequest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ReindexRequest" ((Object -> Parser ReindexRequest)
-> Value -> Parser ReindexRequest)
-> (Object -> Parser ReindexRequest)
-> Value
-> Parser ReindexRequest
forall a b. (a -> b) -> a -> b
$ \Object
v ->
Maybe ReindexConflicts
-> ReindexSource
-> ReindexDest
-> Maybe ReindexScript
-> ReindexRequest
ReindexRequest
(Maybe ReindexConflicts
-> ReindexSource
-> ReindexDest
-> Maybe ReindexScript
-> ReindexRequest)
-> Parser (Maybe ReindexConflicts)
-> Parser
(ReindexSource
-> ReindexDest -> Maybe ReindexScript -> ReindexRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe ReindexConflicts)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"conflicts"
Parser
(ReindexSource
-> ReindexDest -> Maybe ReindexScript -> ReindexRequest)
-> Parser ReindexSource
-> Parser (ReindexDest -> Maybe ReindexScript -> ReindexRequest)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser ReindexSource
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"source"
Parser (ReindexDest -> Maybe ReindexScript -> ReindexRequest)
-> Parser ReindexDest
-> Parser (Maybe ReindexScript -> ReindexRequest)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser ReindexDest
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"dest"
Parser (Maybe ReindexScript -> ReindexRequest)
-> Parser (Maybe ReindexScript) -> Parser ReindexRequest
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe ReindexScript)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"script"
reindexConflictsLens :: Lens' ReindexRequest (Maybe ReindexConflicts)
reindexConflictsLens :: Lens' ReindexRequest (Maybe ReindexConflicts)
reindexConflictsLens = (ReindexRequest -> Maybe ReindexConflicts)
-> (ReindexRequest -> Maybe ReindexConflicts -> ReindexRequest)
-> Lens' ReindexRequest (Maybe ReindexConflicts)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexRequest -> Maybe ReindexConflicts
reindexConflicts (\ReindexRequest
x Maybe ReindexConflicts
y -> ReindexRequest
x {reindexConflicts = y})
reindexSourceLens :: Lens' ReindexRequest ReindexSource
reindexSourceLens :: Lens' ReindexRequest ReindexSource
reindexSourceLens = (ReindexRequest -> ReindexSource)
-> (ReindexRequest -> ReindexSource -> ReindexRequest)
-> Lens' ReindexRequest ReindexSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexRequest -> ReindexSource
reindexSource (\ReindexRequest
x ReindexSource
y -> ReindexRequest
x {reindexSource = y})
reindexDestLens :: Lens' ReindexRequest ReindexDest
reindexDestLens :: Lens' ReindexRequest ReindexDest
reindexDestLens = (ReindexRequest -> ReindexDest)
-> (ReindexRequest -> ReindexDest -> ReindexRequest)
-> Lens' ReindexRequest ReindexDest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexRequest -> ReindexDest
reindexDest (\ReindexRequest
x ReindexDest
y -> ReindexRequest
x {reindexDest = y})
reindexScriptLens :: Lens' ReindexRequest (Maybe ReindexScript)
reindexScriptLens :: Lens' ReindexRequest (Maybe ReindexScript)
reindexScriptLens = (ReindexRequest -> Maybe ReindexScript)
-> (ReindexRequest -> Maybe ReindexScript -> ReindexRequest)
-> Lens' ReindexRequest (Maybe ReindexScript)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexRequest -> Maybe ReindexScript
reindexScript (\ReindexRequest
x Maybe ReindexScript
y -> ReindexRequest
x {reindexScript = y})
data ReindexConflicts
= ReindexAbortOnConflicts
| ReindexProceedOnConflicts
deriving stock (ReindexConflicts -> ReindexConflicts -> Bool
(ReindexConflicts -> ReindexConflicts -> Bool)
-> (ReindexConflicts -> ReindexConflicts -> Bool)
-> Eq ReindexConflicts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReindexConflicts -> ReindexConflicts -> Bool
== :: ReindexConflicts -> ReindexConflicts -> Bool
$c/= :: ReindexConflicts -> ReindexConflicts -> Bool
/= :: ReindexConflicts -> ReindexConflicts -> Bool
Eq, Int -> ReindexConflicts -> ShowS
[ReindexConflicts] -> ShowS
ReindexConflicts -> String
(Int -> ReindexConflicts -> ShowS)
-> (ReindexConflicts -> String)
-> ([ReindexConflicts] -> ShowS)
-> Show ReindexConflicts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReindexConflicts -> ShowS
showsPrec :: Int -> ReindexConflicts -> ShowS
$cshow :: ReindexConflicts -> String
show :: ReindexConflicts -> String
$cshowList :: [ReindexConflicts] -> ShowS
showList :: [ReindexConflicts] -> ShowS
Show, (forall x. ReindexConflicts -> Rep ReindexConflicts x)
-> (forall x. Rep ReindexConflicts x -> ReindexConflicts)
-> Generic ReindexConflicts
forall x. Rep ReindexConflicts x -> ReindexConflicts
forall x. ReindexConflicts -> Rep ReindexConflicts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReindexConflicts -> Rep ReindexConflicts x
from :: forall x. ReindexConflicts -> Rep ReindexConflicts x
$cto :: forall x. Rep ReindexConflicts x -> ReindexConflicts
to :: forall x. Rep ReindexConflicts x -> ReindexConflicts
Generic)
instance FromJSON ReindexConflicts where
parseJSON :: Value -> Parser ReindexConflicts
parseJSON = String
-> (Text -> Parser ReindexConflicts)
-> Value
-> Parser ReindexConflicts
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"ReindexConflicts" ((Text -> Parser ReindexConflicts)
-> Value -> Parser ReindexConflicts)
-> (Text -> Parser ReindexConflicts)
-> Value
-> Parser ReindexConflicts
forall a b. (a -> b) -> a -> b
$ \case
Text
"abort" -> ReindexConflicts -> Parser ReindexConflicts
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReindexConflicts
ReindexAbortOnConflicts
Text
"proceed" -> ReindexConflicts -> Parser ReindexConflicts
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReindexConflicts
ReindexProceedOnConflicts
Text
s -> String -> Parser ReindexConflicts
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ReindexConflicts)
-> String -> Parser ReindexConflicts
forall a b. (a -> b) -> a -> b
$ String
"Expected one of [abort, proceed], found: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
forall a. Show a => a -> String
show Text
s
instance ToJSON ReindexConflicts where
toJSON :: ReindexConflicts -> Value
toJSON =
Text -> Value
String (Text -> Value)
-> (ReindexConflicts -> Text) -> ReindexConflicts -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
ReindexConflicts
ReindexAbortOnConflicts -> Text
"abort"
ReindexConflicts
ReindexProceedOnConflicts -> Text
"proceed"
data ReindexSource = ReindexSource
{ ReindexSource -> NonEmpty IndexName
reindexSourceIndex :: NonEmpty IndexName,
ReindexSource -> Maybe Int
reindexSourceMaxDocs :: Maybe Int,
ReindexSource -> Maybe Query
reindexSourceQuery :: Maybe Query,
ReindexSource -> Maybe Int
reindexSourceSize :: Maybe Int,
ReindexSource -> Maybe ReindexSlice
reindexSourceSlice :: Maybe ReindexSlice
}
deriving stock (ReindexSource -> ReindexSource -> Bool
(ReindexSource -> ReindexSource -> Bool)
-> (ReindexSource -> ReindexSource -> Bool) -> Eq ReindexSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReindexSource -> ReindexSource -> Bool
== :: ReindexSource -> ReindexSource -> Bool
$c/= :: ReindexSource -> ReindexSource -> Bool
/= :: ReindexSource -> ReindexSource -> Bool
Eq, Int -> ReindexSource -> ShowS
[ReindexSource] -> ShowS
ReindexSource -> String
(Int -> ReindexSource -> ShowS)
-> (ReindexSource -> String)
-> ([ReindexSource] -> ShowS)
-> Show ReindexSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReindexSource -> ShowS
showsPrec :: Int -> ReindexSource -> ShowS
$cshow :: ReindexSource -> String
show :: ReindexSource -> String
$cshowList :: [ReindexSource] -> ShowS
showList :: [ReindexSource] -> ShowS
Show, (forall x. ReindexSource -> Rep ReindexSource x)
-> (forall x. Rep ReindexSource x -> ReindexSource)
-> Generic ReindexSource
forall x. Rep ReindexSource x -> ReindexSource
forall x. ReindexSource -> Rep ReindexSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReindexSource -> Rep ReindexSource x
from :: forall x. ReindexSource -> Rep ReindexSource x
$cto :: forall x. Rep ReindexSource x -> ReindexSource
to :: forall x. Rep ReindexSource x -> ReindexSource
Generic)
instance ToJSON ReindexSource where
toJSON :: ReindexSource -> Value
toJSON ReindexSource {Maybe Int
Maybe Query
Maybe ReindexSlice
NonEmpty IndexName
reindexSourceIndex :: ReindexSource -> NonEmpty IndexName
reindexSourceMaxDocs :: ReindexSource -> Maybe Int
reindexSourceQuery :: ReindexSource -> Maybe Query
reindexSourceSize :: ReindexSource -> Maybe Int
reindexSourceSlice :: ReindexSource -> Maybe ReindexSlice
reindexSourceIndex :: NonEmpty IndexName
reindexSourceMaxDocs :: Maybe Int
reindexSourceQuery :: Maybe Query
reindexSourceSize :: Maybe Int
reindexSourceSlice :: Maybe ReindexSlice
..} =
[(Key, Value)] -> Value
omitNulls
[ Key
"index" Key -> NonEmpty IndexName -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= NonEmpty IndexName
reindexSourceIndex,
Key
"max_docs" Key -> Maybe Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
reindexSourceMaxDocs,
Key
"query" Key -> Maybe Query -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Query
reindexSourceQuery,
Key
"size" Key -> Maybe Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
reindexSourceSize,
Key
"slice" Key -> Maybe ReindexSlice -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe ReindexSlice
reindexSourceSlice
]
instance FromJSON ReindexSource where
parseJSON :: Value -> Parser ReindexSource
parseJSON = String
-> (Object -> Parser ReindexSource)
-> Value
-> Parser ReindexSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ReindexSource" ((Object -> Parser ReindexSource) -> Value -> Parser ReindexSource)
-> (Object -> Parser ReindexSource)
-> Value
-> Parser ReindexSource
forall a b. (a -> b) -> a -> b
$ \Object
v ->
NonEmpty IndexName
-> Maybe Int
-> Maybe Query
-> Maybe Int
-> Maybe ReindexSlice
-> ReindexSource
ReindexSource
(NonEmpty IndexName
-> Maybe Int
-> Maybe Query
-> Maybe Int
-> Maybe ReindexSlice
-> ReindexSource)
-> Parser (NonEmpty IndexName)
-> Parser
(Maybe Int
-> Maybe Query -> Maybe Int -> Maybe ReindexSlice -> ReindexSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (NonEmpty IndexName)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"index"
Parser
(Maybe Int
-> Maybe Query -> Maybe Int -> Maybe ReindexSlice -> ReindexSource)
-> Parser (Maybe Int)
-> Parser
(Maybe Query -> Maybe Int -> Maybe ReindexSlice -> ReindexSource)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"max_docs"
Parser
(Maybe Query -> Maybe Int -> Maybe ReindexSlice -> ReindexSource)
-> Parser (Maybe Query)
-> Parser (Maybe Int -> Maybe ReindexSlice -> ReindexSource)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Query)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"query"
Parser (Maybe Int -> Maybe ReindexSlice -> ReindexSource)
-> Parser (Maybe Int)
-> Parser (Maybe ReindexSlice -> ReindexSource)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"size"
Parser (Maybe ReindexSlice -> ReindexSource)
-> Parser (Maybe ReindexSlice) -> Parser ReindexSource
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe ReindexSlice)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"slice"
reindexSourceIndexLens :: Lens' ReindexSource (NonEmpty IndexName)
reindexSourceIndexLens :: Lens' ReindexSource (NonEmpty IndexName)
reindexSourceIndexLens = (ReindexSource -> NonEmpty IndexName)
-> (ReindexSource -> NonEmpty IndexName -> ReindexSource)
-> Lens' ReindexSource (NonEmpty IndexName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexSource -> NonEmpty IndexName
reindexSourceIndex (\ReindexSource
x NonEmpty IndexName
y -> ReindexSource
x {reindexSourceIndex = y})
reindexSourceMaxDocsLens :: Lens' ReindexSource (Maybe Int)
reindexSourceMaxDocsLens :: Lens' ReindexSource (Maybe Int)
reindexSourceMaxDocsLens = (ReindexSource -> Maybe Int)
-> (ReindexSource -> Maybe Int -> ReindexSource)
-> Lens' ReindexSource (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexSource -> Maybe Int
reindexSourceMaxDocs (\ReindexSource
x Maybe Int
y -> ReindexSource
x {reindexSourceMaxDocs = y})
reindexSourceQueryLens :: Lens' ReindexSource (Maybe Query)
reindexSourceQueryLens :: Lens' ReindexSource (Maybe Query)
reindexSourceQueryLens = (ReindexSource -> Maybe Query)
-> (ReindexSource -> Maybe Query -> ReindexSource)
-> Lens' ReindexSource (Maybe Query)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexSource -> Maybe Query
reindexSourceQuery (\ReindexSource
x Maybe Query
y -> ReindexSource
x {reindexSourceQuery = y})
reindexSourceSizeLens :: Lens' ReindexSource (Maybe Int)
reindexSourceSizeLens :: Lens' ReindexSource (Maybe Int)
reindexSourceSizeLens = (ReindexSource -> Maybe Int)
-> (ReindexSource -> Maybe Int -> ReindexSource)
-> Lens' ReindexSource (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexSource -> Maybe Int
reindexSourceSize (\ReindexSource
x Maybe Int
y -> ReindexSource
x {reindexSourceSize = y})
reindexSourceSliceLens :: Lens' ReindexSource (Maybe ReindexSlice)
reindexSourceSliceLens :: Lens' ReindexSource (Maybe ReindexSlice)
reindexSourceSliceLens = (ReindexSource -> Maybe ReindexSlice)
-> (ReindexSource -> Maybe ReindexSlice -> ReindexSource)
-> Lens' ReindexSource (Maybe ReindexSlice)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexSource -> Maybe ReindexSlice
reindexSourceSlice (\ReindexSource
x Maybe ReindexSlice
y -> ReindexSource
x {reindexSourceSlice = y})
data ReindexSlice = ReindexSlice
{ ReindexSlice -> Maybe Int
reindexSliceId :: Maybe Int,
ReindexSlice -> Maybe Int
reindexSliceMax :: Maybe Int
}
deriving stock (ReindexSlice -> ReindexSlice -> Bool
(ReindexSlice -> ReindexSlice -> Bool)
-> (ReindexSlice -> ReindexSlice -> Bool) -> Eq ReindexSlice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReindexSlice -> ReindexSlice -> Bool
== :: ReindexSlice -> ReindexSlice -> Bool
$c/= :: ReindexSlice -> ReindexSlice -> Bool
/= :: ReindexSlice -> ReindexSlice -> Bool
Eq, Int -> ReindexSlice -> ShowS
[ReindexSlice] -> ShowS
ReindexSlice -> String
(Int -> ReindexSlice -> ShowS)
-> (ReindexSlice -> String)
-> ([ReindexSlice] -> ShowS)
-> Show ReindexSlice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReindexSlice -> ShowS
showsPrec :: Int -> ReindexSlice -> ShowS
$cshow :: ReindexSlice -> String
show :: ReindexSlice -> String
$cshowList :: [ReindexSlice] -> ShowS
showList :: [ReindexSlice] -> ShowS
Show, (forall x. ReindexSlice -> Rep ReindexSlice x)
-> (forall x. Rep ReindexSlice x -> ReindexSlice)
-> Generic ReindexSlice
forall x. Rep ReindexSlice x -> ReindexSlice
forall x. ReindexSlice -> Rep ReindexSlice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReindexSlice -> Rep ReindexSlice x
from :: forall x. ReindexSlice -> Rep ReindexSlice x
$cto :: forall x. Rep ReindexSlice x -> ReindexSlice
to :: forall x. Rep ReindexSlice x -> ReindexSlice
Generic)
instance ToJSON ReindexSlice where
toJSON :: ReindexSlice -> Value
toJSON ReindexSlice {Maybe Int
reindexSliceId :: ReindexSlice -> Maybe Int
reindexSliceMax :: ReindexSlice -> Maybe Int
reindexSliceId :: Maybe Int
reindexSliceMax :: Maybe Int
..} =
[(Key, Value)] -> Value
omitNulls [Key
"id" Key -> Maybe Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
reindexSliceId, Key
"max" Key -> Maybe Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
reindexSliceMax]
instance FromJSON ReindexSlice where
parseJSON :: Value -> Parser ReindexSlice
parseJSON = String
-> (Object -> Parser ReindexSlice) -> Value -> Parser ReindexSlice
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ReindexSlice" ((Object -> Parser ReindexSlice) -> Value -> Parser ReindexSlice)
-> (Object -> Parser ReindexSlice) -> Value -> Parser ReindexSlice
forall a b. (a -> b) -> a -> b
$ \Object
v ->
Maybe Int -> Maybe Int -> ReindexSlice
ReindexSlice (Maybe Int -> Maybe Int -> ReindexSlice)
-> Parser (Maybe Int) -> Parser (Maybe Int -> ReindexSlice)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"id" Parser (Maybe Int -> ReindexSlice)
-> Parser (Maybe Int) -> Parser ReindexSlice
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"max"
reindexSliceIdLens :: Lens' ReindexSlice (Maybe Int)
reindexSliceIdLens :: Lens' ReindexSlice (Maybe Int)
reindexSliceIdLens = (ReindexSlice -> Maybe Int)
-> (ReindexSlice -> Maybe Int -> ReindexSlice)
-> Lens' ReindexSlice (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexSlice -> Maybe Int
reindexSliceId (\ReindexSlice
x Maybe Int
y -> ReindexSlice
x {reindexSliceId = y})
reindexSliceMaxLens :: Lens' ReindexSlice (Maybe Int)
reindexSliceMaxLens :: Lens' ReindexSlice (Maybe Int)
reindexSliceMaxLens = (ReindexSlice -> Maybe Int)
-> (ReindexSlice -> Maybe Int -> ReindexSlice)
-> Lens' ReindexSlice (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexSlice -> Maybe Int
reindexSliceMax (\ReindexSlice
x Maybe Int
y -> ReindexSlice
x {reindexSliceMax = y})
data ReindexDest = ReindexDest
{ ReindexDest -> IndexName
reindexDestIndex :: IndexName,
ReindexDest -> Maybe VersionType
reindexDestVersionType :: Maybe VersionType,
ReindexDest -> Maybe ReindexOpType
reindexDestOpType :: Maybe ReindexOpType
}
deriving stock (ReindexDest -> ReindexDest -> Bool
(ReindexDest -> ReindexDest -> Bool)
-> (ReindexDest -> ReindexDest -> Bool) -> Eq ReindexDest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReindexDest -> ReindexDest -> Bool
== :: ReindexDest -> ReindexDest -> Bool
$c/= :: ReindexDest -> ReindexDest -> Bool
/= :: ReindexDest -> ReindexDest -> Bool
Eq, Int -> ReindexDest -> ShowS
[ReindexDest] -> ShowS
ReindexDest -> String
(Int -> ReindexDest -> ShowS)
-> (ReindexDest -> String)
-> ([ReindexDest] -> ShowS)
-> Show ReindexDest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReindexDest -> ShowS
showsPrec :: Int -> ReindexDest -> ShowS
$cshow :: ReindexDest -> String
show :: ReindexDest -> String
$cshowList :: [ReindexDest] -> ShowS
showList :: [ReindexDest] -> ShowS
Show, (forall x. ReindexDest -> Rep ReindexDest x)
-> (forall x. Rep ReindexDest x -> ReindexDest)
-> Generic ReindexDest
forall x. Rep ReindexDest x -> ReindexDest
forall x. ReindexDest -> Rep ReindexDest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReindexDest -> Rep ReindexDest x
from :: forall x. ReindexDest -> Rep ReindexDest x
$cto :: forall x. Rep ReindexDest x -> ReindexDest
to :: forall x. Rep ReindexDest x -> ReindexDest
Generic)
instance ToJSON ReindexDest where
toJSON :: ReindexDest -> Value
toJSON ReindexDest {Maybe ReindexOpType
Maybe VersionType
IndexName
reindexDestIndex :: ReindexDest -> IndexName
reindexDestVersionType :: ReindexDest -> Maybe VersionType
reindexDestOpType :: ReindexDest -> Maybe ReindexOpType
reindexDestIndex :: IndexName
reindexDestVersionType :: Maybe VersionType
reindexDestOpType :: Maybe ReindexOpType
..} =
[(Key, Value)] -> Value
omitNulls
[ Key
"index" Key -> IndexName -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= IndexName
reindexDestIndex,
Key
"version_type" Key -> Maybe VersionType -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe VersionType
reindexDestVersionType,
Key
"op_type" Key -> Maybe ReindexOpType -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe ReindexOpType
reindexDestOpType
]
instance FromJSON ReindexDest where
parseJSON :: Value -> Parser ReindexDest
parseJSON = String
-> (Object -> Parser ReindexDest) -> Value -> Parser ReindexDest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ReindexDest" ((Object -> Parser ReindexDest) -> Value -> Parser ReindexDest)
-> (Object -> Parser ReindexDest) -> Value -> Parser ReindexDest
forall a b. (a -> b) -> a -> b
$ \Object
v ->
IndexName
-> Maybe VersionType -> Maybe ReindexOpType -> ReindexDest
ReindexDest
(IndexName
-> Maybe VersionType -> Maybe ReindexOpType -> ReindexDest)
-> Parser IndexName
-> Parser (Maybe VersionType -> Maybe ReindexOpType -> ReindexDest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser IndexName
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"index"
Parser (Maybe VersionType -> Maybe ReindexOpType -> ReindexDest)
-> Parser (Maybe VersionType)
-> Parser (Maybe ReindexOpType -> ReindexDest)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe VersionType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"version_type"
Parser (Maybe ReindexOpType -> ReindexDest)
-> Parser (Maybe ReindexOpType) -> Parser ReindexDest
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe ReindexOpType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"op_type"
reindexDestIndexLens :: Lens' ReindexDest IndexName
reindexDestIndexLens :: Lens' ReindexDest IndexName
reindexDestIndexLens = (ReindexDest -> IndexName)
-> (ReindexDest -> IndexName -> ReindexDest)
-> Lens' ReindexDest IndexName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexDest -> IndexName
reindexDestIndex (\ReindexDest
x IndexName
y -> ReindexDest
x {reindexDestIndex = y})
reindexDestVersionTypeLens :: Lens' ReindexDest (Maybe VersionType)
reindexDestVersionTypeLens :: Lens' ReindexDest (Maybe VersionType)
reindexDestVersionTypeLens = (ReindexDest -> Maybe VersionType)
-> (ReindexDest -> Maybe VersionType -> ReindexDest)
-> Lens' ReindexDest (Maybe VersionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexDest -> Maybe VersionType
reindexDestVersionType (\ReindexDest
x Maybe VersionType
y -> ReindexDest
x {reindexDestVersionType = y})
reindexDestOpTypeLens :: Lens' ReindexDest (Maybe ReindexOpType)
reindexDestOpTypeLens :: Lens' ReindexDest (Maybe ReindexOpType)
reindexDestOpTypeLens = (ReindexDest -> Maybe ReindexOpType)
-> (ReindexDest -> Maybe ReindexOpType -> ReindexDest)
-> Lens' ReindexDest (Maybe ReindexOpType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexDest -> Maybe ReindexOpType
reindexDestOpType (\ReindexDest
x Maybe ReindexOpType
y -> ReindexDest
x {reindexDestOpType = y})
data VersionType
= VersionTypeInternal
| VersionTypeExternal
| VersionTypeExternalGT
| VersionTypeExternalGTE
deriving stock (VersionType -> VersionType -> Bool
(VersionType -> VersionType -> Bool)
-> (VersionType -> VersionType -> Bool) -> Eq VersionType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VersionType -> VersionType -> Bool
== :: VersionType -> VersionType -> Bool
$c/= :: VersionType -> VersionType -> Bool
/= :: VersionType -> VersionType -> Bool
Eq, Int -> VersionType -> ShowS
[VersionType] -> ShowS
VersionType -> String
(Int -> VersionType -> ShowS)
-> (VersionType -> String)
-> ([VersionType] -> ShowS)
-> Show VersionType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VersionType -> ShowS
showsPrec :: Int -> VersionType -> ShowS
$cshow :: VersionType -> String
show :: VersionType -> String
$cshowList :: [VersionType] -> ShowS
showList :: [VersionType] -> ShowS
Show, (forall x. VersionType -> Rep VersionType x)
-> (forall x. Rep VersionType x -> VersionType)
-> Generic VersionType
forall x. Rep VersionType x -> VersionType
forall x. VersionType -> Rep VersionType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. VersionType -> Rep VersionType x
from :: forall x. VersionType -> Rep VersionType x
$cto :: forall x. Rep VersionType x -> VersionType
to :: forall x. Rep VersionType x -> VersionType
Generic)
instance ToJSON VersionType where
toJSON :: VersionType -> Value
toJSON =
Text -> Value
String (Text -> Value) -> (VersionType -> Text) -> VersionType -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
VersionType
VersionTypeInternal -> Text
"internal"
VersionType
VersionTypeExternal -> Text
"external"
VersionType
VersionTypeExternalGT -> Text
"external_gt"
VersionType
VersionTypeExternalGTE -> Text
"external_gte"
instance FromJSON VersionType where
parseJSON :: Value -> Parser VersionType
parseJSON = String
-> (Text -> Parser VersionType) -> Value -> Parser VersionType
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"VersionType" ((Text -> Parser VersionType) -> Value -> Parser VersionType)
-> (Text -> Parser VersionType) -> Value -> Parser VersionType
forall a b. (a -> b) -> a -> b
$ \case
Text
"internal" -> VersionType -> Parser VersionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure VersionType
VersionTypeInternal
Text
"external" -> VersionType -> Parser VersionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure VersionType
VersionTypeExternal
Text
"external_gt" -> VersionType -> Parser VersionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure VersionType
VersionTypeExternalGT
Text
"external_gte" -> VersionType -> Parser VersionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure VersionType
VersionTypeExternalGTE
Text
s -> String -> Parser VersionType
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser VersionType) -> String -> Parser VersionType
forall a b. (a -> b) -> a -> b
$ String
"Expected one of [internal, external, external_gt, external_gte], found: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
forall a. Show a => a -> String
show Text
s
data ReindexOpType
= OpCreate
| OpIndex
deriving stock (ReindexOpType -> ReindexOpType -> Bool
(ReindexOpType -> ReindexOpType -> Bool)
-> (ReindexOpType -> ReindexOpType -> Bool) -> Eq ReindexOpType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReindexOpType -> ReindexOpType -> Bool
== :: ReindexOpType -> ReindexOpType -> Bool
$c/= :: ReindexOpType -> ReindexOpType -> Bool
/= :: ReindexOpType -> ReindexOpType -> Bool
Eq, Int -> ReindexOpType -> ShowS
[ReindexOpType] -> ShowS
ReindexOpType -> String
(Int -> ReindexOpType -> ShowS)
-> (ReindexOpType -> String)
-> ([ReindexOpType] -> ShowS)
-> Show ReindexOpType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReindexOpType -> ShowS
showsPrec :: Int -> ReindexOpType -> ShowS
$cshow :: ReindexOpType -> String
show :: ReindexOpType -> String
$cshowList :: [ReindexOpType] -> ShowS
showList :: [ReindexOpType] -> ShowS
Show, (forall x. ReindexOpType -> Rep ReindexOpType x)
-> (forall x. Rep ReindexOpType x -> ReindexOpType)
-> Generic ReindexOpType
forall x. Rep ReindexOpType x -> ReindexOpType
forall x. ReindexOpType -> Rep ReindexOpType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReindexOpType -> Rep ReindexOpType x
from :: forall x. ReindexOpType -> Rep ReindexOpType x
$cto :: forall x. Rep ReindexOpType x -> ReindexOpType
to :: forall x. Rep ReindexOpType x -> ReindexOpType
Generic)
instance FromJSON ReindexOpType where
parseJSON :: Value -> Parser ReindexOpType
parseJSON = String
-> (Text -> Parser ReindexOpType) -> Value -> Parser ReindexOpType
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"ReindexOpType" ((Text -> Parser ReindexOpType) -> Value -> Parser ReindexOpType)
-> (Text -> Parser ReindexOpType) -> Value -> Parser ReindexOpType
forall a b. (a -> b) -> a -> b
$ \case
Text
"create" -> ReindexOpType -> Parser ReindexOpType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReindexOpType
OpCreate
Text
"index" -> ReindexOpType -> Parser ReindexOpType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReindexOpType
OpIndex
Text
s -> String -> Parser ReindexOpType
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ReindexOpType) -> String -> Parser ReindexOpType
forall a b. (a -> b) -> a -> b
$ String
"Expected one of [create, index], found: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
forall a. Show a => a -> String
show Text
s
instance ToJSON ReindexOpType where
toJSON :: ReindexOpType -> Value
toJSON ReindexOpType
OpCreate = Text -> Value
String Text
"create"
toJSON ReindexOpType
OpIndex = Text -> Value
String Text
"index"
data ReindexScript = ReindexScript
{ ReindexScript -> ScriptLanguage
reindexScriptLanguage :: ScriptLanguage,
ReindexScript -> Text
reindexScriptSource :: Text
}
deriving stock (ReindexScript -> ReindexScript -> Bool
(ReindexScript -> ReindexScript -> Bool)
-> (ReindexScript -> ReindexScript -> Bool) -> Eq ReindexScript
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReindexScript -> ReindexScript -> Bool
== :: ReindexScript -> ReindexScript -> Bool
$c/= :: ReindexScript -> ReindexScript -> Bool
/= :: ReindexScript -> ReindexScript -> Bool
Eq, Int -> ReindexScript -> ShowS
[ReindexScript] -> ShowS
ReindexScript -> String
(Int -> ReindexScript -> ShowS)
-> (ReindexScript -> String)
-> ([ReindexScript] -> ShowS)
-> Show ReindexScript
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReindexScript -> ShowS
showsPrec :: Int -> ReindexScript -> ShowS
$cshow :: ReindexScript -> String
show :: ReindexScript -> String
$cshowList :: [ReindexScript] -> ShowS
showList :: [ReindexScript] -> ShowS
Show, (forall x. ReindexScript -> Rep ReindexScript x)
-> (forall x. Rep ReindexScript x -> ReindexScript)
-> Generic ReindexScript
forall x. Rep ReindexScript x -> ReindexScript
forall x. ReindexScript -> Rep ReindexScript x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReindexScript -> Rep ReindexScript x
from :: forall x. ReindexScript -> Rep ReindexScript x
$cto :: forall x. Rep ReindexScript x -> ReindexScript
to :: forall x. Rep ReindexScript x -> ReindexScript
Generic)
instance ToJSON ReindexScript where
toJSON :: ReindexScript -> Value
toJSON ReindexScript {Text
ScriptLanguage
reindexScriptLanguage :: ReindexScript -> ScriptLanguage
reindexScriptSource :: ReindexScript -> Text
reindexScriptLanguage :: ScriptLanguage
reindexScriptSource :: Text
..} =
[(Key, Value)] -> Value
object
[ Key
"language" Key -> ScriptLanguage -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ScriptLanguage
reindexScriptLanguage,
Key
"source" Key -> Text -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
reindexScriptSource
]
instance FromJSON ReindexScript where
parseJSON :: Value -> Parser ReindexScript
parseJSON = String
-> (Object -> Parser ReindexScript)
-> Value
-> Parser ReindexScript
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ReindexScript" ((Object -> Parser ReindexScript) -> Value -> Parser ReindexScript)
-> (Object -> Parser ReindexScript)
-> Value
-> Parser ReindexScript
forall a b. (a -> b) -> a -> b
$ \Object
v ->
ScriptLanguage -> Text -> ReindexScript
ReindexScript
(ScriptLanguage -> Text -> ReindexScript)
-> Parser ScriptLanguage -> Parser (Text -> ReindexScript)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser ScriptLanguage
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"language"
Parser (Text -> ReindexScript)
-> Parser Text -> Parser ReindexScript
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"source"
reindexScriptLanguageLens :: Lens' ReindexScript ScriptLanguage
reindexScriptLanguageLens :: Lens' ReindexScript ScriptLanguage
reindexScriptLanguageLens = (ReindexScript -> ScriptLanguage)
-> (ReindexScript -> ScriptLanguage -> ReindexScript)
-> Lens' ReindexScript ScriptLanguage
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexScript -> ScriptLanguage
reindexScriptLanguage (\ReindexScript
x ScriptLanguage
y -> ReindexScript
x {reindexScriptLanguage = y})
reindexScriptSourceLens :: Lens' ReindexScript Text
reindexScriptSourceLens :: Lens' ReindexScript Text
reindexScriptSourceLens = (ReindexScript -> Text)
-> (ReindexScript -> Text -> ReindexScript)
-> Lens' ReindexScript Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexScript -> Text
reindexScriptSource (\ReindexScript
x Text
y -> ReindexScript
x {reindexScriptSource = y})
mkReindexRequest :: IndexName -> IndexName -> ReindexRequest
mkReindexRequest :: IndexName -> IndexName -> ReindexRequest
mkReindexRequest IndexName
src IndexName
dst =
ReindexRequest
{ reindexSource :: ReindexSource
reindexSource =
ReindexSource
{ reindexSourceIndex :: NonEmpty IndexName
reindexSourceIndex = IndexName
src IndexName -> [IndexName] -> NonEmpty IndexName
forall a. a -> [a] -> NonEmpty a
:| [],
reindexSourceMaxDocs :: Maybe Int
reindexSourceMaxDocs = Maybe Int
forall a. Maybe a
Nothing,
reindexSourceQuery :: Maybe Query
reindexSourceQuery = Maybe Query
forall a. Maybe a
Nothing,
reindexSourceSize :: Maybe Int
reindexSourceSize = Maybe Int
forall a. Maybe a
Nothing,
reindexSourceSlice :: Maybe ReindexSlice
reindexSourceSlice = Maybe ReindexSlice
forall a. Maybe a
Nothing
},
reindexDest :: ReindexDest
reindexDest =
ReindexDest
{ reindexDestIndex :: IndexName
reindexDestIndex = IndexName
dst,
reindexDestVersionType :: Maybe VersionType
reindexDestVersionType = Maybe VersionType
forall a. Maybe a
Nothing,
reindexDestOpType :: Maybe ReindexOpType
reindexDestOpType = Maybe ReindexOpType
forall a. Maybe a
Nothing
},
reindexConflicts :: Maybe ReindexConflicts
reindexConflicts = Maybe ReindexConflicts
forall a. Maybe a
Nothing,
reindexScript :: Maybe ReindexScript
reindexScript = Maybe ReindexScript
forall a. Maybe a
Nothing
}
data ReindexResponse = ReindexResponse
{ ReindexResponse -> Maybe Int
reindexResponseTook :: Maybe Int,
ReindexResponse -> Int
reindexResponseUpdated :: Int,
ReindexResponse -> Int
reindexResponseCreated :: Int,
ReindexResponse -> Int
reindexResponseBatches :: Int,
ReindexResponse -> Int
reindexResponseVersionConflicts :: Int,
ReindexResponse -> Int
reindexResponseThrottledMillis :: Int
}
deriving stock (ReindexResponse -> ReindexResponse -> Bool
(ReindexResponse -> ReindexResponse -> Bool)
-> (ReindexResponse -> ReindexResponse -> Bool)
-> Eq ReindexResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReindexResponse -> ReindexResponse -> Bool
== :: ReindexResponse -> ReindexResponse -> Bool
$c/= :: ReindexResponse -> ReindexResponse -> Bool
/= :: ReindexResponse -> ReindexResponse -> Bool
Eq, Int -> ReindexResponse -> ShowS
[ReindexResponse] -> ShowS
ReindexResponse -> String
(Int -> ReindexResponse -> ShowS)
-> (ReindexResponse -> String)
-> ([ReindexResponse] -> ShowS)
-> Show ReindexResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReindexResponse -> ShowS
showsPrec :: Int -> ReindexResponse -> ShowS
$cshow :: ReindexResponse -> String
show :: ReindexResponse -> String
$cshowList :: [ReindexResponse] -> ShowS
showList :: [ReindexResponse] -> ShowS
Show, (forall x. ReindexResponse -> Rep ReindexResponse x)
-> (forall x. Rep ReindexResponse x -> ReindexResponse)
-> Generic ReindexResponse
forall x. Rep ReindexResponse x -> ReindexResponse
forall x. ReindexResponse -> Rep ReindexResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReindexResponse -> Rep ReindexResponse x
from :: forall x. ReindexResponse -> Rep ReindexResponse x
$cto :: forall x. Rep ReindexResponse x -> ReindexResponse
to :: forall x. Rep ReindexResponse x -> ReindexResponse
Generic)
instance ToJSON ReindexResponse where
toJSON :: ReindexResponse -> Value
toJSON ReindexResponse {Int
Maybe Int
reindexResponseTook :: ReindexResponse -> Maybe Int
reindexResponseUpdated :: ReindexResponse -> Int
reindexResponseCreated :: ReindexResponse -> Int
reindexResponseBatches :: ReindexResponse -> Int
reindexResponseVersionConflicts :: ReindexResponse -> Int
reindexResponseThrottledMillis :: ReindexResponse -> Int
reindexResponseTook :: Maybe Int
reindexResponseUpdated :: Int
reindexResponseCreated :: Int
reindexResponseBatches :: Int
reindexResponseVersionConflicts :: Int
reindexResponseThrottledMillis :: Int
..} =
[(Key, Value)] -> Value
omitNulls
[ Key
"took" Key -> Maybe Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
reindexResponseTook,
Key
"updated" Key -> Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Int
reindexResponseUpdated,
Key
"created" Key -> Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Int
reindexResponseCreated,
Key
"batches" Key -> Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Int
reindexResponseBatches,
Key
"version_conflicts" Key -> Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Int
reindexResponseVersionConflicts,
Key
"throttled_millis" Key -> Int -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Int
reindexResponseThrottledMillis
]
instance FromJSON ReindexResponse where
parseJSON :: Value -> Parser ReindexResponse
parseJSON = String
-> (Object -> Parser ReindexResponse)
-> Value
-> Parser ReindexResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ReindexResponse" ((Object -> Parser ReindexResponse)
-> Value -> Parser ReindexResponse)
-> (Object -> Parser ReindexResponse)
-> Value
-> Parser ReindexResponse
forall a b. (a -> b) -> a -> b
$ \Object
v ->
Maybe Int -> Int -> Int -> Int -> Int -> Int -> ReindexResponse
ReindexResponse
(Maybe Int -> Int -> Int -> Int -> Int -> Int -> ReindexResponse)
-> Parser (Maybe Int)
-> Parser (Int -> Int -> Int -> Int -> Int -> ReindexResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"took"
Parser (Int -> Int -> Int -> Int -> Int -> ReindexResponse)
-> Parser Int
-> Parser (Int -> Int -> Int -> Int -> ReindexResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"updated"
Parser (Int -> Int -> Int -> Int -> ReindexResponse)
-> Parser Int -> Parser (Int -> Int -> Int -> ReindexResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"created"
Parser (Int -> Int -> Int -> ReindexResponse)
-> Parser Int -> Parser (Int -> Int -> ReindexResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"batches"
Parser (Int -> Int -> ReindexResponse)
-> Parser Int -> Parser (Int -> ReindexResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"version_conflicts"
Parser (Int -> ReindexResponse)
-> Parser Int -> Parser ReindexResponse
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"throttled_millis"
reindexResponseTookLens :: Lens' ReindexResponse (Maybe Int)
reindexResponseTookLens :: Lens' ReindexResponse (Maybe Int)
reindexResponseTookLens = (ReindexResponse -> Maybe Int)
-> (ReindexResponse -> Maybe Int -> ReindexResponse)
-> Lens' ReindexResponse (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexResponse -> Maybe Int
reindexResponseTook (\ReindexResponse
x Maybe Int
y -> ReindexResponse
x {reindexResponseTook = y})
reindexResponseUpdatedLens :: Lens' ReindexResponse Int
reindexResponseUpdatedLens :: Lens' ReindexResponse Int
reindexResponseUpdatedLens = (ReindexResponse -> Int)
-> (ReindexResponse -> Int -> ReindexResponse)
-> Lens' ReindexResponse Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexResponse -> Int
reindexResponseUpdated (\ReindexResponse
x Int
y -> ReindexResponse
x {reindexResponseUpdated = y})
reindexResponseCreatedLens :: Lens' ReindexResponse Int
reindexResponseCreatedLens :: Lens' ReindexResponse Int
reindexResponseCreatedLens = (ReindexResponse -> Int)
-> (ReindexResponse -> Int -> ReindexResponse)
-> Lens' ReindexResponse Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexResponse -> Int
reindexResponseCreated (\ReindexResponse
x Int
y -> ReindexResponse
x {reindexResponseCreated = y})
reindexResponseBatchesLens :: Lens' ReindexResponse Int
reindexResponseBatchesLens :: Lens' ReindexResponse Int
reindexResponseBatchesLens = (ReindexResponse -> Int)
-> (ReindexResponse -> Int -> ReindexResponse)
-> Lens' ReindexResponse Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexResponse -> Int
reindexResponseBatches (\ReindexResponse
x Int
y -> ReindexResponse
x {reindexResponseBatches = y})
reindexResponseVersionConflictsLens :: Lens' ReindexResponse Int
reindexResponseVersionConflictsLens :: Lens' ReindexResponse Int
reindexResponseVersionConflictsLens = (ReindexResponse -> Int)
-> (ReindexResponse -> Int -> ReindexResponse)
-> Lens' ReindexResponse Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexResponse -> Int
reindexResponseVersionConflicts (\ReindexResponse
x Int
y -> ReindexResponse
x {reindexResponseVersionConflicts = y})
reindexResponseThrottledMillisLens :: Lens' ReindexResponse Int
reindexResponseThrottledMillisLens :: Lens' ReindexResponse Int
reindexResponseThrottledMillisLens = (ReindexResponse -> Int)
-> (ReindexResponse -> Int -> ReindexResponse)
-> Lens' ReindexResponse Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ReindexResponse -> Int
reindexResponseThrottledMillis (\ReindexResponse
x Int
y -> ReindexResponse
x {reindexResponseThrottledMillis = y})