{-# 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.Compliance
-- 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.Compliance where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.ComplianceStatus
import Amazonka.SecurityHub.Types.StatusReason

-- | Contains finding details that are specific to control-based findings.
-- Only returned for findings generated from controls.
--
-- /See:/ 'newCompliance' smart constructor.
data Compliance = Compliance'
  { -- | The result of a standards check.
    --
    -- The valid values for @Status@ are as follows.
    --
    -- -   -   @PASSED@ - Standards check passed for all evaluated resources.
    --
    --     -   @WARNING@ - Some information is missing or this check is not
    --         supported for your configuration.
    --
    --     -   @FAILED@ - Standards check failed for at least one evaluated
    --         resource.
    --
    --     -   @NOT_AVAILABLE@ - Check could not be performed due to a service
    --         outage, API error, or because the result of the Config
    --         evaluation was @NOT_APPLICABLE@. If the Config evaluation result
    --         was @NOT_APPLICABLE@, then after 3 days, Security Hub
    --         automatically archives the finding.
    Compliance -> Maybe ComplianceStatus
status :: Prelude.Maybe ComplianceStatus,
    -- | For a control, the industry or regulatory framework requirements that
    -- are related to the control. The check for that control is aligned with
    -- these requirements.
    Compliance -> Maybe [Text]
relatedRequirements :: Prelude.Maybe [Prelude.Text],
    -- | For findings generated from controls, a list of reasons behind the value
    -- of @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/.
    Compliance -> Maybe [StatusReason]
statusReasons :: Prelude.Maybe [StatusReason]
  }
  deriving (Compliance -> Compliance -> Bool
(Compliance -> Compliance -> Bool)
-> (Compliance -> Compliance -> Bool) -> Eq Compliance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Compliance -> Compliance -> Bool
$c/= :: Compliance -> Compliance -> Bool
== :: Compliance -> Compliance -> Bool
$c== :: Compliance -> Compliance -> Bool
Prelude.Eq, ReadPrec [Compliance]
ReadPrec Compliance
Int -> ReadS Compliance
ReadS [Compliance]
(Int -> ReadS Compliance)
-> ReadS [Compliance]
-> ReadPrec Compliance
-> ReadPrec [Compliance]
-> Read Compliance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Compliance]
$creadListPrec :: ReadPrec [Compliance]
readPrec :: ReadPrec Compliance
$creadPrec :: ReadPrec Compliance
readList :: ReadS [Compliance]
$creadList :: ReadS [Compliance]
readsPrec :: Int -> ReadS Compliance
$creadsPrec :: Int -> ReadS Compliance
Prelude.Read, Int -> Compliance -> ShowS
[Compliance] -> ShowS
Compliance -> String
(Int -> Compliance -> ShowS)
-> (Compliance -> String)
-> ([Compliance] -> ShowS)
-> Show Compliance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Compliance] -> ShowS
$cshowList :: [Compliance] -> ShowS
show :: Compliance -> String
$cshow :: Compliance -> String
showsPrec :: Int -> Compliance -> ShowS
$cshowsPrec :: Int -> Compliance -> ShowS
Prelude.Show, (forall x. Compliance -> Rep Compliance x)
-> (forall x. Rep Compliance x -> Compliance) -> Generic Compliance
forall x. Rep Compliance x -> Compliance
forall x. Compliance -> Rep Compliance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Compliance x -> Compliance
$cfrom :: forall x. Compliance -> Rep Compliance x
Prelude.Generic)

-- |
-- Create a value of 'Compliance' 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:
--
-- 'status', 'compliance_status' - The result of a standards check.
--
-- The valid values for @Status@ are as follows.
--
-- -   -   @PASSED@ - Standards check passed for all evaluated resources.
--
--     -   @WARNING@ - Some information is missing or this check is not
--         supported for your configuration.
--
--     -   @FAILED@ - Standards check failed for at least one evaluated
--         resource.
--
--     -   @NOT_AVAILABLE@ - Check could not be performed due to a service
--         outage, API error, or because the result of the Config
--         evaluation was @NOT_APPLICABLE@. If the Config evaluation result
--         was @NOT_APPLICABLE@, then after 3 days, Security Hub
--         automatically archives the finding.
--
-- 'relatedRequirements', 'compliance_relatedRequirements' - For a control, the industry or regulatory framework requirements that
-- are related to the control. The check for that control is aligned with
-- these requirements.
--
-- 'statusReasons', 'compliance_statusReasons' - For findings generated from controls, a list of reasons behind the value
-- of @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/.
newCompliance ::
  Compliance
newCompliance :: Compliance
newCompliance =
  Compliance' :: Maybe ComplianceStatus
-> Maybe [Text] -> Maybe [StatusReason] -> Compliance
Compliance'
    { $sel:status:Compliance' :: Maybe ComplianceStatus
status = Maybe ComplianceStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:relatedRequirements:Compliance' :: Maybe [Text]
relatedRequirements = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:statusReasons:Compliance' :: Maybe [StatusReason]
statusReasons = Maybe [StatusReason]
forall a. Maybe a
Prelude.Nothing
    }

-- | The result of a standards check.
--
-- The valid values for @Status@ are as follows.
--
-- -   -   @PASSED@ - Standards check passed for all evaluated resources.
--
--     -   @WARNING@ - Some information is missing or this check is not
--         supported for your configuration.
--
--     -   @FAILED@ - Standards check failed for at least one evaluated
--         resource.
--
--     -   @NOT_AVAILABLE@ - Check could not be performed due to a service
--         outage, API error, or because the result of the Config
--         evaluation was @NOT_APPLICABLE@. If the Config evaluation result
--         was @NOT_APPLICABLE@, then after 3 days, Security Hub
--         automatically archives the finding.
compliance_status :: Lens.Lens' Compliance (Prelude.Maybe ComplianceStatus)
compliance_status :: (Maybe ComplianceStatus -> f (Maybe ComplianceStatus))
-> Compliance -> f Compliance
compliance_status = (Compliance -> Maybe ComplianceStatus)
-> (Compliance -> Maybe ComplianceStatus -> Compliance)
-> Lens
     Compliance
     Compliance
     (Maybe ComplianceStatus)
     (Maybe ComplianceStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Compliance' {Maybe ComplianceStatus
status :: Maybe ComplianceStatus
$sel:status:Compliance' :: Compliance -> Maybe ComplianceStatus
status} -> Maybe ComplianceStatus
status) (\s :: Compliance
s@Compliance' {} Maybe ComplianceStatus
a -> Compliance
s {$sel:status:Compliance' :: Maybe ComplianceStatus
status = Maybe ComplianceStatus
a} :: Compliance)

-- | For a control, the industry or regulatory framework requirements that
-- are related to the control. The check for that control is aligned with
-- these requirements.
compliance_relatedRequirements :: Lens.Lens' Compliance (Prelude.Maybe [Prelude.Text])
compliance_relatedRequirements :: (Maybe [Text] -> f (Maybe [Text])) -> Compliance -> f Compliance
compliance_relatedRequirements = (Compliance -> Maybe [Text])
-> (Compliance -> Maybe [Text] -> Compliance)
-> Lens Compliance Compliance (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Compliance' {Maybe [Text]
relatedRequirements :: Maybe [Text]
$sel:relatedRequirements:Compliance' :: Compliance -> Maybe [Text]
relatedRequirements} -> Maybe [Text]
relatedRequirements) (\s :: Compliance
s@Compliance' {} Maybe [Text]
a -> Compliance
s {$sel:relatedRequirements:Compliance' :: Maybe [Text]
relatedRequirements = Maybe [Text]
a} :: Compliance) ((Maybe [Text] -> f (Maybe [Text])) -> Compliance -> f Compliance)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Compliance
-> f Compliance
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | For findings generated from controls, a list of reasons behind the value
-- of @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/.
compliance_statusReasons :: Lens.Lens' Compliance (Prelude.Maybe [StatusReason])
compliance_statusReasons :: (Maybe [StatusReason] -> f (Maybe [StatusReason]))
-> Compliance -> f Compliance
compliance_statusReasons = (Compliance -> Maybe [StatusReason])
-> (Compliance -> Maybe [StatusReason] -> Compliance)
-> Lens
     Compliance Compliance (Maybe [StatusReason]) (Maybe [StatusReason])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Compliance' {Maybe [StatusReason]
statusReasons :: Maybe [StatusReason]
$sel:statusReasons:Compliance' :: Compliance -> Maybe [StatusReason]
statusReasons} -> Maybe [StatusReason]
statusReasons) (\s :: Compliance
s@Compliance' {} Maybe [StatusReason]
a -> Compliance
s {$sel:statusReasons:Compliance' :: Maybe [StatusReason]
statusReasons = Maybe [StatusReason]
a} :: Compliance) ((Maybe [StatusReason] -> f (Maybe [StatusReason]))
 -> Compliance -> f Compliance)
-> ((Maybe [StatusReason] -> f (Maybe [StatusReason]))
    -> Maybe [StatusReason] -> f (Maybe [StatusReason]))
-> (Maybe [StatusReason] -> f (Maybe [StatusReason]))
-> Compliance
-> f Compliance
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [StatusReason] [StatusReason] [StatusReason] [StatusReason]
-> Iso
     (Maybe [StatusReason])
     (Maybe [StatusReason])
     (Maybe [StatusReason])
     (Maybe [StatusReason])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [StatusReason] [StatusReason] [StatusReason] [StatusReason]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Compliance where
  parseJSON :: Value -> Parser Compliance
parseJSON =
    String
-> (Object -> Parser Compliance) -> Value -> Parser Compliance
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Compliance"
      ( \Object
x ->
          Maybe ComplianceStatus
-> Maybe [Text] -> Maybe [StatusReason] -> Compliance
Compliance'
            (Maybe ComplianceStatus
 -> Maybe [Text] -> Maybe [StatusReason] -> Compliance)
-> Parser (Maybe ComplianceStatus)
-> Parser (Maybe [Text] -> Maybe [StatusReason] -> Compliance)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ComplianceStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser (Maybe [Text] -> Maybe [StatusReason] -> Compliance)
-> Parser (Maybe [Text])
-> Parser (Maybe [StatusReason] -> Compliance)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RelatedRequirements"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [StatusReason] -> Compliance)
-> Parser (Maybe [StatusReason]) -> Parser Compliance
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [StatusReason]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatusReasons" Parser (Maybe (Maybe [StatusReason]))
-> Maybe [StatusReason] -> Parser (Maybe [StatusReason])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [StatusReason]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Compliance

instance Prelude.NFData Compliance

instance Core.ToJSON Compliance where
  toJSON :: Compliance -> Value
toJSON Compliance' {Maybe [Text]
Maybe [StatusReason]
Maybe ComplianceStatus
statusReasons :: Maybe [StatusReason]
relatedRequirements :: Maybe [Text]
status :: Maybe ComplianceStatus
$sel:statusReasons:Compliance' :: Compliance -> Maybe [StatusReason]
$sel:relatedRequirements:Compliance' :: Compliance -> Maybe [Text]
$sel:status:Compliance' :: Compliance -> Maybe ComplianceStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Status" Text -> ComplianceStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ComplianceStatus -> Pair) -> Maybe ComplianceStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComplianceStatus
status,
            (Text
"RelatedRequirements" 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]
relatedRequirements,
            (Text
"StatusReasons" Text -> [StatusReason] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([StatusReason] -> Pair) -> Maybe [StatusReason] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [StatusReason]
statusReasons
          ]
      )