{-# 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.OpenSearch.Types.UpgradeHistory
-- 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.OpenSearch.Types.UpgradeHistory where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpenSearch.Types.UpgradeStatus
import Amazonka.OpenSearch.Types.UpgradeStepItem
import qualified Amazonka.Prelude as Prelude

-- | History of the last 10 upgrades and upgrade eligibility checks.
--
-- /See:/ 'newUpgradeHistory' smart constructor.
data UpgradeHistory = UpgradeHistory'
  { -- | The current status of the upgrade. The status can take one of the
    -- following values:
    --
    -- -   In Progress
    -- -   Succeeded
    -- -   Succeeded with Issues
    -- -   Failed
    UpgradeHistory -> Maybe UpgradeStatus
upgradeStatus :: Prelude.Maybe UpgradeStatus,
    -- | A list of @ UpgradeStepItem @ s representing information about each step
    -- performed as part of a specific upgrade or upgrade eligibility check.
    UpgradeHistory -> Maybe [UpgradeStepItem]
stepsList :: Prelude.Maybe [UpgradeStepItem],
    -- | A string that briefly describes the upgrade.
    UpgradeHistory -> Maybe Text
upgradeName :: Prelude.Maybe Prelude.Text,
    -- | UTC timestamp at which the upgrade API call was made in
    -- \"yyyy-MM-ddTHH:mm:ssZ\" format.
    UpgradeHistory -> Maybe POSIX
startTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (UpgradeHistory -> UpgradeHistory -> Bool
(UpgradeHistory -> UpgradeHistory -> Bool)
-> (UpgradeHistory -> UpgradeHistory -> Bool) -> Eq UpgradeHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpgradeHistory -> UpgradeHistory -> Bool
$c/= :: UpgradeHistory -> UpgradeHistory -> Bool
== :: UpgradeHistory -> UpgradeHistory -> Bool
$c== :: UpgradeHistory -> UpgradeHistory -> Bool
Prelude.Eq, ReadPrec [UpgradeHistory]
ReadPrec UpgradeHistory
Int -> ReadS UpgradeHistory
ReadS [UpgradeHistory]
(Int -> ReadS UpgradeHistory)
-> ReadS [UpgradeHistory]
-> ReadPrec UpgradeHistory
-> ReadPrec [UpgradeHistory]
-> Read UpgradeHistory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpgradeHistory]
$creadListPrec :: ReadPrec [UpgradeHistory]
readPrec :: ReadPrec UpgradeHistory
$creadPrec :: ReadPrec UpgradeHistory
readList :: ReadS [UpgradeHistory]
$creadList :: ReadS [UpgradeHistory]
readsPrec :: Int -> ReadS UpgradeHistory
$creadsPrec :: Int -> ReadS UpgradeHistory
Prelude.Read, Int -> UpgradeHistory -> ShowS
[UpgradeHistory] -> ShowS
UpgradeHistory -> String
(Int -> UpgradeHistory -> ShowS)
-> (UpgradeHistory -> String)
-> ([UpgradeHistory] -> ShowS)
-> Show UpgradeHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpgradeHistory] -> ShowS
$cshowList :: [UpgradeHistory] -> ShowS
show :: UpgradeHistory -> String
$cshow :: UpgradeHistory -> String
showsPrec :: Int -> UpgradeHistory -> ShowS
$cshowsPrec :: Int -> UpgradeHistory -> ShowS
Prelude.Show, (forall x. UpgradeHistory -> Rep UpgradeHistory x)
-> (forall x. Rep UpgradeHistory x -> UpgradeHistory)
-> Generic UpgradeHistory
forall x. Rep UpgradeHistory x -> UpgradeHistory
forall x. UpgradeHistory -> Rep UpgradeHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpgradeHistory x -> UpgradeHistory
$cfrom :: forall x. UpgradeHistory -> Rep UpgradeHistory x
Prelude.Generic)

-- |
-- Create a value of 'UpgradeHistory' 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:
--
-- 'upgradeStatus', 'upgradeHistory_upgradeStatus' - The current status of the upgrade. The status can take one of the
-- following values:
--
-- -   In Progress
-- -   Succeeded
-- -   Succeeded with Issues
-- -   Failed
--
-- 'stepsList', 'upgradeHistory_stepsList' - A list of @ UpgradeStepItem @ s representing information about each step
-- performed as part of a specific upgrade or upgrade eligibility check.
--
-- 'upgradeName', 'upgradeHistory_upgradeName' - A string that briefly describes the upgrade.
--
-- 'startTimestamp', 'upgradeHistory_startTimestamp' - UTC timestamp at which the upgrade API call was made in
-- \"yyyy-MM-ddTHH:mm:ssZ\" format.
newUpgradeHistory ::
  UpgradeHistory
newUpgradeHistory :: UpgradeHistory
newUpgradeHistory =
  UpgradeHistory' :: Maybe UpgradeStatus
-> Maybe [UpgradeStepItem]
-> Maybe Text
-> Maybe POSIX
-> UpgradeHistory
UpgradeHistory'
    { $sel:upgradeStatus:UpgradeHistory' :: Maybe UpgradeStatus
upgradeStatus = Maybe UpgradeStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:stepsList:UpgradeHistory' :: Maybe [UpgradeStepItem]
stepsList = Maybe [UpgradeStepItem]
forall a. Maybe a
Prelude.Nothing,
      $sel:upgradeName:UpgradeHistory' :: Maybe Text
upgradeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startTimestamp:UpgradeHistory' :: Maybe POSIX
startTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The current status of the upgrade. The status can take one of the
-- following values:
--
-- -   In Progress
-- -   Succeeded
-- -   Succeeded with Issues
-- -   Failed
upgradeHistory_upgradeStatus :: Lens.Lens' UpgradeHistory (Prelude.Maybe UpgradeStatus)
upgradeHistory_upgradeStatus :: (Maybe UpgradeStatus -> f (Maybe UpgradeStatus))
-> UpgradeHistory -> f UpgradeHistory
upgradeHistory_upgradeStatus = (UpgradeHistory -> Maybe UpgradeStatus)
-> (UpgradeHistory -> Maybe UpgradeStatus -> UpgradeHistory)
-> Lens
     UpgradeHistory
     UpgradeHistory
     (Maybe UpgradeStatus)
     (Maybe UpgradeStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpgradeHistory' {Maybe UpgradeStatus
upgradeStatus :: Maybe UpgradeStatus
$sel:upgradeStatus:UpgradeHistory' :: UpgradeHistory -> Maybe UpgradeStatus
upgradeStatus} -> Maybe UpgradeStatus
upgradeStatus) (\s :: UpgradeHistory
s@UpgradeHistory' {} Maybe UpgradeStatus
a -> UpgradeHistory
s {$sel:upgradeStatus:UpgradeHistory' :: Maybe UpgradeStatus
upgradeStatus = Maybe UpgradeStatus
a} :: UpgradeHistory)

-- | A list of @ UpgradeStepItem @ s representing information about each step
-- performed as part of a specific upgrade or upgrade eligibility check.
upgradeHistory_stepsList :: Lens.Lens' UpgradeHistory (Prelude.Maybe [UpgradeStepItem])
upgradeHistory_stepsList :: (Maybe [UpgradeStepItem] -> f (Maybe [UpgradeStepItem]))
-> UpgradeHistory -> f UpgradeHistory
upgradeHistory_stepsList = (UpgradeHistory -> Maybe [UpgradeStepItem])
-> (UpgradeHistory -> Maybe [UpgradeStepItem] -> UpgradeHistory)
-> Lens
     UpgradeHistory
     UpgradeHistory
     (Maybe [UpgradeStepItem])
     (Maybe [UpgradeStepItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpgradeHistory' {Maybe [UpgradeStepItem]
stepsList :: Maybe [UpgradeStepItem]
$sel:stepsList:UpgradeHistory' :: UpgradeHistory -> Maybe [UpgradeStepItem]
stepsList} -> Maybe [UpgradeStepItem]
stepsList) (\s :: UpgradeHistory
s@UpgradeHistory' {} Maybe [UpgradeStepItem]
a -> UpgradeHistory
s {$sel:stepsList:UpgradeHistory' :: Maybe [UpgradeStepItem]
stepsList = Maybe [UpgradeStepItem]
a} :: UpgradeHistory) ((Maybe [UpgradeStepItem] -> f (Maybe [UpgradeStepItem]))
 -> UpgradeHistory -> f UpgradeHistory)
-> ((Maybe [UpgradeStepItem] -> f (Maybe [UpgradeStepItem]))
    -> Maybe [UpgradeStepItem] -> f (Maybe [UpgradeStepItem]))
-> (Maybe [UpgradeStepItem] -> f (Maybe [UpgradeStepItem]))
-> UpgradeHistory
-> f UpgradeHistory
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [UpgradeStepItem]
  [UpgradeStepItem]
  [UpgradeStepItem]
  [UpgradeStepItem]
-> Iso
     (Maybe [UpgradeStepItem])
     (Maybe [UpgradeStepItem])
     (Maybe [UpgradeStepItem])
     (Maybe [UpgradeStepItem])
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
  [UpgradeStepItem]
  [UpgradeStepItem]
  [UpgradeStepItem]
  [UpgradeStepItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A string that briefly describes the upgrade.
upgradeHistory_upgradeName :: Lens.Lens' UpgradeHistory (Prelude.Maybe Prelude.Text)
upgradeHistory_upgradeName :: (Maybe Text -> f (Maybe Text))
-> UpgradeHistory -> f UpgradeHistory
upgradeHistory_upgradeName = (UpgradeHistory -> Maybe Text)
-> (UpgradeHistory -> Maybe Text -> UpgradeHistory)
-> Lens UpgradeHistory UpgradeHistory (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpgradeHistory' {Maybe Text
upgradeName :: Maybe Text
$sel:upgradeName:UpgradeHistory' :: UpgradeHistory -> Maybe Text
upgradeName} -> Maybe Text
upgradeName) (\s :: UpgradeHistory
s@UpgradeHistory' {} Maybe Text
a -> UpgradeHistory
s {$sel:upgradeName:UpgradeHistory' :: Maybe Text
upgradeName = Maybe Text
a} :: UpgradeHistory)

-- | UTC timestamp at which the upgrade API call was made in
-- \"yyyy-MM-ddTHH:mm:ssZ\" format.
upgradeHistory_startTimestamp :: Lens.Lens' UpgradeHistory (Prelude.Maybe Prelude.UTCTime)
upgradeHistory_startTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> UpgradeHistory -> f UpgradeHistory
upgradeHistory_startTimestamp = (UpgradeHistory -> Maybe POSIX)
-> (UpgradeHistory -> Maybe POSIX -> UpgradeHistory)
-> Lens UpgradeHistory UpgradeHistory (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpgradeHistory' {Maybe POSIX
startTimestamp :: Maybe POSIX
$sel:startTimestamp:UpgradeHistory' :: UpgradeHistory -> Maybe POSIX
startTimestamp} -> Maybe POSIX
startTimestamp) (\s :: UpgradeHistory
s@UpgradeHistory' {} Maybe POSIX
a -> UpgradeHistory
s {$sel:startTimestamp:UpgradeHistory' :: Maybe POSIX
startTimestamp = Maybe POSIX
a} :: UpgradeHistory) ((Maybe POSIX -> f (Maybe POSIX))
 -> UpgradeHistory -> f UpgradeHistory)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> UpgradeHistory
-> f UpgradeHistory
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON UpgradeHistory where
  parseJSON :: Value -> Parser UpgradeHistory
parseJSON =
    String
-> (Object -> Parser UpgradeHistory)
-> Value
-> Parser UpgradeHistory
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UpgradeHistory"
      ( \Object
x ->
          Maybe UpgradeStatus
-> Maybe [UpgradeStepItem]
-> Maybe Text
-> Maybe POSIX
-> UpgradeHistory
UpgradeHistory'
            (Maybe UpgradeStatus
 -> Maybe [UpgradeStepItem]
 -> Maybe Text
 -> Maybe POSIX
 -> UpgradeHistory)
-> Parser (Maybe UpgradeStatus)
-> Parser
     (Maybe [UpgradeStepItem]
      -> Maybe Text -> Maybe POSIX -> UpgradeHistory)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe UpgradeStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UpgradeStatus")
            Parser
  (Maybe [UpgradeStepItem]
   -> Maybe Text -> Maybe POSIX -> UpgradeHistory)
-> Parser (Maybe [UpgradeStepItem])
-> Parser (Maybe Text -> Maybe POSIX -> UpgradeHistory)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [UpgradeStepItem]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StepsList" Parser (Maybe (Maybe [UpgradeStepItem]))
-> Maybe [UpgradeStepItem] -> Parser (Maybe [UpgradeStepItem])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [UpgradeStepItem]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe POSIX -> UpgradeHistory)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> UpgradeHistory)
forall (f :: * -> *) a b. Applicative f => 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
"UpgradeName")
            Parser (Maybe POSIX -> UpgradeHistory)
-> Parser (Maybe POSIX) -> Parser UpgradeHistory
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartTimestamp")
      )

instance Prelude.Hashable UpgradeHistory

instance Prelude.NFData UpgradeHistory