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

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

-- | The status of the trial component.
--
-- /See:/ 'newTrialComponentStatus' smart constructor.
data TrialComponentStatus = TrialComponentStatus'
  { -- | The status of the trial component.
    TrialComponentStatus -> Maybe TrialComponentPrimaryStatus
primaryStatus :: Prelude.Maybe TrialComponentPrimaryStatus,
    -- | If the component failed, a message describing why.
    TrialComponentStatus -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (TrialComponentStatus -> TrialComponentStatus -> Bool
(TrialComponentStatus -> TrialComponentStatus -> Bool)
-> (TrialComponentStatus -> TrialComponentStatus -> Bool)
-> Eq TrialComponentStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrialComponentStatus -> TrialComponentStatus -> Bool
$c/= :: TrialComponentStatus -> TrialComponentStatus -> Bool
== :: TrialComponentStatus -> TrialComponentStatus -> Bool
$c== :: TrialComponentStatus -> TrialComponentStatus -> Bool
Prelude.Eq, ReadPrec [TrialComponentStatus]
ReadPrec TrialComponentStatus
Int -> ReadS TrialComponentStatus
ReadS [TrialComponentStatus]
(Int -> ReadS TrialComponentStatus)
-> ReadS [TrialComponentStatus]
-> ReadPrec TrialComponentStatus
-> ReadPrec [TrialComponentStatus]
-> Read TrialComponentStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrialComponentStatus]
$creadListPrec :: ReadPrec [TrialComponentStatus]
readPrec :: ReadPrec TrialComponentStatus
$creadPrec :: ReadPrec TrialComponentStatus
readList :: ReadS [TrialComponentStatus]
$creadList :: ReadS [TrialComponentStatus]
readsPrec :: Int -> ReadS TrialComponentStatus
$creadsPrec :: Int -> ReadS TrialComponentStatus
Prelude.Read, Int -> TrialComponentStatus -> ShowS
[TrialComponentStatus] -> ShowS
TrialComponentStatus -> String
(Int -> TrialComponentStatus -> ShowS)
-> (TrialComponentStatus -> String)
-> ([TrialComponentStatus] -> ShowS)
-> Show TrialComponentStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrialComponentStatus] -> ShowS
$cshowList :: [TrialComponentStatus] -> ShowS
show :: TrialComponentStatus -> String
$cshow :: TrialComponentStatus -> String
showsPrec :: Int -> TrialComponentStatus -> ShowS
$cshowsPrec :: Int -> TrialComponentStatus -> ShowS
Prelude.Show, (forall x. TrialComponentStatus -> Rep TrialComponentStatus x)
-> (forall x. Rep TrialComponentStatus x -> TrialComponentStatus)
-> Generic TrialComponentStatus
forall x. Rep TrialComponentStatus x -> TrialComponentStatus
forall x. TrialComponentStatus -> Rep TrialComponentStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrialComponentStatus x -> TrialComponentStatus
$cfrom :: forall x. TrialComponentStatus -> Rep TrialComponentStatus x
Prelude.Generic)

-- |
-- Create a value of 'TrialComponentStatus' 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:
--
-- 'primaryStatus', 'trialComponentStatus_primaryStatus' - The status of the trial component.
--
-- 'message', 'trialComponentStatus_message' - If the component failed, a message describing why.
newTrialComponentStatus ::
  TrialComponentStatus
newTrialComponentStatus :: TrialComponentStatus
newTrialComponentStatus =
  TrialComponentStatus' :: Maybe TrialComponentPrimaryStatus
-> Maybe Text -> TrialComponentStatus
TrialComponentStatus'
    { $sel:primaryStatus:TrialComponentStatus' :: Maybe TrialComponentPrimaryStatus
primaryStatus =
        Maybe TrialComponentPrimaryStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:message:TrialComponentStatus' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the trial component.
trialComponentStatus_primaryStatus :: Lens.Lens' TrialComponentStatus (Prelude.Maybe TrialComponentPrimaryStatus)
trialComponentStatus_primaryStatus :: (Maybe TrialComponentPrimaryStatus
 -> f (Maybe TrialComponentPrimaryStatus))
-> TrialComponentStatus -> f TrialComponentStatus
trialComponentStatus_primaryStatus = (TrialComponentStatus -> Maybe TrialComponentPrimaryStatus)
-> (TrialComponentStatus
    -> Maybe TrialComponentPrimaryStatus -> TrialComponentStatus)
-> Lens
     TrialComponentStatus
     TrialComponentStatus
     (Maybe TrialComponentPrimaryStatus)
     (Maybe TrialComponentPrimaryStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrialComponentStatus' {Maybe TrialComponentPrimaryStatus
primaryStatus :: Maybe TrialComponentPrimaryStatus
$sel:primaryStatus:TrialComponentStatus' :: TrialComponentStatus -> Maybe TrialComponentPrimaryStatus
primaryStatus} -> Maybe TrialComponentPrimaryStatus
primaryStatus) (\s :: TrialComponentStatus
s@TrialComponentStatus' {} Maybe TrialComponentPrimaryStatus
a -> TrialComponentStatus
s {$sel:primaryStatus:TrialComponentStatus' :: Maybe TrialComponentPrimaryStatus
primaryStatus = Maybe TrialComponentPrimaryStatus
a} :: TrialComponentStatus)

-- | If the component failed, a message describing why.
trialComponentStatus_message :: Lens.Lens' TrialComponentStatus (Prelude.Maybe Prelude.Text)
trialComponentStatus_message :: (Maybe Text -> f (Maybe Text))
-> TrialComponentStatus -> f TrialComponentStatus
trialComponentStatus_message = (TrialComponentStatus -> Maybe Text)
-> (TrialComponentStatus -> Maybe Text -> TrialComponentStatus)
-> Lens
     TrialComponentStatus TrialComponentStatus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrialComponentStatus' {Maybe Text
message :: Maybe Text
$sel:message:TrialComponentStatus' :: TrialComponentStatus -> Maybe Text
message} -> Maybe Text
message) (\s :: TrialComponentStatus
s@TrialComponentStatus' {} Maybe Text
a -> TrialComponentStatus
s {$sel:message:TrialComponentStatus' :: Maybe Text
message = Maybe Text
a} :: TrialComponentStatus)

instance Core.FromJSON TrialComponentStatus where
  parseJSON :: Value -> Parser TrialComponentStatus
parseJSON =
    String
-> (Object -> Parser TrialComponentStatus)
-> Value
-> Parser TrialComponentStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TrialComponentStatus"
      ( \Object
x ->
          Maybe TrialComponentPrimaryStatus
-> Maybe Text -> TrialComponentStatus
TrialComponentStatus'
            (Maybe TrialComponentPrimaryStatus
 -> Maybe Text -> TrialComponentStatus)
-> Parser (Maybe TrialComponentPrimaryStatus)
-> Parser (Maybe Text -> TrialComponentStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TrialComponentPrimaryStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PrimaryStatus")
            Parser (Maybe Text -> TrialComponentStatus)
-> Parser (Maybe Text) -> Parser TrialComponentStatus
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
"Message")
      )

instance Prelude.Hashable TrialComponentStatus

instance Prelude.NFData TrialComponentStatus

instance Core.ToJSON TrialComponentStatus where
  toJSON :: TrialComponentStatus -> Value
toJSON TrialComponentStatus' {Maybe Text
Maybe TrialComponentPrimaryStatus
message :: Maybe Text
primaryStatus :: Maybe TrialComponentPrimaryStatus
$sel:message:TrialComponentStatus' :: TrialComponentStatus -> Maybe Text
$sel:primaryStatus:TrialComponentStatus' :: TrialComponentStatus -> Maybe TrialComponentPrimaryStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PrimaryStatus" Text -> TrialComponentPrimaryStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TrialComponentPrimaryStatus -> Pair)
-> Maybe TrialComponentPrimaryStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TrialComponentPrimaryStatus
primaryStatus,
            (Text
"Message" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
message
          ]
      )