{-# 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.UpgradeHistory
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ElasticSearch.Types.UpgradeHistory where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticSearch.Types.UpgradeStatus
import Amazonka.ElasticSearch.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'
  { -- | UTC Timestamp at which the Upgrade API call was made in
    -- \"yyyy-MM-ddTHH:mm:ssZ\" format.
    UpgradeHistory -> Maybe POSIX
startTimestamp :: Prelude.Maybe Data.POSIX,
    -- | A list of @ @@UpgradeStepItem@@ @ s representing information about each
    -- step performed as pard of a specific Upgrade or Upgrade Eligibility
    -- Check.
    UpgradeHistory -> Maybe [UpgradeStepItem]
stepsList :: Prelude.Maybe [UpgradeStepItem],
    -- | A string that describes the update briefly
    UpgradeHistory -> Maybe Text
upgradeName :: Prelude.Maybe Prelude.Text,
    -- | The overall status of the update. The status can take one of the
    -- following values:
    --
    -- -   In Progress
    -- -   Succeeded
    -- -   Succeeded with Issues
    -- -   Failed
    UpgradeHistory -> Maybe UpgradeStatus
upgradeStatus :: Prelude.Maybe UpgradeStatus
  }
  deriving (UpgradeHistory -> UpgradeHistory -> Bool
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]
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
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. 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:
--
-- 'startTimestamp', 'upgradeHistory_startTimestamp' - UTC Timestamp at which the Upgrade API call was made in
-- \"yyyy-MM-ddTHH:mm:ssZ\" format.
--
-- 'stepsList', 'upgradeHistory_stepsList' - A list of @ @@UpgradeStepItem@@ @ s representing information about each
-- step performed as pard of a specific Upgrade or Upgrade Eligibility
-- Check.
--
-- 'upgradeName', 'upgradeHistory_upgradeName' - A string that describes the update briefly
--
-- 'upgradeStatus', 'upgradeHistory_upgradeStatus' - The overall status of the update. The status can take one of the
-- following values:
--
-- -   In Progress
-- -   Succeeded
-- -   Succeeded with Issues
-- -   Failed
newUpgradeHistory ::
  UpgradeHistory
newUpgradeHistory :: UpgradeHistory
newUpgradeHistory =
  UpgradeHistory'
    { $sel:startTimestamp:UpgradeHistory' :: Maybe POSIX
startTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:stepsList:UpgradeHistory' :: Maybe [UpgradeStepItem]
stepsList = forall a. Maybe a
Prelude.Nothing,
      $sel:upgradeName:UpgradeHistory' :: Maybe Text
upgradeName = forall a. Maybe a
Prelude.Nothing,
      $sel:upgradeStatus:UpgradeHistory' :: Maybe UpgradeStatus
upgradeStatus = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' UpgradeHistory (Maybe UTCTime)
upgradeHistory_startTimestamp = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A list of @ @@UpgradeStepItem@@ @ s representing information about each
-- step performed as pard of a specific Upgrade or Upgrade Eligibility
-- Check.
upgradeHistory_stepsList :: Lens.Lens' UpgradeHistory (Prelude.Maybe [UpgradeStepItem])
upgradeHistory_stepsList :: Lens' UpgradeHistory (Maybe [UpgradeStepItem])
upgradeHistory_stepsList = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A string that describes the update briefly
upgradeHistory_upgradeName :: Lens.Lens' UpgradeHistory (Prelude.Maybe Prelude.Text)
upgradeHistory_upgradeName :: Lens' UpgradeHistory (Maybe Text)
upgradeHistory_upgradeName = 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)

-- | The overall status of the update. 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 :: Lens' UpgradeHistory (Maybe UpgradeStatus)
upgradeHistory_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)

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

instance Prelude.Hashable UpgradeHistory where
  hashWithSalt :: Int -> UpgradeHistory -> Int
hashWithSalt Int
_salt UpgradeHistory' {Maybe [UpgradeStepItem]
Maybe Text
Maybe POSIX
Maybe UpgradeStatus
upgradeStatus :: Maybe UpgradeStatus
upgradeName :: Maybe Text
stepsList :: Maybe [UpgradeStepItem]
startTimestamp :: Maybe POSIX
$sel:upgradeStatus:UpgradeHistory' :: UpgradeHistory -> Maybe UpgradeStatus
$sel:upgradeName:UpgradeHistory' :: UpgradeHistory -> Maybe Text
$sel:stepsList:UpgradeHistory' :: UpgradeHistory -> Maybe [UpgradeStepItem]
$sel:startTimestamp:UpgradeHistory' :: UpgradeHistory -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [UpgradeStepItem]
stepsList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
upgradeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpgradeStatus
upgradeStatus

instance Prelude.NFData UpgradeHistory where
  rnf :: UpgradeHistory -> ()
rnf UpgradeHistory' {Maybe [UpgradeStepItem]
Maybe Text
Maybe POSIX
Maybe UpgradeStatus
upgradeStatus :: Maybe UpgradeStatus
upgradeName :: Maybe Text
stepsList :: Maybe [UpgradeStepItem]
startTimestamp :: Maybe POSIX
$sel:upgradeStatus:UpgradeHistory' :: UpgradeHistory -> Maybe UpgradeStatus
$sel:upgradeName:UpgradeHistory' :: UpgradeHistory -> Maybe Text
$sel:stepsList:UpgradeHistory' :: UpgradeHistory -> Maybe [UpgradeStepItem]
$sel:startTimestamp:UpgradeHistory' :: UpgradeHistory -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [UpgradeStepItem]
stepsList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
upgradeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UpgradeStatus
upgradeStatus