{-# 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.GetServiceTemplateVersion
-- 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)
--
-- View detail data for a major or minor version of a service template.
module Amazonka.Proton.GetServiceTemplateVersion
  ( -- * Creating a Request
    GetServiceTemplateVersion (..),
    newGetServiceTemplateVersion,

    -- * Request Lenses
    getServiceTemplateVersion_majorVersion,
    getServiceTemplateVersion_minorVersion,
    getServiceTemplateVersion_templateName,

    -- * Destructuring the Response
    GetServiceTemplateVersionResponse (..),
    newGetServiceTemplateVersionResponse,

    -- * Response Lenses
    getServiceTemplateVersionResponse_httpStatus,
    getServiceTemplateVersionResponse_serviceTemplateVersion,
  )
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:/ 'newGetServiceTemplateVersion' smart constructor.
data GetServiceTemplateVersion = GetServiceTemplateVersion'
  { -- | To view service template major version detail data, include
    -- @majorVersion@.
    GetServiceTemplateVersion -> Text
majorVersion :: Prelude.Text,
    -- | To view service template minor version detail data, include
    -- @minorVersion@.
    GetServiceTemplateVersion -> Text
minorVersion :: Prelude.Text,
    -- | The name of the service template.
    GetServiceTemplateVersion -> Text
templateName :: Prelude.Text
  }
  deriving (GetServiceTemplateVersion -> GetServiceTemplateVersion -> Bool
(GetServiceTemplateVersion -> GetServiceTemplateVersion -> Bool)
-> (GetServiceTemplateVersion -> GetServiceTemplateVersion -> Bool)
-> Eq GetServiceTemplateVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceTemplateVersion -> GetServiceTemplateVersion -> Bool
$c/= :: GetServiceTemplateVersion -> GetServiceTemplateVersion -> Bool
== :: GetServiceTemplateVersion -> GetServiceTemplateVersion -> Bool
$c== :: GetServiceTemplateVersion -> GetServiceTemplateVersion -> Bool
Prelude.Eq, ReadPrec [GetServiceTemplateVersion]
ReadPrec GetServiceTemplateVersion
Int -> ReadS GetServiceTemplateVersion
ReadS [GetServiceTemplateVersion]
(Int -> ReadS GetServiceTemplateVersion)
-> ReadS [GetServiceTemplateVersion]
-> ReadPrec GetServiceTemplateVersion
-> ReadPrec [GetServiceTemplateVersion]
-> Read GetServiceTemplateVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceTemplateVersion]
$creadListPrec :: ReadPrec [GetServiceTemplateVersion]
readPrec :: ReadPrec GetServiceTemplateVersion
$creadPrec :: ReadPrec GetServiceTemplateVersion
readList :: ReadS [GetServiceTemplateVersion]
$creadList :: ReadS [GetServiceTemplateVersion]
readsPrec :: Int -> ReadS GetServiceTemplateVersion
$creadsPrec :: Int -> ReadS GetServiceTemplateVersion
Prelude.Read, Int -> GetServiceTemplateVersion -> ShowS
[GetServiceTemplateVersion] -> ShowS
GetServiceTemplateVersion -> String
(Int -> GetServiceTemplateVersion -> ShowS)
-> (GetServiceTemplateVersion -> String)
-> ([GetServiceTemplateVersion] -> ShowS)
-> Show GetServiceTemplateVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceTemplateVersion] -> ShowS
$cshowList :: [GetServiceTemplateVersion] -> ShowS
show :: GetServiceTemplateVersion -> String
$cshow :: GetServiceTemplateVersion -> String
showsPrec :: Int -> GetServiceTemplateVersion -> ShowS
$cshowsPrec :: Int -> GetServiceTemplateVersion -> ShowS
Prelude.Show, (forall x.
 GetServiceTemplateVersion -> Rep GetServiceTemplateVersion x)
-> (forall x.
    Rep GetServiceTemplateVersion x -> GetServiceTemplateVersion)
-> Generic GetServiceTemplateVersion
forall x.
Rep GetServiceTemplateVersion x -> GetServiceTemplateVersion
forall x.
GetServiceTemplateVersion -> Rep GetServiceTemplateVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetServiceTemplateVersion x -> GetServiceTemplateVersion
$cfrom :: forall x.
GetServiceTemplateVersion -> Rep GetServiceTemplateVersion x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceTemplateVersion' 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:
--
-- 'majorVersion', 'getServiceTemplateVersion_majorVersion' - To view service template major version detail data, include
-- @majorVersion@.
--
-- 'minorVersion', 'getServiceTemplateVersion_minorVersion' - To view service template minor version detail data, include
-- @minorVersion@.
--
-- 'templateName', 'getServiceTemplateVersion_templateName' - The name of the service template.
newGetServiceTemplateVersion ::
  -- | 'majorVersion'
  Prelude.Text ->
  -- | 'minorVersion'
  Prelude.Text ->
  -- | 'templateName'
  Prelude.Text ->
  GetServiceTemplateVersion
newGetServiceTemplateVersion :: Text -> Text -> Text -> GetServiceTemplateVersion
newGetServiceTemplateVersion
  Text
pMajorVersion_
  Text
pMinorVersion_
  Text
pTemplateName_ =
    GetServiceTemplateVersion' :: Text -> Text -> Text -> GetServiceTemplateVersion
GetServiceTemplateVersion'
      { $sel:majorVersion:GetServiceTemplateVersion' :: Text
majorVersion =
          Text
pMajorVersion_,
        $sel:minorVersion:GetServiceTemplateVersion' :: Text
minorVersion = Text
pMinorVersion_,
        $sel:templateName:GetServiceTemplateVersion' :: Text
templateName = Text
pTemplateName_
      }

-- | To view service template major version detail data, include
-- @majorVersion@.
getServiceTemplateVersion_majorVersion :: Lens.Lens' GetServiceTemplateVersion Prelude.Text
getServiceTemplateVersion_majorVersion :: (Text -> f Text)
-> GetServiceTemplateVersion -> f GetServiceTemplateVersion
getServiceTemplateVersion_majorVersion = (GetServiceTemplateVersion -> Text)
-> (GetServiceTemplateVersion -> Text -> GetServiceTemplateVersion)
-> Lens
     GetServiceTemplateVersion GetServiceTemplateVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceTemplateVersion' {Text
majorVersion :: Text
$sel:majorVersion:GetServiceTemplateVersion' :: GetServiceTemplateVersion -> Text
majorVersion} -> Text
majorVersion) (\s :: GetServiceTemplateVersion
s@GetServiceTemplateVersion' {} Text
a -> GetServiceTemplateVersion
s {$sel:majorVersion:GetServiceTemplateVersion' :: Text
majorVersion = Text
a} :: GetServiceTemplateVersion)

-- | To view service template minor version detail data, include
-- @minorVersion@.
getServiceTemplateVersion_minorVersion :: Lens.Lens' GetServiceTemplateVersion Prelude.Text
getServiceTemplateVersion_minorVersion :: (Text -> f Text)
-> GetServiceTemplateVersion -> f GetServiceTemplateVersion
getServiceTemplateVersion_minorVersion = (GetServiceTemplateVersion -> Text)
-> (GetServiceTemplateVersion -> Text -> GetServiceTemplateVersion)
-> Lens
     GetServiceTemplateVersion GetServiceTemplateVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceTemplateVersion' {Text
minorVersion :: Text
$sel:minorVersion:GetServiceTemplateVersion' :: GetServiceTemplateVersion -> Text
minorVersion} -> Text
minorVersion) (\s :: GetServiceTemplateVersion
s@GetServiceTemplateVersion' {} Text
a -> GetServiceTemplateVersion
s {$sel:minorVersion:GetServiceTemplateVersion' :: Text
minorVersion = Text
a} :: GetServiceTemplateVersion)

-- | The name of the service template.
getServiceTemplateVersion_templateName :: Lens.Lens' GetServiceTemplateVersion Prelude.Text
getServiceTemplateVersion_templateName :: (Text -> f Text)
-> GetServiceTemplateVersion -> f GetServiceTemplateVersion
getServiceTemplateVersion_templateName = (GetServiceTemplateVersion -> Text)
-> (GetServiceTemplateVersion -> Text -> GetServiceTemplateVersion)
-> Lens
     GetServiceTemplateVersion GetServiceTemplateVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceTemplateVersion' {Text
templateName :: Text
$sel:templateName:GetServiceTemplateVersion' :: GetServiceTemplateVersion -> Text
templateName} -> Text
templateName) (\s :: GetServiceTemplateVersion
s@GetServiceTemplateVersion' {} Text
a -> GetServiceTemplateVersion
s {$sel:templateName:GetServiceTemplateVersion' :: Text
templateName = Text
a} :: GetServiceTemplateVersion)

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

instance Prelude.Hashable GetServiceTemplateVersion

instance Prelude.NFData GetServiceTemplateVersion

instance Core.ToHeaders GetServiceTemplateVersion where
  toHeaders :: GetServiceTemplateVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetServiceTemplateVersion -> 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.GetServiceTemplateVersion" ::
                          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 GetServiceTemplateVersion where
  toJSON :: GetServiceTemplateVersion -> Value
toJSON GetServiceTemplateVersion' {Text
templateName :: Text
minorVersion :: Text
majorVersion :: Text
$sel:templateName:GetServiceTemplateVersion' :: GetServiceTemplateVersion -> Text
$sel:minorVersion:GetServiceTemplateVersion' :: GetServiceTemplateVersion -> Text
$sel:majorVersion:GetServiceTemplateVersion' :: GetServiceTemplateVersion -> 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
"majorVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
majorVersion),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"minorVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
minorVersion),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"templateName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
templateName)
          ]
      )

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

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

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

-- |
-- Create a value of 'GetServiceTemplateVersionResponse' 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', 'getServiceTemplateVersionResponse_httpStatus' - The response's http status code.
--
-- 'serviceTemplateVersion', 'getServiceTemplateVersionResponse_serviceTemplateVersion' - The service template version detail data that\'s returned by AWS Proton.
newGetServiceTemplateVersionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'serviceTemplateVersion'
  ServiceTemplateVersion ->
  GetServiceTemplateVersionResponse
newGetServiceTemplateVersionResponse :: Int -> ServiceTemplateVersion -> GetServiceTemplateVersionResponse
newGetServiceTemplateVersionResponse
  Int
pHttpStatus_
  ServiceTemplateVersion
pServiceTemplateVersion_ =
    GetServiceTemplateVersionResponse' :: Int -> ServiceTemplateVersion -> GetServiceTemplateVersionResponse
GetServiceTemplateVersionResponse'
      { $sel:httpStatus:GetServiceTemplateVersionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:serviceTemplateVersion:GetServiceTemplateVersionResponse' :: ServiceTemplateVersion
serviceTemplateVersion =
          ServiceTemplateVersion
pServiceTemplateVersion_
      }

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

-- | The service template version detail data that\'s returned by AWS Proton.
getServiceTemplateVersionResponse_serviceTemplateVersion :: Lens.Lens' GetServiceTemplateVersionResponse ServiceTemplateVersion
getServiceTemplateVersionResponse_serviceTemplateVersion :: (ServiceTemplateVersion -> f ServiceTemplateVersion)
-> GetServiceTemplateVersionResponse
-> f GetServiceTemplateVersionResponse
getServiceTemplateVersionResponse_serviceTemplateVersion = (GetServiceTemplateVersionResponse -> ServiceTemplateVersion)
-> (GetServiceTemplateVersionResponse
    -> ServiceTemplateVersion -> GetServiceTemplateVersionResponse)
-> Lens
     GetServiceTemplateVersionResponse
     GetServiceTemplateVersionResponse
     ServiceTemplateVersion
     ServiceTemplateVersion
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceTemplateVersionResponse' {ServiceTemplateVersion
serviceTemplateVersion :: ServiceTemplateVersion
$sel:serviceTemplateVersion:GetServiceTemplateVersionResponse' :: GetServiceTemplateVersionResponse -> ServiceTemplateVersion
serviceTemplateVersion} -> ServiceTemplateVersion
serviceTemplateVersion) (\s :: GetServiceTemplateVersionResponse
s@GetServiceTemplateVersionResponse' {} ServiceTemplateVersion
a -> GetServiceTemplateVersionResponse
s {$sel:serviceTemplateVersion:GetServiceTemplateVersionResponse' :: ServiceTemplateVersion
serviceTemplateVersion = ServiceTemplateVersion
a} :: GetServiceTemplateVersionResponse)

instance
  Prelude.NFData
    GetServiceTemplateVersionResponse