{-# 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.GetHostedConfigurationVersion
-- 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)
--
-- Get information about a specific configuration version.
module Amazonka.AppConfig.GetHostedConfigurationVersion
  ( -- * Creating a Request
    GetHostedConfigurationVersion (..),
    newGetHostedConfigurationVersion,

    -- * Request Lenses
    getHostedConfigurationVersion_applicationId,
    getHostedConfigurationVersion_configurationProfileId,
    getHostedConfigurationVersion_versionNumber,

    -- * Destructuring the Response
    HostedConfigurationVersion (..),
    newHostedConfigurationVersion,

    -- * Response Lenses
    hostedConfigurationVersion_content,
    hostedConfigurationVersion_versionNumber,
    hostedConfigurationVersion_applicationId,
    hostedConfigurationVersion_description,
    hostedConfigurationVersion_configurationProfileId,
    hostedConfigurationVersion_contentType,
  )
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:/ 'newGetHostedConfigurationVersion' smart constructor.
data GetHostedConfigurationVersion = GetHostedConfigurationVersion'
  { -- | The application ID.
    GetHostedConfigurationVersion -> Text
applicationId :: Prelude.Text,
    -- | The configuration profile ID.
    GetHostedConfigurationVersion -> Text
configurationProfileId :: Prelude.Text,
    -- | The version.
    GetHostedConfigurationVersion -> Int
versionNumber :: Prelude.Int
  }
  deriving (GetHostedConfigurationVersion
-> GetHostedConfigurationVersion -> Bool
(GetHostedConfigurationVersion
 -> GetHostedConfigurationVersion -> Bool)
-> (GetHostedConfigurationVersion
    -> GetHostedConfigurationVersion -> Bool)
-> Eq GetHostedConfigurationVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetHostedConfigurationVersion
-> GetHostedConfigurationVersion -> Bool
$c/= :: GetHostedConfigurationVersion
-> GetHostedConfigurationVersion -> Bool
== :: GetHostedConfigurationVersion
-> GetHostedConfigurationVersion -> Bool
$c== :: GetHostedConfigurationVersion
-> GetHostedConfigurationVersion -> Bool
Prelude.Eq, ReadPrec [GetHostedConfigurationVersion]
ReadPrec GetHostedConfigurationVersion
Int -> ReadS GetHostedConfigurationVersion
ReadS [GetHostedConfigurationVersion]
(Int -> ReadS GetHostedConfigurationVersion)
-> ReadS [GetHostedConfigurationVersion]
-> ReadPrec GetHostedConfigurationVersion
-> ReadPrec [GetHostedConfigurationVersion]
-> Read GetHostedConfigurationVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetHostedConfigurationVersion]
$creadListPrec :: ReadPrec [GetHostedConfigurationVersion]
readPrec :: ReadPrec GetHostedConfigurationVersion
$creadPrec :: ReadPrec GetHostedConfigurationVersion
readList :: ReadS [GetHostedConfigurationVersion]
$creadList :: ReadS [GetHostedConfigurationVersion]
readsPrec :: Int -> ReadS GetHostedConfigurationVersion
$creadsPrec :: Int -> ReadS GetHostedConfigurationVersion
Prelude.Read, Int -> GetHostedConfigurationVersion -> ShowS
[GetHostedConfigurationVersion] -> ShowS
GetHostedConfigurationVersion -> String
(Int -> GetHostedConfigurationVersion -> ShowS)
-> (GetHostedConfigurationVersion -> String)
-> ([GetHostedConfigurationVersion] -> ShowS)
-> Show GetHostedConfigurationVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetHostedConfigurationVersion] -> ShowS
$cshowList :: [GetHostedConfigurationVersion] -> ShowS
show :: GetHostedConfigurationVersion -> String
$cshow :: GetHostedConfigurationVersion -> String
showsPrec :: Int -> GetHostedConfigurationVersion -> ShowS
$cshowsPrec :: Int -> GetHostedConfigurationVersion -> ShowS
Prelude.Show, (forall x.
 GetHostedConfigurationVersion
 -> Rep GetHostedConfigurationVersion x)
-> (forall x.
    Rep GetHostedConfigurationVersion x
    -> GetHostedConfigurationVersion)
-> Generic GetHostedConfigurationVersion
forall x.
Rep GetHostedConfigurationVersion x
-> GetHostedConfigurationVersion
forall x.
GetHostedConfigurationVersion
-> Rep GetHostedConfigurationVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetHostedConfigurationVersion x
-> GetHostedConfigurationVersion
$cfrom :: forall x.
GetHostedConfigurationVersion
-> Rep GetHostedConfigurationVersion x
Prelude.Generic)

-- |
-- Create a value of 'GetHostedConfigurationVersion' 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', 'getHostedConfigurationVersion_applicationId' - The application ID.
--
-- 'configurationProfileId', 'getHostedConfigurationVersion_configurationProfileId' - The configuration profile ID.
--
-- 'versionNumber', 'getHostedConfigurationVersion_versionNumber' - The version.
newGetHostedConfigurationVersion ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'configurationProfileId'
  Prelude.Text ->
  -- | 'versionNumber'
  Prelude.Int ->
  GetHostedConfigurationVersion
newGetHostedConfigurationVersion :: Text -> Text -> Int -> GetHostedConfigurationVersion
newGetHostedConfigurationVersion
  Text
pApplicationId_
  Text
pConfigurationProfileId_
  Int
pVersionNumber_ =
    GetHostedConfigurationVersion' :: Text -> Text -> Int -> GetHostedConfigurationVersion
GetHostedConfigurationVersion'
      { $sel:applicationId:GetHostedConfigurationVersion' :: Text
applicationId =
          Text
pApplicationId_,
        $sel:configurationProfileId:GetHostedConfigurationVersion' :: Text
configurationProfileId =
          Text
pConfigurationProfileId_,
        $sel:versionNumber:GetHostedConfigurationVersion' :: Int
versionNumber = Int
pVersionNumber_
      }

-- | The application ID.
getHostedConfigurationVersion_applicationId :: Lens.Lens' GetHostedConfigurationVersion Prelude.Text
getHostedConfigurationVersion_applicationId :: (Text -> f Text)
-> GetHostedConfigurationVersion -> f GetHostedConfigurationVersion
getHostedConfigurationVersion_applicationId = (GetHostedConfigurationVersion -> Text)
-> (GetHostedConfigurationVersion
    -> Text -> GetHostedConfigurationVersion)
-> Lens
     GetHostedConfigurationVersion
     GetHostedConfigurationVersion
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetHostedConfigurationVersion' {Text
applicationId :: Text
$sel:applicationId:GetHostedConfigurationVersion' :: GetHostedConfigurationVersion -> Text
applicationId} -> Text
applicationId) (\s :: GetHostedConfigurationVersion
s@GetHostedConfigurationVersion' {} Text
a -> GetHostedConfigurationVersion
s {$sel:applicationId:GetHostedConfigurationVersion' :: Text
applicationId = Text
a} :: GetHostedConfigurationVersion)

-- | The configuration profile ID.
getHostedConfigurationVersion_configurationProfileId :: Lens.Lens' GetHostedConfigurationVersion Prelude.Text
getHostedConfigurationVersion_configurationProfileId :: (Text -> f Text)
-> GetHostedConfigurationVersion -> f GetHostedConfigurationVersion
getHostedConfigurationVersion_configurationProfileId = (GetHostedConfigurationVersion -> Text)
-> (GetHostedConfigurationVersion
    -> Text -> GetHostedConfigurationVersion)
-> Lens
     GetHostedConfigurationVersion
     GetHostedConfigurationVersion
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetHostedConfigurationVersion' {Text
configurationProfileId :: Text
$sel:configurationProfileId:GetHostedConfigurationVersion' :: GetHostedConfigurationVersion -> Text
configurationProfileId} -> Text
configurationProfileId) (\s :: GetHostedConfigurationVersion
s@GetHostedConfigurationVersion' {} Text
a -> GetHostedConfigurationVersion
s {$sel:configurationProfileId:GetHostedConfigurationVersion' :: Text
configurationProfileId = Text
a} :: GetHostedConfigurationVersion)

-- | The version.
getHostedConfigurationVersion_versionNumber :: Lens.Lens' GetHostedConfigurationVersion Prelude.Int
getHostedConfigurationVersion_versionNumber :: (Int -> f Int)
-> GetHostedConfigurationVersion -> f GetHostedConfigurationVersion
getHostedConfigurationVersion_versionNumber = (GetHostedConfigurationVersion -> Int)
-> (GetHostedConfigurationVersion
    -> Int -> GetHostedConfigurationVersion)
-> Lens
     GetHostedConfigurationVersion GetHostedConfigurationVersion Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetHostedConfigurationVersion' {Int
versionNumber :: Int
$sel:versionNumber:GetHostedConfigurationVersion' :: GetHostedConfigurationVersion -> Int
versionNumber} -> Int
versionNumber) (\s :: GetHostedConfigurationVersion
s@GetHostedConfigurationVersion' {} Int
a -> GetHostedConfigurationVersion
s {$sel:versionNumber:GetHostedConfigurationVersion' :: Int
versionNumber = Int
a} :: GetHostedConfigurationVersion)

instance
  Core.AWSRequest
    GetHostedConfigurationVersion
  where
  type
    AWSResponse GetHostedConfigurationVersion =
      HostedConfigurationVersion
  request :: GetHostedConfigurationVersion
-> Request GetHostedConfigurationVersion
request = Service
-> GetHostedConfigurationVersion
-> Request GetHostedConfigurationVersion
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetHostedConfigurationVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetHostedConfigurationVersion)))
response =
    (Int
 -> ResponseHeaders
 -> ByteString
 -> Either String (AWSResponse GetHostedConfigurationVersion))
-> Logger
-> Service
-> Proxy GetHostedConfigurationVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetHostedConfigurationVersion)))
forall (m :: * -> *) a.
MonadResource m =>
(Int
 -> ResponseHeaders -> ByteString -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveBytes
      ( \Int
s ResponseHeaders
h ByteString
x ->
          Maybe (Sensitive ByteString)
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> HostedConfigurationVersion
HostedConfigurationVersion'
            (Maybe (Sensitive ByteString)
 -> Maybe Int
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> HostedConfigurationVersion)
-> Either String (Maybe (Sensitive ByteString))
-> Either
     String
     (Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> HostedConfigurationVersion)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Maybe (Sensitive ByteString)
-> Either String (Maybe (Sensitive ByteString))
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Sensitive ByteString -> Maybe (Sensitive ByteString)
forall a. a -> Maybe a
Prelude.Just (ByteString -> Sensitive ByteString
Prelude.coerce ByteString
x)))
            Either
  String
  (Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> HostedConfigurationVersion)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> HostedConfigurationVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Int)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Version-Number")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> HostedConfigurationVersion)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> HostedConfigurationVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Application-Id")
            Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Text -> HostedConfigurationVersion)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> HostedConfigurationVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Description")
            Either
  String (Maybe Text -> Maybe Text -> HostedConfigurationVersion)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> HostedConfigurationVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Configuration-Profile-Id")
            Either String (Maybe Text -> HostedConfigurationVersion)
-> Either String (Maybe Text)
-> Either String HostedConfigurationVersion
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Content-Type")
      )

instance
  Prelude.Hashable
    GetHostedConfigurationVersion

instance Prelude.NFData GetHostedConfigurationVersion

instance Core.ToHeaders GetHostedConfigurationVersion where
  toHeaders :: GetHostedConfigurationVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetHostedConfigurationVersion -> 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 GetHostedConfigurationVersion where
  toPath :: GetHostedConfigurationVersion -> ByteString
toPath GetHostedConfigurationVersion' {Int
Text
versionNumber :: Int
configurationProfileId :: Text
applicationId :: Text
$sel:versionNumber:GetHostedConfigurationVersion' :: GetHostedConfigurationVersion -> Int
$sel:configurationProfileId:GetHostedConfigurationVersion' :: GetHostedConfigurationVersion -> Text
$sel:applicationId:GetHostedConfigurationVersion' :: GetHostedConfigurationVersion -> 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,
        ByteString
"/hostedconfigurationversions/",
        Int -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Int
versionNumber
      ]

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