@@ -2988,7 +2988,7 @@ instance FromJSON UpdatableIndexSetting where
29882988 <|> blocksWrite `taggedAt` ["blocks", "write"]
29892989 <|> blocksMetaData `taggedAt` ["blocks", "metadata"]
29902990 where taggedAt f ks = taggedAt' f (Object o) ks
2991− taggedAt' f v [] = f =<< (parseJSON v <|> (parseJSON =<< unStringlyTypeJSON v))
2991+ taggedAt' f v [] = f =<< (parseJSON v <|> (parseJSON (unStringlyTypeJSON v)))
29922992 taggedAt' f v (k:ks) = withObject "Object" (\o -> do v' <- o .: k
29932993 taggedAt' f v' ks) v
29942994 numberOfReplicas = pure . NumberOfReplicas
@@ -3030,18 +3030,17 @@ instance FromJSON IndexSettingsSummary where
30303030 redundant (NumberOfReplicas _) = True
30313031 redundant _ = False
30323032
3033−-- | For some reason in the settings API, all leaf values get returned
3033+-- | For some reason in several settings APIs, all leaf values get returned
30343034-- as strings. This function attepmts to recover from this for all
3035−-- non-recursive JSON types. If nothing can be done or the same value
3036−-- would be return, it returns 'mzero'
3037−unStringlyTypeJSON :: MonadPlus m => Value -> m Value
3038−unStringlyTypeJSON (String "true") = return (Bool True)
3039−unStringlyTypeJSON (String "false") = return (Bool False)
3040−unStringlyTypeJSON (String "null") = return Null
3041−unStringlyTypeJSON (String t) = case readMay (T.unpack t) of
3042− Just n -> return (Number n)
3043− Nothing -> mzero
3044−unStringlyTypeJSON _ = mzero
3035+-- non-recursive JSON types. If nothing can be done, the value is left alone.
3036+unStringlyTypeJSON :: Value -> Value
3037+unStringlyTypeJSON (String "true") = Bool True
3038+unStringlyTypeJSON (String "false") = Bool False
3039+unStringlyTypeJSON (String "null") = Null
3040+unStringlyTypeJSON v@(String t) = case readMay (T.unpack t) of
3041+ Just n -> Number n
3042+ Nothing -> v
3043+unStringlyTypeJSON v = v
30453044
30463045
30473046parseSettings :: Object -> Parser [UpdatableIndexSetting]
@@ -3680,7 +3679,7 @@ data SnapshotRepoPattern = ExactRepo SnapshotRepoName
36803679
36813680-- | The unique name of a snapshot repository.
36823681newtype SnapshotRepoName = SnapshotRepoName { snapshotRepoName :: Text }
3683− deriving (Eq, Generic, Show, Typeable, ToJSON, FromJSON)
3682+ deriving (Eq, Ord, Generic, Show, Typeable, ToJSON, FromJSON)
36843683
36853684
36863685-- | A generic representation of a snapshot repo. This is what gets
@@ -3696,15 +3695,26 @@ data GenericSnapshotRepo = GenericSnapshotRepo {
36963695 } deriving (Eq, Generic, Show, Typeable)
36973696
36983697
3698+instance SnapshotRepo GenericSnapshotRepo where
3699+ toGSnapshotRepo = id
3700+ fromGSnapshotRepo = Right
3701+
3702+
36993703newtype SnapshotRepoType = SnapshotRepoType { snapshotRepoType :: Text }
3700− deriving (Eq, Generic, Show, Typeable, ToJSON, FromJSON)
3704+ deriving (Eq, Ord, Generic, Show, Typeable, ToJSON, FromJSON)
37013705
37023706
37033707-- | Opaque representation of snapshot repo settings. Instances of
37043708-- 'SnapshotRepo' will produce this.
37053709newtype GenericSnapshotRepoSettings = GenericSnapshotRepoSettings { gSnapshotRepoSettingsObject :: Object }
3706− deriving (Eq, Generic, Show, Typeable, ToJSON, FromJSON)
3710+ deriving (Eq, Generic, Show, Typeable, ToJSON)
3711+
37073712
3713+ -- Regardless of whether you send strongly typed json, my version of
3714+ -- ES sends back stringly typed json in the settings, e.g. booleans
3715+ -- as strings, so we'll try to convert them.
3716+instance FromJSON GenericSnapshotRepoSettings where
3717+ parseJSON = fmap (GenericSnapshotRepoSettings . fmap unStringlyTypeJSON). parseJSON
37083718
37093719-- | The result of running 'verifySnapshotRepo'. --TODO: more detail once you know what a failure looks like
37103720newtype SnapshotVerification = SnapshotVerification { snapshotNodeVerifications :: [SnapshotNodeVerification] }
@@ -3730,11 +3740,11 @@ data SnapshotNodeVerification = SnapshotNodeVerification {
37303740-- | Unique, automatically-generated name assigned to nodes that are
37313741-- usually returned in node-oriented APIs.
37323742newtype FullNodeId = FullNodeId { fullNodeId :: Text }
3733− deriving (Eq, Generic, Show, Typeable, FromJSON)
3743+ deriving (Eq, Ord, Generic, Show, Typeable, FromJSON)
37343744
37353745
37363746newtype NodeName = NodeName { nodeName :: Text }
3737− deriving (Eq, Generic, Show, Typeable, FromJSON)
3747+ deriving (Eq, Ord, Generic, Show, Typeable, FromJSON)
37383748
37393749
37403750data SnapshotRepoUpdateSettings = SnapshotRepoUpdateSettings {