{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Get detailed 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 detailed
    -- data for.
    GetEnvironmentTemplate -> Text
name :: Prelude.Text
  }
  deriving (GetEnvironmentTemplate -> GetEnvironmentTemplate -> Bool
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]
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
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. 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 detailed
-- data for.
newGetEnvironmentTemplate ::
  -- | 'name'
  Prelude.Text ->
  GetEnvironmentTemplate
newGetEnvironmentTemplate :: Text -> GetEnvironmentTemplate
newGetEnvironmentTemplate Text
pName_ =
  GetEnvironmentTemplate' {$sel:name:GetEnvironmentTemplate' :: Text
name = Text
pName_}

-- | The name of the environment template that you want to get the detailed
-- data for.
getEnvironmentTemplate_name :: Lens.Lens' GetEnvironmentTemplate Prelude.Text
getEnvironmentTemplate_name :: Lens' GetEnvironmentTemplate Text
getEnvironmentTemplate_name = 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 :: (Service -> Service)
-> GetEnvironmentTemplate -> Request GetEnvironmentTemplate
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetEnvironmentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEnvironmentTemplate)))
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 ->
          Int -> EnvironmentTemplate -> GetEnvironmentTemplateResponse
GetEnvironmentTemplateResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"environmentTemplate")
      )

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

instance Prelude.NFData GetEnvironmentTemplate where
  rnf :: GetEnvironmentTemplate -> ()
rnf GetEnvironmentTemplate' {Text
name :: Text
$sel:name:GetEnvironmentTemplate' :: GetEnvironmentTemplate -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
name

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

instance Data.ToJSON GetEnvironmentTemplate where
  toJSON :: GetEnvironmentTemplate -> Value
toJSON GetEnvironmentTemplate' {Text
name :: Text
$sel:name:GetEnvironmentTemplate' :: GetEnvironmentTemplate -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)]
      )

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

instance Data.ToQuery GetEnvironmentTemplate where
  toQuery :: GetEnvironmentTemplate -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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 detailed data of the requested environment template.
    GetEnvironmentTemplateResponse -> EnvironmentTemplate
environmentTemplate :: EnvironmentTemplate
  }
  deriving (GetEnvironmentTemplateResponse
-> GetEnvironmentTemplateResponse -> Bool
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
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.
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 detailed data of the requested environment template.
newGetEnvironmentTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'environmentTemplate'
  EnvironmentTemplate ->
  GetEnvironmentTemplateResponse
newGetEnvironmentTemplateResponse :: Int -> EnvironmentTemplate -> GetEnvironmentTemplateResponse
newGetEnvironmentTemplateResponse
  Int
pHttpStatus_
  EnvironmentTemplate
pEnvironmentTemplate_ =
    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 :: Lens' GetEnvironmentTemplateResponse Int
getEnvironmentTemplateResponse_httpStatus = 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 detailed data of the requested environment template.
getEnvironmentTemplateResponse_environmentTemplate :: Lens.Lens' GetEnvironmentTemplateResponse EnvironmentTemplate
getEnvironmentTemplateResponse_environmentTemplate :: Lens' GetEnvironmentTemplateResponse EnvironmentTemplate
getEnvironmentTemplateResponse_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
  where
  rnf :: GetEnvironmentTemplateResponse -> ()
rnf GetEnvironmentTemplateResponse' {Int
EnvironmentTemplate
environmentTemplate :: EnvironmentTemplate
httpStatus :: Int
$sel:environmentTemplate:GetEnvironmentTemplateResponse' :: GetEnvironmentTemplateResponse -> EnvironmentTemplate
$sel:httpStatus:GetEnvironmentTemplateResponse' :: GetEnvironmentTemplateResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EnvironmentTemplate
environmentTemplate