{-# 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.GetAggregateResourceConfig
-- 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)
--
-- Returns configuration item that is aggregated for your specific resource
-- in a specific source account and region.
module Amazonka.Config.GetAggregateResourceConfig
  ( -- * Creating a Request
    GetAggregateResourceConfig (..),
    newGetAggregateResourceConfig,

    -- * Request Lenses
    getAggregateResourceConfig_configurationAggregatorName,
    getAggregateResourceConfig_resourceIdentifier,

    -- * Destructuring the Response
    GetAggregateResourceConfigResponse (..),
    newGetAggregateResourceConfigResponse,

    -- * Response Lenses
    getAggregateResourceConfigResponse_configurationItem,
    getAggregateResourceConfigResponse_httpStatus,
  )
where

import Amazonka.Config.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetAggregateResourceConfig' smart constructor.
data GetAggregateResourceConfig = GetAggregateResourceConfig'
  { -- | The name of the configuration aggregator.
    GetAggregateResourceConfig -> Text
configurationAggregatorName :: Prelude.Text,
    -- | An object that identifies aggregate resource.
    GetAggregateResourceConfig -> AggregateResourceIdentifier
resourceIdentifier :: AggregateResourceIdentifier
  }
  deriving (GetAggregateResourceConfig -> GetAggregateResourceConfig -> Bool
(GetAggregateResourceConfig -> GetAggregateResourceConfig -> Bool)
-> (GetAggregateResourceConfig
    -> GetAggregateResourceConfig -> Bool)
-> Eq GetAggregateResourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAggregateResourceConfig -> GetAggregateResourceConfig -> Bool
$c/= :: GetAggregateResourceConfig -> GetAggregateResourceConfig -> Bool
== :: GetAggregateResourceConfig -> GetAggregateResourceConfig -> Bool
$c== :: GetAggregateResourceConfig -> GetAggregateResourceConfig -> Bool
Prelude.Eq, ReadPrec [GetAggregateResourceConfig]
ReadPrec GetAggregateResourceConfig
Int -> ReadS GetAggregateResourceConfig
ReadS [GetAggregateResourceConfig]
(Int -> ReadS GetAggregateResourceConfig)
-> ReadS [GetAggregateResourceConfig]
-> ReadPrec GetAggregateResourceConfig
-> ReadPrec [GetAggregateResourceConfig]
-> Read GetAggregateResourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAggregateResourceConfig]
$creadListPrec :: ReadPrec [GetAggregateResourceConfig]
readPrec :: ReadPrec GetAggregateResourceConfig
$creadPrec :: ReadPrec GetAggregateResourceConfig
readList :: ReadS [GetAggregateResourceConfig]
$creadList :: ReadS [GetAggregateResourceConfig]
readsPrec :: Int -> ReadS GetAggregateResourceConfig
$creadsPrec :: Int -> ReadS GetAggregateResourceConfig
Prelude.Read, Int -> GetAggregateResourceConfig -> ShowS
[GetAggregateResourceConfig] -> ShowS
GetAggregateResourceConfig -> String
(Int -> GetAggregateResourceConfig -> ShowS)
-> (GetAggregateResourceConfig -> String)
-> ([GetAggregateResourceConfig] -> ShowS)
-> Show GetAggregateResourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAggregateResourceConfig] -> ShowS
$cshowList :: [GetAggregateResourceConfig] -> ShowS
show :: GetAggregateResourceConfig -> String
$cshow :: GetAggregateResourceConfig -> String
showsPrec :: Int -> GetAggregateResourceConfig -> ShowS
$cshowsPrec :: Int -> GetAggregateResourceConfig -> ShowS
Prelude.Show, (forall x.
 GetAggregateResourceConfig -> Rep GetAggregateResourceConfig x)
-> (forall x.
    Rep GetAggregateResourceConfig x -> GetAggregateResourceConfig)
-> Generic GetAggregateResourceConfig
forall x.
Rep GetAggregateResourceConfig x -> GetAggregateResourceConfig
forall x.
GetAggregateResourceConfig -> Rep GetAggregateResourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAggregateResourceConfig x -> GetAggregateResourceConfig
$cfrom :: forall x.
GetAggregateResourceConfig -> Rep GetAggregateResourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetAggregateResourceConfig' 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:
--
-- 'configurationAggregatorName', 'getAggregateResourceConfig_configurationAggregatorName' - The name of the configuration aggregator.
--
-- 'resourceIdentifier', 'getAggregateResourceConfig_resourceIdentifier' - An object that identifies aggregate resource.
newGetAggregateResourceConfig ::
  -- | 'configurationAggregatorName'
  Prelude.Text ->
  -- | 'resourceIdentifier'
  AggregateResourceIdentifier ->
  GetAggregateResourceConfig
newGetAggregateResourceConfig :: Text -> AggregateResourceIdentifier -> GetAggregateResourceConfig
newGetAggregateResourceConfig
  Text
pConfigurationAggregatorName_
  AggregateResourceIdentifier
pResourceIdentifier_ =
    GetAggregateResourceConfig' :: Text -> AggregateResourceIdentifier -> GetAggregateResourceConfig
GetAggregateResourceConfig'
      { $sel:configurationAggregatorName:GetAggregateResourceConfig' :: Text
configurationAggregatorName =
          Text
pConfigurationAggregatorName_,
        $sel:resourceIdentifier:GetAggregateResourceConfig' :: AggregateResourceIdentifier
resourceIdentifier = AggregateResourceIdentifier
pResourceIdentifier_
      }

-- | The name of the configuration aggregator.
getAggregateResourceConfig_configurationAggregatorName :: Lens.Lens' GetAggregateResourceConfig Prelude.Text
getAggregateResourceConfig_configurationAggregatorName :: (Text -> f Text)
-> GetAggregateResourceConfig -> f GetAggregateResourceConfig
getAggregateResourceConfig_configurationAggregatorName = (GetAggregateResourceConfig -> Text)
-> (GetAggregateResourceConfig
    -> Text -> GetAggregateResourceConfig)
-> Lens
     GetAggregateResourceConfig GetAggregateResourceConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAggregateResourceConfig' {Text
configurationAggregatorName :: Text
$sel:configurationAggregatorName:GetAggregateResourceConfig' :: GetAggregateResourceConfig -> Text
configurationAggregatorName} -> Text
configurationAggregatorName) (\s :: GetAggregateResourceConfig
s@GetAggregateResourceConfig' {} Text
a -> GetAggregateResourceConfig
s {$sel:configurationAggregatorName:GetAggregateResourceConfig' :: Text
configurationAggregatorName = Text
a} :: GetAggregateResourceConfig)

-- | An object that identifies aggregate resource.
getAggregateResourceConfig_resourceIdentifier :: Lens.Lens' GetAggregateResourceConfig AggregateResourceIdentifier
getAggregateResourceConfig_resourceIdentifier :: (AggregateResourceIdentifier -> f AggregateResourceIdentifier)
-> GetAggregateResourceConfig -> f GetAggregateResourceConfig
getAggregateResourceConfig_resourceIdentifier = (GetAggregateResourceConfig -> AggregateResourceIdentifier)
-> (GetAggregateResourceConfig
    -> AggregateResourceIdentifier -> GetAggregateResourceConfig)
-> Lens
     GetAggregateResourceConfig
     GetAggregateResourceConfig
     AggregateResourceIdentifier
     AggregateResourceIdentifier
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAggregateResourceConfig' {AggregateResourceIdentifier
resourceIdentifier :: AggregateResourceIdentifier
$sel:resourceIdentifier:GetAggregateResourceConfig' :: GetAggregateResourceConfig -> AggregateResourceIdentifier
resourceIdentifier} -> AggregateResourceIdentifier
resourceIdentifier) (\s :: GetAggregateResourceConfig
s@GetAggregateResourceConfig' {} AggregateResourceIdentifier
a -> GetAggregateResourceConfig
s {$sel:resourceIdentifier:GetAggregateResourceConfig' :: AggregateResourceIdentifier
resourceIdentifier = AggregateResourceIdentifier
a} :: GetAggregateResourceConfig)

instance Core.AWSRequest GetAggregateResourceConfig where
  type
    AWSResponse GetAggregateResourceConfig =
      GetAggregateResourceConfigResponse
  request :: GetAggregateResourceConfig -> Request GetAggregateResourceConfig
request = Service
-> GetAggregateResourceConfig -> Request GetAggregateResourceConfig
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAggregateResourceConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAggregateResourceConfig)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAggregateResourceConfig))
-> Logger
-> Service
-> Proxy GetAggregateResourceConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAggregateResourceConfig)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ConfigurationItem
-> Int -> GetAggregateResourceConfigResponse
GetAggregateResourceConfigResponse'
            (Maybe ConfigurationItem
 -> Int -> GetAggregateResourceConfigResponse)
-> Either String (Maybe ConfigurationItem)
-> Either String (Int -> GetAggregateResourceConfigResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ConfigurationItem)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ConfigurationItem")
            Either String (Int -> GetAggregateResourceConfigResponse)
-> Either String Int
-> Either String GetAggregateResourceConfigResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetAggregateResourceConfig

instance Prelude.NFData GetAggregateResourceConfig

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

instance Core.ToJSON GetAggregateResourceConfig where
  toJSON :: GetAggregateResourceConfig -> Value
toJSON GetAggregateResourceConfig' {Text
AggregateResourceIdentifier
resourceIdentifier :: AggregateResourceIdentifier
configurationAggregatorName :: Text
$sel:resourceIdentifier:GetAggregateResourceConfig' :: GetAggregateResourceConfig -> AggregateResourceIdentifier
$sel:configurationAggregatorName:GetAggregateResourceConfig' :: GetAggregateResourceConfig -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ConfigurationAggregatorName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
configurationAggregatorName
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ResourceIdentifier" Text -> AggregateResourceIdentifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AggregateResourceIdentifier
resourceIdentifier)
          ]
      )

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

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

-- | /See:/ 'newGetAggregateResourceConfigResponse' smart constructor.
data GetAggregateResourceConfigResponse = GetAggregateResourceConfigResponse'
  { -- | Returns a @ConfigurationItem@ object.
    GetAggregateResourceConfigResponse -> Maybe ConfigurationItem
configurationItem :: Prelude.Maybe ConfigurationItem,
    -- | The response's http status code.
    GetAggregateResourceConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetAggregateResourceConfigResponse
-> GetAggregateResourceConfigResponse -> Bool
(GetAggregateResourceConfigResponse
 -> GetAggregateResourceConfigResponse -> Bool)
-> (GetAggregateResourceConfigResponse
    -> GetAggregateResourceConfigResponse -> Bool)
-> Eq GetAggregateResourceConfigResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAggregateResourceConfigResponse
-> GetAggregateResourceConfigResponse -> Bool
$c/= :: GetAggregateResourceConfigResponse
-> GetAggregateResourceConfigResponse -> Bool
== :: GetAggregateResourceConfigResponse
-> GetAggregateResourceConfigResponse -> Bool
$c== :: GetAggregateResourceConfigResponse
-> GetAggregateResourceConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetAggregateResourceConfigResponse]
ReadPrec GetAggregateResourceConfigResponse
Int -> ReadS GetAggregateResourceConfigResponse
ReadS [GetAggregateResourceConfigResponse]
(Int -> ReadS GetAggregateResourceConfigResponse)
-> ReadS [GetAggregateResourceConfigResponse]
-> ReadPrec GetAggregateResourceConfigResponse
-> ReadPrec [GetAggregateResourceConfigResponse]
-> Read GetAggregateResourceConfigResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAggregateResourceConfigResponse]
$creadListPrec :: ReadPrec [GetAggregateResourceConfigResponse]
readPrec :: ReadPrec GetAggregateResourceConfigResponse
$creadPrec :: ReadPrec GetAggregateResourceConfigResponse
readList :: ReadS [GetAggregateResourceConfigResponse]
$creadList :: ReadS [GetAggregateResourceConfigResponse]
readsPrec :: Int -> ReadS GetAggregateResourceConfigResponse
$creadsPrec :: Int -> ReadS GetAggregateResourceConfigResponse
Prelude.Read, Int -> GetAggregateResourceConfigResponse -> ShowS
[GetAggregateResourceConfigResponse] -> ShowS
GetAggregateResourceConfigResponse -> String
(Int -> GetAggregateResourceConfigResponse -> ShowS)
-> (GetAggregateResourceConfigResponse -> String)
-> ([GetAggregateResourceConfigResponse] -> ShowS)
-> Show GetAggregateResourceConfigResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAggregateResourceConfigResponse] -> ShowS
$cshowList :: [GetAggregateResourceConfigResponse] -> ShowS
show :: GetAggregateResourceConfigResponse -> String
$cshow :: GetAggregateResourceConfigResponse -> String
showsPrec :: Int -> GetAggregateResourceConfigResponse -> ShowS
$cshowsPrec :: Int -> GetAggregateResourceConfigResponse -> ShowS
Prelude.Show, (forall x.
 GetAggregateResourceConfigResponse
 -> Rep GetAggregateResourceConfigResponse x)
-> (forall x.
    Rep GetAggregateResourceConfigResponse x
    -> GetAggregateResourceConfigResponse)
-> Generic GetAggregateResourceConfigResponse
forall x.
Rep GetAggregateResourceConfigResponse x
-> GetAggregateResourceConfigResponse
forall x.
GetAggregateResourceConfigResponse
-> Rep GetAggregateResourceConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAggregateResourceConfigResponse x
-> GetAggregateResourceConfigResponse
$cfrom :: forall x.
GetAggregateResourceConfigResponse
-> Rep GetAggregateResourceConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAggregateResourceConfigResponse' 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:
--
-- 'configurationItem', 'getAggregateResourceConfigResponse_configurationItem' - Returns a @ConfigurationItem@ object.
--
-- 'httpStatus', 'getAggregateResourceConfigResponse_httpStatus' - The response's http status code.
newGetAggregateResourceConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAggregateResourceConfigResponse
newGetAggregateResourceConfigResponse :: Int -> GetAggregateResourceConfigResponse
newGetAggregateResourceConfigResponse Int
pHttpStatus_ =
  GetAggregateResourceConfigResponse' :: Maybe ConfigurationItem
-> Int -> GetAggregateResourceConfigResponse
GetAggregateResourceConfigResponse'
    { $sel:configurationItem:GetAggregateResourceConfigResponse' :: Maybe ConfigurationItem
configurationItem =
        Maybe ConfigurationItem
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAggregateResourceConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns a @ConfigurationItem@ object.
getAggregateResourceConfigResponse_configurationItem :: Lens.Lens' GetAggregateResourceConfigResponse (Prelude.Maybe ConfigurationItem)
getAggregateResourceConfigResponse_configurationItem :: (Maybe ConfigurationItem -> f (Maybe ConfigurationItem))
-> GetAggregateResourceConfigResponse
-> f GetAggregateResourceConfigResponse
getAggregateResourceConfigResponse_configurationItem = (GetAggregateResourceConfigResponse -> Maybe ConfigurationItem)
-> (GetAggregateResourceConfigResponse
    -> Maybe ConfigurationItem -> GetAggregateResourceConfigResponse)
-> Lens
     GetAggregateResourceConfigResponse
     GetAggregateResourceConfigResponse
     (Maybe ConfigurationItem)
     (Maybe ConfigurationItem)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAggregateResourceConfigResponse' {Maybe ConfigurationItem
configurationItem :: Maybe ConfigurationItem
$sel:configurationItem:GetAggregateResourceConfigResponse' :: GetAggregateResourceConfigResponse -> Maybe ConfigurationItem
configurationItem} -> Maybe ConfigurationItem
configurationItem) (\s :: GetAggregateResourceConfigResponse
s@GetAggregateResourceConfigResponse' {} Maybe ConfigurationItem
a -> GetAggregateResourceConfigResponse
s {$sel:configurationItem:GetAggregateResourceConfigResponse' :: Maybe ConfigurationItem
configurationItem = Maybe ConfigurationItem
a} :: GetAggregateResourceConfigResponse)

-- | The response's http status code.
getAggregateResourceConfigResponse_httpStatus :: Lens.Lens' GetAggregateResourceConfigResponse Prelude.Int
getAggregateResourceConfigResponse_httpStatus :: (Int -> f Int)
-> GetAggregateResourceConfigResponse
-> f GetAggregateResourceConfigResponse
getAggregateResourceConfigResponse_httpStatus = (GetAggregateResourceConfigResponse -> Int)
-> (GetAggregateResourceConfigResponse
    -> Int -> GetAggregateResourceConfigResponse)
-> Lens
     GetAggregateResourceConfigResponse
     GetAggregateResourceConfigResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAggregateResourceConfigResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetAggregateResourceConfigResponse' :: GetAggregateResourceConfigResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetAggregateResourceConfigResponse
s@GetAggregateResourceConfigResponse' {} Int
a -> GetAggregateResourceConfigResponse
s {$sel:httpStatus:GetAggregateResourceConfigResponse' :: Int
httpStatus = Int
a} :: GetAggregateResourceConfigResponse)

instance
  Prelude.NFData
    GetAggregateResourceConfigResponse