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

import Amazonka.AppStream.Types.ImageStateChangeReasonCode
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 state change occurred.
--
-- /See:/ 'newImageStateChangeReason' smart constructor.
data ImageStateChangeReason = ImageStateChangeReason'
  { -- | The state change reason code.
    ImageStateChangeReason -> Maybe ImageStateChangeReasonCode
code :: Prelude.Maybe ImageStateChangeReasonCode,
    -- | The state change reason message.
    ImageStateChangeReason -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (ImageStateChangeReason -> ImageStateChangeReason -> Bool
(ImageStateChangeReason -> ImageStateChangeReason -> Bool)
-> (ImageStateChangeReason -> ImageStateChangeReason -> Bool)
-> Eq ImageStateChangeReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageStateChangeReason -> ImageStateChangeReason -> Bool
$c/= :: ImageStateChangeReason -> ImageStateChangeReason -> Bool
== :: ImageStateChangeReason -> ImageStateChangeReason -> Bool
$c== :: ImageStateChangeReason -> ImageStateChangeReason -> Bool
Prelude.Eq, ReadPrec [ImageStateChangeReason]
ReadPrec ImageStateChangeReason
Int -> ReadS ImageStateChangeReason
ReadS [ImageStateChangeReason]
(Int -> ReadS ImageStateChangeReason)
-> ReadS [ImageStateChangeReason]
-> ReadPrec ImageStateChangeReason
-> ReadPrec [ImageStateChangeReason]
-> Read ImageStateChangeReason
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageStateChangeReason]
$creadListPrec :: ReadPrec [ImageStateChangeReason]
readPrec :: ReadPrec ImageStateChangeReason
$creadPrec :: ReadPrec ImageStateChangeReason
readList :: ReadS [ImageStateChangeReason]
$creadList :: ReadS [ImageStateChangeReason]
readsPrec :: Int -> ReadS ImageStateChangeReason
$creadsPrec :: Int -> ReadS ImageStateChangeReason
Prelude.Read, Int -> ImageStateChangeReason -> ShowS
[ImageStateChangeReason] -> ShowS
ImageStateChangeReason -> String
(Int -> ImageStateChangeReason -> ShowS)
-> (ImageStateChangeReason -> String)
-> ([ImageStateChangeReason] -> ShowS)
-> Show ImageStateChangeReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageStateChangeReason] -> ShowS
$cshowList :: [ImageStateChangeReason] -> ShowS
show :: ImageStateChangeReason -> String
$cshow :: ImageStateChangeReason -> String
showsPrec :: Int -> ImageStateChangeReason -> ShowS
$cshowsPrec :: Int -> ImageStateChangeReason -> ShowS
Prelude.Show, (forall x. ImageStateChangeReason -> Rep ImageStateChangeReason x)
-> (forall x.
    Rep ImageStateChangeReason x -> ImageStateChangeReason)
-> Generic ImageStateChangeReason
forall x. Rep ImageStateChangeReason x -> ImageStateChangeReason
forall x. ImageStateChangeReason -> Rep ImageStateChangeReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageStateChangeReason x -> ImageStateChangeReason
$cfrom :: forall x. ImageStateChangeReason -> Rep ImageStateChangeReason x
Prelude.Generic)

-- |
-- Create a value of 'ImageStateChangeReason' 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', 'imageStateChangeReason_code' - The state change reason code.
--
-- 'message', 'imageStateChangeReason_message' - The state change reason message.
newImageStateChangeReason ::
  ImageStateChangeReason
newImageStateChangeReason :: ImageStateChangeReason
newImageStateChangeReason =
  ImageStateChangeReason' :: Maybe ImageStateChangeReasonCode
-> Maybe Text -> ImageStateChangeReason
ImageStateChangeReason'
    { $sel:code:ImageStateChangeReason' :: Maybe ImageStateChangeReasonCode
code = Maybe ImageStateChangeReasonCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:ImageStateChangeReason' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.NFData ImageStateChangeReason