{-# 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.AuditManager.Types.ControlSet
-- 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.AuditManager.Types.ControlSet where

import Amazonka.AuditManager.Types.Control
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A set of controls in Audit Manager.
--
-- /See:/ 'newControlSet' smart constructor.
data ControlSet = ControlSet'
  { -- | The list of controls within the control set.
    ControlSet -> Maybe (NonEmpty Control)
controls :: Prelude.Maybe (Prelude.NonEmpty Control),
    -- | The name of the control set.
    ControlSet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the control set in the assessment. This is the control
    -- set name in a plain string format.
    ControlSet -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (ControlSet -> ControlSet -> Bool
(ControlSet -> ControlSet -> Bool)
-> (ControlSet -> ControlSet -> Bool) -> Eq ControlSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ControlSet -> ControlSet -> Bool
$c/= :: ControlSet -> ControlSet -> Bool
== :: ControlSet -> ControlSet -> Bool
$c== :: ControlSet -> ControlSet -> Bool
Prelude.Eq, ReadPrec [ControlSet]
ReadPrec ControlSet
Int -> ReadS ControlSet
ReadS [ControlSet]
(Int -> ReadS ControlSet)
-> ReadS [ControlSet]
-> ReadPrec ControlSet
-> ReadPrec [ControlSet]
-> Read ControlSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ControlSet]
$creadListPrec :: ReadPrec [ControlSet]
readPrec :: ReadPrec ControlSet
$creadPrec :: ReadPrec ControlSet
readList :: ReadS [ControlSet]
$creadList :: ReadS [ControlSet]
readsPrec :: Int -> ReadS ControlSet
$creadsPrec :: Int -> ReadS ControlSet
Prelude.Read, Int -> ControlSet -> ShowS
[ControlSet] -> ShowS
ControlSet -> String
(Int -> ControlSet -> ShowS)
-> (ControlSet -> String)
-> ([ControlSet] -> ShowS)
-> Show ControlSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ControlSet] -> ShowS
$cshowList :: [ControlSet] -> ShowS
show :: ControlSet -> String
$cshow :: ControlSet -> String
showsPrec :: Int -> ControlSet -> ShowS
$cshowsPrec :: Int -> ControlSet -> ShowS
Prelude.Show, (forall x. ControlSet -> Rep ControlSet x)
-> (forall x. Rep ControlSet x -> ControlSet) -> Generic ControlSet
forall x. Rep ControlSet x -> ControlSet
forall x. ControlSet -> Rep ControlSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ControlSet x -> ControlSet
$cfrom :: forall x. ControlSet -> Rep ControlSet x
Prelude.Generic)

-- |
-- Create a value of 'ControlSet' 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:
--
-- 'controls', 'controlSet_controls' - The list of controls within the control set.
--
-- 'name', 'controlSet_name' - The name of the control set.
--
-- 'id', 'controlSet_id' - The identifier of the control set in the assessment. This is the control
-- set name in a plain string format.
newControlSet ::
  ControlSet
newControlSet :: ControlSet
newControlSet =
  ControlSet' :: Maybe (NonEmpty Control) -> Maybe Text -> Maybe Text -> ControlSet
ControlSet'
    { $sel:controls:ControlSet' :: Maybe (NonEmpty Control)
controls = Maybe (NonEmpty Control)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ControlSet' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:ControlSet' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of controls within the control set.
controlSet_controls :: Lens.Lens' ControlSet (Prelude.Maybe (Prelude.NonEmpty Control))
controlSet_controls :: (Maybe (NonEmpty Control) -> f (Maybe (NonEmpty Control)))
-> ControlSet -> f ControlSet
controlSet_controls = (ControlSet -> Maybe (NonEmpty Control))
-> (ControlSet -> Maybe (NonEmpty Control) -> ControlSet)
-> Lens
     ControlSet
     ControlSet
     (Maybe (NonEmpty Control))
     (Maybe (NonEmpty Control))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlSet' {Maybe (NonEmpty Control)
controls :: Maybe (NonEmpty Control)
$sel:controls:ControlSet' :: ControlSet -> Maybe (NonEmpty Control)
controls} -> Maybe (NonEmpty Control)
controls) (\s :: ControlSet
s@ControlSet' {} Maybe (NonEmpty Control)
a -> ControlSet
s {$sel:controls:ControlSet' :: Maybe (NonEmpty Control)
controls = Maybe (NonEmpty Control)
a} :: ControlSet) ((Maybe (NonEmpty Control) -> f (Maybe (NonEmpty Control)))
 -> ControlSet -> f ControlSet)
-> ((Maybe (NonEmpty Control) -> f (Maybe (NonEmpty Control)))
    -> Maybe (NonEmpty Control) -> f (Maybe (NonEmpty Control)))
-> (Maybe (NonEmpty Control) -> f (Maybe (NonEmpty Control)))
-> ControlSet
-> f ControlSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Control)
  (NonEmpty Control)
  (NonEmpty Control)
  (NonEmpty Control)
-> Iso
     (Maybe (NonEmpty Control))
     (Maybe (NonEmpty Control))
     (Maybe (NonEmpty Control))
     (Maybe (NonEmpty Control))
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
  (NonEmpty Control)
  (NonEmpty Control)
  (NonEmpty Control)
  (NonEmpty Control)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the control set.
controlSet_name :: Lens.Lens' ControlSet (Prelude.Maybe Prelude.Text)
controlSet_name :: (Maybe Text -> f (Maybe Text)) -> ControlSet -> f ControlSet
controlSet_name = (ControlSet -> Maybe Text)
-> (ControlSet -> Maybe Text -> ControlSet)
-> Lens ControlSet ControlSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlSet' {Maybe Text
name :: Maybe Text
$sel:name:ControlSet' :: ControlSet -> Maybe Text
name} -> Maybe Text
name) (\s :: ControlSet
s@ControlSet' {} Maybe Text
a -> ControlSet
s {$sel:name:ControlSet' :: Maybe Text
name = Maybe Text
a} :: ControlSet)

-- | The identifier of the control set in the assessment. This is the control
-- set name in a plain string format.
controlSet_id :: Lens.Lens' ControlSet (Prelude.Maybe Prelude.Text)
controlSet_id :: (Maybe Text -> f (Maybe Text)) -> ControlSet -> f ControlSet
controlSet_id = (ControlSet -> Maybe Text)
-> (ControlSet -> Maybe Text -> ControlSet)
-> Lens ControlSet ControlSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlSet' {Maybe Text
id :: Maybe Text
$sel:id:ControlSet' :: ControlSet -> Maybe Text
id} -> Maybe Text
id) (\s :: ControlSet
s@ControlSet' {} Maybe Text
a -> ControlSet
s {$sel:id:ControlSet' :: Maybe Text
id = Maybe Text
a} :: ControlSet)

instance Core.FromJSON ControlSet where
  parseJSON :: Value -> Parser ControlSet
parseJSON =
    String
-> (Object -> Parser ControlSet) -> Value -> Parser ControlSet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ControlSet"
      ( \Object
x ->
          Maybe (NonEmpty Control) -> Maybe Text -> Maybe Text -> ControlSet
ControlSet'
            (Maybe (NonEmpty Control)
 -> Maybe Text -> Maybe Text -> ControlSet)
-> Parser (Maybe (NonEmpty Control))
-> Parser (Maybe Text -> Maybe Text -> ControlSet)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Control))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"controls")
            Parser (Maybe Text -> Maybe Text -> ControlSet)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ControlSet)
forall (f :: * -> *) a b. Applicative f => 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
"name")
            Parser (Maybe Text -> ControlSet)
-> Parser (Maybe Text) -> Parser ControlSet
forall (f :: * -> *) a b. Applicative f => 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
"id")
      )

instance Prelude.Hashable ControlSet

instance Prelude.NFData ControlSet