{-# 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.GetServiceTemplate
-- 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 a service template.
module Amazonka.Proton.GetServiceTemplate
  ( -- * Creating a Request
    GetServiceTemplate (..),
    newGetServiceTemplate,

    -- * Request Lenses
    getServiceTemplate_name,

    -- * Destructuring the Response
    GetServiceTemplateResponse (..),
    newGetServiceTemplateResponse,

    -- * Response Lenses
    getServiceTemplateResponse_httpStatus,
    getServiceTemplateResponse_serviceTemplate,
  )
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:/ 'newGetServiceTemplate' smart constructor.
data GetServiceTemplate = GetServiceTemplate'
  { -- | The name of the service template that you want to get detail data for.
    GetServiceTemplate -> Text
name :: Prelude.Text
  }
  deriving (GetServiceTemplate -> GetServiceTemplate -> Bool
(GetServiceTemplate -> GetServiceTemplate -> Bool)
-> (GetServiceTemplate -> GetServiceTemplate -> Bool)
-> Eq GetServiceTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceTemplate -> GetServiceTemplate -> Bool
$c/= :: GetServiceTemplate -> GetServiceTemplate -> Bool
== :: GetServiceTemplate -> GetServiceTemplate -> Bool
$c== :: GetServiceTemplate -> GetServiceTemplate -> Bool
Prelude.Eq, ReadPrec [GetServiceTemplate]
ReadPrec GetServiceTemplate
Int -> ReadS GetServiceTemplate
ReadS [GetServiceTemplate]
(Int -> ReadS GetServiceTemplate)
-> ReadS [GetServiceTemplate]
-> ReadPrec GetServiceTemplate
-> ReadPrec [GetServiceTemplate]
-> Read GetServiceTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceTemplate]
$creadListPrec :: ReadPrec [GetServiceTemplate]
readPrec :: ReadPrec GetServiceTemplate
$creadPrec :: ReadPrec GetServiceTemplate
readList :: ReadS [GetServiceTemplate]
$creadList :: ReadS [GetServiceTemplate]
readsPrec :: Int -> ReadS GetServiceTemplate
$creadsPrec :: Int -> ReadS GetServiceTemplate
Prelude.Read, Int -> GetServiceTemplate -> ShowS
[GetServiceTemplate] -> ShowS
GetServiceTemplate -> String
(Int -> GetServiceTemplate -> ShowS)
-> (GetServiceTemplate -> String)
-> ([GetServiceTemplate] -> ShowS)
-> Show GetServiceTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceTemplate] -> ShowS
$cshowList :: [GetServiceTemplate] -> ShowS
show :: GetServiceTemplate -> String
$cshow :: GetServiceTemplate -> String
showsPrec :: Int -> GetServiceTemplate -> ShowS
$cshowsPrec :: Int -> GetServiceTemplate -> ShowS
Prelude.Show, (forall x. GetServiceTemplate -> Rep GetServiceTemplate x)
-> (forall x. Rep GetServiceTemplate x -> GetServiceTemplate)
-> Generic GetServiceTemplate
forall x. Rep GetServiceTemplate x -> GetServiceTemplate
forall x. GetServiceTemplate -> Rep GetServiceTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetServiceTemplate x -> GetServiceTemplate
$cfrom :: forall x. GetServiceTemplate -> Rep GetServiceTemplate x
Prelude.Generic)

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

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

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

instance Prelude.Hashable GetServiceTemplate

instance Prelude.NFData GetServiceTemplate

instance Core.ToHeaders GetServiceTemplate where
  toHeaders :: GetServiceTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetServiceTemplate -> 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.GetServiceTemplate" ::
                          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 GetServiceTemplate where
  toJSON :: GetServiceTemplate -> Value
toJSON GetServiceTemplate' {Text
name :: Text
$sel:name:GetServiceTemplate' :: GetServiceTemplate -> 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 GetServiceTemplate where
  toPath :: GetServiceTemplate -> ByteString
toPath = ByteString -> GetServiceTemplate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetServiceTemplateResponse' 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', 'getServiceTemplateResponse_httpStatus' - The response's http status code.
--
-- 'serviceTemplate', 'getServiceTemplateResponse_serviceTemplate' - The service template detail data that\'s returned by AWS Proton.
newGetServiceTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'serviceTemplate'
  ServiceTemplate ->
  GetServiceTemplateResponse
newGetServiceTemplateResponse :: Int -> ServiceTemplate -> GetServiceTemplateResponse
newGetServiceTemplateResponse
  Int
pHttpStatus_
  ServiceTemplate
pServiceTemplate_ =
    GetServiceTemplateResponse' :: Int -> ServiceTemplate -> GetServiceTemplateResponse
GetServiceTemplateResponse'
      { $sel:httpStatus:GetServiceTemplateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:serviceTemplate:GetServiceTemplateResponse' :: ServiceTemplate
serviceTemplate = ServiceTemplate
pServiceTemplate_
      }

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

-- | The service template detail data that\'s returned by AWS Proton.
getServiceTemplateResponse_serviceTemplate :: Lens.Lens' GetServiceTemplateResponse ServiceTemplate
getServiceTemplateResponse_serviceTemplate :: (ServiceTemplate -> f ServiceTemplate)
-> GetServiceTemplateResponse -> f GetServiceTemplateResponse
getServiceTemplateResponse_serviceTemplate = (GetServiceTemplateResponse -> ServiceTemplate)
-> (GetServiceTemplateResponse
    -> ServiceTemplate -> GetServiceTemplateResponse)
-> Lens
     GetServiceTemplateResponse
     GetServiceTemplateResponse
     ServiceTemplate
     ServiceTemplate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceTemplateResponse' {ServiceTemplate
serviceTemplate :: ServiceTemplate
$sel:serviceTemplate:GetServiceTemplateResponse' :: GetServiceTemplateResponse -> ServiceTemplate
serviceTemplate} -> ServiceTemplate
serviceTemplate) (\s :: GetServiceTemplateResponse
s@GetServiceTemplateResponse' {} ServiceTemplate
a -> GetServiceTemplateResponse
s {$sel:serviceTemplate:GetServiceTemplateResponse' :: ServiceTemplate
serviceTemplate = ServiceTemplate
a} :: GetServiceTemplateResponse)

instance Prelude.NFData GetServiceTemplateResponse