{-# 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.AppStream.Types.ImageBuilderStateChangeReason
-- 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.AppStream.Types.ImageBuilderStateChangeReason where

import Amazonka.AppStream.Types.ImageBuilderStateChangeReasonCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the reason why the last image builder state change occurred.
--
-- /See:/ 'newImageBuilderStateChangeReason' smart constructor.
data ImageBuilderStateChangeReason = ImageBuilderStateChangeReason'
  { -- | The state change reason code.
    ImageBuilderStateChangeReason
-> Maybe ImageBuilderStateChangeReasonCode
code :: Prelude.Maybe ImageBuilderStateChangeReasonCode,
    -- | The state change reason message.
    ImageBuilderStateChangeReason -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (ImageBuilderStateChangeReason
-> ImageBuilderStateChangeReason -> Bool
(ImageBuilderStateChangeReason
 -> ImageBuilderStateChangeReason -> Bool)
-> (ImageBuilderStateChangeReason
    -> ImageBuilderStateChangeReason -> Bool)
-> Eq ImageBuilderStateChangeReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageBuilderStateChangeReason
-> ImageBuilderStateChangeReason -> Bool
$c/= :: ImageBuilderStateChangeReason
-> ImageBuilderStateChangeReason -> Bool
== :: ImageBuilderStateChangeReason
-> ImageBuilderStateChangeReason -> Bool
$c== :: ImageBuilderStateChangeReason
-> ImageBuilderStateChangeReason -> Bool
Prelude.Eq, ReadPrec [ImageBuilderStateChangeReason]
ReadPrec ImageBuilderStateChangeReason
Int -> ReadS ImageBuilderStateChangeReason
ReadS [ImageBuilderStateChangeReason]
(Int -> ReadS ImageBuilderStateChangeReason)
-> ReadS [ImageBuilderStateChangeReason]
-> ReadPrec ImageBuilderStateChangeReason
-> ReadPrec [ImageBuilderStateChangeReason]
-> Read ImageBuilderStateChangeReason
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageBuilderStateChangeReason]
$creadListPrec :: ReadPrec [ImageBuilderStateChangeReason]
readPrec :: ReadPrec ImageBuilderStateChangeReason
$creadPrec :: ReadPrec ImageBuilderStateChangeReason
readList :: ReadS [ImageBuilderStateChangeReason]
$creadList :: ReadS [ImageBuilderStateChangeReason]
readsPrec :: Int -> ReadS ImageBuilderStateChangeReason
$creadsPrec :: Int -> ReadS ImageBuilderStateChangeReason
Prelude.Read, Int -> ImageBuilderStateChangeReason -> ShowS
[ImageBuilderStateChangeReason] -> ShowS
ImageBuilderStateChangeReason -> String
(Int -> ImageBuilderStateChangeReason -> ShowS)
-> (ImageBuilderStateChangeReason -> String)
-> ([ImageBuilderStateChangeReason] -> ShowS)
-> Show ImageBuilderStateChangeReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageBuilderStateChangeReason] -> ShowS
$cshowList :: [ImageBuilderStateChangeReason] -> ShowS
show :: ImageBuilderStateChangeReason -> String
$cshow :: ImageBuilderStateChangeReason -> String
showsPrec :: Int -> ImageBuilderStateChangeReason -> ShowS
$cshowsPrec :: Int -> ImageBuilderStateChangeReason -> ShowS
Prelude.Show, (forall x.
 ImageBuilderStateChangeReason
 -> Rep ImageBuilderStateChangeReason x)
-> (forall x.
    Rep ImageBuilderStateChangeReason x
    -> ImageBuilderStateChangeReason)
-> Generic ImageBuilderStateChangeReason
forall x.
Rep ImageBuilderStateChangeReason x
-> ImageBuilderStateChangeReason
forall x.
ImageBuilderStateChangeReason
-> Rep ImageBuilderStateChangeReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ImageBuilderStateChangeReason x
-> ImageBuilderStateChangeReason
$cfrom :: forall x.
ImageBuilderStateChangeReason
-> Rep ImageBuilderStateChangeReason x
Prelude.Generic)

-- |
-- Create a value of 'ImageBuilderStateChangeReason' 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:
--
-- 'code', 'imageBuilderStateChangeReason_code' - The state change reason code.
--
-- 'message', 'imageBuilderStateChangeReason_message' - The state change reason message.
newImageBuilderStateChangeReason ::
  ImageBuilderStateChangeReason
newImageBuilderStateChangeReason :: ImageBuilderStateChangeReason
newImageBuilderStateChangeReason =
  ImageBuilderStateChangeReason' :: Maybe ImageBuilderStateChangeReasonCode
-> Maybe Text -> ImageBuilderStateChangeReason
ImageBuilderStateChangeReason'
    { $sel:code:ImageBuilderStateChangeReason' :: Maybe ImageBuilderStateChangeReasonCode
code =
        Maybe ImageBuilderStateChangeReasonCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:ImageBuilderStateChangeReason' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The state change reason code.
imageBuilderStateChangeReason_code :: Lens.Lens' ImageBuilderStateChangeReason (Prelude.Maybe ImageBuilderStateChangeReasonCode)
imageBuilderStateChangeReason_code :: (Maybe ImageBuilderStateChangeReasonCode
 -> f (Maybe ImageBuilderStateChangeReasonCode))
-> ImageBuilderStateChangeReason -> f ImageBuilderStateChangeReason
imageBuilderStateChangeReason_code = (ImageBuilderStateChangeReason
 -> Maybe ImageBuilderStateChangeReasonCode)
-> (ImageBuilderStateChangeReason
    -> Maybe ImageBuilderStateChangeReasonCode
    -> ImageBuilderStateChangeReason)
-> Lens
     ImageBuilderStateChangeReason
     ImageBuilderStateChangeReason
     (Maybe ImageBuilderStateChangeReasonCode)
     (Maybe ImageBuilderStateChangeReasonCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageBuilderStateChangeReason' {Maybe ImageBuilderStateChangeReasonCode
code :: Maybe ImageBuilderStateChangeReasonCode
$sel:code:ImageBuilderStateChangeReason' :: ImageBuilderStateChangeReason
-> Maybe ImageBuilderStateChangeReasonCode
code} -> Maybe ImageBuilderStateChangeReasonCode
code) (\s :: ImageBuilderStateChangeReason
s@ImageBuilderStateChangeReason' {} Maybe ImageBuilderStateChangeReasonCode
a -> ImageBuilderStateChangeReason
s {$sel:code:ImageBuilderStateChangeReason' :: Maybe ImageBuilderStateChangeReasonCode
code = Maybe ImageBuilderStateChangeReasonCode
a} :: ImageBuilderStateChangeReason)

-- | The state change reason message.
imageBuilderStateChangeReason_message :: Lens.Lens' ImageBuilderStateChangeReason (Prelude.Maybe Prelude.Text)
imageBuilderStateChangeReason_message :: (Maybe Text -> f (Maybe Text))
-> ImageBuilderStateChangeReason -> f ImageBuilderStateChangeReason
imageBuilderStateChangeReason_message = (ImageBuilderStateChangeReason -> Maybe Text)
-> (ImageBuilderStateChangeReason
    -> Maybe Text -> ImageBuilderStateChangeReason)
-> Lens
     ImageBuilderStateChangeReason
     ImageBuilderStateChangeReason
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageBuilderStateChangeReason' {Maybe Text
message :: Maybe Text
$sel:message:ImageBuilderStateChangeReason' :: ImageBuilderStateChangeReason -> Maybe Text
message} -> Maybe Text
message) (\s :: ImageBuilderStateChangeReason
s@ImageBuilderStateChangeReason' {} Maybe Text
a -> ImageBuilderStateChangeReason
s {$sel:message:ImageBuilderStateChangeReason' :: Maybe Text
message = Maybe Text
a} :: ImageBuilderStateChangeReason)

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

instance Prelude.NFData ImageBuilderStateChangeReason