{-# 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.DescribeConfigurationRecorders
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the details for the specified configuration recorders. If the
-- configuration recorder is not specified, this action returns the details
-- for all configuration recorders associated with the account.
--
-- Currently, you can specify only one configuration recorder per region in
-- your account.
module Amazonka.Config.DescribeConfigurationRecorders
  ( -- * Creating a Request
    DescribeConfigurationRecorders (..),
    newDescribeConfigurationRecorders,

    -- * Request Lenses
    describeConfigurationRecorders_configurationRecorderNames,

    -- * Destructuring the Response
    DescribeConfigurationRecordersResponse (..),
    newDescribeConfigurationRecordersResponse,

    -- * Response Lenses
    describeConfigurationRecordersResponse_configurationRecorders,
    describeConfigurationRecordersResponse_httpStatus,
  )
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 DescribeConfigurationRecorders action.
--
-- /See:/ 'newDescribeConfigurationRecorders' smart constructor.
data DescribeConfigurationRecorders = DescribeConfigurationRecorders'
  { -- | A list of configuration recorder names.
    DescribeConfigurationRecorders -> Maybe [Text]
configurationRecorderNames :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribeConfigurationRecorders
-> DescribeConfigurationRecorders -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeConfigurationRecorders
-> DescribeConfigurationRecorders -> Bool
$c/= :: DescribeConfigurationRecorders
-> DescribeConfigurationRecorders -> Bool
== :: DescribeConfigurationRecorders
-> DescribeConfigurationRecorders -> Bool
$c== :: DescribeConfigurationRecorders
-> DescribeConfigurationRecorders -> Bool
Prelude.Eq, ReadPrec [DescribeConfigurationRecorders]
ReadPrec DescribeConfigurationRecorders
Int -> ReadS DescribeConfigurationRecorders
ReadS [DescribeConfigurationRecorders]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeConfigurationRecorders]
$creadListPrec :: ReadPrec [DescribeConfigurationRecorders]
readPrec :: ReadPrec DescribeConfigurationRecorders
$creadPrec :: ReadPrec DescribeConfigurationRecorders
readList :: ReadS [DescribeConfigurationRecorders]
$creadList :: ReadS [DescribeConfigurationRecorders]
readsPrec :: Int -> ReadS DescribeConfigurationRecorders
$creadsPrec :: Int -> ReadS DescribeConfigurationRecorders
Prelude.Read, Int -> DescribeConfigurationRecorders -> ShowS
[DescribeConfigurationRecorders] -> ShowS
DescribeConfigurationRecorders -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeConfigurationRecorders] -> ShowS
$cshowList :: [DescribeConfigurationRecorders] -> ShowS
show :: DescribeConfigurationRecorders -> String
$cshow :: DescribeConfigurationRecorders -> String
showsPrec :: Int -> DescribeConfigurationRecorders -> ShowS
$cshowsPrec :: Int -> DescribeConfigurationRecorders -> ShowS
Prelude.Show, forall x.
Rep DescribeConfigurationRecorders x
-> DescribeConfigurationRecorders
forall x.
DescribeConfigurationRecorders
-> Rep DescribeConfigurationRecorders x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeConfigurationRecorders x
-> DescribeConfigurationRecorders
$cfrom :: forall x.
DescribeConfigurationRecorders
-> Rep DescribeConfigurationRecorders x
Prelude.Generic)

-- |
-- Create a value of 'DescribeConfigurationRecorders' 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:
--
-- 'configurationRecorderNames', 'describeConfigurationRecorders_configurationRecorderNames' - A list of configuration recorder names.
newDescribeConfigurationRecorders ::
  DescribeConfigurationRecorders
newDescribeConfigurationRecorders :: DescribeConfigurationRecorders
newDescribeConfigurationRecorders =
  DescribeConfigurationRecorders'
    { $sel:configurationRecorderNames:DescribeConfigurationRecorders' :: Maybe [Text]
configurationRecorderNames =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A list of configuration recorder names.
describeConfigurationRecorders_configurationRecorderNames :: Lens.Lens' DescribeConfigurationRecorders (Prelude.Maybe [Prelude.Text])
describeConfigurationRecorders_configurationRecorderNames :: Lens' DescribeConfigurationRecorders (Maybe [Text])
describeConfigurationRecorders_configurationRecorderNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurationRecorders' {Maybe [Text]
configurationRecorderNames :: Maybe [Text]
$sel:configurationRecorderNames:DescribeConfigurationRecorders' :: DescribeConfigurationRecorders -> Maybe [Text]
configurationRecorderNames} -> Maybe [Text]
configurationRecorderNames) (\s :: DescribeConfigurationRecorders
s@DescribeConfigurationRecorders' {} Maybe [Text]
a -> DescribeConfigurationRecorders
s {$sel:configurationRecorderNames:DescribeConfigurationRecorders' :: Maybe [Text]
configurationRecorderNames = Maybe [Text]
a} :: DescribeConfigurationRecorders) 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

instance
  Core.AWSRequest
    DescribeConfigurationRecorders
  where
  type
    AWSResponse DescribeConfigurationRecorders =
      DescribeConfigurationRecordersResponse
  request :: (Service -> Service)
-> DescribeConfigurationRecorders
-> Request DescribeConfigurationRecorders
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 DescribeConfigurationRecorders
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeConfigurationRecorders)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [ConfigurationRecorder]
-> Int -> DescribeConfigurationRecordersResponse
DescribeConfigurationRecordersResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ConfigurationRecorders"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    DescribeConfigurationRecorders
  where
  hashWithSalt :: Int -> DescribeConfigurationRecorders -> Int
hashWithSalt
    Int
_salt
    DescribeConfigurationRecorders' {Maybe [Text]
configurationRecorderNames :: Maybe [Text]
$sel:configurationRecorderNames:DescribeConfigurationRecorders' :: DescribeConfigurationRecorders -> Maybe [Text]
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
configurationRecorderNames

instance
  Prelude.NFData
    DescribeConfigurationRecorders
  where
  rnf :: DescribeConfigurationRecorders -> ()
rnf DescribeConfigurationRecorders' {Maybe [Text]
configurationRecorderNames :: Maybe [Text]
$sel:configurationRecorderNames:DescribeConfigurationRecorders' :: DescribeConfigurationRecorders -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
configurationRecorderNames

instance
  Data.ToHeaders
    DescribeConfigurationRecorders
  where
  toHeaders :: DescribeConfigurationRecorders -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"StarlingDoveService.DescribeConfigurationRecorders" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeConfigurationRecorders where
  toJSON :: DescribeConfigurationRecorders -> Value
toJSON DescribeConfigurationRecorders' {Maybe [Text]
configurationRecorderNames :: Maybe [Text]
$sel:configurationRecorderNames:DescribeConfigurationRecorders' :: DescribeConfigurationRecorders -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ConfigurationRecorderNames" 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 [Text]
configurationRecorderNames
          ]
      )

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

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

-- | The output for the DescribeConfigurationRecorders action.
--
-- /See:/ 'newDescribeConfigurationRecordersResponse' smart constructor.
data DescribeConfigurationRecordersResponse = DescribeConfigurationRecordersResponse'
  { -- | A list that contains the descriptions of the specified configuration
    -- recorders.
    DescribeConfigurationRecordersResponse
-> Maybe [ConfigurationRecorder]
configurationRecorders :: Prelude.Maybe [ConfigurationRecorder],
    -- | The response's http status code.
    DescribeConfigurationRecordersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeConfigurationRecordersResponse
-> DescribeConfigurationRecordersResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeConfigurationRecordersResponse
-> DescribeConfigurationRecordersResponse -> Bool
$c/= :: DescribeConfigurationRecordersResponse
-> DescribeConfigurationRecordersResponse -> Bool
== :: DescribeConfigurationRecordersResponse
-> DescribeConfigurationRecordersResponse -> Bool
$c== :: DescribeConfigurationRecordersResponse
-> DescribeConfigurationRecordersResponse -> Bool
Prelude.Eq, ReadPrec [DescribeConfigurationRecordersResponse]
ReadPrec DescribeConfigurationRecordersResponse
Int -> ReadS DescribeConfigurationRecordersResponse
ReadS [DescribeConfigurationRecordersResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeConfigurationRecordersResponse]
$creadListPrec :: ReadPrec [DescribeConfigurationRecordersResponse]
readPrec :: ReadPrec DescribeConfigurationRecordersResponse
$creadPrec :: ReadPrec DescribeConfigurationRecordersResponse
readList :: ReadS [DescribeConfigurationRecordersResponse]
$creadList :: ReadS [DescribeConfigurationRecordersResponse]
readsPrec :: Int -> ReadS DescribeConfigurationRecordersResponse
$creadsPrec :: Int -> ReadS DescribeConfigurationRecordersResponse
Prelude.Read, Int -> DescribeConfigurationRecordersResponse -> ShowS
[DescribeConfigurationRecordersResponse] -> ShowS
DescribeConfigurationRecordersResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeConfigurationRecordersResponse] -> ShowS
$cshowList :: [DescribeConfigurationRecordersResponse] -> ShowS
show :: DescribeConfigurationRecordersResponse -> String
$cshow :: DescribeConfigurationRecordersResponse -> String
showsPrec :: Int -> DescribeConfigurationRecordersResponse -> ShowS
$cshowsPrec :: Int -> DescribeConfigurationRecordersResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeConfigurationRecordersResponse x
-> DescribeConfigurationRecordersResponse
forall x.
DescribeConfigurationRecordersResponse
-> Rep DescribeConfigurationRecordersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeConfigurationRecordersResponse x
-> DescribeConfigurationRecordersResponse
$cfrom :: forall x.
DescribeConfigurationRecordersResponse
-> Rep DescribeConfigurationRecordersResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeConfigurationRecordersResponse' 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:
--
-- 'configurationRecorders', 'describeConfigurationRecordersResponse_configurationRecorders' - A list that contains the descriptions of the specified configuration
-- recorders.
--
-- 'httpStatus', 'describeConfigurationRecordersResponse_httpStatus' - The response's http status code.
newDescribeConfigurationRecordersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeConfigurationRecordersResponse
newDescribeConfigurationRecordersResponse :: Int -> DescribeConfigurationRecordersResponse
newDescribeConfigurationRecordersResponse
  Int
pHttpStatus_ =
    DescribeConfigurationRecordersResponse'
      { $sel:configurationRecorders:DescribeConfigurationRecordersResponse' :: Maybe [ConfigurationRecorder]
configurationRecorders =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeConfigurationRecordersResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | A list that contains the descriptions of the specified configuration
-- recorders.
describeConfigurationRecordersResponse_configurationRecorders :: Lens.Lens' DescribeConfigurationRecordersResponse (Prelude.Maybe [ConfigurationRecorder])
describeConfigurationRecordersResponse_configurationRecorders :: Lens'
  DescribeConfigurationRecordersResponse
  (Maybe [ConfigurationRecorder])
describeConfigurationRecordersResponse_configurationRecorders = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurationRecordersResponse' {Maybe [ConfigurationRecorder]
configurationRecorders :: Maybe [ConfigurationRecorder]
$sel:configurationRecorders:DescribeConfigurationRecordersResponse' :: DescribeConfigurationRecordersResponse
-> Maybe [ConfigurationRecorder]
configurationRecorders} -> Maybe [ConfigurationRecorder]
configurationRecorders) (\s :: DescribeConfigurationRecordersResponse
s@DescribeConfigurationRecordersResponse' {} Maybe [ConfigurationRecorder]
a -> DescribeConfigurationRecordersResponse
s {$sel:configurationRecorders:DescribeConfigurationRecordersResponse' :: Maybe [ConfigurationRecorder]
configurationRecorders = Maybe [ConfigurationRecorder]
a} :: DescribeConfigurationRecordersResponse) 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 response's http status code.
describeConfigurationRecordersResponse_httpStatus :: Lens.Lens' DescribeConfigurationRecordersResponse Prelude.Int
describeConfigurationRecordersResponse_httpStatus :: Lens' DescribeConfigurationRecordersResponse Int
describeConfigurationRecordersResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurationRecordersResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeConfigurationRecordersResponse' :: DescribeConfigurationRecordersResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeConfigurationRecordersResponse
s@DescribeConfigurationRecordersResponse' {} Int
a -> DescribeConfigurationRecordersResponse
s {$sel:httpStatus:DescribeConfigurationRecordersResponse' :: Int
httpStatus = Int
a} :: DescribeConfigurationRecordersResponse)

instance
  Prelude.NFData
    DescribeConfigurationRecordersResponse
  where
  rnf :: DescribeConfigurationRecordersResponse -> ()
rnf DescribeConfigurationRecordersResponse' {Int
Maybe [ConfigurationRecorder]
httpStatus :: Int
configurationRecorders :: Maybe [ConfigurationRecorder]
$sel:httpStatus:DescribeConfigurationRecordersResponse' :: DescribeConfigurationRecordersResponse -> Int
$sel:configurationRecorders:DescribeConfigurationRecordersResponse' :: DescribeConfigurationRecordersResponse
-> Maybe [ConfigurationRecorder]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ConfigurationRecorder]
configurationRecorders
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus