{-# 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.SageMaker.Types.AlgorithmStatusItem
-- 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.SageMaker.Types.AlgorithmStatusItem where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.DetailedAlgorithmStatus

-- | Represents the overall status of an algorithm.
--
-- /See:/ 'newAlgorithmStatusItem' smart constructor.
data AlgorithmStatusItem = AlgorithmStatusItem'
  { -- | if the overall status is @Failed@, the reason for the failure.
    AlgorithmStatusItem -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | The name of the algorithm for which the overall status is being
    -- reported.
    AlgorithmStatusItem -> Text
name :: Prelude.Text,
    -- | The current status.
    AlgorithmStatusItem -> DetailedAlgorithmStatus
status :: DetailedAlgorithmStatus
  }
  deriving (AlgorithmStatusItem -> AlgorithmStatusItem -> Bool
(AlgorithmStatusItem -> AlgorithmStatusItem -> Bool)
-> (AlgorithmStatusItem -> AlgorithmStatusItem -> Bool)
-> Eq AlgorithmStatusItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlgorithmStatusItem -> AlgorithmStatusItem -> Bool
$c/= :: AlgorithmStatusItem -> AlgorithmStatusItem -> Bool
== :: AlgorithmStatusItem -> AlgorithmStatusItem -> Bool
$c== :: AlgorithmStatusItem -> AlgorithmStatusItem -> Bool
Prelude.Eq, ReadPrec [AlgorithmStatusItem]
ReadPrec AlgorithmStatusItem
Int -> ReadS AlgorithmStatusItem
ReadS [AlgorithmStatusItem]
(Int -> ReadS AlgorithmStatusItem)
-> ReadS [AlgorithmStatusItem]
-> ReadPrec AlgorithmStatusItem
-> ReadPrec [AlgorithmStatusItem]
-> Read AlgorithmStatusItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlgorithmStatusItem]
$creadListPrec :: ReadPrec [AlgorithmStatusItem]
readPrec :: ReadPrec AlgorithmStatusItem
$creadPrec :: ReadPrec AlgorithmStatusItem
readList :: ReadS [AlgorithmStatusItem]
$creadList :: ReadS [AlgorithmStatusItem]
readsPrec :: Int -> ReadS AlgorithmStatusItem
$creadsPrec :: Int -> ReadS AlgorithmStatusItem
Prelude.Read, Int -> AlgorithmStatusItem -> ShowS
[AlgorithmStatusItem] -> ShowS
AlgorithmStatusItem -> String
(Int -> AlgorithmStatusItem -> ShowS)
-> (AlgorithmStatusItem -> String)
-> ([AlgorithmStatusItem] -> ShowS)
-> Show AlgorithmStatusItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlgorithmStatusItem] -> ShowS
$cshowList :: [AlgorithmStatusItem] -> ShowS
show :: AlgorithmStatusItem -> String
$cshow :: AlgorithmStatusItem -> String
showsPrec :: Int -> AlgorithmStatusItem -> ShowS
$cshowsPrec :: Int -> AlgorithmStatusItem -> ShowS
Prelude.Show, (forall x. AlgorithmStatusItem -> Rep AlgorithmStatusItem x)
-> (forall x. Rep AlgorithmStatusItem x -> AlgorithmStatusItem)
-> Generic AlgorithmStatusItem
forall x. Rep AlgorithmStatusItem x -> AlgorithmStatusItem
forall x. AlgorithmStatusItem -> Rep AlgorithmStatusItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlgorithmStatusItem x -> AlgorithmStatusItem
$cfrom :: forall x. AlgorithmStatusItem -> Rep AlgorithmStatusItem x
Prelude.Generic)

-- |
-- Create a value of 'AlgorithmStatusItem' 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:
--
-- 'failureReason', 'algorithmStatusItem_failureReason' - if the overall status is @Failed@, the reason for the failure.
--
-- 'name', 'algorithmStatusItem_name' - The name of the algorithm for which the overall status is being
-- reported.
--
-- 'status', 'algorithmStatusItem_status' - The current status.
newAlgorithmStatusItem ::
  -- | 'name'
  Prelude.Text ->
  -- | 'status'
  DetailedAlgorithmStatus ->
  AlgorithmStatusItem
newAlgorithmStatusItem :: Text -> DetailedAlgorithmStatus -> AlgorithmStatusItem
newAlgorithmStatusItem Text
pName_ DetailedAlgorithmStatus
pStatus_ =
  AlgorithmStatusItem' :: Maybe Text
-> Text -> DetailedAlgorithmStatus -> AlgorithmStatusItem
AlgorithmStatusItem'
    { $sel:failureReason:AlgorithmStatusItem' :: Maybe Text
failureReason =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AlgorithmStatusItem' :: Text
name = Text
pName_,
      $sel:status:AlgorithmStatusItem' :: DetailedAlgorithmStatus
status = DetailedAlgorithmStatus
pStatus_
    }

-- | if the overall status is @Failed@, the reason for the failure.
algorithmStatusItem_failureReason :: Lens.Lens' AlgorithmStatusItem (Prelude.Maybe Prelude.Text)
algorithmStatusItem_failureReason :: (Maybe Text -> f (Maybe Text))
-> AlgorithmStatusItem -> f AlgorithmStatusItem
algorithmStatusItem_failureReason = (AlgorithmStatusItem -> Maybe Text)
-> (AlgorithmStatusItem -> Maybe Text -> AlgorithmStatusItem)
-> Lens
     AlgorithmStatusItem AlgorithmStatusItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlgorithmStatusItem' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:AlgorithmStatusItem' :: AlgorithmStatusItem -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: AlgorithmStatusItem
s@AlgorithmStatusItem' {} Maybe Text
a -> AlgorithmStatusItem
s {$sel:failureReason:AlgorithmStatusItem' :: Maybe Text
failureReason = Maybe Text
a} :: AlgorithmStatusItem)

-- | The name of the algorithm for which the overall status is being
-- reported.
algorithmStatusItem_name :: Lens.Lens' AlgorithmStatusItem Prelude.Text
algorithmStatusItem_name :: (Text -> f Text) -> AlgorithmStatusItem -> f AlgorithmStatusItem
algorithmStatusItem_name = (AlgorithmStatusItem -> Text)
-> (AlgorithmStatusItem -> Text -> AlgorithmStatusItem)
-> Lens AlgorithmStatusItem AlgorithmStatusItem Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlgorithmStatusItem' {Text
name :: Text
$sel:name:AlgorithmStatusItem' :: AlgorithmStatusItem -> Text
name} -> Text
name) (\s :: AlgorithmStatusItem
s@AlgorithmStatusItem' {} Text
a -> AlgorithmStatusItem
s {$sel:name:AlgorithmStatusItem' :: Text
name = Text
a} :: AlgorithmStatusItem)

-- | The current status.
algorithmStatusItem_status :: Lens.Lens' AlgorithmStatusItem DetailedAlgorithmStatus
algorithmStatusItem_status :: (DetailedAlgorithmStatus -> f DetailedAlgorithmStatus)
-> AlgorithmStatusItem -> f AlgorithmStatusItem
algorithmStatusItem_status = (AlgorithmStatusItem -> DetailedAlgorithmStatus)
-> (AlgorithmStatusItem
    -> DetailedAlgorithmStatus -> AlgorithmStatusItem)
-> Lens
     AlgorithmStatusItem
     AlgorithmStatusItem
     DetailedAlgorithmStatus
     DetailedAlgorithmStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlgorithmStatusItem' {DetailedAlgorithmStatus
status :: DetailedAlgorithmStatus
$sel:status:AlgorithmStatusItem' :: AlgorithmStatusItem -> DetailedAlgorithmStatus
status} -> DetailedAlgorithmStatus
status) (\s :: AlgorithmStatusItem
s@AlgorithmStatusItem' {} DetailedAlgorithmStatus
a -> AlgorithmStatusItem
s {$sel:status:AlgorithmStatusItem' :: DetailedAlgorithmStatus
status = DetailedAlgorithmStatus
a} :: AlgorithmStatusItem)

instance Core.FromJSON AlgorithmStatusItem where
  parseJSON :: Value -> Parser AlgorithmStatusItem
parseJSON =
    String
-> (Object -> Parser AlgorithmStatusItem)
-> Value
-> Parser AlgorithmStatusItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AlgorithmStatusItem"
      ( \Object
x ->
          Maybe Text
-> Text -> DetailedAlgorithmStatus -> AlgorithmStatusItem
AlgorithmStatusItem'
            (Maybe Text
 -> Text -> DetailedAlgorithmStatus -> AlgorithmStatusItem)
-> Parser (Maybe Text)
-> Parser (Text -> DetailedAlgorithmStatus -> AlgorithmStatusItem)
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
"FailureReason")
            Parser (Text -> DetailedAlgorithmStatus -> AlgorithmStatusItem)
-> Parser Text
-> Parser (DetailedAlgorithmStatus -> AlgorithmStatusItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser (DetailedAlgorithmStatus -> AlgorithmStatusItem)
-> Parser DetailedAlgorithmStatus -> Parser AlgorithmStatusItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser DetailedAlgorithmStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Status")
      )

instance Prelude.Hashable AlgorithmStatusItem

instance Prelude.NFData AlgorithmStatusItem