{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | A list of @ParameterName@ and @ParameterValue@ pairs.
    FrameworkControl -> Maybe [ControlInputParameter]
controlInputParameters :: Prelude.Maybe [ControlInputParameter],
    -- | 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
    -- <aws-backup/latest/devguide/API_ControlScope.html ControlScope.>
    FrameworkControl -> Maybe ControlScope
controlScope :: Prelude.Maybe ControlScope,
    -- | The name of a control. This name is between 1 and 256 characters.
    FrameworkControl -> Text
controlName :: Prelude.Text
  }
  deriving (FrameworkControl -> FrameworkControl -> Bool
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]
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
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. 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:
--
-- 'controlInputParameters', 'frameworkControl_controlInputParameters' - A list of @ParameterName@ and @ParameterValue@ pairs.
--
-- '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
-- <aws-backup/latest/devguide/API_ControlScope.html ControlScope.>
--
-- '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'
    { $sel:controlInputParameters:FrameworkControl' :: Maybe [ControlInputParameter]
controlInputParameters =
        forall a. Maybe a
Prelude.Nothing,
      $sel:controlScope:FrameworkControl' :: Maybe ControlScope
controlScope = forall a. Maybe a
Prelude.Nothing,
      $sel:controlName:FrameworkControl' :: Text
controlName = Text
pControlName_
    }

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

-- | 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
-- <aws-backup/latest/devguide/API_ControlScope.html ControlScope.>
frameworkControl_controlScope :: Lens.Lens' FrameworkControl (Prelude.Maybe ControlScope)
frameworkControl_controlScope :: Lens' FrameworkControl (Maybe ControlScope)
frameworkControl_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)

-- | The name of a control. This name is between 1 and 256 characters.
frameworkControl_controlName :: Lens.Lens' FrameworkControl Prelude.Text
frameworkControl_controlName :: Lens' FrameworkControl Text
frameworkControl_controlName = 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 Data.FromJSON FrameworkControl where
  parseJSON :: Value -> Parser FrameworkControl
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FrameworkControl"
      ( \Object
x ->
          Maybe [ControlInputParameter]
-> Maybe ControlScope -> Text -> FrameworkControl
FrameworkControl'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ControlInputParameters"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ControlScope")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ControlName")
      )

instance Prelude.Hashable FrameworkControl where
  hashWithSalt :: Int -> FrameworkControl -> Int
hashWithSalt Int
_salt FrameworkControl' {Maybe [ControlInputParameter]
Maybe ControlScope
Text
controlName :: Text
controlScope :: Maybe ControlScope
controlInputParameters :: Maybe [ControlInputParameter]
$sel:controlName:FrameworkControl' :: FrameworkControl -> Text
$sel:controlScope:FrameworkControl' :: FrameworkControl -> Maybe ControlScope
$sel:controlInputParameters:FrameworkControl' :: FrameworkControl -> Maybe [ControlInputParameter]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ControlInputParameter]
controlInputParameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ControlScope
controlScope
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
controlName

instance Prelude.NFData FrameworkControl where
  rnf :: FrameworkControl -> ()
rnf FrameworkControl' {Maybe [ControlInputParameter]
Maybe ControlScope
Text
controlName :: Text
controlScope :: Maybe ControlScope
controlInputParameters :: Maybe [ControlInputParameter]
$sel:controlName:FrameworkControl' :: FrameworkControl -> Text
$sel:controlScope:FrameworkControl' :: FrameworkControl -> Maybe ControlScope
$sel:controlInputParameters:FrameworkControl' :: FrameworkControl -> Maybe [ControlInputParameter]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ControlInputParameter]
controlInputParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ControlScope
controlScope
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
controlName

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