{-# 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.Connect.UpdateContactFlowContent
-- 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 the specified flow.
--
-- You can also create and update flows using the
-- <https://docs.aws.amazon.com/connect/latest/APIReference/flow-language.html Amazon Connect Flow language>.
module Amazonka.Connect.UpdateContactFlowContent
  ( -- * Creating a Request
    UpdateContactFlowContent (..),
    newUpdateContactFlowContent,

    -- * Request Lenses
    updateContactFlowContent_instanceId,
    updateContactFlowContent_contactFlowId,
    updateContactFlowContent_content,

    -- * Destructuring the Response
    UpdateContactFlowContentResponse (..),
    newUpdateContactFlowContentResponse,
  )
where

import Amazonka.Connect.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:/ 'newUpdateContactFlowContent' smart constructor.
data UpdateContactFlowContent = UpdateContactFlowContent'
  { -- | The identifier of the Amazon Connect instance.
    UpdateContactFlowContent -> Text
instanceId :: Prelude.Text,
    -- | The identifier of the flow.
    UpdateContactFlowContent -> Text
contactFlowId :: Prelude.Text,
    -- | The JSON string that represents flow\'s content. For an example, see
    -- <https://docs.aws.amazon.com/connect/latest/APIReference/flow-language-example.html Example contact flow in Amazon Connect Flow language>.
    UpdateContactFlowContent -> Text
content :: Prelude.Text
  }
  deriving (UpdateContactFlowContent -> UpdateContactFlowContent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateContactFlowContent -> UpdateContactFlowContent -> Bool
$c/= :: UpdateContactFlowContent -> UpdateContactFlowContent -> Bool
== :: UpdateContactFlowContent -> UpdateContactFlowContent -> Bool
$c== :: UpdateContactFlowContent -> UpdateContactFlowContent -> Bool
Prelude.Eq, ReadPrec [UpdateContactFlowContent]
ReadPrec UpdateContactFlowContent
Int -> ReadS UpdateContactFlowContent
ReadS [UpdateContactFlowContent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateContactFlowContent]
$creadListPrec :: ReadPrec [UpdateContactFlowContent]
readPrec :: ReadPrec UpdateContactFlowContent
$creadPrec :: ReadPrec UpdateContactFlowContent
readList :: ReadS [UpdateContactFlowContent]
$creadList :: ReadS [UpdateContactFlowContent]
readsPrec :: Int -> ReadS UpdateContactFlowContent
$creadsPrec :: Int -> ReadS UpdateContactFlowContent
Prelude.Read, Int -> UpdateContactFlowContent -> ShowS
[UpdateContactFlowContent] -> ShowS
UpdateContactFlowContent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateContactFlowContent] -> ShowS
$cshowList :: [UpdateContactFlowContent] -> ShowS
show :: UpdateContactFlowContent -> String
$cshow :: UpdateContactFlowContent -> String
showsPrec :: Int -> UpdateContactFlowContent -> ShowS
$cshowsPrec :: Int -> UpdateContactFlowContent -> ShowS
Prelude.Show, forall x.
Rep UpdateContactFlowContent x -> UpdateContactFlowContent
forall x.
UpdateContactFlowContent -> Rep UpdateContactFlowContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateContactFlowContent x -> UpdateContactFlowContent
$cfrom :: forall x.
UpdateContactFlowContent -> Rep UpdateContactFlowContent x
Prelude.Generic)

-- |
-- Create a value of 'UpdateContactFlowContent' 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:
--
-- 'instanceId', 'updateContactFlowContent_instanceId' - The identifier of the Amazon Connect instance.
--
-- 'contactFlowId', 'updateContactFlowContent_contactFlowId' - The identifier of the flow.
--
-- 'content', 'updateContactFlowContent_content' - The JSON string that represents flow\'s content. For an example, see
-- <https://docs.aws.amazon.com/connect/latest/APIReference/flow-language-example.html Example contact flow in Amazon Connect Flow language>.
newUpdateContactFlowContent ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'contactFlowId'
  Prelude.Text ->
  -- | 'content'
  Prelude.Text ->
  UpdateContactFlowContent
newUpdateContactFlowContent :: Text -> Text -> Text -> UpdateContactFlowContent
newUpdateContactFlowContent
  Text
pInstanceId_
  Text
pContactFlowId_
  Text
pContent_ =
    UpdateContactFlowContent'
      { $sel:instanceId:UpdateContactFlowContent' :: Text
instanceId =
          Text
pInstanceId_,
        $sel:contactFlowId:UpdateContactFlowContent' :: Text
contactFlowId = Text
pContactFlowId_,
        $sel:content:UpdateContactFlowContent' :: Text
content = Text
pContent_
      }

-- | The identifier of the Amazon Connect instance.
updateContactFlowContent_instanceId :: Lens.Lens' UpdateContactFlowContent Prelude.Text
updateContactFlowContent_instanceId :: Lens' UpdateContactFlowContent Text
updateContactFlowContent_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactFlowContent' {Text
instanceId :: Text
$sel:instanceId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
instanceId} -> Text
instanceId) (\s :: UpdateContactFlowContent
s@UpdateContactFlowContent' {} Text
a -> UpdateContactFlowContent
s {$sel:instanceId:UpdateContactFlowContent' :: Text
instanceId = Text
a} :: UpdateContactFlowContent)

-- | The identifier of the flow.
updateContactFlowContent_contactFlowId :: Lens.Lens' UpdateContactFlowContent Prelude.Text
updateContactFlowContent_contactFlowId :: Lens' UpdateContactFlowContent Text
updateContactFlowContent_contactFlowId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactFlowContent' {Text
contactFlowId :: Text
$sel:contactFlowId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
contactFlowId} -> Text
contactFlowId) (\s :: UpdateContactFlowContent
s@UpdateContactFlowContent' {} Text
a -> UpdateContactFlowContent
s {$sel:contactFlowId:UpdateContactFlowContent' :: Text
contactFlowId = Text
a} :: UpdateContactFlowContent)

-- | The JSON string that represents flow\'s content. For an example, see
-- <https://docs.aws.amazon.com/connect/latest/APIReference/flow-language-example.html Example contact flow in Amazon Connect Flow language>.
updateContactFlowContent_content :: Lens.Lens' UpdateContactFlowContent Prelude.Text
updateContactFlowContent_content :: Lens' UpdateContactFlowContent Text
updateContactFlowContent_content = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactFlowContent' {Text
content :: Text
$sel:content:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
content} -> Text
content) (\s :: UpdateContactFlowContent
s@UpdateContactFlowContent' {} Text
a -> UpdateContactFlowContent
s {$sel:content:UpdateContactFlowContent' :: Text
content = Text
a} :: UpdateContactFlowContent)

instance Core.AWSRequest UpdateContactFlowContent where
  type
    AWSResponse UpdateContactFlowContent =
      UpdateContactFlowContentResponse
  request :: (Service -> Service)
-> UpdateContactFlowContent -> Request UpdateContactFlowContent
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 UpdateContactFlowContent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateContactFlowContent)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      UpdateContactFlowContentResponse
UpdateContactFlowContentResponse'

instance Prelude.Hashable UpdateContactFlowContent where
  hashWithSalt :: Int -> UpdateContactFlowContent -> Int
hashWithSalt Int
_salt UpdateContactFlowContent' {Text
content :: Text
contactFlowId :: Text
instanceId :: Text
$sel:content:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
$sel:contactFlowId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
$sel:instanceId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactFlowId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
content

instance Prelude.NFData UpdateContactFlowContent where
  rnf :: UpdateContactFlowContent -> ()
rnf UpdateContactFlowContent' {Text
content :: Text
contactFlowId :: Text
instanceId :: Text
$sel:content:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
$sel:contactFlowId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
$sel:instanceId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
contactFlowId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
content

instance Data.ToHeaders UpdateContactFlowContent where
  toHeaders :: UpdateContactFlowContent -> [Header]
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 -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateContactFlowContent where
  toJSON :: UpdateContactFlowContent -> Value
toJSON UpdateContactFlowContent' {Text
content :: Text
contactFlowId :: Text
instanceId :: Text
$sel:content:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
$sel:contactFlowId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
$sel:instanceId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Content" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
content)]
      )

instance Data.ToPath UpdateContactFlowContent where
  toPath :: UpdateContactFlowContent -> ByteString
toPath UpdateContactFlowContent' {Text
content :: Text
contactFlowId :: Text
instanceId :: Text
$sel:content:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
$sel:contactFlowId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
$sel:instanceId:UpdateContactFlowContent' :: UpdateContactFlowContent -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/contact-flows/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
instanceId,
        ByteString
"/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
contactFlowId,
        ByteString
"/content"
      ]

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

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

-- |
-- Create a value of 'UpdateContactFlowContentResponse' 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.
newUpdateContactFlowContentResponse ::
  UpdateContactFlowContentResponse
newUpdateContactFlowContentResponse :: UpdateContactFlowContentResponse
newUpdateContactFlowContentResponse =
  UpdateContactFlowContentResponse
UpdateContactFlowContentResponse'

instance
  Prelude.NFData
    UpdateContactFlowContentResponse
  where
  rnf :: UpdateContactFlowContentResponse -> ()
rnf UpdateContactFlowContentResponse
_ = ()