{-# 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.Proton.GetEnvironmentTemplate
-- 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 detail data for an environment template.
module Amazonka.Proton.GetEnvironmentTemplate
  ( -- * Creating a Request
    GetEnvironmentTemplate (..),
    newGetEnvironmentTemplate,

    -- * Request Lenses
    getEnvironmentTemplate_name,

    -- * Destructuring the Response
    GetEnvironmentTemplateResponse (..),
    newGetEnvironmentTemplateResponse,

    -- * Response Lenses
    getEnvironmentTemplateResponse_httpStatus,
    getEnvironmentTemplateResponse_environmentTemplate,
  )
where

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

-- | /See:/ 'newGetEnvironmentTemplate' smart constructor.
data GetEnvironmentTemplate = GetEnvironmentTemplate'
  { -- | The name of the environment template that you want to get the detail
    -- data for.
    GetEnvironmentTemplate -> Text
name :: Prelude.Text
  }
  deriving (GetEnvironmentTemplate -> GetEnvironmentTemplate -> Bool
(GetEnvironmentTemplate -> GetEnvironmentTemplate -> Bool)
-> (GetEnvironmentTemplate -> GetEnvironmentTemplate -> Bool)
-> Eq GetEnvironmentTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEnvironmentTemplate -> GetEnvironmentTemplate -> Bool
$c/= :: GetEnvironmentTemplate -> GetEnvironmentTemplate -> Bool
== :: GetEnvironmentTemplate -> GetEnvironmentTemplate -> Bool
$c== :: GetEnvironmentTemplate -> GetEnvironmentTemplate -> Bool
Prelude.Eq, ReadPrec [GetEnvironmentTemplate]
ReadPrec GetEnvironmentTemplate
Int -> ReadS GetEnvironmentTemplate
ReadS [GetEnvironmentTemplate]
(Int -> ReadS GetEnvironmentTemplate)
-> ReadS [GetEnvironmentTemplate]
-> ReadPrec GetEnvironmentTemplate
-> ReadPrec [GetEnvironmentTemplate]
-> Read GetEnvironmentTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEnvironmentTemplate]
$creadListPrec :: ReadPrec [GetEnvironmentTemplate]
readPrec :: ReadPrec GetEnvironmentTemplate
$creadPrec :: ReadPrec GetEnvironmentTemplate
readList :: ReadS [GetEnvironmentTemplate]
$creadList :: ReadS [GetEnvironmentTemplate]
readsPrec :: Int -> ReadS GetEnvironmentTemplate
$creadsPrec :: Int -> ReadS GetEnvironmentTemplate
Prelude.Read, Int -> GetEnvironmentTemplate -> ShowS
[GetEnvironmentTemplate] -> ShowS
GetEnvironmentTemplate -> String
(Int -> GetEnvironmentTemplate -> ShowS)
-> (GetEnvironmentTemplate -> String)
-> ([GetEnvironmentTemplate] -> ShowS)
-> Show GetEnvironmentTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEnvironmentTemplate] -> ShowS
$cshowList :: [GetEnvironmentTemplate] -> ShowS
show :: GetEnvironmentTemplate -> String
$cshow :: GetEnvironmentTemplate -> String
showsPrec :: Int -> GetEnvironmentTemplate -> ShowS
$cshowsPrec :: Int -> GetEnvironmentTemplate -> ShowS
Prelude.Show, (forall x. GetEnvironmentTemplate -> Rep GetEnvironmentTemplate x)
-> (forall x.
    Rep GetEnvironmentTemplate x -> GetEnvironmentTemplate)
-> Generic GetEnvironmentTemplate
forall x. Rep GetEnvironmentTemplate x -> GetEnvironmentTemplate
forall x. GetEnvironmentTemplate -> Rep GetEnvironmentTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEnvironmentTemplate x -> GetEnvironmentTemplate
$cfrom :: forall x. GetEnvironmentTemplate -> Rep GetEnvironmentTemplate x
Prelude.Generic)

-- |
-- Create a value of 'GetEnvironmentTemplate' 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:
--
-- 'name', 'getEnvironmentTemplate_name' - The name of the environment template that you want to get the detail
-- data for.
newGetEnvironmentTemplate ::
  -- | 'name'
  Prelude.Text ->
  GetEnvironmentTemplate
newGetEnvironmentTemplate :: Text -> GetEnvironmentTemplate
newGetEnvironmentTemplate Text
pName_ =
  GetEnvironmentTemplate' :: Text -> GetEnvironmentTemplate
GetEnvironmentTemplate' {$sel:name:GetEnvironmentTemplate' :: Text
name = Text
pName_}

-- | The name of the environment template that you want to get the detail
-- data for.
getEnvironmentTemplate_name :: Lens.Lens' GetEnvironmentTemplate Prelude.Text
getEnvironmentTemplate_name :: (Text -> f Text)
-> GetEnvironmentTemplate -> f GetEnvironmentTemplate
getEnvironmentTemplate_name = (GetEnvironmentTemplate -> Text)
-> (GetEnvironmentTemplate -> Text -> GetEnvironmentTemplate)
-> Lens GetEnvironmentTemplate GetEnvironmentTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEnvironmentTemplate' {Text
name :: Text
$sel:name:GetEnvironmentTemplate' :: GetEnvironmentTemplate -> Text
name} -> Text
name) (\s :: GetEnvironmentTemplate
s@GetEnvironmentTemplate' {} Text
a -> GetEnvironmentTemplate
s {$sel:name:GetEnvironmentTemplate' :: Text
name = Text
a} :: GetEnvironmentTemplate)

instance Core.AWSRequest GetEnvironmentTemplate where
  type
    AWSResponse GetEnvironmentTemplate =
      GetEnvironmentTemplateResponse
  request :: GetEnvironmentTemplate -> Request GetEnvironmentTemplate
request = Service -> GetEnvironmentTemplate -> Request GetEnvironmentTemplate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetEnvironmentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEnvironmentTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetEnvironmentTemplate))
-> Logger
-> Service
-> Proxy GetEnvironmentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEnvironmentTemplate)))
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 ->
          Int -> EnvironmentTemplate -> GetEnvironmentTemplateResponse
GetEnvironmentTemplateResponse'
            (Int -> EnvironmentTemplate -> GetEnvironmentTemplateResponse)
-> Either String Int
-> Either
     String (EnvironmentTemplate -> GetEnvironmentTemplateResponse)
forall (f :: * -> *) a b. Functor 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))
            Either
  String (EnvironmentTemplate -> GetEnvironmentTemplateResponse)
-> Either String EnvironmentTemplate
-> Either String GetEnvironmentTemplateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String EnvironmentTemplate
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"environmentTemplate")
      )

instance Prelude.Hashable GetEnvironmentTemplate

instance Prelude.NFData GetEnvironmentTemplate

instance Core.ToHeaders GetEnvironmentTemplate where
  toHeaders :: GetEnvironmentTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetEnvironmentTemplate -> 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
"AwsProton20200720.GetEnvironmentTemplate" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetEnvironmentTemplate where
  toJSON :: GetEnvironmentTemplate -> Value
toJSON GetEnvironmentTemplate' {Text
name :: Text
$sel:name:GetEnvironmentTemplate' :: GetEnvironmentTemplate -> 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
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)]
      )

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

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

-- | /See:/ 'newGetEnvironmentTemplateResponse' smart constructor.
data GetEnvironmentTemplateResponse = GetEnvironmentTemplateResponse'
  { -- | The response's http status code.
    GetEnvironmentTemplateResponse -> Int
httpStatus :: Prelude.Int,
    -- | The environment template detail data that\'s returned by AWS Proton.
    GetEnvironmentTemplateResponse -> EnvironmentTemplate
environmentTemplate :: EnvironmentTemplate
  }
  deriving (GetEnvironmentTemplateResponse
-> GetEnvironmentTemplateResponse -> Bool
(GetEnvironmentTemplateResponse
 -> GetEnvironmentTemplateResponse -> Bool)
-> (GetEnvironmentTemplateResponse
    -> GetEnvironmentTemplateResponse -> Bool)
-> Eq GetEnvironmentTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEnvironmentTemplateResponse
-> GetEnvironmentTemplateResponse -> Bool
$c/= :: GetEnvironmentTemplateResponse
-> GetEnvironmentTemplateResponse -> Bool
== :: GetEnvironmentTemplateResponse
-> GetEnvironmentTemplateResponse -> Bool
$c== :: GetEnvironmentTemplateResponse
-> GetEnvironmentTemplateResponse -> Bool
Prelude.Eq, Int -> GetEnvironmentTemplateResponse -> ShowS
[GetEnvironmentTemplateResponse] -> ShowS
GetEnvironmentTemplateResponse -> String
(Int -> GetEnvironmentTemplateResponse -> ShowS)
-> (GetEnvironmentTemplateResponse -> String)
-> ([GetEnvironmentTemplateResponse] -> ShowS)
-> Show GetEnvironmentTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEnvironmentTemplateResponse] -> ShowS
$cshowList :: [GetEnvironmentTemplateResponse] -> ShowS
show :: GetEnvironmentTemplateResponse -> String
$cshow :: GetEnvironmentTemplateResponse -> String
showsPrec :: Int -> GetEnvironmentTemplateResponse -> ShowS
$cshowsPrec :: Int -> GetEnvironmentTemplateResponse -> ShowS
Prelude.Show, (forall x.
 GetEnvironmentTemplateResponse
 -> Rep GetEnvironmentTemplateResponse x)
-> (forall x.
    Rep GetEnvironmentTemplateResponse x
    -> GetEnvironmentTemplateResponse)
-> Generic GetEnvironmentTemplateResponse
forall x.
Rep GetEnvironmentTemplateResponse x
-> GetEnvironmentTemplateResponse
forall x.
GetEnvironmentTemplateResponse
-> Rep GetEnvironmentTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEnvironmentTemplateResponse x
-> GetEnvironmentTemplateResponse
$cfrom :: forall x.
GetEnvironmentTemplateResponse
-> Rep GetEnvironmentTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetEnvironmentTemplateResponse' 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:
--
-- 'httpStatus', 'getEnvironmentTemplateResponse_httpStatus' - The response's http status code.
--
-- 'environmentTemplate', 'getEnvironmentTemplateResponse_environmentTemplate' - The environment template detail data that\'s returned by AWS Proton.
newGetEnvironmentTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'environmentTemplate'
  EnvironmentTemplate ->
  GetEnvironmentTemplateResponse
newGetEnvironmentTemplateResponse :: Int -> EnvironmentTemplate -> GetEnvironmentTemplateResponse
newGetEnvironmentTemplateResponse
  Int
pHttpStatus_
  EnvironmentTemplate
pEnvironmentTemplate_ =
    GetEnvironmentTemplateResponse' :: Int -> EnvironmentTemplate -> GetEnvironmentTemplateResponse
GetEnvironmentTemplateResponse'
      { $sel:httpStatus:GetEnvironmentTemplateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:environmentTemplate:GetEnvironmentTemplateResponse' :: EnvironmentTemplate
environmentTemplate = EnvironmentTemplate
pEnvironmentTemplate_
      }

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

-- | The environment template detail data that\'s returned by AWS Proton.
getEnvironmentTemplateResponse_environmentTemplate :: Lens.Lens' GetEnvironmentTemplateResponse EnvironmentTemplate
getEnvironmentTemplateResponse_environmentTemplate :: (EnvironmentTemplate -> f EnvironmentTemplate)
-> GetEnvironmentTemplateResponse
-> f GetEnvironmentTemplateResponse
getEnvironmentTemplateResponse_environmentTemplate = (GetEnvironmentTemplateResponse -> EnvironmentTemplate)
-> (GetEnvironmentTemplateResponse
    -> EnvironmentTemplate -> GetEnvironmentTemplateResponse)
-> Lens
     GetEnvironmentTemplateResponse
     GetEnvironmentTemplateResponse
     EnvironmentTemplate
     EnvironmentTemplate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEnvironmentTemplateResponse' {EnvironmentTemplate
environmentTemplate :: EnvironmentTemplate
$sel:environmentTemplate:GetEnvironmentTemplateResponse' :: GetEnvironmentTemplateResponse -> EnvironmentTemplate
environmentTemplate} -> EnvironmentTemplate
environmentTemplate) (\s :: GetEnvironmentTemplateResponse
s@GetEnvironmentTemplateResponse' {} EnvironmentTemplate
a -> GetEnvironmentTemplateResponse
s {$sel:environmentTemplate:GetEnvironmentTemplateResponse' :: EnvironmentTemplate
environmentTemplate = EnvironmentTemplate
a} :: GetEnvironmentTemplateResponse)

instance
  Prelude.NFData
    GetEnvironmentTemplateResponse