{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ElasticSearch.Types.CompatibleVersionsMap
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ElasticSearch.Types.CompatibleVersionsMap where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A map from an @ ElasticsearchVersion @ to a list of compatible
-- @ ElasticsearchVersion @ s to which the domain can be upgraded.
--
-- /See:/ 'newCompatibleVersionsMap' smart constructor.
data CompatibleVersionsMap = CompatibleVersionsMap'
  { -- | The current version of Elasticsearch on which a domain is.
    CompatibleVersionsMap -> Maybe Text
sourceVersion :: Prelude.Maybe Prelude.Text,
    CompatibleVersionsMap -> Maybe [Text]
targetVersions :: Prelude.Maybe [Prelude.Text]
  }
  deriving (CompatibleVersionsMap -> CompatibleVersionsMap -> Bool
(CompatibleVersionsMap -> CompatibleVersionsMap -> Bool)
-> (CompatibleVersionsMap -> CompatibleVersionsMap -> Bool)
-> Eq CompatibleVersionsMap
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompatibleVersionsMap -> CompatibleVersionsMap -> Bool
$c/= :: CompatibleVersionsMap -> CompatibleVersionsMap -> Bool
== :: CompatibleVersionsMap -> CompatibleVersionsMap -> Bool
$c== :: CompatibleVersionsMap -> CompatibleVersionsMap -> Bool
Prelude.Eq, ReadPrec [CompatibleVersionsMap]
ReadPrec CompatibleVersionsMap
Int -> ReadS CompatibleVersionsMap
ReadS [CompatibleVersionsMap]
(Int -> ReadS CompatibleVersionsMap)
-> ReadS [CompatibleVersionsMap]
-> ReadPrec CompatibleVersionsMap
-> ReadPrec [CompatibleVersionsMap]
-> Read CompatibleVersionsMap
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompatibleVersionsMap]
$creadListPrec :: ReadPrec [CompatibleVersionsMap]
readPrec :: ReadPrec CompatibleVersionsMap
$creadPrec :: ReadPrec CompatibleVersionsMap
readList :: ReadS [CompatibleVersionsMap]
$creadList :: ReadS [CompatibleVersionsMap]
readsPrec :: Int -> ReadS CompatibleVersionsMap
$creadsPrec :: Int -> ReadS CompatibleVersionsMap
Prelude.Read, Int -> CompatibleVersionsMap -> ShowS
[CompatibleVersionsMap] -> ShowS
CompatibleVersionsMap -> String
(Int -> CompatibleVersionsMap -> ShowS)
-> (CompatibleVersionsMap -> String)
-> ([CompatibleVersionsMap] -> ShowS)
-> Show CompatibleVersionsMap
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompatibleVersionsMap] -> ShowS
$cshowList :: [CompatibleVersionsMap] -> ShowS
show :: CompatibleVersionsMap -> String
$cshow :: CompatibleVersionsMap -> String
showsPrec :: Int -> CompatibleVersionsMap -> ShowS
$cshowsPrec :: Int -> CompatibleVersionsMap -> ShowS
Prelude.Show, (forall x. CompatibleVersionsMap -> Rep CompatibleVersionsMap x)
-> (forall x. Rep CompatibleVersionsMap x -> CompatibleVersionsMap)
-> Generic CompatibleVersionsMap
forall x. Rep CompatibleVersionsMap x -> CompatibleVersionsMap
forall x. CompatibleVersionsMap -> Rep CompatibleVersionsMap x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CompatibleVersionsMap x -> CompatibleVersionsMap
$cfrom :: forall x. CompatibleVersionsMap -> Rep CompatibleVersionsMap x
Prelude.Generic)

-- |
-- Create a value of 'CompatibleVersionsMap' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'sourceVersion', 'compatibleVersionsMap_sourceVersion' - The current version of Elasticsearch on which a domain is.
--
-- 'targetVersions', 'compatibleVersionsMap_targetVersions' - Undocumented member.
newCompatibleVersionsMap ::
  CompatibleVersionsMap
newCompatibleVersionsMap :: CompatibleVersionsMap
newCompatibleVersionsMap =
  CompatibleVersionsMap' :: Maybe Text -> Maybe [Text] -> CompatibleVersionsMap
CompatibleVersionsMap'
    { $sel:sourceVersion:CompatibleVersionsMap' :: Maybe Text
sourceVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetVersions:CompatibleVersionsMap' :: Maybe [Text]
targetVersions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The current version of Elasticsearch on which a domain is.
compatibleVersionsMap_sourceVersion :: Lens.Lens' CompatibleVersionsMap (Prelude.Maybe Prelude.Text)
compatibleVersionsMap_sourceVersion :: (Maybe Text -> f (Maybe Text))
-> CompatibleVersionsMap -> f CompatibleVersionsMap
compatibleVersionsMap_sourceVersion = (CompatibleVersionsMap -> Maybe Text)
-> (CompatibleVersionsMap -> Maybe Text -> CompatibleVersionsMap)
-> Lens
     CompatibleVersionsMap
     CompatibleVersionsMap
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompatibleVersionsMap' {Maybe Text
sourceVersion :: Maybe Text
$sel:sourceVersion:CompatibleVersionsMap' :: CompatibleVersionsMap -> Maybe Text
sourceVersion} -> Maybe Text
sourceVersion) (\s :: CompatibleVersionsMap
s@CompatibleVersionsMap' {} Maybe Text
a -> CompatibleVersionsMap
s {$sel:sourceVersion:CompatibleVersionsMap' :: Maybe Text
sourceVersion = Maybe Text
a} :: CompatibleVersionsMap)

-- | Undocumented member.
compatibleVersionsMap_targetVersions :: Lens.Lens' CompatibleVersionsMap (Prelude.Maybe [Prelude.Text])
compatibleVersionsMap_targetVersions :: (Maybe [Text] -> f (Maybe [Text]))
-> CompatibleVersionsMap -> f CompatibleVersionsMap
compatibleVersionsMap_targetVersions = (CompatibleVersionsMap -> Maybe [Text])
-> (CompatibleVersionsMap -> Maybe [Text] -> CompatibleVersionsMap)
-> Lens
     CompatibleVersionsMap
     CompatibleVersionsMap
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompatibleVersionsMap' {Maybe [Text]
targetVersions :: Maybe [Text]
$sel:targetVersions:CompatibleVersionsMap' :: CompatibleVersionsMap -> Maybe [Text]
targetVersions} -> Maybe [Text]
targetVersions) (\s :: CompatibleVersionsMap
s@CompatibleVersionsMap' {} Maybe [Text]
a -> CompatibleVersionsMap
s {$sel:targetVersions:CompatibleVersionsMap' :: Maybe [Text]
targetVersions = Maybe [Text]
a} :: CompatibleVersionsMap) ((Maybe [Text] -> f (Maybe [Text]))
 -> CompatibleVersionsMap -> f CompatibleVersionsMap)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CompatibleVersionsMap
-> f CompatibleVersionsMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON CompatibleVersionsMap where
  parseJSON :: Value -> Parser CompatibleVersionsMap
parseJSON =
    String
-> (Object -> Parser CompatibleVersionsMap)
-> Value
-> Parser CompatibleVersionsMap
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CompatibleVersionsMap"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> CompatibleVersionsMap
CompatibleVersionsMap'
            (Maybe Text -> Maybe [Text] -> CompatibleVersionsMap)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> CompatibleVersionsMap)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SourceVersion")
            Parser (Maybe [Text] -> CompatibleVersionsMap)
-> Parser (Maybe [Text]) -> Parser CompatibleVersionsMap
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetVersions"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable CompatibleVersionsMap

instance Prelude.NFData CompatibleVersionsMap