{-# 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.Backup.Types.FrameworkControl
-- 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.Backup.Types.FrameworkControl where

import Amazonka.Backup.Types.ControlInputParameter
import Amazonka.Backup.Types.ControlScope
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains detailed information about all of the controls of a framework.
-- Each framework must contain at least one control.
--
-- /See:/ 'newFrameworkControl' smart constructor.
data FrameworkControl = FrameworkControl'
  { -- | The scope of a control. The control scope defines what the control will
    -- evaluate. Three examples of control scopes are: a specific backup plan,
    -- all backup plans with a specific tag, or all backup plans. For more
    -- information, see @ControlScope@.
    FrameworkControl -> Maybe ControlScope
controlScope :: Prelude.Maybe ControlScope,
    -- | A list of @ParameterName@ and @ParameterValue@ pairs.
    FrameworkControl -> Maybe [ControlInputParameter]
controlInputParameters :: Prelude.Maybe [ControlInputParameter],
    -- | The name of a control. This name is between 1 and 256 characters.
    FrameworkControl -> Text
controlName :: Prelude.Text
  }
  deriving (FrameworkControl -> FrameworkControl -> Bool
(FrameworkControl -> FrameworkControl -> Bool)
-> (FrameworkControl -> FrameworkControl -> Bool)
-> Eq FrameworkControl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FrameworkControl -> FrameworkControl -> Bool
$c/= :: FrameworkControl -> FrameworkControl -> Bool
== :: FrameworkControl -> FrameworkControl -> Bool
$c== :: FrameworkControl -> FrameworkControl -> Bool
Prelude.Eq, ReadPrec [FrameworkControl]
ReadPrec FrameworkControl
Int -> ReadS FrameworkControl
ReadS [FrameworkControl]
(Int -> ReadS FrameworkControl)
-> ReadS [FrameworkControl]
-> ReadPrec FrameworkControl
-> ReadPrec [FrameworkControl]
-> Read FrameworkControl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FrameworkControl]
$creadListPrec :: ReadPrec [FrameworkControl]
readPrec :: ReadPrec FrameworkControl
$creadPrec :: ReadPrec FrameworkControl
readList :: ReadS [FrameworkControl]
$creadList :: ReadS [FrameworkControl]
readsPrec :: Int -> ReadS FrameworkControl
$creadsPrec :: Int -> ReadS FrameworkControl
Prelude.Read, Int -> FrameworkControl -> ShowS
[FrameworkControl] -> ShowS
FrameworkControl -> String
(Int -> FrameworkControl -> ShowS)
-> (FrameworkControl -> String)
-> ([FrameworkControl] -> ShowS)
-> Show FrameworkControl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FrameworkControl] -> ShowS
$cshowList :: [FrameworkControl] -> ShowS
show :: FrameworkControl -> String
$cshow :: FrameworkControl -> String
showsPrec :: Int -> FrameworkControl -> ShowS
$cshowsPrec :: Int -> FrameworkControl -> ShowS
Prelude.Show, (forall x. FrameworkControl -> Rep FrameworkControl x)
-> (forall x. Rep FrameworkControl x -> FrameworkControl)
-> Generic FrameworkControl
forall x. Rep FrameworkControl x -> FrameworkControl
forall x. FrameworkControl -> Rep FrameworkControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FrameworkControl x -> FrameworkControl
$cfrom :: forall x. FrameworkControl -> Rep FrameworkControl x
Prelude.Generic)

-- |
-- Create a value of 'FrameworkControl' 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:
--
-- 'controlScope', 'frameworkControl_controlScope' - The scope of a control. The control scope defines what the control will
-- evaluate. Three examples of control scopes are: a specific backup plan,
-- all backup plans with a specific tag, or all backup plans. For more
-- information, see @ControlScope@.
--
-- 'controlInputParameters', 'frameworkControl_controlInputParameters' - A list of @ParameterName@ and @ParameterValue@ pairs.
--
-- 'controlName', 'frameworkControl_controlName' - The name of a control. This name is between 1 and 256 characters.
newFrameworkControl ::
  -- | 'controlName'
  Prelude.Text ->
  FrameworkControl
newFrameworkControl :: Text -> FrameworkControl
newFrameworkControl Text
pControlName_ =
  FrameworkControl' :: Maybe ControlScope
-> Maybe [ControlInputParameter] -> Text -> FrameworkControl
FrameworkControl'
    { $sel:controlScope:FrameworkControl' :: Maybe ControlScope
controlScope = Maybe ControlScope
forall a. Maybe a
Prelude.Nothing,
      $sel:controlInputParameters:FrameworkControl' :: Maybe [ControlInputParameter]
controlInputParameters = Maybe [ControlInputParameter]
forall a. Maybe a
Prelude.Nothing,
      $sel:controlName:FrameworkControl' :: Text
controlName = Text
pControlName_
    }

-- | The scope of a control. The control scope defines what the control will
-- evaluate. Three examples of control scopes are: a specific backup plan,
-- all backup plans with a specific tag, or all backup plans. For more
-- information, see @ControlScope@.
frameworkControl_controlScope :: Lens.Lens' FrameworkControl (Prelude.Maybe ControlScope)
frameworkControl_controlScope :: (Maybe ControlScope -> f (Maybe ControlScope))
-> FrameworkControl -> f FrameworkControl
frameworkControl_controlScope = (FrameworkControl -> Maybe ControlScope)
-> (FrameworkControl -> Maybe ControlScope -> FrameworkControl)
-> Lens
     FrameworkControl
     FrameworkControl
     (Maybe ControlScope)
     (Maybe ControlScope)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrameworkControl' {Maybe ControlScope
controlScope :: Maybe ControlScope
$sel:controlScope:FrameworkControl' :: FrameworkControl -> Maybe ControlScope
controlScope} -> Maybe ControlScope
controlScope) (\s :: FrameworkControl
s@FrameworkControl' {} Maybe ControlScope
a -> FrameworkControl
s {$sel:controlScope:FrameworkControl' :: Maybe ControlScope
controlScope = Maybe ControlScope
a} :: FrameworkControl)

-- | A list of @ParameterName@ and @ParameterValue@ pairs.
frameworkControl_controlInputParameters :: Lens.Lens' FrameworkControl (Prelude.Maybe [ControlInputParameter])
frameworkControl_controlInputParameters :: (Maybe [ControlInputParameter]
 -> f (Maybe [ControlInputParameter]))
-> FrameworkControl -> f FrameworkControl
frameworkControl_controlInputParameters = (FrameworkControl -> Maybe [ControlInputParameter])
-> (FrameworkControl
    -> Maybe [ControlInputParameter] -> FrameworkControl)
-> Lens
     FrameworkControl
     FrameworkControl
     (Maybe [ControlInputParameter])
     (Maybe [ControlInputParameter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrameworkControl' {Maybe [ControlInputParameter]
controlInputParameters :: Maybe [ControlInputParameter]
$sel:controlInputParameters:FrameworkControl' :: FrameworkControl -> Maybe [ControlInputParameter]
controlInputParameters} -> Maybe [ControlInputParameter]
controlInputParameters) (\s :: FrameworkControl
s@FrameworkControl' {} Maybe [ControlInputParameter]
a -> FrameworkControl
s {$sel:controlInputParameters:FrameworkControl' :: Maybe [ControlInputParameter]
controlInputParameters = Maybe [ControlInputParameter]
a} :: FrameworkControl) ((Maybe [ControlInputParameter]
  -> f (Maybe [ControlInputParameter]))
 -> FrameworkControl -> f FrameworkControl)
-> ((Maybe [ControlInputParameter]
     -> f (Maybe [ControlInputParameter]))
    -> Maybe [ControlInputParameter]
    -> f (Maybe [ControlInputParameter]))
-> (Maybe [ControlInputParameter]
    -> f (Maybe [ControlInputParameter]))
-> FrameworkControl
-> f FrameworkControl
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ControlInputParameter]
  [ControlInputParameter]
  [ControlInputParameter]
  [ControlInputParameter]
-> Iso
     (Maybe [ControlInputParameter])
     (Maybe [ControlInputParameter])
     (Maybe [ControlInputParameter])
     (Maybe [ControlInputParameter])
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
  [ControlInputParameter]
  [ControlInputParameter]
  [ControlInputParameter]
  [ControlInputParameter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of a control. This name is between 1 and 256 characters.
frameworkControl_controlName :: Lens.Lens' FrameworkControl Prelude.Text
frameworkControl_controlName :: (Text -> f Text) -> FrameworkControl -> f FrameworkControl
frameworkControl_controlName = (FrameworkControl -> Text)
-> (FrameworkControl -> Text -> FrameworkControl)
-> Lens FrameworkControl FrameworkControl Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrameworkControl' {Text
controlName :: Text
$sel:controlName:FrameworkControl' :: FrameworkControl -> Text
controlName} -> Text
controlName) (\s :: FrameworkControl
s@FrameworkControl' {} Text
a -> FrameworkControl
s {$sel:controlName:FrameworkControl' :: Text
controlName = Text
a} :: FrameworkControl)

instance Core.FromJSON FrameworkControl where
  parseJSON :: Value -> Parser FrameworkControl
parseJSON =
    String
-> (Object -> Parser FrameworkControl)
-> Value
-> Parser FrameworkControl
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FrameworkControl"
      ( \Object
x ->
          Maybe ControlScope
-> Maybe [ControlInputParameter] -> Text -> FrameworkControl
FrameworkControl'
            (Maybe ControlScope
 -> Maybe [ControlInputParameter] -> Text -> FrameworkControl)
-> Parser (Maybe ControlScope)
-> Parser
     (Maybe [ControlInputParameter] -> Text -> FrameworkControl)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ControlScope)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ControlScope")
            Parser (Maybe [ControlInputParameter] -> Text -> FrameworkControl)
-> Parser (Maybe [ControlInputParameter])
-> Parser (Text -> FrameworkControl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ControlInputParameter]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ControlInputParameters"
                            Parser (Maybe (Maybe [ControlInputParameter]))
-> Maybe [ControlInputParameter]
-> Parser (Maybe [ControlInputParameter])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ControlInputParameter]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Text -> FrameworkControl)
-> Parser Text -> Parser FrameworkControl
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
"ControlName")
      )

instance Prelude.Hashable FrameworkControl

instance Prelude.NFData FrameworkControl

instance Core.ToJSON FrameworkControl where
  toJSON :: FrameworkControl -> Value
toJSON FrameworkControl' {Maybe [ControlInputParameter]
Maybe ControlScope
Text
controlName :: Text
controlInputParameters :: Maybe [ControlInputParameter]
controlScope :: Maybe ControlScope
$sel:controlName:FrameworkControl' :: FrameworkControl -> Text
$sel:controlInputParameters:FrameworkControl' :: FrameworkControl -> Maybe [ControlInputParameter]
$sel:controlScope:FrameworkControl' :: FrameworkControl -> Maybe ControlScope
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ControlScope" Text -> ControlScope -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ControlScope -> Pair) -> Maybe ControlScope -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ControlScope
controlScope,
            (Text
"ControlInputParameters" Text -> [ControlInputParameter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ControlInputParameter] -> Pair)
-> Maybe [ControlInputParameter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ControlInputParameter]
controlInputParameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ControlName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
controlName)
          ]
      )