{-# 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.AppMesh.UpdateMesh
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an existing service mesh.
module Amazonka.AppMesh.UpdateMesh
  ( -- * Creating a Request
    UpdateMesh (..),
    newUpdateMesh,

    -- * Request Lenses
    updateMesh_clientToken,
    updateMesh_spec,
    updateMesh_meshName,

    -- * Destructuring the Response
    UpdateMeshResponse (..),
    newUpdateMeshResponse,

    -- * Response Lenses
    updateMeshResponse_httpStatus,
    updateMeshResponse_mesh,
  )
where

import Amazonka.AppMesh.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newUpdateMesh' smart constructor.
data UpdateMesh = UpdateMesh'
  { -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. Up to 36 letters, numbers, hyphens, and
    -- underscores are allowed.
    UpdateMesh -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The service mesh specification to apply.
    UpdateMesh -> Maybe MeshSpec
spec :: Prelude.Maybe MeshSpec,
    -- | The name of the service mesh to update.
    UpdateMesh -> Text
meshName :: Prelude.Text
  }
  deriving (UpdateMesh -> UpdateMesh -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMesh -> UpdateMesh -> Bool
$c/= :: UpdateMesh -> UpdateMesh -> Bool
== :: UpdateMesh -> UpdateMesh -> Bool
$c== :: UpdateMesh -> UpdateMesh -> Bool
Prelude.Eq, ReadPrec [UpdateMesh]
ReadPrec UpdateMesh
Int -> ReadS UpdateMesh
ReadS [UpdateMesh]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMesh]
$creadListPrec :: ReadPrec [UpdateMesh]
readPrec :: ReadPrec UpdateMesh
$creadPrec :: ReadPrec UpdateMesh
readList :: ReadS [UpdateMesh]
$creadList :: ReadS [UpdateMesh]
readsPrec :: Int -> ReadS UpdateMesh
$creadsPrec :: Int -> ReadS UpdateMesh
Prelude.Read, Int -> UpdateMesh -> ShowS
[UpdateMesh] -> ShowS
UpdateMesh -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMesh] -> ShowS
$cshowList :: [UpdateMesh] -> ShowS
show :: UpdateMesh -> String
$cshow :: UpdateMesh -> String
showsPrec :: Int -> UpdateMesh -> ShowS
$cshowsPrec :: Int -> UpdateMesh -> ShowS
Prelude.Show, forall x. Rep UpdateMesh x -> UpdateMesh
forall x. UpdateMesh -> Rep UpdateMesh x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMesh x -> UpdateMesh
$cfrom :: forall x. UpdateMesh -> Rep UpdateMesh x
Prelude.Generic)

-- |
-- Create a value of 'UpdateMesh' 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:
--
-- 'clientToken', 'updateMesh_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. Up to 36 letters, numbers, hyphens, and
-- underscores are allowed.
--
-- 'spec', 'updateMesh_spec' - The service mesh specification to apply.
--
-- 'meshName', 'updateMesh_meshName' - The name of the service mesh to update.
newUpdateMesh ::
  -- | 'meshName'
  Prelude.Text ->
  UpdateMesh
newUpdateMesh :: Text -> UpdateMesh
newUpdateMesh Text
pMeshName_ =
  UpdateMesh'
    { $sel:clientToken:UpdateMesh' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:spec:UpdateMesh' :: Maybe MeshSpec
spec = forall a. Maybe a
Prelude.Nothing,
      $sel:meshName:UpdateMesh' :: Text
meshName = Text
pMeshName_
    }

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. Up to 36 letters, numbers, hyphens, and
-- underscores are allowed.
updateMesh_clientToken :: Lens.Lens' UpdateMesh (Prelude.Maybe Prelude.Text)
updateMesh_clientToken :: Lens' UpdateMesh (Maybe Text)
updateMesh_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMesh' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:UpdateMesh' :: UpdateMesh -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: UpdateMesh
s@UpdateMesh' {} Maybe Text
a -> UpdateMesh
s {$sel:clientToken:UpdateMesh' :: Maybe Text
clientToken = Maybe Text
a} :: UpdateMesh)

-- | The service mesh specification to apply.
updateMesh_spec :: Lens.Lens' UpdateMesh (Prelude.Maybe MeshSpec)
updateMesh_spec :: Lens' UpdateMesh (Maybe MeshSpec)
updateMesh_spec = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMesh' {Maybe MeshSpec
spec :: Maybe MeshSpec
$sel:spec:UpdateMesh' :: UpdateMesh -> Maybe MeshSpec
spec} -> Maybe MeshSpec
spec) (\s :: UpdateMesh
s@UpdateMesh' {} Maybe MeshSpec
a -> UpdateMesh
s {$sel:spec:UpdateMesh' :: Maybe MeshSpec
spec = Maybe MeshSpec
a} :: UpdateMesh)

-- | The name of the service mesh to update.
updateMesh_meshName :: Lens.Lens' UpdateMesh Prelude.Text
updateMesh_meshName :: Lens' UpdateMesh Text
updateMesh_meshName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMesh' {Text
meshName :: Text
$sel:meshName:UpdateMesh' :: UpdateMesh -> Text
meshName} -> Text
meshName) (\s :: UpdateMesh
s@UpdateMesh' {} Text
a -> UpdateMesh
s {$sel:meshName:UpdateMesh' :: Text
meshName = Text
a} :: UpdateMesh)

instance Core.AWSRequest UpdateMesh where
  type AWSResponse UpdateMesh = UpdateMeshResponse
  request :: (Service -> Service) -> UpdateMesh -> Request UpdateMesh
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateMesh
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMesh)))
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 -> MeshData -> UpdateMeshResponse
UpdateMeshResponse'
            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.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateMesh where
  hashWithSalt :: Int -> UpdateMesh -> Int
hashWithSalt Int
_salt UpdateMesh' {Maybe Text
Maybe MeshSpec
Text
meshName :: Text
spec :: Maybe MeshSpec
clientToken :: Maybe Text
$sel:meshName:UpdateMesh' :: UpdateMesh -> Text
$sel:spec:UpdateMesh' :: UpdateMesh -> Maybe MeshSpec
$sel:clientToken:UpdateMesh' :: UpdateMesh -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MeshSpec
spec
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
meshName

instance Prelude.NFData UpdateMesh where
  rnf :: UpdateMesh -> ()
rnf UpdateMesh' {Maybe Text
Maybe MeshSpec
Text
meshName :: Text
spec :: Maybe MeshSpec
clientToken :: Maybe Text
$sel:meshName:UpdateMesh' :: UpdateMesh -> Text
$sel:spec:UpdateMesh' :: UpdateMesh -> Maybe MeshSpec
$sel:clientToken:UpdateMesh' :: UpdateMesh -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MeshSpec
spec
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
meshName

instance Data.ToHeaders UpdateMesh where
  toHeaders :: UpdateMesh -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateMesh where
  toJSON :: UpdateMesh -> Value
toJSON UpdateMesh' {Maybe Text
Maybe MeshSpec
Text
meshName :: Text
spec :: Maybe MeshSpec
clientToken :: Maybe Text
$sel:meshName:UpdateMesh' :: UpdateMesh -> Text
$sel:spec:UpdateMesh' :: UpdateMesh -> Maybe MeshSpec
$sel:clientToken:UpdateMesh' :: UpdateMesh -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientToken" 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 Text
clientToken,
            (Key
"spec" 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 MeshSpec
spec
          ]
      )

instance Data.ToPath UpdateMesh where
  toPath :: UpdateMesh -> ByteString
toPath UpdateMesh' {Maybe Text
Maybe MeshSpec
Text
meshName :: Text
spec :: Maybe MeshSpec
clientToken :: Maybe Text
$sel:meshName:UpdateMesh' :: UpdateMesh -> Text
$sel:spec:UpdateMesh' :: UpdateMesh -> Maybe MeshSpec
$sel:clientToken:UpdateMesh' :: UpdateMesh -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v20190125/meshes/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
meshName]

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

-- |
--
-- /See:/ 'newUpdateMeshResponse' smart constructor.
data UpdateMeshResponse = UpdateMeshResponse'
  { -- | The response's http status code.
    UpdateMeshResponse -> Int
httpStatus :: Prelude.Int,
    UpdateMeshResponse -> MeshData
mesh :: MeshData
  }
  deriving (UpdateMeshResponse -> UpdateMeshResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMeshResponse -> UpdateMeshResponse -> Bool
$c/= :: UpdateMeshResponse -> UpdateMeshResponse -> Bool
== :: UpdateMeshResponse -> UpdateMeshResponse -> Bool
$c== :: UpdateMeshResponse -> UpdateMeshResponse -> Bool
Prelude.Eq, ReadPrec [UpdateMeshResponse]
ReadPrec UpdateMeshResponse
Int -> ReadS UpdateMeshResponse
ReadS [UpdateMeshResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMeshResponse]
$creadListPrec :: ReadPrec [UpdateMeshResponse]
readPrec :: ReadPrec UpdateMeshResponse
$creadPrec :: ReadPrec UpdateMeshResponse
readList :: ReadS [UpdateMeshResponse]
$creadList :: ReadS [UpdateMeshResponse]
readsPrec :: Int -> ReadS UpdateMeshResponse
$creadsPrec :: Int -> ReadS UpdateMeshResponse
Prelude.Read, Int -> UpdateMeshResponse -> ShowS
[UpdateMeshResponse] -> ShowS
UpdateMeshResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMeshResponse] -> ShowS
$cshowList :: [UpdateMeshResponse] -> ShowS
show :: UpdateMeshResponse -> String
$cshow :: UpdateMeshResponse -> String
showsPrec :: Int -> UpdateMeshResponse -> ShowS
$cshowsPrec :: Int -> UpdateMeshResponse -> ShowS
Prelude.Show, forall x. Rep UpdateMeshResponse x -> UpdateMeshResponse
forall x. UpdateMeshResponse -> Rep UpdateMeshResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMeshResponse x -> UpdateMeshResponse
$cfrom :: forall x. UpdateMeshResponse -> Rep UpdateMeshResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateMeshResponse' 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', 'updateMeshResponse_httpStatus' - The response's http status code.
--
-- 'mesh', 'updateMeshResponse_mesh' - Undocumented member.
newUpdateMeshResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'mesh'
  MeshData ->
  UpdateMeshResponse
newUpdateMeshResponse :: Int -> MeshData -> UpdateMeshResponse
newUpdateMeshResponse Int
pHttpStatus_ MeshData
pMesh_ =
  UpdateMeshResponse'
    { $sel:httpStatus:UpdateMeshResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:mesh:UpdateMeshResponse' :: MeshData
mesh = MeshData
pMesh_
    }

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

-- | Undocumented member.
updateMeshResponse_mesh :: Lens.Lens' UpdateMeshResponse MeshData
updateMeshResponse_mesh :: Lens' UpdateMeshResponse MeshData
updateMeshResponse_mesh = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMeshResponse' {MeshData
mesh :: MeshData
$sel:mesh:UpdateMeshResponse' :: UpdateMeshResponse -> MeshData
mesh} -> MeshData
mesh) (\s :: UpdateMeshResponse
s@UpdateMeshResponse' {} MeshData
a -> UpdateMeshResponse
s {$sel:mesh:UpdateMeshResponse' :: MeshData
mesh = MeshData
a} :: UpdateMeshResponse)

instance Prelude.NFData UpdateMeshResponse where
  rnf :: UpdateMeshResponse -> ()
rnf UpdateMeshResponse' {Int
MeshData
mesh :: MeshData
httpStatus :: Int
$sel:mesh:UpdateMeshResponse' :: UpdateMeshResponse -> MeshData
$sel:httpStatus:UpdateMeshResponse' :: UpdateMeshResponse -> 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 MeshData
mesh