{-# 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.UpgradeStepItem
-- 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.UpgradeStepItem where

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

-- | Represents a single step of the upgrade or upgrade eligibility check
-- workflow.
--
-- /See:/ 'newUpgradeStepItem' smart constructor.
data UpgradeStepItem = UpgradeStepItem'
  { -- | The current status of the upgrade. The status can take one of the
    -- following values:
    --
    -- -   In Progress
    -- -   Succeeded
    -- -   Succeeded with Issues
    -- -   Failed
    UpgradeStepItem -> Maybe UpgradeStatus
upgradeStepStatus :: Prelude.Maybe UpgradeStatus,
    -- | The floating point value representing the progress percentage of a
    -- particular step.
    UpgradeStepItem -> Maybe Double
progressPercent :: Prelude.Maybe Prelude.Double,
    -- | A list of strings containing detailed information about the errors
    -- encountered in a particular step.
    UpgradeStepItem -> Maybe [Text]
issues :: Prelude.Maybe [Prelude.Text],
    -- | One of three steps an upgrade or upgrade eligibility check goes through:
    --
    -- -   PreUpgradeCheck
    -- -   Snapshot
    -- -   Upgrade
    UpgradeStepItem -> Maybe UpgradeStep
upgradeStep :: Prelude.Maybe UpgradeStep
  }
  deriving (UpgradeStepItem -> UpgradeStepItem -> Bool
(UpgradeStepItem -> UpgradeStepItem -> Bool)
-> (UpgradeStepItem -> UpgradeStepItem -> Bool)
-> Eq UpgradeStepItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpgradeStepItem -> UpgradeStepItem -> Bool
$c/= :: UpgradeStepItem -> UpgradeStepItem -> Bool
== :: UpgradeStepItem -> UpgradeStepItem -> Bool
$c== :: UpgradeStepItem -> UpgradeStepItem -> Bool
Prelude.Eq, ReadPrec [UpgradeStepItem]
ReadPrec UpgradeStepItem
Int -> ReadS UpgradeStepItem
ReadS [UpgradeStepItem]
(Int -> ReadS UpgradeStepItem)
-> ReadS [UpgradeStepItem]
-> ReadPrec UpgradeStepItem
-> ReadPrec [UpgradeStepItem]
-> Read UpgradeStepItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpgradeStepItem]
$creadListPrec :: ReadPrec [UpgradeStepItem]
readPrec :: ReadPrec UpgradeStepItem
$creadPrec :: ReadPrec UpgradeStepItem
readList :: ReadS [UpgradeStepItem]
$creadList :: ReadS [UpgradeStepItem]
readsPrec :: Int -> ReadS UpgradeStepItem
$creadsPrec :: Int -> ReadS UpgradeStepItem
Prelude.Read, Int -> UpgradeStepItem -> ShowS
[UpgradeStepItem] -> ShowS
UpgradeStepItem -> String
(Int -> UpgradeStepItem -> ShowS)
-> (UpgradeStepItem -> String)
-> ([UpgradeStepItem] -> ShowS)
-> Show UpgradeStepItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpgradeStepItem] -> ShowS
$cshowList :: [UpgradeStepItem] -> ShowS
show :: UpgradeStepItem -> String
$cshow :: UpgradeStepItem -> String
showsPrec :: Int -> UpgradeStepItem -> ShowS
$cshowsPrec :: Int -> UpgradeStepItem -> ShowS
Prelude.Show, (forall x. UpgradeStepItem -> Rep UpgradeStepItem x)
-> (forall x. Rep UpgradeStepItem x -> UpgradeStepItem)
-> Generic UpgradeStepItem
forall x. Rep UpgradeStepItem x -> UpgradeStepItem
forall x. UpgradeStepItem -> Rep UpgradeStepItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpgradeStepItem x -> UpgradeStepItem
$cfrom :: forall x. UpgradeStepItem -> Rep UpgradeStepItem x
Prelude.Generic)

-- |
-- Create a value of 'UpgradeStepItem' 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:
--
-- 'upgradeStepStatus', 'upgradeStepItem_upgradeStepStatus' - The current status of the upgrade. The status can take one of the
-- following values:
--
-- -   In Progress
-- -   Succeeded
-- -   Succeeded with Issues
-- -   Failed
--
-- 'progressPercent', 'upgradeStepItem_progressPercent' - The floating point value representing the progress percentage of a
-- particular step.
--
-- 'issues', 'upgradeStepItem_issues' - A list of strings containing detailed information about the errors
-- encountered in a particular step.
--
-- 'upgradeStep', 'upgradeStepItem_upgradeStep' - One of three steps an upgrade or upgrade eligibility check goes through:
--
-- -   PreUpgradeCheck
-- -   Snapshot
-- -   Upgrade
newUpgradeStepItem ::
  UpgradeStepItem
newUpgradeStepItem :: UpgradeStepItem
newUpgradeStepItem =
  UpgradeStepItem' :: Maybe UpgradeStatus
-> Maybe Double
-> Maybe [Text]
-> Maybe UpgradeStep
-> UpgradeStepItem
UpgradeStepItem'
    { $sel:upgradeStepStatus:UpgradeStepItem' :: Maybe UpgradeStatus
upgradeStepStatus =
        Maybe UpgradeStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:progressPercent:UpgradeStepItem' :: Maybe Double
progressPercent = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:issues:UpgradeStepItem' :: Maybe [Text]
issues = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:upgradeStep:UpgradeStepItem' :: Maybe UpgradeStep
upgradeStep = Maybe UpgradeStep
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
upgradeStepItem_upgradeStepStatus :: Lens.Lens' UpgradeStepItem (Prelude.Maybe UpgradeStatus)
upgradeStepItem_upgradeStepStatus :: (Maybe UpgradeStatus -> f (Maybe UpgradeStatus))
-> UpgradeStepItem -> f UpgradeStepItem
upgradeStepItem_upgradeStepStatus = (UpgradeStepItem -> Maybe UpgradeStatus)
-> (UpgradeStepItem -> Maybe UpgradeStatus -> UpgradeStepItem)
-> Lens
     UpgradeStepItem
     UpgradeStepItem
     (Maybe UpgradeStatus)
     (Maybe UpgradeStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpgradeStepItem' {Maybe UpgradeStatus
upgradeStepStatus :: Maybe UpgradeStatus
$sel:upgradeStepStatus:UpgradeStepItem' :: UpgradeStepItem -> Maybe UpgradeStatus
upgradeStepStatus} -> Maybe UpgradeStatus
upgradeStepStatus) (\s :: UpgradeStepItem
s@UpgradeStepItem' {} Maybe UpgradeStatus
a -> UpgradeStepItem
s {$sel:upgradeStepStatus:UpgradeStepItem' :: Maybe UpgradeStatus
upgradeStepStatus = Maybe UpgradeStatus
a} :: UpgradeStepItem)

-- | The floating point value representing the progress percentage of a
-- particular step.
upgradeStepItem_progressPercent :: Lens.Lens' UpgradeStepItem (Prelude.Maybe Prelude.Double)
upgradeStepItem_progressPercent :: (Maybe Double -> f (Maybe Double))
-> UpgradeStepItem -> f UpgradeStepItem
upgradeStepItem_progressPercent = (UpgradeStepItem -> Maybe Double)
-> (UpgradeStepItem -> Maybe Double -> UpgradeStepItem)
-> Lens
     UpgradeStepItem UpgradeStepItem (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpgradeStepItem' {Maybe Double
progressPercent :: Maybe Double
$sel:progressPercent:UpgradeStepItem' :: UpgradeStepItem -> Maybe Double
progressPercent} -> Maybe Double
progressPercent) (\s :: UpgradeStepItem
s@UpgradeStepItem' {} Maybe Double
a -> UpgradeStepItem
s {$sel:progressPercent:UpgradeStepItem' :: Maybe Double
progressPercent = Maybe Double
a} :: UpgradeStepItem)

-- | A list of strings containing detailed information about the errors
-- encountered in a particular step.
upgradeStepItem_issues :: Lens.Lens' UpgradeStepItem (Prelude.Maybe [Prelude.Text])
upgradeStepItem_issues :: (Maybe [Text] -> f (Maybe [Text]))
-> UpgradeStepItem -> f UpgradeStepItem
upgradeStepItem_issues = (UpgradeStepItem -> Maybe [Text])
-> (UpgradeStepItem -> Maybe [Text] -> UpgradeStepItem)
-> Lens
     UpgradeStepItem UpgradeStepItem (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpgradeStepItem' {Maybe [Text]
issues :: Maybe [Text]
$sel:issues:UpgradeStepItem' :: UpgradeStepItem -> Maybe [Text]
issues} -> Maybe [Text]
issues) (\s :: UpgradeStepItem
s@UpgradeStepItem' {} Maybe [Text]
a -> UpgradeStepItem
s {$sel:issues:UpgradeStepItem' :: Maybe [Text]
issues = Maybe [Text]
a} :: UpgradeStepItem) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpgradeStepItem -> f UpgradeStepItem)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpgradeStepItem
-> f UpgradeStepItem
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

-- | One of three steps an upgrade or upgrade eligibility check goes through:
--
-- -   PreUpgradeCheck
-- -   Snapshot
-- -   Upgrade
upgradeStepItem_upgradeStep :: Lens.Lens' UpgradeStepItem (Prelude.Maybe UpgradeStep)
upgradeStepItem_upgradeStep :: (Maybe UpgradeStep -> f (Maybe UpgradeStep))
-> UpgradeStepItem -> f UpgradeStepItem
upgradeStepItem_upgradeStep = (UpgradeStepItem -> Maybe UpgradeStep)
-> (UpgradeStepItem -> Maybe UpgradeStep -> UpgradeStepItem)
-> Lens
     UpgradeStepItem
     UpgradeStepItem
     (Maybe UpgradeStep)
     (Maybe UpgradeStep)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpgradeStepItem' {Maybe UpgradeStep
upgradeStep :: Maybe UpgradeStep
$sel:upgradeStep:UpgradeStepItem' :: UpgradeStepItem -> Maybe UpgradeStep
upgradeStep} -> Maybe UpgradeStep
upgradeStep) (\s :: UpgradeStepItem
s@UpgradeStepItem' {} Maybe UpgradeStep
a -> UpgradeStepItem
s {$sel:upgradeStep:UpgradeStepItem' :: Maybe UpgradeStep
upgradeStep = Maybe UpgradeStep
a} :: UpgradeStepItem)

instance Core.FromJSON UpgradeStepItem where
  parseJSON :: Value -> Parser UpgradeStepItem
parseJSON =
    String
-> (Object -> Parser UpgradeStepItem)
-> Value
-> Parser UpgradeStepItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UpgradeStepItem"
      ( \Object
x ->
          Maybe UpgradeStatus
-> Maybe Double
-> Maybe [Text]
-> Maybe UpgradeStep
-> UpgradeStepItem
UpgradeStepItem'
            (Maybe UpgradeStatus
 -> Maybe Double
 -> Maybe [Text]
 -> Maybe UpgradeStep
 -> UpgradeStepItem)
-> Parser (Maybe UpgradeStatus)
-> Parser
     (Maybe Double
      -> Maybe [Text] -> Maybe UpgradeStep -> UpgradeStepItem)
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
"UpgradeStepStatus")
            Parser
  (Maybe Double
   -> Maybe [Text] -> Maybe UpgradeStep -> UpgradeStepItem)
-> Parser (Maybe Double)
-> Parser (Maybe [Text] -> Maybe UpgradeStep -> UpgradeStepItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProgressPercent")
            Parser (Maybe [Text] -> Maybe UpgradeStep -> UpgradeStepItem)
-> Parser (Maybe [Text])
-> Parser (Maybe UpgradeStep -> UpgradeStepItem)
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
"Issues" 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)
            Parser (Maybe UpgradeStep -> UpgradeStepItem)
-> Parser (Maybe UpgradeStep) -> Parser UpgradeStepItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UpgradeStep)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UpgradeStep")
      )

instance Prelude.Hashable UpgradeStepItem

instance Prelude.NFData UpgradeStepItem