{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.PutConfigurationRecorder
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a new configuration recorder to record the selected resource
-- configurations.
--
-- You can use this action to change the role @roleARN@ or the
-- @recordingGroup@ of an existing recorder. To change the role, call the
-- action on the existing configuration recorder and specify a role.
--
-- Currently, you can specify only one configuration recorder per region in
-- your account.
--
-- If @ConfigurationRecorder@ does not have the __recordingGroup__
-- parameter specified, the default is to record all supported resource
-- types.
module Amazonka.Config.PutConfigurationRecorder
  ( -- * Creating a Request
    PutConfigurationRecorder (..),
    newPutConfigurationRecorder,

    -- * Request Lenses
    putConfigurationRecorder_configurationRecorder,

    -- * Destructuring the Response
    PutConfigurationRecorderResponse (..),
    newPutConfigurationRecorderResponse,
  )
where

import Amazonka.Config.Types
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The input for the PutConfigurationRecorder action.
--
-- /See:/ 'newPutConfigurationRecorder' smart constructor.
data PutConfigurationRecorder = PutConfigurationRecorder'
  { -- | The configuration recorder object that records each configuration change
    -- made to the resources.
    PutConfigurationRecorder -> ConfigurationRecorder
configurationRecorder :: ConfigurationRecorder
  }
  deriving (PutConfigurationRecorder -> PutConfigurationRecorder -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutConfigurationRecorder -> PutConfigurationRecorder -> Bool
$c/= :: PutConfigurationRecorder -> PutConfigurationRecorder -> Bool
== :: PutConfigurationRecorder -> PutConfigurationRecorder -> Bool
$c== :: PutConfigurationRecorder -> PutConfigurationRecorder -> Bool
Prelude.Eq, ReadPrec [PutConfigurationRecorder]
ReadPrec PutConfigurationRecorder
Int -> ReadS PutConfigurationRecorder
ReadS [PutConfigurationRecorder]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutConfigurationRecorder]
$creadListPrec :: ReadPrec [PutConfigurationRecorder]
readPrec :: ReadPrec PutConfigurationRecorder
$creadPrec :: ReadPrec PutConfigurationRecorder
readList :: ReadS [PutConfigurationRecorder]
$creadList :: ReadS [PutConfigurationRecorder]
readsPrec :: Int -> ReadS PutConfigurationRecorder
$creadsPrec :: Int -> ReadS PutConfigurationRecorder
Prelude.Read, Int -> PutConfigurationRecorder -> ShowS
[PutConfigurationRecorder] -> ShowS
PutConfigurationRecorder -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutConfigurationRecorder] -> ShowS
$cshowList :: [PutConfigurationRecorder] -> ShowS
show :: PutConfigurationRecorder -> String
$cshow :: PutConfigurationRecorder -> String
showsPrec :: Int -> PutConfigurationRecorder -> ShowS
$cshowsPrec :: Int -> PutConfigurationRecorder -> ShowS
Prelude.Show, forall x.
Rep PutConfigurationRecorder x -> PutConfigurationRecorder
forall x.
PutConfigurationRecorder -> Rep PutConfigurationRecorder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutConfigurationRecorder x -> PutConfigurationRecorder
$cfrom :: forall x.
PutConfigurationRecorder -> Rep PutConfigurationRecorder x
Prelude.Generic)

-- |
-- Create a value of 'PutConfigurationRecorder' 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:
--
-- 'configurationRecorder', 'putConfigurationRecorder_configurationRecorder' - The configuration recorder object that records each configuration change
-- made to the resources.
newPutConfigurationRecorder ::
  -- | 'configurationRecorder'
  ConfigurationRecorder ->
  PutConfigurationRecorder
newPutConfigurationRecorder :: ConfigurationRecorder -> PutConfigurationRecorder
newPutConfigurationRecorder ConfigurationRecorder
pConfigurationRecorder_ =
  PutConfigurationRecorder'
    { $sel:configurationRecorder:PutConfigurationRecorder' :: ConfigurationRecorder
configurationRecorder =
        ConfigurationRecorder
pConfigurationRecorder_
    }

-- | The configuration recorder object that records each configuration change
-- made to the resources.
putConfigurationRecorder_configurationRecorder :: Lens.Lens' PutConfigurationRecorder ConfigurationRecorder
putConfigurationRecorder_configurationRecorder :: Lens' PutConfigurationRecorder ConfigurationRecorder
putConfigurationRecorder_configurationRecorder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutConfigurationRecorder' {ConfigurationRecorder
configurationRecorder :: ConfigurationRecorder
$sel:configurationRecorder:PutConfigurationRecorder' :: PutConfigurationRecorder -> ConfigurationRecorder
configurationRecorder} -> ConfigurationRecorder
configurationRecorder) (\s :: PutConfigurationRecorder
s@PutConfigurationRecorder' {} ConfigurationRecorder
a -> PutConfigurationRecorder
s {$sel:configurationRecorder:PutConfigurationRecorder' :: ConfigurationRecorder
configurationRecorder = ConfigurationRecorder
a} :: PutConfigurationRecorder)

instance Core.AWSRequest PutConfigurationRecorder where
  type
    AWSResponse PutConfigurationRecorder =
      PutConfigurationRecorderResponse
  request :: (Service -> Service)
-> PutConfigurationRecorder -> Request PutConfigurationRecorder
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutConfigurationRecorder
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutConfigurationRecorder)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      PutConfigurationRecorderResponse
PutConfigurationRecorderResponse'

instance Prelude.Hashable PutConfigurationRecorder where
  hashWithSalt :: Int -> PutConfigurationRecorder -> Int
hashWithSalt Int
_salt PutConfigurationRecorder' {ConfigurationRecorder
configurationRecorder :: ConfigurationRecorder
$sel:configurationRecorder:PutConfigurationRecorder' :: PutConfigurationRecorder -> ConfigurationRecorder
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConfigurationRecorder
configurationRecorder

instance Prelude.NFData PutConfigurationRecorder where
  rnf :: PutConfigurationRecorder -> ()
rnf PutConfigurationRecorder' {ConfigurationRecorder
configurationRecorder :: ConfigurationRecorder
$sel:configurationRecorder:PutConfigurationRecorder' :: PutConfigurationRecorder -> ConfigurationRecorder
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ConfigurationRecorder
configurationRecorder

instance Data.ToHeaders PutConfigurationRecorder where
  toHeaders :: PutConfigurationRecorder -> [Header]
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"StarlingDoveService.PutConfigurationRecorder" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PutConfigurationRecorder where
  toJSON :: PutConfigurationRecorder -> Value
toJSON PutConfigurationRecorder' {ConfigurationRecorder
configurationRecorder :: ConfigurationRecorder
$sel:configurationRecorder:PutConfigurationRecorder' :: PutConfigurationRecorder -> ConfigurationRecorder
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"ConfigurationRecorder"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ConfigurationRecorder
configurationRecorder
              )
          ]
      )

instance Data.ToPath PutConfigurationRecorder where
  toPath :: PutConfigurationRecorder -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery PutConfigurationRecorder where
  toQuery :: PutConfigurationRecorder -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newPutConfigurationRecorderResponse' smart constructor.
data PutConfigurationRecorderResponse = PutConfigurationRecorderResponse'
  {
  }
  deriving (PutConfigurationRecorderResponse
-> PutConfigurationRecorderResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutConfigurationRecorderResponse
-> PutConfigurationRecorderResponse -> Bool
$c/= :: PutConfigurationRecorderResponse
-> PutConfigurationRecorderResponse -> Bool
== :: PutConfigurationRecorderResponse
-> PutConfigurationRecorderResponse -> Bool
$c== :: PutConfigurationRecorderResponse
-> PutConfigurationRecorderResponse -> Bool
Prelude.Eq, ReadPrec [PutConfigurationRecorderResponse]
ReadPrec PutConfigurationRecorderResponse
Int -> ReadS PutConfigurationRecorderResponse
ReadS [PutConfigurationRecorderResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutConfigurationRecorderResponse]
$creadListPrec :: ReadPrec [PutConfigurationRecorderResponse]
readPrec :: ReadPrec PutConfigurationRecorderResponse
$creadPrec :: ReadPrec PutConfigurationRecorderResponse
readList :: ReadS [PutConfigurationRecorderResponse]
$creadList :: ReadS [PutConfigurationRecorderResponse]
readsPrec :: Int -> ReadS PutConfigurationRecorderResponse
$creadsPrec :: Int -> ReadS PutConfigurationRecorderResponse
Prelude.Read, Int -> PutConfigurationRecorderResponse -> ShowS
[PutConfigurationRecorderResponse] -> ShowS
PutConfigurationRecorderResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutConfigurationRecorderResponse] -> ShowS
$cshowList :: [PutConfigurationRecorderResponse] -> ShowS
show :: PutConfigurationRecorderResponse -> String
$cshow :: PutConfigurationRecorderResponse -> String
showsPrec :: Int -> PutConfigurationRecorderResponse -> ShowS
$cshowsPrec :: Int -> PutConfigurationRecorderResponse -> ShowS
Prelude.Show, forall x.
Rep PutConfigurationRecorderResponse x
-> PutConfigurationRecorderResponse
forall x.
PutConfigurationRecorderResponse
-> Rep PutConfigurationRecorderResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutConfigurationRecorderResponse x
-> PutConfigurationRecorderResponse
$cfrom :: forall x.
PutConfigurationRecorderResponse
-> Rep PutConfigurationRecorderResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutConfigurationRecorderResponse' 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.
newPutConfigurationRecorderResponse ::
  PutConfigurationRecorderResponse
newPutConfigurationRecorderResponse :: PutConfigurationRecorderResponse
newPutConfigurationRecorderResponse =
  PutConfigurationRecorderResponse
PutConfigurationRecorderResponse'

instance
  Prelude.NFData
    PutConfigurationRecorderResponse
  where
  rnf :: PutConfigurationRecorderResponse -> ()
rnf PutConfigurationRecorderResponse
_ = ()