{-# 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-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 the specified contact flow.
--
-- You can also create and update contact flows using the
-- <https://docs.aws.amazon.com/connect/latest/adminguide/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.Lens as Lens
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 contact flow.
    UpdateContactFlowContent -> Text
contactFlowId :: Prelude.Text,
    -- | The JSON string that represents contact flow’s content. For an example,
    -- see
    -- <https://docs.aws.amazon.com/connect/latest/adminguide/flow-language-example.html Example contact flow in Amazon Connect Flow language>
    -- in the /Amazon Connect Administrator Guide/.
    UpdateContactFlowContent -> Text
content :: Prelude.Text
  }
  deriving (UpdateContactFlowContent -> UpdateContactFlowContent -> Bool
(UpdateContactFlowContent -> UpdateContactFlowContent -> Bool)
-> (UpdateContactFlowContent -> UpdateContactFlowContent -> Bool)
-> Eq UpdateContactFlowContent
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]
(Int -> ReadS UpdateContactFlowContent)
-> ReadS [UpdateContactFlowContent]
-> ReadPrec UpdateContactFlowContent
-> ReadPrec [UpdateContactFlowContent]
-> Read 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
(Int -> UpdateContactFlowContent -> ShowS)
-> (UpdateContactFlowContent -> String)
-> ([UpdateContactFlowContent] -> ShowS)
-> Show UpdateContactFlowContent
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.
 UpdateContactFlowContent -> Rep UpdateContactFlowContent x)
-> (forall x.
    Rep UpdateContactFlowContent x -> UpdateContactFlowContent)
-> Generic UpdateContactFlowContent
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 contact flow.
--
-- 'content', 'updateContactFlowContent_content' - The JSON string that represents contact flow’s content. For an example,
-- see
-- <https://docs.aws.amazon.com/connect/latest/adminguide/flow-language-example.html Example contact flow in Amazon Connect Flow language>
-- in the /Amazon Connect Administrator Guide/.
newUpdateContactFlowContent ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'contactFlowId'
  Prelude.Text ->
  -- | 'content'
  Prelude.Text ->
  UpdateContactFlowContent
newUpdateContactFlowContent :: Text -> Text -> Text -> UpdateContactFlowContent
newUpdateContactFlowContent
  Text
pInstanceId_
  Text
pContactFlowId_
  Text
pContent_ =
    UpdateContactFlowContent' :: Text -> Text -> Text -> UpdateContactFlowContent
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 :: (Text -> f Text)
-> UpdateContactFlowContent -> f UpdateContactFlowContent
updateContactFlowContent_instanceId = (UpdateContactFlowContent -> Text)
-> (UpdateContactFlowContent -> Text -> UpdateContactFlowContent)
-> Lens UpdateContactFlowContent UpdateContactFlowContent Text Text
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 contact flow.
updateContactFlowContent_contactFlowId :: Lens.Lens' UpdateContactFlowContent Prelude.Text
updateContactFlowContent_contactFlowId :: (Text -> f Text)
-> UpdateContactFlowContent -> f UpdateContactFlowContent
updateContactFlowContent_contactFlowId = (UpdateContactFlowContent -> Text)
-> (UpdateContactFlowContent -> Text -> UpdateContactFlowContent)
-> Lens UpdateContactFlowContent UpdateContactFlowContent Text Text
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 contact flow’s content. For an example,
-- see
-- <https://docs.aws.amazon.com/connect/latest/adminguide/flow-language-example.html Example contact flow in Amazon Connect Flow language>
-- in the /Amazon Connect Administrator Guide/.
updateContactFlowContent_content :: Lens.Lens' UpdateContactFlowContent Prelude.Text
updateContactFlowContent_content :: (Text -> f Text)
-> UpdateContactFlowContent -> f UpdateContactFlowContent
updateContactFlowContent_content = (UpdateContactFlowContent -> Text)
-> (UpdateContactFlowContent -> Text -> UpdateContactFlowContent)
-> Lens UpdateContactFlowContent UpdateContactFlowContent Text Text
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 :: UpdateContactFlowContent -> Request UpdateContactFlowContent
request = Service
-> UpdateContactFlowContent -> Request UpdateContactFlowContent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateContactFlowContent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateContactFlowContent)))
response =
    AWSResponse UpdateContactFlowContent
-> Logger
-> Service
-> Proxy UpdateContactFlowContent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateContactFlowContent)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse UpdateContactFlowContent
UpdateContactFlowContentResponse
UpdateContactFlowContentResponse'

instance Prelude.Hashable UpdateContactFlowContent

instance Prelude.NFData UpdateContactFlowContent

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Content" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
content)]
      )

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/contact-flows/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
instanceId,
        ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
contactFlowId,
        ByteString
"/content"
      ]

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

-- | /See:/ 'newUpdateContactFlowContentResponse' smart constructor.
data UpdateContactFlowContentResponse = UpdateContactFlowContentResponse'
  {
  }
  deriving (UpdateContactFlowContentResponse
-> UpdateContactFlowContentResponse -> Bool
(UpdateContactFlowContentResponse
 -> UpdateContactFlowContentResponse -> Bool)
-> (UpdateContactFlowContentResponse
    -> UpdateContactFlowContentResponse -> Bool)
-> Eq UpdateContactFlowContentResponse
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]
(Int -> ReadS UpdateContactFlowContentResponse)
-> ReadS [UpdateContactFlowContentResponse]
-> ReadPrec UpdateContactFlowContentResponse
-> ReadPrec [UpdateContactFlowContentResponse]
-> Read 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
(Int -> UpdateContactFlowContentResponse -> ShowS)
-> (UpdateContactFlowContentResponse -> String)
-> ([UpdateContactFlowContentResponse] -> ShowS)
-> Show UpdateContactFlowContentResponse
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.
 UpdateContactFlowContentResponse
 -> Rep UpdateContactFlowContentResponse x)
-> (forall x.
    Rep UpdateContactFlowContentResponse x
    -> UpdateContactFlowContentResponse)
-> Generic UpdateContactFlowContentResponse
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