{-# 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-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)
--
-- Retrieve 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_retrievalRoleArn,
    configurationProfile_validators,
    configurationProfile_locationUri,
    configurationProfile_applicationId,
    configurationProfile_name,
    configurationProfile_id,
    configurationProfile_description,
  )
where

import Amazonka.AppConfig.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:/ '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 you want to get.
    GetConfigurationProfile -> Text
configurationProfileId :: Prelude.Text
  }
  deriving (GetConfigurationProfile -> GetConfigurationProfile -> Bool
(GetConfigurationProfile -> GetConfigurationProfile -> Bool)
-> (GetConfigurationProfile -> GetConfigurationProfile -> Bool)
-> Eq GetConfigurationProfile
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]
(Int -> ReadS GetConfigurationProfile)
-> ReadS [GetConfigurationProfile]
-> ReadPrec GetConfigurationProfile
-> ReadPrec [GetConfigurationProfile]
-> Read 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
(Int -> GetConfigurationProfile -> ShowS)
-> (GetConfigurationProfile -> String)
-> ([GetConfigurationProfile] -> ShowS)
-> Show GetConfigurationProfile
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.
 GetConfigurationProfile -> Rep GetConfigurationProfile x)
-> (forall x.
    Rep GetConfigurationProfile x -> GetConfigurationProfile)
-> Generic GetConfigurationProfile
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 you want to get.
newGetConfigurationProfile ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'configurationProfileId'
  Prelude.Text ->
  GetConfigurationProfile
newGetConfigurationProfile :: Text -> Text -> GetConfigurationProfile
newGetConfigurationProfile
  Text
pApplicationId_
  Text
pConfigurationProfileId_ =
    GetConfigurationProfile' :: Text -> Text -> GetConfigurationProfile
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 :: (Text -> f Text)
-> GetConfigurationProfile -> f GetConfigurationProfile
getConfigurationProfile_applicationId = (GetConfigurationProfile -> Text)
-> (GetConfigurationProfile -> Text -> GetConfigurationProfile)
-> Lens GetConfigurationProfile GetConfigurationProfile Text Text
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 you want to get.
getConfigurationProfile_configurationProfileId :: Lens.Lens' GetConfigurationProfile Prelude.Text
getConfigurationProfile_configurationProfileId :: (Text -> f Text)
-> GetConfigurationProfile -> f GetConfigurationProfile
getConfigurationProfile_configurationProfileId = (GetConfigurationProfile -> Text)
-> (GetConfigurationProfile -> Text -> GetConfigurationProfile)
-> Lens GetConfigurationProfile GetConfigurationProfile Text Text
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 :: GetConfigurationProfile -> Request GetConfigurationProfile
request = Service
-> GetConfigurationProfile -> Request GetConfigurationProfile
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetConfigurationProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetConfigurationProfile)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetConfigurationProfile))
-> Logger
-> Service
-> Proxy GetConfigurationProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetConfigurationProfile)))
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 -> Object -> Either String ConfigurationProfile
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetConfigurationProfile

instance Prelude.NFData GetConfigurationProfile

instance Core.ToHeaders GetConfigurationProfile where
  toHeaders :: GetConfigurationProfile -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetConfigurationProfile -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetConfigurationProfile where
  toPath :: GetConfigurationProfile -> ByteString
toPath GetConfigurationProfile' {Text
configurationProfileId :: Text
applicationId :: Text
$sel:configurationProfileId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
$sel:applicationId:GetConfigurationProfile' :: GetConfigurationProfile -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/configurationprofiles/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
configurationProfileId
      ]

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