{-# 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.StartContactRecording
-- 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)
--
-- Starts recording the contact when the agent joins the call.
-- StartContactRecording is a one-time action. For example, if you use
-- StopContactRecording to stop recording an ongoing call, you can\'t use
-- StartContactRecording to restart it. For scenarios where the recording
-- has started and you want to suspend and resume it, such as when
-- collecting sensitive information (for example, a credit card number),
-- use SuspendContactRecording and ResumeContactRecording.
--
-- You can use this API to override the recording behavior configured in
-- the
-- <https://docs.aws.amazon.com/connect/latest/adminguide/set-recording-behavior.html Set recording behavior>
-- block.
--
-- Only voice recordings are supported at this time.
module Amazonka.Connect.StartContactRecording
  ( -- * Creating a Request
    StartContactRecording (..),
    newStartContactRecording,

    -- * Request Lenses
    startContactRecording_instanceId,
    startContactRecording_contactId,
    startContactRecording_initialContactId,
    startContactRecording_voiceRecordingConfiguration,

    -- * Destructuring the Response
    StartContactRecordingResponse (..),
    newStartContactRecordingResponse,

    -- * Response Lenses
    startContactRecordingResponse_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:/ 'newStartContactRecording' smart constructor.
data StartContactRecording = StartContactRecording'
  { -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    StartContactRecording -> Text
instanceId :: Prelude.Text,
    -- | The identifier of the contact.
    StartContactRecording -> Text
contactId :: Prelude.Text,
    -- | The identifier of the contact. This is the identifier of the contact
    -- associated with the first interaction with the contact center.
    StartContactRecording -> Text
initialContactId :: Prelude.Text,
    -- | The person being recorded.
    StartContactRecording -> VoiceRecordingConfiguration
voiceRecordingConfiguration :: VoiceRecordingConfiguration
  }
  deriving (StartContactRecording -> StartContactRecording -> Bool
(StartContactRecording -> StartContactRecording -> Bool)
-> (StartContactRecording -> StartContactRecording -> Bool)
-> Eq StartContactRecording
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartContactRecording -> StartContactRecording -> Bool
$c/= :: StartContactRecording -> StartContactRecording -> Bool
== :: StartContactRecording -> StartContactRecording -> Bool
$c== :: StartContactRecording -> StartContactRecording -> Bool
Prelude.Eq, ReadPrec [StartContactRecording]
ReadPrec StartContactRecording
Int -> ReadS StartContactRecording
ReadS [StartContactRecording]
(Int -> ReadS StartContactRecording)
-> ReadS [StartContactRecording]
-> ReadPrec StartContactRecording
-> ReadPrec [StartContactRecording]
-> Read StartContactRecording
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartContactRecording]
$creadListPrec :: ReadPrec [StartContactRecording]
readPrec :: ReadPrec StartContactRecording
$creadPrec :: ReadPrec StartContactRecording
readList :: ReadS [StartContactRecording]
$creadList :: ReadS [StartContactRecording]
readsPrec :: Int -> ReadS StartContactRecording
$creadsPrec :: Int -> ReadS StartContactRecording
Prelude.Read, Int -> StartContactRecording -> ShowS
[StartContactRecording] -> ShowS
StartContactRecording -> String
(Int -> StartContactRecording -> ShowS)
-> (StartContactRecording -> String)
-> ([StartContactRecording] -> ShowS)
-> Show StartContactRecording
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartContactRecording] -> ShowS
$cshowList :: [StartContactRecording] -> ShowS
show :: StartContactRecording -> String
$cshow :: StartContactRecording -> String
showsPrec :: Int -> StartContactRecording -> ShowS
$cshowsPrec :: Int -> StartContactRecording -> ShowS
Prelude.Show, (forall x. StartContactRecording -> Rep StartContactRecording x)
-> (forall x. Rep StartContactRecording x -> StartContactRecording)
-> Generic StartContactRecording
forall x. Rep StartContactRecording x -> StartContactRecording
forall x. StartContactRecording -> Rep StartContactRecording x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartContactRecording x -> StartContactRecording
$cfrom :: forall x. StartContactRecording -> Rep StartContactRecording x
Prelude.Generic)

-- |
-- Create a value of 'StartContactRecording' 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', 'startContactRecording_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'contactId', 'startContactRecording_contactId' - The identifier of the contact.
--
-- 'initialContactId', 'startContactRecording_initialContactId' - The identifier of the contact. This is the identifier of the contact
-- associated with the first interaction with the contact center.
--
-- 'voiceRecordingConfiguration', 'startContactRecording_voiceRecordingConfiguration' - The person being recorded.
newStartContactRecording ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'contactId'
  Prelude.Text ->
  -- | 'initialContactId'
  Prelude.Text ->
  -- | 'voiceRecordingConfiguration'
  VoiceRecordingConfiguration ->
  StartContactRecording
newStartContactRecording :: Text
-> Text
-> Text
-> VoiceRecordingConfiguration
-> StartContactRecording
newStartContactRecording
  Text
pInstanceId_
  Text
pContactId_
  Text
pInitialContactId_
  VoiceRecordingConfiguration
pVoiceRecordingConfiguration_ =
    StartContactRecording' :: Text
-> Text
-> Text
-> VoiceRecordingConfiguration
-> StartContactRecording
StartContactRecording'
      { $sel:instanceId:StartContactRecording' :: Text
instanceId = Text
pInstanceId_,
        $sel:contactId:StartContactRecording' :: Text
contactId = Text
pContactId_,
        $sel:initialContactId:StartContactRecording' :: Text
initialContactId = Text
pInitialContactId_,
        $sel:voiceRecordingConfiguration:StartContactRecording' :: VoiceRecordingConfiguration
voiceRecordingConfiguration =
          VoiceRecordingConfiguration
pVoiceRecordingConfiguration_
      }

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
startContactRecording_instanceId :: Lens.Lens' StartContactRecording Prelude.Text
startContactRecording_instanceId :: (Text -> f Text)
-> StartContactRecording -> f StartContactRecording
startContactRecording_instanceId = (StartContactRecording -> Text)
-> (StartContactRecording -> Text -> StartContactRecording)
-> Lens StartContactRecording StartContactRecording Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContactRecording' {Text
instanceId :: Text
$sel:instanceId:StartContactRecording' :: StartContactRecording -> Text
instanceId} -> Text
instanceId) (\s :: StartContactRecording
s@StartContactRecording' {} Text
a -> StartContactRecording
s {$sel:instanceId:StartContactRecording' :: Text
instanceId = Text
a} :: StartContactRecording)

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

-- | The identifier of the contact. This is the identifier of the contact
-- associated with the first interaction with the contact center.
startContactRecording_initialContactId :: Lens.Lens' StartContactRecording Prelude.Text
startContactRecording_initialContactId :: (Text -> f Text)
-> StartContactRecording -> f StartContactRecording
startContactRecording_initialContactId = (StartContactRecording -> Text)
-> (StartContactRecording -> Text -> StartContactRecording)
-> Lens StartContactRecording StartContactRecording Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContactRecording' {Text
initialContactId :: Text
$sel:initialContactId:StartContactRecording' :: StartContactRecording -> Text
initialContactId} -> Text
initialContactId) (\s :: StartContactRecording
s@StartContactRecording' {} Text
a -> StartContactRecording
s {$sel:initialContactId:StartContactRecording' :: Text
initialContactId = Text
a} :: StartContactRecording)

-- | The person being recorded.
startContactRecording_voiceRecordingConfiguration :: Lens.Lens' StartContactRecording VoiceRecordingConfiguration
startContactRecording_voiceRecordingConfiguration :: (VoiceRecordingConfiguration -> f VoiceRecordingConfiguration)
-> StartContactRecording -> f StartContactRecording
startContactRecording_voiceRecordingConfiguration = (StartContactRecording -> VoiceRecordingConfiguration)
-> (StartContactRecording
    -> VoiceRecordingConfiguration -> StartContactRecording)
-> Lens
     StartContactRecording
     StartContactRecording
     VoiceRecordingConfiguration
     VoiceRecordingConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContactRecording' {VoiceRecordingConfiguration
voiceRecordingConfiguration :: VoiceRecordingConfiguration
$sel:voiceRecordingConfiguration:StartContactRecording' :: StartContactRecording -> VoiceRecordingConfiguration
voiceRecordingConfiguration} -> VoiceRecordingConfiguration
voiceRecordingConfiguration) (\s :: StartContactRecording
s@StartContactRecording' {} VoiceRecordingConfiguration
a -> StartContactRecording
s {$sel:voiceRecordingConfiguration:StartContactRecording' :: VoiceRecordingConfiguration
voiceRecordingConfiguration = VoiceRecordingConfiguration
a} :: StartContactRecording)

instance Core.AWSRequest StartContactRecording where
  type
    AWSResponse StartContactRecording =
      StartContactRecordingResponse
  request :: StartContactRecording -> Request StartContactRecording
request = Service -> StartContactRecording -> Request StartContactRecording
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartContactRecording
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartContactRecording)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StartContactRecording))
-> Logger
-> Service
-> Proxy StartContactRecording
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartContactRecording)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartContactRecordingResponse
StartContactRecordingResponse'
            (Int -> StartContactRecordingResponse)
-> Either String Int -> Either String StartContactRecordingResponse
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))
      )

instance Prelude.Hashable StartContactRecording

instance Prelude.NFData StartContactRecording

instance Core.ToHeaders StartContactRecording where
  toHeaders :: StartContactRecording -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartContactRecording -> 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 StartContactRecording where
  toJSON :: StartContactRecording -> Value
toJSON StartContactRecording' {Text
VoiceRecordingConfiguration
voiceRecordingConfiguration :: VoiceRecordingConfiguration
initialContactId :: Text
contactId :: Text
instanceId :: Text
$sel:voiceRecordingConfiguration:StartContactRecording' :: StartContactRecording -> VoiceRecordingConfiguration
$sel:initialContactId:StartContactRecording' :: StartContactRecording -> Text
$sel:contactId:StartContactRecording' :: StartContactRecording -> Text
$sel:instanceId:StartContactRecording' :: StartContactRecording -> 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
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ContactId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"InitialContactId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
initialContactId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"VoiceRecordingConfiguration"
                  Text -> VoiceRecordingConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= VoiceRecordingConfiguration
voiceRecordingConfiguration
              )
          ]
      )

instance Core.ToPath StartContactRecording where
  toPath :: StartContactRecording -> ByteString
toPath = ByteString -> StartContactRecording -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/contact/start-recording"

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

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

-- |
-- Create a value of 'StartContactRecordingResponse' 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', 'startContactRecordingResponse_httpStatus' - The response's http status code.
newStartContactRecordingResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartContactRecordingResponse
newStartContactRecordingResponse :: Int -> StartContactRecordingResponse
newStartContactRecordingResponse Int
pHttpStatus_ =
  StartContactRecordingResponse' :: Int -> StartContactRecordingResponse
StartContactRecordingResponse'
    { $sel:httpStatus:StartContactRecordingResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData StartContactRecordingResponse