{-# 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.AssociateBot
-- 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)
--
-- This API is in preview release for Amazon Connect and is subject to
-- change.
--
-- Allows the specified Amazon Connect instance to access the specified
-- Amazon Lex or Amazon Lex V2 bot.
module Amazonka.Connect.AssociateBot
  ( -- * Creating a Request
    AssociateBot (..),
    newAssociateBot,

    -- * Request Lenses
    associateBot_lexBot,
    associateBot_lexV2Bot,
    associateBot_instanceId,

    -- * Destructuring the Response
    AssociateBotResponse (..),
    newAssociateBotResponse,
  )
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:/ 'newAssociateBot' smart constructor.
data AssociateBot = AssociateBot'
  { AssociateBot -> Maybe LexBot
lexBot :: Prelude.Maybe LexBot,
    -- | The Amazon Lex V2 bot to associate with the instance.
    AssociateBot -> Maybe LexV2Bot
lexV2Bot :: Prelude.Maybe LexV2Bot,
    -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    AssociateBot -> Text
instanceId :: Prelude.Text
  }
  deriving (AssociateBot -> AssociateBot -> Bool
(AssociateBot -> AssociateBot -> Bool)
-> (AssociateBot -> AssociateBot -> Bool) -> Eq AssociateBot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateBot -> AssociateBot -> Bool
$c/= :: AssociateBot -> AssociateBot -> Bool
== :: AssociateBot -> AssociateBot -> Bool
$c== :: AssociateBot -> AssociateBot -> Bool
Prelude.Eq, ReadPrec [AssociateBot]
ReadPrec AssociateBot
Int -> ReadS AssociateBot
ReadS [AssociateBot]
(Int -> ReadS AssociateBot)
-> ReadS [AssociateBot]
-> ReadPrec AssociateBot
-> ReadPrec [AssociateBot]
-> Read AssociateBot
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateBot]
$creadListPrec :: ReadPrec [AssociateBot]
readPrec :: ReadPrec AssociateBot
$creadPrec :: ReadPrec AssociateBot
readList :: ReadS [AssociateBot]
$creadList :: ReadS [AssociateBot]
readsPrec :: Int -> ReadS AssociateBot
$creadsPrec :: Int -> ReadS AssociateBot
Prelude.Read, Int -> AssociateBot -> ShowS
[AssociateBot] -> ShowS
AssociateBot -> String
(Int -> AssociateBot -> ShowS)
-> (AssociateBot -> String)
-> ([AssociateBot] -> ShowS)
-> Show AssociateBot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateBot] -> ShowS
$cshowList :: [AssociateBot] -> ShowS
show :: AssociateBot -> String
$cshow :: AssociateBot -> String
showsPrec :: Int -> AssociateBot -> ShowS
$cshowsPrec :: Int -> AssociateBot -> ShowS
Prelude.Show, (forall x. AssociateBot -> Rep AssociateBot x)
-> (forall x. Rep AssociateBot x -> AssociateBot)
-> Generic AssociateBot
forall x. Rep AssociateBot x -> AssociateBot
forall x. AssociateBot -> Rep AssociateBot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateBot x -> AssociateBot
$cfrom :: forall x. AssociateBot -> Rep AssociateBot x
Prelude.Generic)

-- |
-- Create a value of 'AssociateBot' 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:
--
-- 'lexBot', 'associateBot_lexBot' - Undocumented member.
--
-- 'lexV2Bot', 'associateBot_lexV2Bot' - The Amazon Lex V2 bot to associate with the instance.
--
-- 'instanceId', 'associateBot_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
newAssociateBot ::
  -- | 'instanceId'
  Prelude.Text ->
  AssociateBot
newAssociateBot :: Text -> AssociateBot
newAssociateBot Text
pInstanceId_ =
  AssociateBot' :: Maybe LexBot -> Maybe LexV2Bot -> Text -> AssociateBot
AssociateBot'
    { $sel:lexBot:AssociateBot' :: Maybe LexBot
lexBot = Maybe LexBot
forall a. Maybe a
Prelude.Nothing,
      $sel:lexV2Bot:AssociateBot' :: Maybe LexV2Bot
lexV2Bot = Maybe LexV2Bot
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:AssociateBot' :: Text
instanceId = Text
pInstanceId_
    }

-- | Undocumented member.
associateBot_lexBot :: Lens.Lens' AssociateBot (Prelude.Maybe LexBot)
associateBot_lexBot :: (Maybe LexBot -> f (Maybe LexBot))
-> AssociateBot -> f AssociateBot
associateBot_lexBot = (AssociateBot -> Maybe LexBot)
-> (AssociateBot -> Maybe LexBot -> AssociateBot)
-> Lens AssociateBot AssociateBot (Maybe LexBot) (Maybe LexBot)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateBot' {Maybe LexBot
lexBot :: Maybe LexBot
$sel:lexBot:AssociateBot' :: AssociateBot -> Maybe LexBot
lexBot} -> Maybe LexBot
lexBot) (\s :: AssociateBot
s@AssociateBot' {} Maybe LexBot
a -> AssociateBot
s {$sel:lexBot:AssociateBot' :: Maybe LexBot
lexBot = Maybe LexBot
a} :: AssociateBot)

-- | The Amazon Lex V2 bot to associate with the instance.
associateBot_lexV2Bot :: Lens.Lens' AssociateBot (Prelude.Maybe LexV2Bot)
associateBot_lexV2Bot :: (Maybe LexV2Bot -> f (Maybe LexV2Bot))
-> AssociateBot -> f AssociateBot
associateBot_lexV2Bot = (AssociateBot -> Maybe LexV2Bot)
-> (AssociateBot -> Maybe LexV2Bot -> AssociateBot)
-> Lens AssociateBot AssociateBot (Maybe LexV2Bot) (Maybe LexV2Bot)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateBot' {Maybe LexV2Bot
lexV2Bot :: Maybe LexV2Bot
$sel:lexV2Bot:AssociateBot' :: AssociateBot -> Maybe LexV2Bot
lexV2Bot} -> Maybe LexV2Bot
lexV2Bot) (\s :: AssociateBot
s@AssociateBot' {} Maybe LexV2Bot
a -> AssociateBot
s {$sel:lexV2Bot:AssociateBot' :: Maybe LexV2Bot
lexV2Bot = Maybe LexV2Bot
a} :: AssociateBot)

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

instance Core.AWSRequest AssociateBot where
  type AWSResponse AssociateBot = AssociateBotResponse
  request :: AssociateBot -> Request AssociateBot
request = Service -> AssociateBot -> Request AssociateBot
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateBot)))
response = AWSResponse AssociateBot
-> Logger
-> Service
-> Proxy AssociateBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateBot)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse AssociateBot
AssociateBotResponse
AssociateBotResponse'

instance Prelude.Hashable AssociateBot

instance Prelude.NFData AssociateBot

instance Core.ToHeaders AssociateBot where
  toHeaders :: AssociateBot -> [Header]
toHeaders =
    [Header] -> AssociateBot -> [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 AssociateBot where
  toJSON :: AssociateBot -> Value
toJSON AssociateBot' {Maybe LexBot
Maybe LexV2Bot
Text
instanceId :: Text
lexV2Bot :: Maybe LexV2Bot
lexBot :: Maybe LexBot
$sel:instanceId:AssociateBot' :: AssociateBot -> Text
$sel:lexV2Bot:AssociateBot' :: AssociateBot -> Maybe LexV2Bot
$sel:lexBot:AssociateBot' :: AssociateBot -> Maybe LexBot
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LexBot" Text -> LexBot -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LexBot -> Pair) -> Maybe LexBot -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LexBot
lexBot,
            (Text
"LexV2Bot" Text -> LexV2Bot -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LexV2Bot -> Pair) -> Maybe LexV2Bot -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LexV2Bot
lexV2Bot
          ]
      )

instance Core.ToPath AssociateBot where
  toPath :: AssociateBot -> ByteString
toPath AssociateBot' {Maybe LexBot
Maybe LexV2Bot
Text
instanceId :: Text
lexV2Bot :: Maybe LexV2Bot
lexBot :: Maybe LexBot
$sel:instanceId:AssociateBot' :: AssociateBot -> Text
$sel:lexV2Bot:AssociateBot' :: AssociateBot -> Maybe LexV2Bot
$sel:lexBot:AssociateBot' :: AssociateBot -> Maybe LexBot
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/instance/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
instanceId, ByteString
"/bot"]

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

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

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

instance Prelude.NFData AssociateBotResponse