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

import Amazonka.AccessAnalyzer.Types.ReasonCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(StatusReason -> StatusReason -> Bool)
-> (StatusReason -> StatusReason -> Bool) -> Eq StatusReason
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]
(Int -> ReadS StatusReason)
-> ReadS [StatusReason]
-> ReadPrec StatusReason
-> ReadPrec [StatusReason]
-> Read 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
(Int -> StatusReason -> ShowS)
-> (StatusReason -> String)
-> ([StatusReason] -> ShowS)
-> Show StatusReason
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. StatusReason -> Rep StatusReason x)
-> (forall x. Rep StatusReason x -> StatusReason)
-> Generic StatusReason
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' :: ReasonCode -> StatusReason
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 :: (ReasonCode -> f ReasonCode) -> StatusReason -> f StatusReason
statusReason_code = (StatusReason -> ReasonCode)
-> (StatusReason -> ReasonCode -> StatusReason)
-> Lens StatusReason StatusReason ReasonCode ReasonCode
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 Core.FromJSON StatusReason where
  parseJSON :: Value -> Parser StatusReason
parseJSON =
    String
-> (Object -> Parser StatusReason) -> Value -> Parser StatusReason
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StatusReason"
      (\Object
x -> ReasonCode -> StatusReason
StatusReason' (ReasonCode -> StatusReason)
-> Parser ReasonCode -> Parser StatusReason
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ReasonCode
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"code"))

instance Prelude.Hashable StatusReason

instance Prelude.NFData StatusReason