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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides additional context for the value of @Compliance.Status@.
--
-- /See:/ 'newStatusReason' smart constructor.
data StatusReason = StatusReason'
  { -- | The corresponding description for the status reason code.
    StatusReason -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A code that represents a reason for the control status. For the list of
    -- status reason codes and their meanings, see
    -- <https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-results.html#securityhub-standards-results-asff Standards-related information in the ASFF>
    -- in the /Security Hub User Guide/.
    StatusReason -> Text
reasonCode :: Prelude.Text
  }
  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:
--
-- 'description', 'statusReason_description' - The corresponding description for the status reason code.
--
-- 'reasonCode', 'statusReason_reasonCode' - A code that represents a reason for the control status. For the list of
-- status reason codes and their meanings, see
-- <https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-results.html#securityhub-standards-results-asff Standards-related information in the ASFF>
-- in the /Security Hub User Guide/.
newStatusReason ::
  -- | 'reasonCode'
  Prelude.Text ->
  StatusReason
newStatusReason :: Text -> StatusReason
newStatusReason Text
pReasonCode_ =
  StatusReason' :: Maybe Text -> Text -> StatusReason
StatusReason'
    { $sel:description:StatusReason' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reasonCode:StatusReason' :: Text
reasonCode = Text
pReasonCode_
    }

-- | The corresponding description for the status reason code.
statusReason_description :: Lens.Lens' StatusReason (Prelude.Maybe Prelude.Text)
statusReason_description :: (Maybe Text -> f (Maybe Text)) -> StatusReason -> f StatusReason
statusReason_description = (StatusReason -> Maybe Text)
-> (StatusReason -> Maybe Text -> StatusReason)
-> Lens StatusReason StatusReason (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatusReason' {Maybe Text
description :: Maybe Text
$sel:description:StatusReason' :: StatusReason -> Maybe Text
description} -> Maybe Text
description) (\s :: StatusReason
s@StatusReason' {} Maybe Text
a -> StatusReason
s {$sel:description:StatusReason' :: Maybe Text
description = Maybe Text
a} :: StatusReason)

-- | A code that represents a reason for the control status. For the list of
-- status reason codes and their meanings, see
-- <https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-results.html#securityhub-standards-results-asff Standards-related information in the ASFF>
-- in the /Security Hub User Guide/.
statusReason_reasonCode :: Lens.Lens' StatusReason Prelude.Text
statusReason_reasonCode :: (Text -> f Text) -> StatusReason -> f StatusReason
statusReason_reasonCode = (StatusReason -> Text)
-> (StatusReason -> Text -> StatusReason)
-> Lens StatusReason StatusReason Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatusReason' {Text
reasonCode :: Text
$sel:reasonCode:StatusReason' :: StatusReason -> Text
reasonCode} -> Text
reasonCode) (\s :: StatusReason
s@StatusReason' {} Text
a -> StatusReason
s {$sel:reasonCode:StatusReason' :: Text
reasonCode = Text
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 ->
          Maybe Text -> Text -> StatusReason
StatusReason'
            (Maybe Text -> Text -> StatusReason)
-> Parser (Maybe Text) -> Parser (Text -> StatusReason)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Description")
            Parser (Text -> StatusReason) -> Parser Text -> Parser StatusReason
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ReasonCode")
      )

instance Prelude.Hashable StatusReason

instance Prelude.NFData StatusReason

instance Core.ToJSON StatusReason where
  toJSON :: StatusReason -> Value
toJSON StatusReason' {Maybe Text
Text
reasonCode :: Text
description :: Maybe Text
$sel:reasonCode:StatusReason' :: StatusReason -> Text
$sel:description:StatusReason' :: StatusReason -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ReasonCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
reasonCode)
          ]
      )