{-# 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.AppConfig.GetConfigurationProfile
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information about a configuration profile.
module Amazonka.AppConfig.GetConfigurationProfile
  ( -- * Creating a Request
    GetConfigurationProfile (..),
    newGetConfigurationProfile,

    -- * Request Lenses
    getConfigurationProfile_applicationId,
    getConfigurationProfile_configurationProfileId,

    -- * Destructuring the Response
    ConfigurationProfile (..),
    newConfigurationProfile,

    -- * Response Lenses
    configurationProfile_applicationId,
    configurationProfile_description,
    configurationProfile_id,
    configurationProfile_locationUri,
    configurationProfile_name,
    configurationProfile_retrievalRoleArn,
    configurationProfile_type,
    configurationProfile_validators,
  )
where

import Amazonka.AppConfig.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

-- | /See:/ 'newGetConfigurationProfile' smart constructor.
data GetConfigurationProfile = GetConfigurationProfile'
  { -- | The ID of the application that includes the configuration profile you
    -- want to get.
    GetConfigurationProfile -> Text
applicationId :: Prelude.Text,
    -- | The ID of the configuration profile that you want to get.
    GetConfigurationProfile -> Text
configurationProfileId :: Prelude.Text
  }
  deriving (GetConfigurationProfile -> GetConfigurationProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetConfigurationProfile -> GetConfigurationProfile -> Bool
$c/= :: GetConfigurationProfile -> GetConfigurationProfile -> Bool
== :: GetConfigurationProfile -> GetConfigurationProfile -> Bool
$c== :: GetConfigurationProfile -> GetConfigurationProfile -> Bool
Prelude.Eq, ReadPrec [GetConfigurationProfile]
ReadPrec GetConfigurationProfile
Int -> ReadS GetConfigurationProfile
ReadS [GetConfigurationProfile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetConfigurationProfile]
$creadListPrec :: ReadPrec [GetConfigurationProfile]
readPrec :: ReadPrec GetConfigurationProfile
$creadPrec :: ReadPrec GetConfigurationProfile
readList :: ReadS [GetConfigurationProfile]
$creadList :: ReadS [GetConfigurationProfile]
readsPrec :: Int -> ReadS GetConfigurationProfile
$creadsPrec :: Int -> ReadS GetConfigurationProfile
Prelude.Read, Int -> GetConfigurationProfile -> ShowS
[GetConfigurationProfile] -> ShowS
GetConfigurationProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetConfigurationProfile] -> ShowS
$cshowList :: [GetConfigurationProfile] -> ShowS
show :: GetConfigurationProfile -> String
$cshow :: GetConfigurationProfile -> String
showsPrec :: Int -> GetConfigurationProfile -> ShowS
$cshowsPrec :: Int -> GetConfigurationProfile -> ShowS
Prelude.Show, forall x. Rep GetConfigurationProfile x -> GetConfigurationProfile
forall x. GetConfigurationProfile -> Rep GetConfigurationProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetConfigurationProfile x -> GetConfigurationProfile
$cfrom :: forall x. GetConfigurationProfile -> Rep GetConfigurationProfile x
Prelude.Generic)

-- |
-- Create a value of 'GetConfigurationProfile' 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:
--
-- 'applicationId', 'getConfigurationProfile_applicationId' - The ID of the application that includes the configuration profile you
-- want to get.
--
-- 'configurationProfileId', 'getConfigurationProfile_configurationProfileId' - The ID of the configuration profile that you want to get.
newGetConfigurationProfile ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'configurationProfileId'
  Prelude.Text ->
  GetConfigurationProfile
newGetConfigurationProfile :: Text -> Text -> GetConfigurationProfile
newGetConfigurationProfile
  Text
pApplicationId_
  Text
pConfigurationProfileId_ =
    GetConfigurationProfile'
      { $sel:applicationId:GetConfigurationProfile' :: Text
applicationId =
          Text
pApplicationId_,
        $sel:configurationProfileId:GetConfigurationProfile' :: Text
configurationProfileId = Text
pConfigurationProfileId_
      }

-- | The ID of the application that includes the configuration profile you
-- want to get.
getConfigurationProfile_applicationId :: Lens.Lens' GetConfigurationProfile Prelude.Text
getConfigurationProfile_applicationId :: Lens' GetConfigurationProfile Text
getConfigurationProfile_applicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetConfigurationProfile' {Text
applicationId :: Text
$sel:applicationId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
applicationId} -> Text
applicationId) (\s :: GetConfigurationProfile
s@GetConfigurationProfile' {} Text
a -> GetConfigurationProfile
s {$sel:applicationId:GetConfigurationProfile' :: Text
applicationId = Text
a} :: GetConfigurationProfile)

-- | The ID of the configuration profile that you want to get.
getConfigurationProfile_configurationProfileId :: Lens.Lens' GetConfigurationProfile Prelude.Text
getConfigurationProfile_configurationProfileId :: Lens' GetConfigurationProfile Text
getConfigurationProfile_configurationProfileId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetConfigurationProfile' {Text
configurationProfileId :: Text
$sel:configurationProfileId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
configurationProfileId} -> Text
configurationProfileId) (\s :: GetConfigurationProfile
s@GetConfigurationProfile' {} Text
a -> GetConfigurationProfile
s {$sel:configurationProfileId:GetConfigurationProfile' :: Text
configurationProfileId = Text
a} :: GetConfigurationProfile)

instance Core.AWSRequest GetConfigurationProfile where
  type
    AWSResponse GetConfigurationProfile =
      ConfigurationProfile
  request :: (Service -> Service)
-> GetConfigurationProfile -> Request GetConfigurationProfile
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetConfigurationProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetConfigurationProfile)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable GetConfigurationProfile where
  hashWithSalt :: Int -> GetConfigurationProfile -> Int
hashWithSalt Int
_salt GetConfigurationProfile' {Text
configurationProfileId :: Text
applicationId :: Text
$sel:configurationProfileId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
$sel:applicationId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
configurationProfileId

instance Prelude.NFData GetConfigurationProfile where
  rnf :: GetConfigurationProfile -> ()
rnf GetConfigurationProfile' {Text
configurationProfileId :: Text
applicationId :: Text
$sel:configurationProfileId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
$sel:applicationId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
configurationProfileId

instance Data.ToHeaders GetConfigurationProfile where
  toHeaders :: GetConfigurationProfile -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetConfigurationProfile where
  toPath :: GetConfigurationProfile -> ByteString
toPath GetConfigurationProfile' {Text
configurationProfileId :: Text
applicationId :: Text
$sel:configurationProfileId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
$sel:applicationId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId,
        ByteString
"/configurationprofiles/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
configurationProfileId
      ]

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