{-# 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.GetTemplateSyncConfig
-- 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 detail data for a template sync configuration.
module Amazonka.Proton.GetTemplateSyncConfig
  ( -- * Creating a Request
    GetTemplateSyncConfig (..),
    newGetTemplateSyncConfig,

    -- * Request Lenses
    getTemplateSyncConfig_templateName,
    getTemplateSyncConfig_templateType,

    -- * Destructuring the Response
    GetTemplateSyncConfigResponse (..),
    newGetTemplateSyncConfigResponse,

    -- * Response Lenses
    getTemplateSyncConfigResponse_templateSyncConfig,
    getTemplateSyncConfigResponse_httpStatus,
  )
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:/ 'newGetTemplateSyncConfig' smart constructor.
data GetTemplateSyncConfig = GetTemplateSyncConfig'
  { -- | The template name.
    GetTemplateSyncConfig -> Text
templateName :: Prelude.Text,
    -- | The template type.
    GetTemplateSyncConfig -> TemplateType
templateType :: TemplateType
  }
  deriving (GetTemplateSyncConfig -> GetTemplateSyncConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTemplateSyncConfig -> GetTemplateSyncConfig -> Bool
$c/= :: GetTemplateSyncConfig -> GetTemplateSyncConfig -> Bool
== :: GetTemplateSyncConfig -> GetTemplateSyncConfig -> Bool
$c== :: GetTemplateSyncConfig -> GetTemplateSyncConfig -> Bool
Prelude.Eq, ReadPrec [GetTemplateSyncConfig]
ReadPrec GetTemplateSyncConfig
Int -> ReadS GetTemplateSyncConfig
ReadS [GetTemplateSyncConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTemplateSyncConfig]
$creadListPrec :: ReadPrec [GetTemplateSyncConfig]
readPrec :: ReadPrec GetTemplateSyncConfig
$creadPrec :: ReadPrec GetTemplateSyncConfig
readList :: ReadS [GetTemplateSyncConfig]
$creadList :: ReadS [GetTemplateSyncConfig]
readsPrec :: Int -> ReadS GetTemplateSyncConfig
$creadsPrec :: Int -> ReadS GetTemplateSyncConfig
Prelude.Read, Int -> GetTemplateSyncConfig -> ShowS
[GetTemplateSyncConfig] -> ShowS
GetTemplateSyncConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTemplateSyncConfig] -> ShowS
$cshowList :: [GetTemplateSyncConfig] -> ShowS
show :: GetTemplateSyncConfig -> String
$cshow :: GetTemplateSyncConfig -> String
showsPrec :: Int -> GetTemplateSyncConfig -> ShowS
$cshowsPrec :: Int -> GetTemplateSyncConfig -> ShowS
Prelude.Show, forall x. Rep GetTemplateSyncConfig x -> GetTemplateSyncConfig
forall x. GetTemplateSyncConfig -> Rep GetTemplateSyncConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTemplateSyncConfig x -> GetTemplateSyncConfig
$cfrom :: forall x. GetTemplateSyncConfig -> Rep GetTemplateSyncConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetTemplateSyncConfig' 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:
--
-- 'templateName', 'getTemplateSyncConfig_templateName' - The template name.
--
-- 'templateType', 'getTemplateSyncConfig_templateType' - The template type.
newGetTemplateSyncConfig ::
  -- | 'templateName'
  Prelude.Text ->
  -- | 'templateType'
  TemplateType ->
  GetTemplateSyncConfig
newGetTemplateSyncConfig :: Text -> TemplateType -> GetTemplateSyncConfig
newGetTemplateSyncConfig
  Text
pTemplateName_
  TemplateType
pTemplateType_ =
    GetTemplateSyncConfig'
      { $sel:templateName:GetTemplateSyncConfig' :: Text
templateName =
          Text
pTemplateName_,
        $sel:templateType:GetTemplateSyncConfig' :: TemplateType
templateType = TemplateType
pTemplateType_
      }

-- | The template name.
getTemplateSyncConfig_templateName :: Lens.Lens' GetTemplateSyncConfig Prelude.Text
getTemplateSyncConfig_templateName :: Lens' GetTemplateSyncConfig Text
getTemplateSyncConfig_templateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTemplateSyncConfig' {Text
templateName :: Text
$sel:templateName:GetTemplateSyncConfig' :: GetTemplateSyncConfig -> Text
templateName} -> Text
templateName) (\s :: GetTemplateSyncConfig
s@GetTemplateSyncConfig' {} Text
a -> GetTemplateSyncConfig
s {$sel:templateName:GetTemplateSyncConfig' :: Text
templateName = Text
a} :: GetTemplateSyncConfig)

-- | The template type.
getTemplateSyncConfig_templateType :: Lens.Lens' GetTemplateSyncConfig TemplateType
getTemplateSyncConfig_templateType :: Lens' GetTemplateSyncConfig TemplateType
getTemplateSyncConfig_templateType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTemplateSyncConfig' {TemplateType
templateType :: TemplateType
$sel:templateType:GetTemplateSyncConfig' :: GetTemplateSyncConfig -> TemplateType
templateType} -> TemplateType
templateType) (\s :: GetTemplateSyncConfig
s@GetTemplateSyncConfig' {} TemplateType
a -> GetTemplateSyncConfig
s {$sel:templateType:GetTemplateSyncConfig' :: TemplateType
templateType = TemplateType
a} :: GetTemplateSyncConfig)

instance Core.AWSRequest GetTemplateSyncConfig where
  type
    AWSResponse GetTemplateSyncConfig =
      GetTemplateSyncConfigResponse
  request :: (Service -> Service)
-> GetTemplateSyncConfig -> Request GetTemplateSyncConfig
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 GetTemplateSyncConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetTemplateSyncConfig)))
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 ->
          Maybe TemplateSyncConfig -> Int -> GetTemplateSyncConfigResponse
GetTemplateSyncConfigResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"templateSyncConfig")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetTemplateSyncConfig where
  hashWithSalt :: Int -> GetTemplateSyncConfig -> Int
hashWithSalt Int
_salt GetTemplateSyncConfig' {Text
TemplateType
templateType :: TemplateType
templateName :: Text
$sel:templateType:GetTemplateSyncConfig' :: GetTemplateSyncConfig -> TemplateType
$sel:templateName:GetTemplateSyncConfig' :: GetTemplateSyncConfig -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
templateName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TemplateType
templateType

instance Prelude.NFData GetTemplateSyncConfig where
  rnf :: GetTemplateSyncConfig -> ()
rnf GetTemplateSyncConfig' {Text
TemplateType
templateType :: TemplateType
templateName :: Text
$sel:templateType:GetTemplateSyncConfig' :: GetTemplateSyncConfig -> TemplateType
$sel:templateName:GetTemplateSyncConfig' :: GetTemplateSyncConfig -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
templateName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TemplateType
templateType

instance Data.ToHeaders GetTemplateSyncConfig where
  toHeaders :: GetTemplateSyncConfig -> 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.GetTemplateSyncConfig" ::
                          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 GetTemplateSyncConfig where
  toJSON :: GetTemplateSyncConfig -> Value
toJSON GetTemplateSyncConfig' {Text
TemplateType
templateType :: TemplateType
templateName :: Text
$sel:templateType:GetTemplateSyncConfig' :: GetTemplateSyncConfig -> TemplateType
$sel:templateName:GetTemplateSyncConfig' :: GetTemplateSyncConfig -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"templateName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
templateName),
            forall a. a -> Maybe a
Prelude.Just (Key
"templateType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TemplateType
templateType)
          ]
      )

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

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

-- | /See:/ 'newGetTemplateSyncConfigResponse' smart constructor.
data GetTemplateSyncConfigResponse = GetTemplateSyncConfigResponse'
  { -- | The template sync configuration detail data that\'s returned by Proton.
    GetTemplateSyncConfigResponse -> Maybe TemplateSyncConfig
templateSyncConfig :: Prelude.Maybe TemplateSyncConfig,
    -- | The response's http status code.
    GetTemplateSyncConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetTemplateSyncConfigResponse
-> GetTemplateSyncConfigResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTemplateSyncConfigResponse
-> GetTemplateSyncConfigResponse -> Bool
$c/= :: GetTemplateSyncConfigResponse
-> GetTemplateSyncConfigResponse -> Bool
== :: GetTemplateSyncConfigResponse
-> GetTemplateSyncConfigResponse -> Bool
$c== :: GetTemplateSyncConfigResponse
-> GetTemplateSyncConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetTemplateSyncConfigResponse]
ReadPrec GetTemplateSyncConfigResponse
Int -> ReadS GetTemplateSyncConfigResponse
ReadS [GetTemplateSyncConfigResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTemplateSyncConfigResponse]
$creadListPrec :: ReadPrec [GetTemplateSyncConfigResponse]
readPrec :: ReadPrec GetTemplateSyncConfigResponse
$creadPrec :: ReadPrec GetTemplateSyncConfigResponse
readList :: ReadS [GetTemplateSyncConfigResponse]
$creadList :: ReadS [GetTemplateSyncConfigResponse]
readsPrec :: Int -> ReadS GetTemplateSyncConfigResponse
$creadsPrec :: Int -> ReadS GetTemplateSyncConfigResponse
Prelude.Read, Int -> GetTemplateSyncConfigResponse -> ShowS
[GetTemplateSyncConfigResponse] -> ShowS
GetTemplateSyncConfigResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTemplateSyncConfigResponse] -> ShowS
$cshowList :: [GetTemplateSyncConfigResponse] -> ShowS
show :: GetTemplateSyncConfigResponse -> String
$cshow :: GetTemplateSyncConfigResponse -> String
showsPrec :: Int -> GetTemplateSyncConfigResponse -> ShowS
$cshowsPrec :: Int -> GetTemplateSyncConfigResponse -> ShowS
Prelude.Show, forall x.
Rep GetTemplateSyncConfigResponse x
-> GetTemplateSyncConfigResponse
forall x.
GetTemplateSyncConfigResponse
-> Rep GetTemplateSyncConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetTemplateSyncConfigResponse x
-> GetTemplateSyncConfigResponse
$cfrom :: forall x.
GetTemplateSyncConfigResponse
-> Rep GetTemplateSyncConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetTemplateSyncConfigResponse' 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:
--
-- 'templateSyncConfig', 'getTemplateSyncConfigResponse_templateSyncConfig' - The template sync configuration detail data that\'s returned by Proton.
--
-- 'httpStatus', 'getTemplateSyncConfigResponse_httpStatus' - The response's http status code.
newGetTemplateSyncConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetTemplateSyncConfigResponse
newGetTemplateSyncConfigResponse :: Int -> GetTemplateSyncConfigResponse
newGetTemplateSyncConfigResponse Int
pHttpStatus_ =
  GetTemplateSyncConfigResponse'
    { $sel:templateSyncConfig:GetTemplateSyncConfigResponse' :: Maybe TemplateSyncConfig
templateSyncConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetTemplateSyncConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The template sync configuration detail data that\'s returned by Proton.
getTemplateSyncConfigResponse_templateSyncConfig :: Lens.Lens' GetTemplateSyncConfigResponse (Prelude.Maybe TemplateSyncConfig)
getTemplateSyncConfigResponse_templateSyncConfig :: Lens' GetTemplateSyncConfigResponse (Maybe TemplateSyncConfig)
getTemplateSyncConfigResponse_templateSyncConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTemplateSyncConfigResponse' {Maybe TemplateSyncConfig
templateSyncConfig :: Maybe TemplateSyncConfig
$sel:templateSyncConfig:GetTemplateSyncConfigResponse' :: GetTemplateSyncConfigResponse -> Maybe TemplateSyncConfig
templateSyncConfig} -> Maybe TemplateSyncConfig
templateSyncConfig) (\s :: GetTemplateSyncConfigResponse
s@GetTemplateSyncConfigResponse' {} Maybe TemplateSyncConfig
a -> GetTemplateSyncConfigResponse
s {$sel:templateSyncConfig:GetTemplateSyncConfigResponse' :: Maybe TemplateSyncConfig
templateSyncConfig = Maybe TemplateSyncConfig
a} :: GetTemplateSyncConfigResponse)

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

instance Prelude.NFData GetTemplateSyncConfigResponse where
  rnf :: GetTemplateSyncConfigResponse -> ()
rnf GetTemplateSyncConfigResponse' {Int
Maybe TemplateSyncConfig
httpStatus :: Int
templateSyncConfig :: Maybe TemplateSyncConfig
$sel:httpStatus:GetTemplateSyncConfigResponse' :: GetTemplateSyncConfigResponse -> Int
$sel:templateSyncConfig:GetTemplateSyncConfigResponse' :: GetTemplateSyncConfigResponse -> Maybe TemplateSyncConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe TemplateSyncConfig
templateSyncConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus