{-# 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.AccessAnalyzer.Types.StatusReason
-- 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.AccessAnalyzer.Types.StatusReason where

import Amazonka.AccessAnalyzer.Types.ReasonCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Provides more details about the current status of the analyzer. For
-- example, if the creation for the analyzer fails, a @Failed@ status is
-- returned. For an analyzer with organization as the type, this failure
-- can be due to an issue with creating the service-linked roles required
-- in the member accounts of the Amazon Web Services organization.
--
-- /See:/ 'newStatusReason' smart constructor.
data StatusReason = StatusReason'
  { -- | The reason code for the current status of the analyzer.
    StatusReason -> ReasonCode
code :: ReasonCode
  }
  deriving (StatusReason -> StatusReason -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatusReason -> StatusReason -> Bool
$c/= :: StatusReason -> StatusReason -> Bool
== :: StatusReason -> StatusReason -> Bool
$c== :: StatusReason -> StatusReason -> Bool
Prelude.Eq, ReadPrec [StatusReason]
ReadPrec StatusReason
Int -> ReadS StatusReason
ReadS [StatusReason]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatusReason]
$creadListPrec :: ReadPrec [StatusReason]
readPrec :: ReadPrec StatusReason
$creadPrec :: ReadPrec StatusReason
readList :: ReadS [StatusReason]
$creadList :: ReadS [StatusReason]
readsPrec :: Int -> ReadS StatusReason
$creadsPrec :: Int -> ReadS StatusReason
Prelude.Read, Int -> StatusReason -> ShowS
[StatusReason] -> ShowS
StatusReason -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatusReason] -> ShowS
$cshowList :: [StatusReason] -> ShowS
show :: StatusReason -> String
$cshow :: StatusReason -> String
showsPrec :: Int -> StatusReason -> ShowS
$cshowsPrec :: Int -> StatusReason -> ShowS
Prelude.Show, forall x. Rep StatusReason x -> StatusReason
forall x. StatusReason -> Rep StatusReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatusReason x -> StatusReason
$cfrom :: forall x. StatusReason -> Rep StatusReason x
Prelude.Generic)

-- |
-- Create a value of 'StatusReason' 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', 'statusReason_code' - The reason code for the current status of the analyzer.
newStatusReason ::
  -- | 'code'
  ReasonCode ->
  StatusReason
newStatusReason :: ReasonCode -> StatusReason
newStatusReason ReasonCode
pCode_ = StatusReason' {$sel:code:StatusReason' :: ReasonCode
code = ReasonCode
pCode_}

-- | The reason code for the current status of the analyzer.
statusReason_code :: Lens.Lens' StatusReason ReasonCode
statusReason_code :: Lens' StatusReason ReasonCode
statusReason_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatusReason' {ReasonCode
code :: ReasonCode
$sel:code:StatusReason' :: StatusReason -> ReasonCode
code} -> ReasonCode
code) (\s :: StatusReason
s@StatusReason' {} ReasonCode
a -> StatusReason
s {$sel:code:StatusReason' :: ReasonCode
code = ReasonCode
a} :: StatusReason)

instance Data.FromJSON StatusReason where
  parseJSON :: Value -> Parser StatusReason
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StatusReason"
      (\Object
x -> ReasonCode -> StatusReason
StatusReason' 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
"code"))

instance Prelude.Hashable StatusReason where
  hashWithSalt :: Int -> StatusReason -> Int
hashWithSalt Int
_salt StatusReason' {ReasonCode
code :: ReasonCode
$sel:code:StatusReason' :: StatusReason -> ReasonCode
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ReasonCode
code

instance Prelude.NFData StatusReason where
  rnf :: StatusReason -> ()
rnf StatusReason' {ReasonCode
code :: ReasonCode
$sel:code:StatusReason' :: StatusReason -> ReasonCode
..} = forall a. NFData a => a -> ()
Prelude.rnf ReasonCode
code