{-# 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.Config.Types.ConfigurationRecorder
-- 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.Config.Types.ConfigurationRecorder where

import Amazonka.Config.Types.RecordingGroup
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the recording of configuration changes of an
-- Amazon Web Services resource.
--
-- /See:/ 'newConfigurationRecorder' smart constructor.
data ConfigurationRecorder = ConfigurationRecorder'
  { -- | The name of the recorder. By default, Config automatically assigns the
    -- name \"default\" when creating the configuration recorder. You cannot
    -- change the assigned name.
    ConfigurationRecorder -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Specifies the types of Amazon Web Services resources for which Config
    -- records configuration changes.
    ConfigurationRecorder -> Maybe RecordingGroup
recordingGroup :: Prelude.Maybe RecordingGroup,
    -- | Amazon Resource Name (ARN) of the IAM role used to describe the Amazon
    -- Web Services resources associated with the account.
    ConfigurationRecorder -> Maybe Text
roleARN :: Prelude.Maybe Prelude.Text
  }
  deriving (ConfigurationRecorder -> ConfigurationRecorder -> Bool
(ConfigurationRecorder -> ConfigurationRecorder -> Bool)
-> (ConfigurationRecorder -> ConfigurationRecorder -> Bool)
-> Eq ConfigurationRecorder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigurationRecorder -> ConfigurationRecorder -> Bool
$c/= :: ConfigurationRecorder -> ConfigurationRecorder -> Bool
== :: ConfigurationRecorder -> ConfigurationRecorder -> Bool
$c== :: ConfigurationRecorder -> ConfigurationRecorder -> Bool
Prelude.Eq, ReadPrec [ConfigurationRecorder]
ReadPrec ConfigurationRecorder
Int -> ReadS ConfigurationRecorder
ReadS [ConfigurationRecorder]
(Int -> ReadS ConfigurationRecorder)
-> ReadS [ConfigurationRecorder]
-> ReadPrec ConfigurationRecorder
-> ReadPrec [ConfigurationRecorder]
-> Read ConfigurationRecorder
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigurationRecorder]
$creadListPrec :: ReadPrec [ConfigurationRecorder]
readPrec :: ReadPrec ConfigurationRecorder
$creadPrec :: ReadPrec ConfigurationRecorder
readList :: ReadS [ConfigurationRecorder]
$creadList :: ReadS [ConfigurationRecorder]
readsPrec :: Int -> ReadS ConfigurationRecorder
$creadsPrec :: Int -> ReadS ConfigurationRecorder
Prelude.Read, Int -> ConfigurationRecorder -> ShowS
[ConfigurationRecorder] -> ShowS
ConfigurationRecorder -> String
(Int -> ConfigurationRecorder -> ShowS)
-> (ConfigurationRecorder -> String)
-> ([ConfigurationRecorder] -> ShowS)
-> Show ConfigurationRecorder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigurationRecorder] -> ShowS
$cshowList :: [ConfigurationRecorder] -> ShowS
show :: ConfigurationRecorder -> String
$cshow :: ConfigurationRecorder -> String
showsPrec :: Int -> ConfigurationRecorder -> ShowS
$cshowsPrec :: Int -> ConfigurationRecorder -> ShowS
Prelude.Show, (forall x. ConfigurationRecorder -> Rep ConfigurationRecorder x)
-> (forall x. Rep ConfigurationRecorder x -> ConfigurationRecorder)
-> Generic ConfigurationRecorder
forall x. Rep ConfigurationRecorder x -> ConfigurationRecorder
forall x. ConfigurationRecorder -> Rep ConfigurationRecorder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigurationRecorder x -> ConfigurationRecorder
$cfrom :: forall x. ConfigurationRecorder -> Rep ConfigurationRecorder x
Prelude.Generic)

-- |
-- Create a value of 'ConfigurationRecorder' 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:
--
-- 'name', 'configurationRecorder_name' - The name of the recorder. By default, Config automatically assigns the
-- name \"default\" when creating the configuration recorder. You cannot
-- change the assigned name.
--
-- 'recordingGroup', 'configurationRecorder_recordingGroup' - Specifies the types of Amazon Web Services resources for which Config
-- records configuration changes.
--
-- 'roleARN', 'configurationRecorder_roleARN' - Amazon Resource Name (ARN) of the IAM role used to describe the Amazon
-- Web Services resources associated with the account.
newConfigurationRecorder ::
  ConfigurationRecorder
newConfigurationRecorder :: ConfigurationRecorder
newConfigurationRecorder =
  ConfigurationRecorder' :: Maybe Text
-> Maybe RecordingGroup -> Maybe Text -> ConfigurationRecorder
ConfigurationRecorder'
    { $sel:name:ConfigurationRecorder' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recordingGroup:ConfigurationRecorder' :: Maybe RecordingGroup
recordingGroup = Maybe RecordingGroup
forall a. Maybe a
Prelude.Nothing,
      $sel:roleARN:ConfigurationRecorder' :: Maybe Text
roleARN = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the recorder. By default, Config automatically assigns the
-- name \"default\" when creating the configuration recorder. You cannot
-- change the assigned name.
configurationRecorder_name :: Lens.Lens' ConfigurationRecorder (Prelude.Maybe Prelude.Text)
configurationRecorder_name :: (Maybe Text -> f (Maybe Text))
-> ConfigurationRecorder -> f ConfigurationRecorder
configurationRecorder_name = (ConfigurationRecorder -> Maybe Text)
-> (ConfigurationRecorder -> Maybe Text -> ConfigurationRecorder)
-> Lens
     ConfigurationRecorder
     ConfigurationRecorder
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationRecorder' {Maybe Text
name :: Maybe Text
$sel:name:ConfigurationRecorder' :: ConfigurationRecorder -> Maybe Text
name} -> Maybe Text
name) (\s :: ConfigurationRecorder
s@ConfigurationRecorder' {} Maybe Text
a -> ConfigurationRecorder
s {$sel:name:ConfigurationRecorder' :: Maybe Text
name = Maybe Text
a} :: ConfigurationRecorder)

-- | Specifies the types of Amazon Web Services resources for which Config
-- records configuration changes.
configurationRecorder_recordingGroup :: Lens.Lens' ConfigurationRecorder (Prelude.Maybe RecordingGroup)
configurationRecorder_recordingGroup :: (Maybe RecordingGroup -> f (Maybe RecordingGroup))
-> ConfigurationRecorder -> f ConfigurationRecorder
configurationRecorder_recordingGroup = (ConfigurationRecorder -> Maybe RecordingGroup)
-> (ConfigurationRecorder
    -> Maybe RecordingGroup -> ConfigurationRecorder)
-> Lens
     ConfigurationRecorder
     ConfigurationRecorder
     (Maybe RecordingGroup)
     (Maybe RecordingGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationRecorder' {Maybe RecordingGroup
recordingGroup :: Maybe RecordingGroup
$sel:recordingGroup:ConfigurationRecorder' :: ConfigurationRecorder -> Maybe RecordingGroup
recordingGroup} -> Maybe RecordingGroup
recordingGroup) (\s :: ConfigurationRecorder
s@ConfigurationRecorder' {} Maybe RecordingGroup
a -> ConfigurationRecorder
s {$sel:recordingGroup:ConfigurationRecorder' :: Maybe RecordingGroup
recordingGroup = Maybe RecordingGroup
a} :: ConfigurationRecorder)

-- | Amazon Resource Name (ARN) of the IAM role used to describe the Amazon
-- Web Services resources associated with the account.
configurationRecorder_roleARN :: Lens.Lens' ConfigurationRecorder (Prelude.Maybe Prelude.Text)
configurationRecorder_roleARN :: (Maybe Text -> f (Maybe Text))
-> ConfigurationRecorder -> f ConfigurationRecorder
configurationRecorder_roleARN = (ConfigurationRecorder -> Maybe Text)
-> (ConfigurationRecorder -> Maybe Text -> ConfigurationRecorder)
-> Lens
     ConfigurationRecorder
     ConfigurationRecorder
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationRecorder' {Maybe Text
roleARN :: Maybe Text
$sel:roleARN:ConfigurationRecorder' :: ConfigurationRecorder -> Maybe Text
roleARN} -> Maybe Text
roleARN) (\s :: ConfigurationRecorder
s@ConfigurationRecorder' {} Maybe Text
a -> ConfigurationRecorder
s {$sel:roleARN:ConfigurationRecorder' :: Maybe Text
roleARN = Maybe Text
a} :: ConfigurationRecorder)

instance Core.FromJSON ConfigurationRecorder where
  parseJSON :: Value -> Parser ConfigurationRecorder
parseJSON =
    String
-> (Object -> Parser ConfigurationRecorder)
-> Value
-> Parser ConfigurationRecorder
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfigurationRecorder"
      ( \Object
x ->
          Maybe Text
-> Maybe RecordingGroup -> Maybe Text -> ConfigurationRecorder
ConfigurationRecorder'
            (Maybe Text
 -> Maybe RecordingGroup -> Maybe Text -> ConfigurationRecorder)
-> Parser (Maybe Text)
-> Parser
     (Maybe RecordingGroup -> Maybe Text -> ConfigurationRecorder)
forall (f :: * -> *) a b. Functor 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 RecordingGroup -> Maybe Text -> ConfigurationRecorder)
-> Parser (Maybe RecordingGroup)
-> Parser (Maybe Text -> ConfigurationRecorder)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RecordingGroup)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"recordingGroup")
            Parser (Maybe Text -> ConfigurationRecorder)
-> Parser (Maybe Text) -> Parser ConfigurationRecorder
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
"roleARN")
      )

instance Prelude.Hashable ConfigurationRecorder

instance Prelude.NFData ConfigurationRecorder

instance Core.ToJSON ConfigurationRecorder where
  toJSON :: ConfigurationRecorder -> Value
toJSON ConfigurationRecorder' {Maybe Text
Maybe RecordingGroup
roleARN :: Maybe Text
recordingGroup :: Maybe RecordingGroup
name :: Maybe Text
$sel:roleARN:ConfigurationRecorder' :: ConfigurationRecorder -> Maybe Text
$sel:recordingGroup:ConfigurationRecorder' :: ConfigurationRecorder -> Maybe RecordingGroup
$sel:name:ConfigurationRecorder' :: ConfigurationRecorder -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"name" 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
name,
            (Text
"recordingGroup" Text -> RecordingGroup -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RecordingGroup -> Pair) -> Maybe RecordingGroup -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RecordingGroup
recordingGroup,
            (Text
"roleARN" 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
roleARN
          ]
      )