{-# 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.EC2.Types.FpgaImageState
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EC2.Types.FpgaImageState where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.FpgaImageStateCode
import qualified Amazonka.Prelude as Prelude

-- | Describes the state of the bitstream generation process for an Amazon
-- FPGA image (AFI).
--
-- /See:/ 'newFpgaImageState' smart constructor.
data FpgaImageState = FpgaImageState'
  { -- | The state. The following are the possible values:
    --
    -- -   @pending@ - AFI bitstream generation is in progress.
    --
    -- -   @available@ - The AFI is available for use.
    --
    -- -   @failed@ - AFI bitstream generation failed.
    --
    -- -   @unavailable@ - The AFI is no longer available for use.
    FpgaImageState -> Maybe FpgaImageStateCode
code :: Prelude.Maybe FpgaImageStateCode,
    -- | If the state is @failed@, this is the error message.
    FpgaImageState -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (FpgaImageState -> FpgaImageState -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FpgaImageState -> FpgaImageState -> Bool
$c/= :: FpgaImageState -> FpgaImageState -> Bool
== :: FpgaImageState -> FpgaImageState -> Bool
$c== :: FpgaImageState -> FpgaImageState -> Bool
Prelude.Eq, ReadPrec [FpgaImageState]
ReadPrec FpgaImageState
Int -> ReadS FpgaImageState
ReadS [FpgaImageState]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FpgaImageState]
$creadListPrec :: ReadPrec [FpgaImageState]
readPrec :: ReadPrec FpgaImageState
$creadPrec :: ReadPrec FpgaImageState
readList :: ReadS [FpgaImageState]
$creadList :: ReadS [FpgaImageState]
readsPrec :: Int -> ReadS FpgaImageState
$creadsPrec :: Int -> ReadS FpgaImageState
Prelude.Read, Int -> FpgaImageState -> ShowS
[FpgaImageState] -> ShowS
FpgaImageState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FpgaImageState] -> ShowS
$cshowList :: [FpgaImageState] -> ShowS
show :: FpgaImageState -> String
$cshow :: FpgaImageState -> String
showsPrec :: Int -> FpgaImageState -> ShowS
$cshowsPrec :: Int -> FpgaImageState -> ShowS
Prelude.Show, forall x. Rep FpgaImageState x -> FpgaImageState
forall x. FpgaImageState -> Rep FpgaImageState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FpgaImageState x -> FpgaImageState
$cfrom :: forall x. FpgaImageState -> Rep FpgaImageState x
Prelude.Generic)

-- |
-- Create a value of 'FpgaImageState' 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', 'fpgaImageState_code' - The state. The following are the possible values:
--
-- -   @pending@ - AFI bitstream generation is in progress.
--
-- -   @available@ - The AFI is available for use.
--
-- -   @failed@ - AFI bitstream generation failed.
--
-- -   @unavailable@ - The AFI is no longer available for use.
--
-- 'message', 'fpgaImageState_message' - If the state is @failed@, this is the error message.
newFpgaImageState ::
  FpgaImageState
newFpgaImageState :: FpgaImageState
newFpgaImageState =
  FpgaImageState'
    { $sel:code:FpgaImageState' :: Maybe FpgaImageStateCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:FpgaImageState' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The state. The following are the possible values:
--
-- -   @pending@ - AFI bitstream generation is in progress.
--
-- -   @available@ - The AFI is available for use.
--
-- -   @failed@ - AFI bitstream generation failed.
--
-- -   @unavailable@ - The AFI is no longer available for use.
fpgaImageState_code :: Lens.Lens' FpgaImageState (Prelude.Maybe FpgaImageStateCode)
fpgaImageState_code :: Lens' FpgaImageState (Maybe FpgaImageStateCode)
fpgaImageState_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FpgaImageState' {Maybe FpgaImageStateCode
code :: Maybe FpgaImageStateCode
$sel:code:FpgaImageState' :: FpgaImageState -> Maybe FpgaImageStateCode
code} -> Maybe FpgaImageStateCode
code) (\s :: FpgaImageState
s@FpgaImageState' {} Maybe FpgaImageStateCode
a -> FpgaImageState
s {$sel:code:FpgaImageState' :: Maybe FpgaImageStateCode
code = Maybe FpgaImageStateCode
a} :: FpgaImageState)

-- | If the state is @failed@, this is the error message.
fpgaImageState_message :: Lens.Lens' FpgaImageState (Prelude.Maybe Prelude.Text)
fpgaImageState_message :: Lens' FpgaImageState (Maybe Text)
fpgaImageState_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FpgaImageState' {Maybe Text
message :: Maybe Text
$sel:message:FpgaImageState' :: FpgaImageState -> Maybe Text
message} -> Maybe Text
message) (\s :: FpgaImageState
s@FpgaImageState' {} Maybe Text
a -> FpgaImageState
s {$sel:message:FpgaImageState' :: Maybe Text
message = Maybe Text
a} :: FpgaImageState)

instance Data.FromXML FpgaImageState where
  parseXML :: [Node] -> Either String FpgaImageState
parseXML [Node]
x =
    Maybe FpgaImageStateCode -> Maybe Text -> FpgaImageState
FpgaImageState'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"code")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"message")

instance Prelude.Hashable FpgaImageState where
  hashWithSalt :: Int -> FpgaImageState -> Int
hashWithSalt Int
_salt FpgaImageState' {Maybe Text
Maybe FpgaImageStateCode
message :: Maybe Text
code :: Maybe FpgaImageStateCode
$sel:message:FpgaImageState' :: FpgaImageState -> Maybe Text
$sel:code:FpgaImageState' :: FpgaImageState -> Maybe FpgaImageStateCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FpgaImageStateCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData FpgaImageState where
  rnf :: FpgaImageState -> ()
rnf FpgaImageState' {Maybe Text
Maybe FpgaImageStateCode
message :: Maybe Text
code :: Maybe FpgaImageStateCode
$sel:message:FpgaImageState' :: FpgaImageState -> Maybe Text
$sel:code:FpgaImageState' :: FpgaImageState -> Maybe FpgaImageStateCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FpgaImageStateCode
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message