{-# 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.Inspector2.Types.State
-- 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.Inspector2.Types.State where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector2.Types.ErrorCode
import Amazonka.Inspector2.Types.Status
import qualified Amazonka.Prelude as Prelude

-- | An object that described the state of Amazon Inspector scans for an
-- account.
--
-- /See:/ 'newState' smart constructor.
data State = State'
  { -- | The error code explaining why the account failed to enable Amazon
    -- Inspector.
    State -> ErrorCode
errorCode :: ErrorCode,
    -- | The error message received when the account failed to enable Amazon
    -- Inspector.
    State -> Text
errorMessage :: Prelude.Text,
    -- | The status of Amazon Inspector for the account.
    State -> Status
status :: Status
  }
  deriving (State -> State -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: State -> State -> Bool
$c/= :: State -> State -> Bool
== :: State -> State -> Bool
$c== :: State -> State -> Bool
Prelude.Eq, ReadPrec [State]
ReadPrec State
Int -> ReadS State
ReadS [State]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [State]
$creadListPrec :: ReadPrec [State]
readPrec :: ReadPrec State
$creadPrec :: ReadPrec State
readList :: ReadS [State]
$creadList :: ReadS [State]
readsPrec :: Int -> ReadS State
$creadsPrec :: Int -> ReadS State
Prelude.Read, Int -> State -> ShowS
[State] -> ShowS
State -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [State] -> ShowS
$cshowList :: [State] -> ShowS
show :: State -> String
$cshow :: State -> String
showsPrec :: Int -> State -> ShowS
$cshowsPrec :: Int -> State -> ShowS
Prelude.Show, forall x. Rep State x -> State
forall x. State -> Rep State x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep State x -> State
$cfrom :: forall x. State -> Rep State x
Prelude.Generic)

-- |
-- Create a value of 'State' 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:
--
-- 'errorCode', 'state_errorCode' - The error code explaining why the account failed to enable Amazon
-- Inspector.
--
-- 'errorMessage', 'state_errorMessage' - The error message received when the account failed to enable Amazon
-- Inspector.
--
-- 'status', 'state_status' - The status of Amazon Inspector for the account.
newState ::
  -- | 'errorCode'
  ErrorCode ->
  -- | 'errorMessage'
  Prelude.Text ->
  -- | 'status'
  Status ->
  State
newState :: ErrorCode -> Text -> Status -> State
newState ErrorCode
pErrorCode_ Text
pErrorMessage_ Status
pStatus_ =
  State'
    { $sel:errorCode:State' :: ErrorCode
errorCode = ErrorCode
pErrorCode_,
      $sel:errorMessage:State' :: Text
errorMessage = Text
pErrorMessage_,
      $sel:status:State' :: Status
status = Status
pStatus_
    }

-- | The error code explaining why the account failed to enable Amazon
-- Inspector.
state_errorCode :: Lens.Lens' State ErrorCode
state_errorCode :: Lens' State ErrorCode
state_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\State' {ErrorCode
errorCode :: ErrorCode
$sel:errorCode:State' :: State -> ErrorCode
errorCode} -> ErrorCode
errorCode) (\s :: State
s@State' {} ErrorCode
a -> State
s {$sel:errorCode:State' :: ErrorCode
errorCode = ErrorCode
a} :: State)

-- | The error message received when the account failed to enable Amazon
-- Inspector.
state_errorMessage :: Lens.Lens' State Prelude.Text
state_errorMessage :: Lens' State Text
state_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\State' {Text
errorMessage :: Text
$sel:errorMessage:State' :: State -> Text
errorMessage} -> Text
errorMessage) (\s :: State
s@State' {} Text
a -> State
s {$sel:errorMessage:State' :: Text
errorMessage = Text
a} :: State)

-- | The status of Amazon Inspector for the account.
state_status :: Lens.Lens' State Status
state_status :: Lens' State Status
state_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\State' {Status
status :: Status
$sel:status:State' :: State -> Status
status} -> Status
status) (\s :: State
s@State' {} Status
a -> State
s {$sel:status:State' :: Status
status = Status
a} :: State)

instance Data.FromJSON State where
  parseJSON :: Value -> Parser State
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"State"
      ( \Object
x ->
          ErrorCode -> Text -> Status -> State
State'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"errorCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"errorMessage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"status")
      )

instance Prelude.Hashable State where
  hashWithSalt :: Int -> State -> Int
hashWithSalt Int
_salt State' {Text
ErrorCode
Status
status :: Status
errorMessage :: Text
errorCode :: ErrorCode
$sel:status:State' :: State -> Status
$sel:errorMessage:State' :: State -> Text
$sel:errorCode:State' :: State -> ErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ErrorCode
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Status
status

instance Prelude.NFData State where
  rnf :: State -> ()
rnf State' {Text
ErrorCode
Status
status :: Status
errorMessage :: Text
errorCode :: ErrorCode
$sel:status:State' :: State -> Status
$sel:errorMessage:State' :: State -> Text
$sel:errorCode:State' :: State -> ErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ErrorCode
errorCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Status
status