{-# 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.FailedAccount
-- 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.FailedAccount 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.ResourceStatus
import Amazonka.Inspector2.Types.Status
import qualified Amazonka.Prelude as Prelude

-- | An object with details on why an account failed to enable Amazon
-- Inspector.
--
-- /See:/ 'newFailedAccount' smart constructor.
data FailedAccount = FailedAccount'
  { -- | An object detailing which resources Amazon Inspector is enabled to scan
    -- for the account.
    FailedAccount -> Maybe ResourceStatus
resourceStatus :: Prelude.Maybe ResourceStatus,
    -- | The status of Amazon Inspector for the account.
    FailedAccount -> Maybe Status
status :: Prelude.Maybe Status,
    -- | The Amazon Web Services account ID.
    FailedAccount -> Text
accountId :: Prelude.Text,
    -- | The error code explaining why the account failed to enable Amazon
    -- Inspector.
    FailedAccount -> ErrorCode
errorCode :: ErrorCode,
    -- | The error message received when the account failed to enable Amazon
    -- Inspector.
    FailedAccount -> Text
errorMessage :: Prelude.Text
  }
  deriving (FailedAccount -> FailedAccount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailedAccount -> FailedAccount -> Bool
$c/= :: FailedAccount -> FailedAccount -> Bool
== :: FailedAccount -> FailedAccount -> Bool
$c== :: FailedAccount -> FailedAccount -> Bool
Prelude.Eq, ReadPrec [FailedAccount]
ReadPrec FailedAccount
Int -> ReadS FailedAccount
ReadS [FailedAccount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailedAccount]
$creadListPrec :: ReadPrec [FailedAccount]
readPrec :: ReadPrec FailedAccount
$creadPrec :: ReadPrec FailedAccount
readList :: ReadS [FailedAccount]
$creadList :: ReadS [FailedAccount]
readsPrec :: Int -> ReadS FailedAccount
$creadsPrec :: Int -> ReadS FailedAccount
Prelude.Read, Int -> FailedAccount -> ShowS
[FailedAccount] -> ShowS
FailedAccount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailedAccount] -> ShowS
$cshowList :: [FailedAccount] -> ShowS
show :: FailedAccount -> String
$cshow :: FailedAccount -> String
showsPrec :: Int -> FailedAccount -> ShowS
$cshowsPrec :: Int -> FailedAccount -> ShowS
Prelude.Show, forall x. Rep FailedAccount x -> FailedAccount
forall x. FailedAccount -> Rep FailedAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailedAccount x -> FailedAccount
$cfrom :: forall x. FailedAccount -> Rep FailedAccount x
Prelude.Generic)

-- |
-- Create a value of 'FailedAccount' 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:
--
-- 'resourceStatus', 'failedAccount_resourceStatus' - An object detailing which resources Amazon Inspector is enabled to scan
-- for the account.
--
-- 'status', 'failedAccount_status' - The status of Amazon Inspector for the account.
--
-- 'accountId', 'failedAccount_accountId' - The Amazon Web Services account ID.
--
-- 'errorCode', 'failedAccount_errorCode' - The error code explaining why the account failed to enable Amazon
-- Inspector.
--
-- 'errorMessage', 'failedAccount_errorMessage' - The error message received when the account failed to enable Amazon
-- Inspector.
newFailedAccount ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'errorCode'
  ErrorCode ->
  -- | 'errorMessage'
  Prelude.Text ->
  FailedAccount
newFailedAccount :: Text -> ErrorCode -> Text -> FailedAccount
newFailedAccount
  Text
pAccountId_
  ErrorCode
pErrorCode_
  Text
pErrorMessage_ =
    FailedAccount'
      { $sel:resourceStatus:FailedAccount' :: Maybe ResourceStatus
resourceStatus = forall a. Maybe a
Prelude.Nothing,
        $sel:status:FailedAccount' :: Maybe Status
status = forall a. Maybe a
Prelude.Nothing,
        $sel:accountId:FailedAccount' :: Text
accountId = Text
pAccountId_,
        $sel:errorCode:FailedAccount' :: ErrorCode
errorCode = ErrorCode
pErrorCode_,
        $sel:errorMessage:FailedAccount' :: Text
errorMessage = Text
pErrorMessage_
      }

-- | An object detailing which resources Amazon Inspector is enabled to scan
-- for the account.
failedAccount_resourceStatus :: Lens.Lens' FailedAccount (Prelude.Maybe ResourceStatus)
failedAccount_resourceStatus :: Lens' FailedAccount (Maybe ResourceStatus)
failedAccount_resourceStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedAccount' {Maybe ResourceStatus
resourceStatus :: Maybe ResourceStatus
$sel:resourceStatus:FailedAccount' :: FailedAccount -> Maybe ResourceStatus
resourceStatus} -> Maybe ResourceStatus
resourceStatus) (\s :: FailedAccount
s@FailedAccount' {} Maybe ResourceStatus
a -> FailedAccount
s {$sel:resourceStatus:FailedAccount' :: Maybe ResourceStatus
resourceStatus = Maybe ResourceStatus
a} :: FailedAccount)

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

-- | The Amazon Web Services account ID.
failedAccount_accountId :: Lens.Lens' FailedAccount Prelude.Text
failedAccount_accountId :: Lens' FailedAccount Text
failedAccount_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedAccount' {Text
accountId :: Text
$sel:accountId:FailedAccount' :: FailedAccount -> Text
accountId} -> Text
accountId) (\s :: FailedAccount
s@FailedAccount' {} Text
a -> FailedAccount
s {$sel:accountId:FailedAccount' :: Text
accountId = Text
a} :: FailedAccount)

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

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

instance Data.FromJSON FailedAccount where
  parseJSON :: Value -> Parser FailedAccount
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FailedAccount"
      ( \Object
x ->
          Maybe ResourceStatus
-> Maybe Status -> Text -> ErrorCode -> Text -> FailedAccount
FailedAccount'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"resourceStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"status")
            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
"accountId")
            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
"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")
      )

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

instance Prelude.NFData FailedAccount where
  rnf :: FailedAccount -> ()
rnf FailedAccount' {Maybe Status
Maybe ResourceStatus
Text
ErrorCode
errorMessage :: Text
errorCode :: ErrorCode
accountId :: Text
status :: Maybe Status
resourceStatus :: Maybe ResourceStatus
$sel:errorMessage:FailedAccount' :: FailedAccount -> Text
$sel:errorCode:FailedAccount' :: FailedAccount -> ErrorCode
$sel:accountId:FailedAccount' :: FailedAccount -> Text
$sel:status:FailedAccount' :: FailedAccount -> Maybe Status
$sel:resourceStatus:FailedAccount' :: FailedAccount -> Maybe ResourceStatus
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceStatus
resourceStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Status
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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