{-# 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.UpdateEnvironmentTemplate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update an environment template.
module Amazonka.Proton.UpdateEnvironmentTemplate
  ( -- * Creating a Request
    UpdateEnvironmentTemplate (..),
    newUpdateEnvironmentTemplate,

    -- * Request Lenses
    updateEnvironmentTemplate_description,
    updateEnvironmentTemplate_displayName,
    updateEnvironmentTemplate_name,

    -- * Destructuring the Response
    UpdateEnvironmentTemplateResponse (..),
    newUpdateEnvironmentTemplateResponse,

    -- * Response Lenses
    updateEnvironmentTemplateResponse_httpStatus,
    updateEnvironmentTemplateResponse_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:/ 'newUpdateEnvironmentTemplate' smart constructor.
data UpdateEnvironmentTemplate = UpdateEnvironmentTemplate'
  { -- | A description of the environment template update.
    UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
description :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The name of the environment template to update as displayed in the
    -- developer interface.
    UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
displayName :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The name of the environment template to update.
    UpdateEnvironmentTemplate -> Text
name :: Prelude.Text
  }
  deriving (UpdateEnvironmentTemplate -> UpdateEnvironmentTemplate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEnvironmentTemplate -> UpdateEnvironmentTemplate -> Bool
$c/= :: UpdateEnvironmentTemplate -> UpdateEnvironmentTemplate -> Bool
== :: UpdateEnvironmentTemplate -> UpdateEnvironmentTemplate -> Bool
$c== :: UpdateEnvironmentTemplate -> UpdateEnvironmentTemplate -> Bool
Prelude.Eq, Int -> UpdateEnvironmentTemplate -> ShowS
[UpdateEnvironmentTemplate] -> ShowS
UpdateEnvironmentTemplate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEnvironmentTemplate] -> ShowS
$cshowList :: [UpdateEnvironmentTemplate] -> ShowS
show :: UpdateEnvironmentTemplate -> String
$cshow :: UpdateEnvironmentTemplate -> String
showsPrec :: Int -> UpdateEnvironmentTemplate -> ShowS
$cshowsPrec :: Int -> UpdateEnvironmentTemplate -> ShowS
Prelude.Show, forall x.
Rep UpdateEnvironmentTemplate x -> UpdateEnvironmentTemplate
forall x.
UpdateEnvironmentTemplate -> Rep UpdateEnvironmentTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateEnvironmentTemplate x -> UpdateEnvironmentTemplate
$cfrom :: forall x.
UpdateEnvironmentTemplate -> Rep UpdateEnvironmentTemplate x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEnvironmentTemplate' 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:
--
-- 'description', 'updateEnvironmentTemplate_description' - A description of the environment template update.
--
-- 'displayName', 'updateEnvironmentTemplate_displayName' - The name of the environment template to update as displayed in the
-- developer interface.
--
-- 'name', 'updateEnvironmentTemplate_name' - The name of the environment template to update.
newUpdateEnvironmentTemplate ::
  -- | 'name'
  Prelude.Text ->
  UpdateEnvironmentTemplate
newUpdateEnvironmentTemplate :: Text -> UpdateEnvironmentTemplate
newUpdateEnvironmentTemplate Text
pName_ =
  UpdateEnvironmentTemplate'
    { $sel:description:UpdateEnvironmentTemplate' :: Maybe (Sensitive Text)
description =
        forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:UpdateEnvironmentTemplate' :: Maybe (Sensitive Text)
displayName = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateEnvironmentTemplate' :: Text
name = Text
pName_
    }

-- | A description of the environment template update.
updateEnvironmentTemplate_description :: Lens.Lens' UpdateEnvironmentTemplate (Prelude.Maybe Prelude.Text)
updateEnvironmentTemplate_description :: Lens' UpdateEnvironmentTemplate (Maybe Text)
updateEnvironmentTemplate_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironmentTemplate' {Maybe (Sensitive Text)
description :: Maybe (Sensitive Text)
$sel:description:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
description} -> Maybe (Sensitive Text)
description) (\s :: UpdateEnvironmentTemplate
s@UpdateEnvironmentTemplate' {} Maybe (Sensitive Text)
a -> UpdateEnvironmentTemplate
s {$sel:description:UpdateEnvironmentTemplate' :: Maybe (Sensitive Text)
description = Maybe (Sensitive Text)
a} :: UpdateEnvironmentTemplate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The name of the environment template to update as displayed in the
-- developer interface.
updateEnvironmentTemplate_displayName :: Lens.Lens' UpdateEnvironmentTemplate (Prelude.Maybe Prelude.Text)
updateEnvironmentTemplate_displayName :: Lens' UpdateEnvironmentTemplate (Maybe Text)
updateEnvironmentTemplate_displayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironmentTemplate' {Maybe (Sensitive Text)
displayName :: Maybe (Sensitive Text)
$sel:displayName:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
displayName} -> Maybe (Sensitive Text)
displayName) (\s :: UpdateEnvironmentTemplate
s@UpdateEnvironmentTemplate' {} Maybe (Sensitive Text)
a -> UpdateEnvironmentTemplate
s {$sel:displayName:UpdateEnvironmentTemplate' :: Maybe (Sensitive Text)
displayName = Maybe (Sensitive Text)
a} :: UpdateEnvironmentTemplate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The name of the environment template to update.
updateEnvironmentTemplate_name :: Lens.Lens' UpdateEnvironmentTemplate Prelude.Text
updateEnvironmentTemplate_name :: Lens' UpdateEnvironmentTemplate Text
updateEnvironmentTemplate_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironmentTemplate' {Text
name :: Text
$sel:name:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Text
name} -> Text
name) (\s :: UpdateEnvironmentTemplate
s@UpdateEnvironmentTemplate' {} Text
a -> UpdateEnvironmentTemplate
s {$sel:name:UpdateEnvironmentTemplate' :: Text
name = Text
a} :: UpdateEnvironmentTemplate)

instance Core.AWSRequest UpdateEnvironmentTemplate where
  type
    AWSResponse UpdateEnvironmentTemplate =
      UpdateEnvironmentTemplateResponse
  request :: (Service -> Service)
-> UpdateEnvironmentTemplate -> Request UpdateEnvironmentTemplate
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 UpdateEnvironmentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEnvironmentTemplate)))
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 -> UpdateEnvironmentTemplateResponse
UpdateEnvironmentTemplateResponse'
            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 UpdateEnvironmentTemplate where
  hashWithSalt :: Int -> UpdateEnvironmentTemplate -> Int
hashWithSalt Int
_salt UpdateEnvironmentTemplate' {Maybe (Sensitive Text)
Text
name :: Text
displayName :: Maybe (Sensitive Text)
description :: Maybe (Sensitive Text)
$sel:name:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Text
$sel:displayName:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
$sel:description:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
displayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData UpdateEnvironmentTemplate where
  rnf :: UpdateEnvironmentTemplate -> ()
rnf UpdateEnvironmentTemplate' {Maybe (Sensitive Text)
Text
name :: Text
displayName :: Maybe (Sensitive Text)
description :: Maybe (Sensitive Text)
$sel:name:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Text
$sel:displayName:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
$sel:description:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
displayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders UpdateEnvironmentTemplate where
  toHeaders :: UpdateEnvironmentTemplate -> 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.UpdateEnvironmentTemplate" ::
                          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 UpdateEnvironmentTemplate where
  toJSON :: UpdateEnvironmentTemplate -> Value
toJSON UpdateEnvironmentTemplate' {Maybe (Sensitive Text)
Text
name :: Text
displayName :: Maybe (Sensitive Text)
description :: Maybe (Sensitive Text)
$sel:name:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Text
$sel:displayName:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
$sel:description:UpdateEnvironmentTemplate' :: UpdateEnvironmentTemplate -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
description,
            (Key
"displayName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
displayName,
            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 UpdateEnvironmentTemplate where
  toPath :: UpdateEnvironmentTemplate -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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

instance
  Prelude.NFData
    UpdateEnvironmentTemplateResponse
  where
  rnf :: UpdateEnvironmentTemplateResponse -> ()
rnf UpdateEnvironmentTemplateResponse' {Int
EnvironmentTemplate
environmentTemplate :: EnvironmentTemplate
httpStatus :: Int
$sel:environmentTemplate:UpdateEnvironmentTemplateResponse' :: UpdateEnvironmentTemplateResponse -> EnvironmentTemplate
$sel:httpStatus:UpdateEnvironmentTemplateResponse' :: UpdateEnvironmentTemplateResponse -> 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