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

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

-- | Contains detailed information about a report setting.
--
-- /See:/ 'newReportSetting' smart constructor.
data ReportSetting = ReportSetting'
  { -- | The Amazon Resource Names (ARNs) of the frameworks a report covers.
    ReportSetting -> Maybe [Text]
frameworkArns :: Prelude.Maybe [Prelude.Text],
    -- | The number of frameworks a report covers.
    ReportSetting -> Maybe Int
numberOfFrameworks :: Prelude.Maybe Prelude.Int,
    -- | Identifies the report template for the report. Reports are built using a
    -- report template. The report templates are:
    --
    -- @RESOURCE_COMPLIANCE_REPORT | CONTROL_COMPLIANCE_REPORT | BACKUP_JOB_REPORT | COPY_JOB_REPORT | RESTORE_JOB_REPORT@
    ReportSetting -> Text
reportTemplate :: Prelude.Text
  }
  deriving (ReportSetting -> ReportSetting -> Bool
(ReportSetting -> ReportSetting -> Bool)
-> (ReportSetting -> ReportSetting -> Bool) -> Eq ReportSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReportSetting -> ReportSetting -> Bool
$c/= :: ReportSetting -> ReportSetting -> Bool
== :: ReportSetting -> ReportSetting -> Bool
$c== :: ReportSetting -> ReportSetting -> Bool
Prelude.Eq, ReadPrec [ReportSetting]
ReadPrec ReportSetting
Int -> ReadS ReportSetting
ReadS [ReportSetting]
(Int -> ReadS ReportSetting)
-> ReadS [ReportSetting]
-> ReadPrec ReportSetting
-> ReadPrec [ReportSetting]
-> Read ReportSetting
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReportSetting]
$creadListPrec :: ReadPrec [ReportSetting]
readPrec :: ReadPrec ReportSetting
$creadPrec :: ReadPrec ReportSetting
readList :: ReadS [ReportSetting]
$creadList :: ReadS [ReportSetting]
readsPrec :: Int -> ReadS ReportSetting
$creadsPrec :: Int -> ReadS ReportSetting
Prelude.Read, Int -> ReportSetting -> ShowS
[ReportSetting] -> ShowS
ReportSetting -> String
(Int -> ReportSetting -> ShowS)
-> (ReportSetting -> String)
-> ([ReportSetting] -> ShowS)
-> Show ReportSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReportSetting] -> ShowS
$cshowList :: [ReportSetting] -> ShowS
show :: ReportSetting -> String
$cshow :: ReportSetting -> String
showsPrec :: Int -> ReportSetting -> ShowS
$cshowsPrec :: Int -> ReportSetting -> ShowS
Prelude.Show, (forall x. ReportSetting -> Rep ReportSetting x)
-> (forall x. Rep ReportSetting x -> ReportSetting)
-> Generic ReportSetting
forall x. Rep ReportSetting x -> ReportSetting
forall x. ReportSetting -> Rep ReportSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReportSetting x -> ReportSetting
$cfrom :: forall x. ReportSetting -> Rep ReportSetting x
Prelude.Generic)

-- |
-- Create a value of 'ReportSetting' 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:
--
-- 'frameworkArns', 'reportSetting_frameworkArns' - The Amazon Resource Names (ARNs) of the frameworks a report covers.
--
-- 'numberOfFrameworks', 'reportSetting_numberOfFrameworks' - The number of frameworks a report covers.
--
-- 'reportTemplate', 'reportSetting_reportTemplate' - Identifies the report template for the report. Reports are built using a
-- report template. The report templates are:
--
-- @RESOURCE_COMPLIANCE_REPORT | CONTROL_COMPLIANCE_REPORT | BACKUP_JOB_REPORT | COPY_JOB_REPORT | RESTORE_JOB_REPORT@
newReportSetting ::
  -- | 'reportTemplate'
  Prelude.Text ->
  ReportSetting
newReportSetting :: Text -> ReportSetting
newReportSetting Text
pReportTemplate_ =
  ReportSetting' :: Maybe [Text] -> Maybe Int -> Text -> ReportSetting
ReportSetting'
    { $sel:frameworkArns:ReportSetting' :: Maybe [Text]
frameworkArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfFrameworks:ReportSetting' :: Maybe Int
numberOfFrameworks = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:reportTemplate:ReportSetting' :: Text
reportTemplate = Text
pReportTemplate_
    }

-- | The Amazon Resource Names (ARNs) of the frameworks a report covers.
reportSetting_frameworkArns :: Lens.Lens' ReportSetting (Prelude.Maybe [Prelude.Text])
reportSetting_frameworkArns :: (Maybe [Text] -> f (Maybe [Text]))
-> ReportSetting -> f ReportSetting
reportSetting_frameworkArns = (ReportSetting -> Maybe [Text])
-> (ReportSetting -> Maybe [Text] -> ReportSetting)
-> Lens ReportSetting ReportSetting (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportSetting' {Maybe [Text]
frameworkArns :: Maybe [Text]
$sel:frameworkArns:ReportSetting' :: ReportSetting -> Maybe [Text]
frameworkArns} -> Maybe [Text]
frameworkArns) (\s :: ReportSetting
s@ReportSetting' {} Maybe [Text]
a -> ReportSetting
s {$sel:frameworkArns:ReportSetting' :: Maybe [Text]
frameworkArns = Maybe [Text]
a} :: ReportSetting) ((Maybe [Text] -> f (Maybe [Text]))
 -> ReportSetting -> f ReportSetting)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ReportSetting
-> f ReportSetting
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

-- | The number of frameworks a report covers.
reportSetting_numberOfFrameworks :: Lens.Lens' ReportSetting (Prelude.Maybe Prelude.Int)
reportSetting_numberOfFrameworks :: (Maybe Int -> f (Maybe Int)) -> ReportSetting -> f ReportSetting
reportSetting_numberOfFrameworks = (ReportSetting -> Maybe Int)
-> (ReportSetting -> Maybe Int -> ReportSetting)
-> Lens ReportSetting ReportSetting (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportSetting' {Maybe Int
numberOfFrameworks :: Maybe Int
$sel:numberOfFrameworks:ReportSetting' :: ReportSetting -> Maybe Int
numberOfFrameworks} -> Maybe Int
numberOfFrameworks) (\s :: ReportSetting
s@ReportSetting' {} Maybe Int
a -> ReportSetting
s {$sel:numberOfFrameworks:ReportSetting' :: Maybe Int
numberOfFrameworks = Maybe Int
a} :: ReportSetting)

-- | Identifies the report template for the report. Reports are built using a
-- report template. The report templates are:
--
-- @RESOURCE_COMPLIANCE_REPORT | CONTROL_COMPLIANCE_REPORT | BACKUP_JOB_REPORT | COPY_JOB_REPORT | RESTORE_JOB_REPORT@
reportSetting_reportTemplate :: Lens.Lens' ReportSetting Prelude.Text
reportSetting_reportTemplate :: (Text -> f Text) -> ReportSetting -> f ReportSetting
reportSetting_reportTemplate = (ReportSetting -> Text)
-> (ReportSetting -> Text -> ReportSetting)
-> Lens ReportSetting ReportSetting Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportSetting' {Text
reportTemplate :: Text
$sel:reportTemplate:ReportSetting' :: ReportSetting -> Text
reportTemplate} -> Text
reportTemplate) (\s :: ReportSetting
s@ReportSetting' {} Text
a -> ReportSetting
s {$sel:reportTemplate:ReportSetting' :: Text
reportTemplate = Text
a} :: ReportSetting)

instance Core.FromJSON ReportSetting where
  parseJSON :: Value -> Parser ReportSetting
parseJSON =
    String
-> (Object -> Parser ReportSetting)
-> Value
-> Parser ReportSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReportSetting"
      ( \Object
x ->
          Maybe [Text] -> Maybe Int -> Text -> ReportSetting
ReportSetting'
            (Maybe [Text] -> Maybe Int -> Text -> ReportSetting)
-> Parser (Maybe [Text])
-> Parser (Maybe Int -> Text -> ReportSetting)
forall (f :: * -> *) a b. Functor 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
"FrameworkArns" 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 Int -> Text -> ReportSetting)
-> Parser (Maybe Int) -> Parser (Text -> ReportSetting)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NumberOfFrameworks")
            Parser (Text -> ReportSetting)
-> Parser Text -> Parser ReportSetting
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
"ReportTemplate")
      )

instance Prelude.Hashable ReportSetting

instance Prelude.NFData ReportSetting

instance Core.ToJSON ReportSetting where
  toJSON :: ReportSetting -> Value
toJSON ReportSetting' {Maybe Int
Maybe [Text]
Text
reportTemplate :: Text
numberOfFrameworks :: Maybe Int
frameworkArns :: Maybe [Text]
$sel:reportTemplate:ReportSetting' :: ReportSetting -> Text
$sel:numberOfFrameworks:ReportSetting' :: ReportSetting -> Maybe Int
$sel:frameworkArns:ReportSetting' :: ReportSetting -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FrameworkArns" 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]
frameworkArns,
            (Text
"NumberOfFrameworks" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
numberOfFrameworks,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ReportTemplate" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
reportTemplate)
          ]
      )