{-# 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-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)
--
-- 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.Lens as Lens
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
(UpdateMesh -> UpdateMesh -> Bool)
-> (UpdateMesh -> UpdateMesh -> Bool) -> Eq UpdateMesh
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]
(Int -> ReadS UpdateMesh)
-> ReadS [UpdateMesh]
-> ReadPrec UpdateMesh
-> ReadPrec [UpdateMesh]
-> Read 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
(Int -> UpdateMesh -> ShowS)
-> (UpdateMesh -> String)
-> ([UpdateMesh] -> ShowS)
-> Show UpdateMesh
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. UpdateMesh -> Rep UpdateMesh x)
-> (forall x. Rep UpdateMesh x -> UpdateMesh) -> Generic UpdateMesh
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' :: Maybe Text -> Maybe MeshSpec -> Text -> UpdateMesh
UpdateMesh'
    { $sel:clientToken:UpdateMesh' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:spec:UpdateMesh' :: Maybe MeshSpec
spec = Maybe MeshSpec
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 :: (Maybe Text -> f (Maybe Text)) -> UpdateMesh -> f UpdateMesh
updateMesh_clientToken = (UpdateMesh -> Maybe Text)
-> (UpdateMesh -> Maybe Text -> UpdateMesh)
-> Lens UpdateMesh UpdateMesh (Maybe Text) (Maybe Text)
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 :: (Maybe MeshSpec -> f (Maybe MeshSpec))
-> UpdateMesh -> f UpdateMesh
updateMesh_spec = (UpdateMesh -> Maybe MeshSpec)
-> (UpdateMesh -> Maybe MeshSpec -> UpdateMesh)
-> Lens UpdateMesh UpdateMesh (Maybe MeshSpec) (Maybe MeshSpec)
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 :: (Text -> f Text) -> UpdateMesh -> f UpdateMesh
updateMesh_meshName = (UpdateMesh -> Text)
-> (UpdateMesh -> Text -> UpdateMesh)
-> Lens UpdateMesh UpdateMesh Text Text
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 :: UpdateMesh -> Request UpdateMesh
request = Service -> UpdateMesh -> Request UpdateMesh
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateMesh
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMesh)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateMesh))
-> Logger
-> Service
-> Proxy UpdateMesh
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMesh)))
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 -> MeshData -> UpdateMeshResponse
UpdateMeshResponse'
            (Int -> MeshData -> UpdateMeshResponse)
-> Either String Int
-> Either String (MeshData -> UpdateMeshResponse)
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 (MeshData -> UpdateMeshResponse)
-> Either String MeshData -> Either String UpdateMeshResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String MeshData
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateMesh

instance Prelude.NFData UpdateMesh

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            (Text
"spec" Text -> MeshSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MeshSpec -> Pair) -> Maybe MeshSpec -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MeshSpec
spec
          ]
      )

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v20190125/meshes/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
meshName]

instance Core.ToQuery UpdateMesh where
  toQuery :: UpdateMesh -> QueryString
toQuery = QueryString -> UpdateMesh -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateMeshResponse -> UpdateMeshResponse -> Bool)
-> (UpdateMeshResponse -> UpdateMeshResponse -> Bool)
-> Eq UpdateMeshResponse
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]
(Int -> ReadS UpdateMeshResponse)
-> ReadS [UpdateMeshResponse]
-> ReadPrec UpdateMeshResponse
-> ReadPrec [UpdateMeshResponse]
-> Read 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
(Int -> UpdateMeshResponse -> ShowS)
-> (UpdateMeshResponse -> String)
-> ([UpdateMeshResponse] -> ShowS)
-> Show UpdateMeshResponse
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. UpdateMeshResponse -> Rep UpdateMeshResponse x)
-> (forall x. Rep UpdateMeshResponse x -> UpdateMeshResponse)
-> Generic UpdateMeshResponse
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' :: Int -> MeshData -> UpdateMeshResponse
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 :: (Int -> f Int) -> UpdateMeshResponse -> f UpdateMeshResponse
updateMeshResponse_httpStatus = (UpdateMeshResponse -> Int)
-> (UpdateMeshResponse -> Int -> UpdateMeshResponse)
-> Lens UpdateMeshResponse UpdateMeshResponse Int Int
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 :: (MeshData -> f MeshData)
-> UpdateMeshResponse -> f UpdateMeshResponse
updateMeshResponse_mesh = (UpdateMeshResponse -> MeshData)
-> (UpdateMeshResponse -> MeshData -> UpdateMeshResponse)
-> Lens UpdateMeshResponse UpdateMeshResponse MeshData MeshData
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