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

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

-- | Specifies the types of Amazon Web Services resource for which Config
-- records configuration changes.
--
-- In the recording group, you specify whether all supported types or
-- specific types of resources are recorded.
--
-- By default, Config records configuration changes for all supported types
-- of regional resources that Config discovers in the region in which it is
-- running. Regional resources are tied to a region and can be used only in
-- that region. Examples of regional resources are EC2 instances and EBS
-- volumes.
--
-- You can also have Config record configuration changes for supported
-- types of global resources (for example, IAM resources). Global resources
-- are not tied to an individual region and can be used in all regions.
--
-- The configuration details for any global resource are the same in all
-- regions. If you customize Config in multiple regions to record global
-- resources, it will create multiple configuration items each time a
-- global resource changes: one configuration item for each region. These
-- configuration items will contain identical data. To prevent duplicate
-- configuration items, you should consider customizing Config in only one
-- region to record global resources, unless you want the configuration
-- items to be available in multiple regions.
--
-- If you don\'t want Config to record all resources, you can specify which
-- types of resources it will record with the @resourceTypes@ parameter.
--
-- For a list of supported resource types, see
-- <https://docs.aws.amazon.com/config/latest/developerguide/resource-config-reference.html#supported-resources Supported Resource Types>.
--
-- For more information, see
-- <https://docs.aws.amazon.com/config/latest/developerguide/select-resources.html Selecting Which Resources Config Records>.
--
-- /See:/ 'newRecordingGroup' smart constructor.
data RecordingGroup = RecordingGroup'
  { -- | Specifies whether Config records configuration changes for every
    -- supported type of regional resource.
    --
    -- If you set this option to @true@, when Config adds support for a new
    -- type of regional resource, it starts recording resources of that type
    -- automatically.
    --
    -- If you set this option to @true@, you cannot enumerate a list of
    -- @resourceTypes@.
    RecordingGroup -> Maybe Bool
allSupported :: Prelude.Maybe Prelude.Bool,
    -- | Specifies whether Config includes all supported types of global
    -- resources (for example, IAM resources) with the resources that it
    -- records.
    --
    -- Before you can set this option to @true@, you must set the
    -- @allSupported@ option to @true@.
    --
    -- If you set this option to @true@, when Config adds support for a new
    -- type of global resource, it starts recording resources of that type
    -- automatically.
    --
    -- The configuration details for any global resource are the same in all
    -- regions. To prevent duplicate configuration items, you should consider
    -- customizing Config in only one region to record global resources.
    RecordingGroup -> Maybe Bool
includeGlobalResourceTypes :: Prelude.Maybe Prelude.Bool,
    -- | A comma-separated list that specifies the types of Amazon Web Services
    -- resources for which Config records configuration changes (for example,
    -- @AWS::EC2::Instance@ or @AWS::CloudTrail::Trail@).
    --
    -- To record all configuration changes, you must set the @allSupported@
    -- option to @true@.
    --
    -- If you set this option to @false@, when Config adds support for a new
    -- type of resource, it will not record resources of that type unless you
    -- manually add that type to your recording group.
    --
    -- For a list of valid @resourceTypes@ values, see the __resourceType
    -- Value__ column in
    -- <https://docs.aws.amazon.com/config/latest/developerguide/resource-config-reference.html#supported-resources Supported Amazon Web Services resource Types>.
    RecordingGroup -> Maybe [ResourceType]
resourceTypes :: Prelude.Maybe [ResourceType]
  }
  deriving (RecordingGroup -> RecordingGroup -> Bool
(RecordingGroup -> RecordingGroup -> Bool)
-> (RecordingGroup -> RecordingGroup -> Bool) -> Eq RecordingGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecordingGroup -> RecordingGroup -> Bool
$c/= :: RecordingGroup -> RecordingGroup -> Bool
== :: RecordingGroup -> RecordingGroup -> Bool
$c== :: RecordingGroup -> RecordingGroup -> Bool
Prelude.Eq, ReadPrec [RecordingGroup]
ReadPrec RecordingGroup
Int -> ReadS RecordingGroup
ReadS [RecordingGroup]
(Int -> ReadS RecordingGroup)
-> ReadS [RecordingGroup]
-> ReadPrec RecordingGroup
-> ReadPrec [RecordingGroup]
-> Read RecordingGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecordingGroup]
$creadListPrec :: ReadPrec [RecordingGroup]
readPrec :: ReadPrec RecordingGroup
$creadPrec :: ReadPrec RecordingGroup
readList :: ReadS [RecordingGroup]
$creadList :: ReadS [RecordingGroup]
readsPrec :: Int -> ReadS RecordingGroup
$creadsPrec :: Int -> ReadS RecordingGroup
Prelude.Read, Int -> RecordingGroup -> ShowS
[RecordingGroup] -> ShowS
RecordingGroup -> String
(Int -> RecordingGroup -> ShowS)
-> (RecordingGroup -> String)
-> ([RecordingGroup] -> ShowS)
-> Show RecordingGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecordingGroup] -> ShowS
$cshowList :: [RecordingGroup] -> ShowS
show :: RecordingGroup -> String
$cshow :: RecordingGroup -> String
showsPrec :: Int -> RecordingGroup -> ShowS
$cshowsPrec :: Int -> RecordingGroup -> ShowS
Prelude.Show, (forall x. RecordingGroup -> Rep RecordingGroup x)
-> (forall x. Rep RecordingGroup x -> RecordingGroup)
-> Generic RecordingGroup
forall x. Rep RecordingGroup x -> RecordingGroup
forall x. RecordingGroup -> Rep RecordingGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecordingGroup x -> RecordingGroup
$cfrom :: forall x. RecordingGroup -> Rep RecordingGroup x
Prelude.Generic)

-- |
-- Create a value of 'RecordingGroup' 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:
--
-- 'allSupported', 'recordingGroup_allSupported' - Specifies whether Config records configuration changes for every
-- supported type of regional resource.
--
-- If you set this option to @true@, when Config adds support for a new
-- type of regional resource, it starts recording resources of that type
-- automatically.
--
-- If you set this option to @true@, you cannot enumerate a list of
-- @resourceTypes@.
--
-- 'includeGlobalResourceTypes', 'recordingGroup_includeGlobalResourceTypes' - Specifies whether Config includes all supported types of global
-- resources (for example, IAM resources) with the resources that it
-- records.
--
-- Before you can set this option to @true@, you must set the
-- @allSupported@ option to @true@.
--
-- If you set this option to @true@, when Config adds support for a new
-- type of global resource, it starts recording resources of that type
-- automatically.
--
-- The configuration details for any global resource are the same in all
-- regions. To prevent duplicate configuration items, you should consider
-- customizing Config in only one region to record global resources.
--
-- 'resourceTypes', 'recordingGroup_resourceTypes' - A comma-separated list that specifies the types of Amazon Web Services
-- resources for which Config records configuration changes (for example,
-- @AWS::EC2::Instance@ or @AWS::CloudTrail::Trail@).
--
-- To record all configuration changes, you must set the @allSupported@
-- option to @true@.
--
-- If you set this option to @false@, when Config adds support for a new
-- type of resource, it will not record resources of that type unless you
-- manually add that type to your recording group.
--
-- For a list of valid @resourceTypes@ values, see the __resourceType
-- Value__ column in
-- <https://docs.aws.amazon.com/config/latest/developerguide/resource-config-reference.html#supported-resources Supported Amazon Web Services resource Types>.
newRecordingGroup ::
  RecordingGroup
newRecordingGroup :: RecordingGroup
newRecordingGroup =
  RecordingGroup' :: Maybe Bool -> Maybe Bool -> Maybe [ResourceType] -> RecordingGroup
RecordingGroup'
    { $sel:allSupported:RecordingGroup' :: Maybe Bool
allSupported = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:includeGlobalResourceTypes:RecordingGroup' :: Maybe Bool
includeGlobalResourceTypes = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceTypes:RecordingGroup' :: Maybe [ResourceType]
resourceTypes = Maybe [ResourceType]
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether Config records configuration changes for every
-- supported type of regional resource.
--
-- If you set this option to @true@, when Config adds support for a new
-- type of regional resource, it starts recording resources of that type
-- automatically.
--
-- If you set this option to @true@, you cannot enumerate a list of
-- @resourceTypes@.
recordingGroup_allSupported :: Lens.Lens' RecordingGroup (Prelude.Maybe Prelude.Bool)
recordingGroup_allSupported :: (Maybe Bool -> f (Maybe Bool))
-> RecordingGroup -> f RecordingGroup
recordingGroup_allSupported = (RecordingGroup -> Maybe Bool)
-> (RecordingGroup -> Maybe Bool -> RecordingGroup)
-> Lens RecordingGroup RecordingGroup (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecordingGroup' {Maybe Bool
allSupported :: Maybe Bool
$sel:allSupported:RecordingGroup' :: RecordingGroup -> Maybe Bool
allSupported} -> Maybe Bool
allSupported) (\s :: RecordingGroup
s@RecordingGroup' {} Maybe Bool
a -> RecordingGroup
s {$sel:allSupported:RecordingGroup' :: Maybe Bool
allSupported = Maybe Bool
a} :: RecordingGroup)

-- | Specifies whether Config includes all supported types of global
-- resources (for example, IAM resources) with the resources that it
-- records.
--
-- Before you can set this option to @true@, you must set the
-- @allSupported@ option to @true@.
--
-- If you set this option to @true@, when Config adds support for a new
-- type of global resource, it starts recording resources of that type
-- automatically.
--
-- The configuration details for any global resource are the same in all
-- regions. To prevent duplicate configuration items, you should consider
-- customizing Config in only one region to record global resources.
recordingGroup_includeGlobalResourceTypes :: Lens.Lens' RecordingGroup (Prelude.Maybe Prelude.Bool)
recordingGroup_includeGlobalResourceTypes :: (Maybe Bool -> f (Maybe Bool))
-> RecordingGroup -> f RecordingGroup
recordingGroup_includeGlobalResourceTypes = (RecordingGroup -> Maybe Bool)
-> (RecordingGroup -> Maybe Bool -> RecordingGroup)
-> Lens RecordingGroup RecordingGroup (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecordingGroup' {Maybe Bool
includeGlobalResourceTypes :: Maybe Bool
$sel:includeGlobalResourceTypes:RecordingGroup' :: RecordingGroup -> Maybe Bool
includeGlobalResourceTypes} -> Maybe Bool
includeGlobalResourceTypes) (\s :: RecordingGroup
s@RecordingGroup' {} Maybe Bool
a -> RecordingGroup
s {$sel:includeGlobalResourceTypes:RecordingGroup' :: Maybe Bool
includeGlobalResourceTypes = Maybe Bool
a} :: RecordingGroup)

-- | A comma-separated list that specifies the types of Amazon Web Services
-- resources for which Config records configuration changes (for example,
-- @AWS::EC2::Instance@ or @AWS::CloudTrail::Trail@).
--
-- To record all configuration changes, you must set the @allSupported@
-- option to @true@.
--
-- If you set this option to @false@, when Config adds support for a new
-- type of resource, it will not record resources of that type unless you
-- manually add that type to your recording group.
--
-- For a list of valid @resourceTypes@ values, see the __resourceType
-- Value__ column in
-- <https://docs.aws.amazon.com/config/latest/developerguide/resource-config-reference.html#supported-resources Supported Amazon Web Services resource Types>.
recordingGroup_resourceTypes :: Lens.Lens' RecordingGroup (Prelude.Maybe [ResourceType])
recordingGroup_resourceTypes :: (Maybe [ResourceType] -> f (Maybe [ResourceType]))
-> RecordingGroup -> f RecordingGroup
recordingGroup_resourceTypes = (RecordingGroup -> Maybe [ResourceType])
-> (RecordingGroup -> Maybe [ResourceType] -> RecordingGroup)
-> Lens
     RecordingGroup
     RecordingGroup
     (Maybe [ResourceType])
     (Maybe [ResourceType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecordingGroup' {Maybe [ResourceType]
resourceTypes :: Maybe [ResourceType]
$sel:resourceTypes:RecordingGroup' :: RecordingGroup -> Maybe [ResourceType]
resourceTypes} -> Maybe [ResourceType]
resourceTypes) (\s :: RecordingGroup
s@RecordingGroup' {} Maybe [ResourceType]
a -> RecordingGroup
s {$sel:resourceTypes:RecordingGroup' :: Maybe [ResourceType]
resourceTypes = Maybe [ResourceType]
a} :: RecordingGroup) ((Maybe [ResourceType] -> f (Maybe [ResourceType]))
 -> RecordingGroup -> f RecordingGroup)
-> ((Maybe [ResourceType] -> f (Maybe [ResourceType]))
    -> Maybe [ResourceType] -> f (Maybe [ResourceType]))
-> (Maybe [ResourceType] -> f (Maybe [ResourceType]))
-> RecordingGroup
-> f RecordingGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ResourceType] [ResourceType] [ResourceType] [ResourceType]
-> Iso
     (Maybe [ResourceType])
     (Maybe [ResourceType])
     (Maybe [ResourceType])
     (Maybe [ResourceType])
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 [ResourceType] [ResourceType] [ResourceType] [ResourceType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON RecordingGroup where
  parseJSON :: Value -> Parser RecordingGroup
parseJSON =
    String
-> (Object -> Parser RecordingGroup)
-> Value
-> Parser RecordingGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecordingGroup"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> Maybe [ResourceType] -> RecordingGroup
RecordingGroup'
            (Maybe Bool
 -> Maybe Bool -> Maybe [ResourceType] -> RecordingGroup)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> Maybe [ResourceType] -> RecordingGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"allSupported")
            Parser (Maybe Bool -> Maybe [ResourceType] -> RecordingGroup)
-> Parser (Maybe Bool)
-> Parser (Maybe [ResourceType] -> RecordingGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"includeGlobalResourceTypes")
            Parser (Maybe [ResourceType] -> RecordingGroup)
-> Parser (Maybe [ResourceType]) -> Parser RecordingGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ResourceType]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceTypes" Parser (Maybe (Maybe [ResourceType]))
-> Maybe [ResourceType] -> Parser (Maybe [ResourceType])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ResourceType]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable RecordingGroup

instance Prelude.NFData RecordingGroup

instance Core.ToJSON RecordingGroup where
  toJSON :: RecordingGroup -> Value
toJSON RecordingGroup' {Maybe Bool
Maybe [ResourceType]
resourceTypes :: Maybe [ResourceType]
includeGlobalResourceTypes :: Maybe Bool
allSupported :: Maybe Bool
$sel:resourceTypes:RecordingGroup' :: RecordingGroup -> Maybe [ResourceType]
$sel:includeGlobalResourceTypes:RecordingGroup' :: RecordingGroup -> Maybe Bool
$sel:allSupported:RecordingGroup' :: RecordingGroup -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"allSupported" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allSupported,
            (Text
"includeGlobalResourceTypes" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeGlobalResourceTypes,
            (Text
"resourceTypes" Text -> [ResourceType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ResourceType] -> Pair) -> Maybe [ResourceType] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ResourceType]
resourceTypes
          ]
      )