{-# 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.DescribeContactFlow
-- 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)
--
-- Describes 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.DescribeContactFlow
  ( -- * Creating a Request
    DescribeContactFlow (..),
    newDescribeContactFlow,

    -- * Request Lenses
    describeContactFlow_instanceId,
    describeContactFlow_contactFlowId,

    -- * Destructuring the Response
    DescribeContactFlowResponse (..),
    newDescribeContactFlowResponse,

    -- * Response Lenses
    describeContactFlowResponse_contactFlow,
    describeContactFlowResponse_httpStatus,
  )
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:/ 'newDescribeContactFlow' smart constructor.
data DescribeContactFlow = DescribeContactFlow'
  { -- | The identifier of the Amazon Connect instance.
    DescribeContactFlow -> Text
instanceId :: Prelude.Text,
    -- | The identifier of the contact flow.
    DescribeContactFlow -> Text
contactFlowId :: Prelude.Text
  }
  deriving (DescribeContactFlow -> DescribeContactFlow -> Bool
(DescribeContactFlow -> DescribeContactFlow -> Bool)
-> (DescribeContactFlow -> DescribeContactFlow -> Bool)
-> Eq DescribeContactFlow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeContactFlow -> DescribeContactFlow -> Bool
$c/= :: DescribeContactFlow -> DescribeContactFlow -> Bool
== :: DescribeContactFlow -> DescribeContactFlow -> Bool
$c== :: DescribeContactFlow -> DescribeContactFlow -> Bool
Prelude.Eq, ReadPrec [DescribeContactFlow]
ReadPrec DescribeContactFlow
Int -> ReadS DescribeContactFlow
ReadS [DescribeContactFlow]
(Int -> ReadS DescribeContactFlow)
-> ReadS [DescribeContactFlow]
-> ReadPrec DescribeContactFlow
-> ReadPrec [DescribeContactFlow]
-> Read DescribeContactFlow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeContactFlow]
$creadListPrec :: ReadPrec [DescribeContactFlow]
readPrec :: ReadPrec DescribeContactFlow
$creadPrec :: ReadPrec DescribeContactFlow
readList :: ReadS [DescribeContactFlow]
$creadList :: ReadS [DescribeContactFlow]
readsPrec :: Int -> ReadS DescribeContactFlow
$creadsPrec :: Int -> ReadS DescribeContactFlow
Prelude.Read, Int -> DescribeContactFlow -> ShowS
[DescribeContactFlow] -> ShowS
DescribeContactFlow -> String
(Int -> DescribeContactFlow -> ShowS)
-> (DescribeContactFlow -> String)
-> ([DescribeContactFlow] -> ShowS)
-> Show DescribeContactFlow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeContactFlow] -> ShowS
$cshowList :: [DescribeContactFlow] -> ShowS
show :: DescribeContactFlow -> String
$cshow :: DescribeContactFlow -> String
showsPrec :: Int -> DescribeContactFlow -> ShowS
$cshowsPrec :: Int -> DescribeContactFlow -> ShowS
Prelude.Show, (forall x. DescribeContactFlow -> Rep DescribeContactFlow x)
-> (forall x. Rep DescribeContactFlow x -> DescribeContactFlow)
-> Generic DescribeContactFlow
forall x. Rep DescribeContactFlow x -> DescribeContactFlow
forall x. DescribeContactFlow -> Rep DescribeContactFlow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeContactFlow x -> DescribeContactFlow
$cfrom :: forall x. DescribeContactFlow -> Rep DescribeContactFlow x
Prelude.Generic)

-- |
-- Create a value of 'DescribeContactFlow' 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', 'describeContactFlow_instanceId' - The identifier of the Amazon Connect instance.
--
-- 'contactFlowId', 'describeContactFlow_contactFlowId' - The identifier of the contact flow.
newDescribeContactFlow ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'contactFlowId'
  Prelude.Text ->
  DescribeContactFlow
newDescribeContactFlow :: Text -> Text -> DescribeContactFlow
newDescribeContactFlow Text
pInstanceId_ Text
pContactFlowId_ =
  DescribeContactFlow' :: Text -> Text -> DescribeContactFlow
DescribeContactFlow'
    { $sel:instanceId:DescribeContactFlow' :: Text
instanceId = Text
pInstanceId_,
      $sel:contactFlowId:DescribeContactFlow' :: Text
contactFlowId = Text
pContactFlowId_
    }

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

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

instance Core.AWSRequest DescribeContactFlow where
  type
    AWSResponse DescribeContactFlow =
      DescribeContactFlowResponse
  request :: DescribeContactFlow -> Request DescribeContactFlow
request = Service -> DescribeContactFlow -> Request DescribeContactFlow
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeContactFlow
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeContactFlow)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeContactFlow))
-> Logger
-> Service
-> Proxy DescribeContactFlow
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeContactFlow)))
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 ->
          Maybe ContactFlow -> Int -> DescribeContactFlowResponse
DescribeContactFlowResponse'
            (Maybe ContactFlow -> Int -> DescribeContactFlowResponse)
-> Either String (Maybe ContactFlow)
-> Either String (Int -> DescribeContactFlowResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ContactFlow)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ContactFlow")
            Either String (Int -> DescribeContactFlowResponse)
-> Either String Int -> Either String DescribeContactFlowResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable DescribeContactFlow

instance Prelude.NFData DescribeContactFlow

instance Core.ToHeaders DescribeContactFlow where
  toHeaders :: DescribeContactFlow -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeContactFlow -> 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.ToPath DescribeContactFlow where
  toPath :: DescribeContactFlow -> ByteString
toPath DescribeContactFlow' {Text
contactFlowId :: Text
instanceId :: Text
$sel:contactFlowId:DescribeContactFlow' :: DescribeContactFlow -> Text
$sel:instanceId:DescribeContactFlow' :: DescribeContactFlow -> 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
      ]

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

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

-- |
-- Create a value of 'DescribeContactFlowResponse' 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:
--
-- 'contactFlow', 'describeContactFlowResponse_contactFlow' - Information about the contact flow.
--
-- 'httpStatus', 'describeContactFlowResponse_httpStatus' - The response's http status code.
newDescribeContactFlowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeContactFlowResponse
newDescribeContactFlowResponse :: Int -> DescribeContactFlowResponse
newDescribeContactFlowResponse Int
pHttpStatus_ =
  DescribeContactFlowResponse' :: Maybe ContactFlow -> Int -> DescribeContactFlowResponse
DescribeContactFlowResponse'
    { $sel:contactFlow:DescribeContactFlowResponse' :: Maybe ContactFlow
contactFlow =
        Maybe ContactFlow
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeContactFlowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the contact flow.
describeContactFlowResponse_contactFlow :: Lens.Lens' DescribeContactFlowResponse (Prelude.Maybe ContactFlow)
describeContactFlowResponse_contactFlow :: (Maybe ContactFlow -> f (Maybe ContactFlow))
-> DescribeContactFlowResponse -> f DescribeContactFlowResponse
describeContactFlowResponse_contactFlow = (DescribeContactFlowResponse -> Maybe ContactFlow)
-> (DescribeContactFlowResponse
    -> Maybe ContactFlow -> DescribeContactFlowResponse)
-> Lens
     DescribeContactFlowResponse
     DescribeContactFlowResponse
     (Maybe ContactFlow)
     (Maybe ContactFlow)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeContactFlowResponse' {Maybe ContactFlow
contactFlow :: Maybe ContactFlow
$sel:contactFlow:DescribeContactFlowResponse' :: DescribeContactFlowResponse -> Maybe ContactFlow
contactFlow} -> Maybe ContactFlow
contactFlow) (\s :: DescribeContactFlowResponse
s@DescribeContactFlowResponse' {} Maybe ContactFlow
a -> DescribeContactFlowResponse
s {$sel:contactFlow:DescribeContactFlowResponse' :: Maybe ContactFlow
contactFlow = Maybe ContactFlow
a} :: DescribeContactFlowResponse)

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

instance Prelude.NFData DescribeContactFlowResponse