{-# 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.DescribeConfigurationRecorderStatus
-- 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 current status of the specified configuration recorder. If a
-- configuration recorder is not specified, this action returns the status
-- of all configuration recorders associated with the account.
--
-- Currently, you can specify only one configuration recorder per region in
-- your account.
module Amazonka.Config.DescribeConfigurationRecorderStatus
  ( -- * Creating a Request
    DescribeConfigurationRecorderStatus (..),
    newDescribeConfigurationRecorderStatus,

    -- * Request Lenses
    describeConfigurationRecorderStatus_configurationRecorderNames,

    -- * Destructuring the Response
    DescribeConfigurationRecorderStatusResponse (..),
    newDescribeConfigurationRecorderStatusResponse,

    -- * Response Lenses
    describeConfigurationRecorderStatusResponse_configurationRecordersStatus,
    describeConfigurationRecorderStatusResponse_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 DescribeConfigurationRecorderStatus action.
--
-- /See:/ 'newDescribeConfigurationRecorderStatus' smart constructor.
data DescribeConfigurationRecorderStatus = DescribeConfigurationRecorderStatus'
  { -- | The name(s) of the configuration recorder. If the name is not specified,
    -- the action returns the current status of all the configuration recorders
    -- associated with the account.
    DescribeConfigurationRecorderStatus -> Maybe [Text]
configurationRecorderNames :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribeConfigurationRecorderStatus
-> DescribeConfigurationRecorderStatus -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeConfigurationRecorderStatus
-> DescribeConfigurationRecorderStatus -> Bool
$c/= :: DescribeConfigurationRecorderStatus
-> DescribeConfigurationRecorderStatus -> Bool
== :: DescribeConfigurationRecorderStatus
-> DescribeConfigurationRecorderStatus -> Bool
$c== :: DescribeConfigurationRecorderStatus
-> DescribeConfigurationRecorderStatus -> Bool
Prelude.Eq, ReadPrec [DescribeConfigurationRecorderStatus]
ReadPrec DescribeConfigurationRecorderStatus
Int -> ReadS DescribeConfigurationRecorderStatus
ReadS [DescribeConfigurationRecorderStatus]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeConfigurationRecorderStatus]
$creadListPrec :: ReadPrec [DescribeConfigurationRecorderStatus]
readPrec :: ReadPrec DescribeConfigurationRecorderStatus
$creadPrec :: ReadPrec DescribeConfigurationRecorderStatus
readList :: ReadS [DescribeConfigurationRecorderStatus]
$creadList :: ReadS [DescribeConfigurationRecorderStatus]
readsPrec :: Int -> ReadS DescribeConfigurationRecorderStatus
$creadsPrec :: Int -> ReadS DescribeConfigurationRecorderStatus
Prelude.Read, Int -> DescribeConfigurationRecorderStatus -> ShowS
[DescribeConfigurationRecorderStatus] -> ShowS
DescribeConfigurationRecorderStatus -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeConfigurationRecorderStatus] -> ShowS
$cshowList :: [DescribeConfigurationRecorderStatus] -> ShowS
show :: DescribeConfigurationRecorderStatus -> String
$cshow :: DescribeConfigurationRecorderStatus -> String
showsPrec :: Int -> DescribeConfigurationRecorderStatus -> ShowS
$cshowsPrec :: Int -> DescribeConfigurationRecorderStatus -> ShowS
Prelude.Show, forall x.
Rep DescribeConfigurationRecorderStatus x
-> DescribeConfigurationRecorderStatus
forall x.
DescribeConfigurationRecorderStatus
-> Rep DescribeConfigurationRecorderStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeConfigurationRecorderStatus x
-> DescribeConfigurationRecorderStatus
$cfrom :: forall x.
DescribeConfigurationRecorderStatus
-> Rep DescribeConfigurationRecorderStatus x
Prelude.Generic)

-- |
-- Create a value of 'DescribeConfigurationRecorderStatus' 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', 'describeConfigurationRecorderStatus_configurationRecorderNames' - The name(s) of the configuration recorder. If the name is not specified,
-- the action returns the current status of all the configuration recorders
-- associated with the account.
newDescribeConfigurationRecorderStatus ::
  DescribeConfigurationRecorderStatus
newDescribeConfigurationRecorderStatus :: DescribeConfigurationRecorderStatus
newDescribeConfigurationRecorderStatus =
  DescribeConfigurationRecorderStatus'
    { $sel:configurationRecorderNames:DescribeConfigurationRecorderStatus' :: Maybe [Text]
configurationRecorderNames =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The name(s) of the configuration recorder. If the name is not specified,
-- the action returns the current status of all the configuration recorders
-- associated with the account.
describeConfigurationRecorderStatus_configurationRecorderNames :: Lens.Lens' DescribeConfigurationRecorderStatus (Prelude.Maybe [Prelude.Text])
describeConfigurationRecorderStatus_configurationRecorderNames :: Lens' DescribeConfigurationRecorderStatus (Maybe [Text])
describeConfigurationRecorderStatus_configurationRecorderNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurationRecorderStatus' {Maybe [Text]
configurationRecorderNames :: Maybe [Text]
$sel:configurationRecorderNames:DescribeConfigurationRecorderStatus' :: DescribeConfigurationRecorderStatus -> Maybe [Text]
configurationRecorderNames} -> Maybe [Text]
configurationRecorderNames) (\s :: DescribeConfigurationRecorderStatus
s@DescribeConfigurationRecorderStatus' {} Maybe [Text]
a -> DescribeConfigurationRecorderStatus
s {$sel:configurationRecorderNames:DescribeConfigurationRecorderStatus' :: Maybe [Text]
configurationRecorderNames = Maybe [Text]
a} :: DescribeConfigurationRecorderStatus) 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
    DescribeConfigurationRecorderStatus
  where
  type
    AWSResponse DescribeConfigurationRecorderStatus =
      DescribeConfigurationRecorderStatusResponse
  request :: (Service -> Service)
-> DescribeConfigurationRecorderStatus
-> Request DescribeConfigurationRecorderStatus
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 DescribeConfigurationRecorderStatus
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeConfigurationRecorderStatus)))
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 [ConfigurationRecorderStatus]
-> Int -> DescribeConfigurationRecorderStatusResponse
DescribeConfigurationRecorderStatusResponse'
            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
"ConfigurationRecordersStatus"
                            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
    DescribeConfigurationRecorderStatus
  where
  hashWithSalt :: Int -> DescribeConfigurationRecorderStatus -> Int
hashWithSalt
    Int
_salt
    DescribeConfigurationRecorderStatus' {Maybe [Text]
configurationRecorderNames :: Maybe [Text]
$sel:configurationRecorderNames:DescribeConfigurationRecorderStatus' :: DescribeConfigurationRecorderStatus -> Maybe [Text]
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
configurationRecorderNames

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

instance
  Data.ToHeaders
    DescribeConfigurationRecorderStatus
  where
  toHeaders :: DescribeConfigurationRecorderStatus -> 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.DescribeConfigurationRecorderStatus" ::
                          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
    DescribeConfigurationRecorderStatus
  where
  toJSON :: DescribeConfigurationRecorderStatus -> Value
toJSON DescribeConfigurationRecorderStatus' {Maybe [Text]
configurationRecorderNames :: Maybe [Text]
$sel:configurationRecorderNames:DescribeConfigurationRecorderStatus' :: DescribeConfigurationRecorderStatus -> 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
    DescribeConfigurationRecorderStatus
  where
  toPath :: DescribeConfigurationRecorderStatus -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DescribeConfigurationRecorderStatusResponse' 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:
--
-- 'configurationRecordersStatus', 'describeConfigurationRecorderStatusResponse_configurationRecordersStatus' - A list that contains status of the specified recorders.
--
-- 'httpStatus', 'describeConfigurationRecorderStatusResponse_httpStatus' - The response's http status code.
newDescribeConfigurationRecorderStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeConfigurationRecorderStatusResponse
newDescribeConfigurationRecorderStatusResponse :: Int -> DescribeConfigurationRecorderStatusResponse
newDescribeConfigurationRecorderStatusResponse
  Int
pHttpStatus_ =
    DescribeConfigurationRecorderStatusResponse'
      { $sel:configurationRecordersStatus:DescribeConfigurationRecorderStatusResponse' :: Maybe [ConfigurationRecorderStatus]
configurationRecordersStatus =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeConfigurationRecorderStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | A list that contains status of the specified recorders.
describeConfigurationRecorderStatusResponse_configurationRecordersStatus :: Lens.Lens' DescribeConfigurationRecorderStatusResponse (Prelude.Maybe [ConfigurationRecorderStatus])
describeConfigurationRecorderStatusResponse_configurationRecordersStatus :: Lens'
  DescribeConfigurationRecorderStatusResponse
  (Maybe [ConfigurationRecorderStatus])
describeConfigurationRecorderStatusResponse_configurationRecordersStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurationRecorderStatusResponse' {Maybe [ConfigurationRecorderStatus]
configurationRecordersStatus :: Maybe [ConfigurationRecorderStatus]
$sel:configurationRecordersStatus:DescribeConfigurationRecorderStatusResponse' :: DescribeConfigurationRecorderStatusResponse
-> Maybe [ConfigurationRecorderStatus]
configurationRecordersStatus} -> Maybe [ConfigurationRecorderStatus]
configurationRecordersStatus) (\s :: DescribeConfigurationRecorderStatusResponse
s@DescribeConfigurationRecorderStatusResponse' {} Maybe [ConfigurationRecorderStatus]
a -> DescribeConfigurationRecorderStatusResponse
s {$sel:configurationRecordersStatus:DescribeConfigurationRecorderStatusResponse' :: Maybe [ConfigurationRecorderStatus]
configurationRecordersStatus = Maybe [ConfigurationRecorderStatus]
a} :: DescribeConfigurationRecorderStatusResponse) 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.
describeConfigurationRecorderStatusResponse_httpStatus :: Lens.Lens' DescribeConfigurationRecorderStatusResponse Prelude.Int
describeConfigurationRecorderStatusResponse_httpStatus :: Lens' DescribeConfigurationRecorderStatusResponse Int
describeConfigurationRecorderStatusResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurationRecorderStatusResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeConfigurationRecorderStatusResponse' :: DescribeConfigurationRecorderStatusResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeConfigurationRecorderStatusResponse
s@DescribeConfigurationRecorderStatusResponse' {} Int
a -> DescribeConfigurationRecorderStatusResponse
s {$sel:httpStatus:DescribeConfigurationRecorderStatusResponse' :: Int
httpStatus = Int
a} :: DescribeConfigurationRecorderStatusResponse)

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