{-# 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.AssociateLambdaFunction
-- 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
-- Lambda function.
module Amazonka.Connect.AssociateLambdaFunction
  ( -- * Creating a Request
    AssociateLambdaFunction (..),
    newAssociateLambdaFunction,

    -- * Request Lenses
    associateLambdaFunction_instanceId,
    associateLambdaFunction_functionArn,

    -- * Destructuring the Response
    AssociateLambdaFunctionResponse (..),
    newAssociateLambdaFunctionResponse,
  )
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:/ 'newAssociateLambdaFunction' smart constructor.
data AssociateLambdaFunction = AssociateLambdaFunction'
  { -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    AssociateLambdaFunction -> Text
instanceId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the Lambda function being associated.
    -- Maximum number of characters allowed is 140.
    AssociateLambdaFunction -> Text
functionArn :: Prelude.Text
  }
  deriving (AssociateLambdaFunction -> AssociateLambdaFunction -> Bool
(AssociateLambdaFunction -> AssociateLambdaFunction -> Bool)
-> (AssociateLambdaFunction -> AssociateLambdaFunction -> Bool)
-> Eq AssociateLambdaFunction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateLambdaFunction -> AssociateLambdaFunction -> Bool
$c/= :: AssociateLambdaFunction -> AssociateLambdaFunction -> Bool
== :: AssociateLambdaFunction -> AssociateLambdaFunction -> Bool
$c== :: AssociateLambdaFunction -> AssociateLambdaFunction -> Bool
Prelude.Eq, ReadPrec [AssociateLambdaFunction]
ReadPrec AssociateLambdaFunction
Int -> ReadS AssociateLambdaFunction
ReadS [AssociateLambdaFunction]
(Int -> ReadS AssociateLambdaFunction)
-> ReadS [AssociateLambdaFunction]
-> ReadPrec AssociateLambdaFunction
-> ReadPrec [AssociateLambdaFunction]
-> Read AssociateLambdaFunction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateLambdaFunction]
$creadListPrec :: ReadPrec [AssociateLambdaFunction]
readPrec :: ReadPrec AssociateLambdaFunction
$creadPrec :: ReadPrec AssociateLambdaFunction
readList :: ReadS [AssociateLambdaFunction]
$creadList :: ReadS [AssociateLambdaFunction]
readsPrec :: Int -> ReadS AssociateLambdaFunction
$creadsPrec :: Int -> ReadS AssociateLambdaFunction
Prelude.Read, Int -> AssociateLambdaFunction -> ShowS
[AssociateLambdaFunction] -> ShowS
AssociateLambdaFunction -> String
(Int -> AssociateLambdaFunction -> ShowS)
-> (AssociateLambdaFunction -> String)
-> ([AssociateLambdaFunction] -> ShowS)
-> Show AssociateLambdaFunction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateLambdaFunction] -> ShowS
$cshowList :: [AssociateLambdaFunction] -> ShowS
show :: AssociateLambdaFunction -> String
$cshow :: AssociateLambdaFunction -> String
showsPrec :: Int -> AssociateLambdaFunction -> ShowS
$cshowsPrec :: Int -> AssociateLambdaFunction -> ShowS
Prelude.Show, (forall x.
 AssociateLambdaFunction -> Rep AssociateLambdaFunction x)
-> (forall x.
    Rep AssociateLambdaFunction x -> AssociateLambdaFunction)
-> Generic AssociateLambdaFunction
forall x. Rep AssociateLambdaFunction x -> AssociateLambdaFunction
forall x. AssociateLambdaFunction -> Rep AssociateLambdaFunction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateLambdaFunction x -> AssociateLambdaFunction
$cfrom :: forall x. AssociateLambdaFunction -> Rep AssociateLambdaFunction x
Prelude.Generic)

-- |
-- Create a value of 'AssociateLambdaFunction' 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', 'associateLambdaFunction_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'functionArn', 'associateLambdaFunction_functionArn' - The Amazon Resource Name (ARN) for the Lambda function being associated.
-- Maximum number of characters allowed is 140.
newAssociateLambdaFunction ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'functionArn'
  Prelude.Text ->
  AssociateLambdaFunction
newAssociateLambdaFunction :: Text -> Text -> AssociateLambdaFunction
newAssociateLambdaFunction Text
pInstanceId_ Text
pFunctionArn_ =
  AssociateLambdaFunction' :: Text -> Text -> AssociateLambdaFunction
AssociateLambdaFunction'
    { $sel:instanceId:AssociateLambdaFunction' :: Text
instanceId = Text
pInstanceId_,
      $sel:functionArn:AssociateLambdaFunction' :: Text
functionArn = Text
pFunctionArn_
    }

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

-- | The Amazon Resource Name (ARN) for the Lambda function being associated.
-- Maximum number of characters allowed is 140.
associateLambdaFunction_functionArn :: Lens.Lens' AssociateLambdaFunction Prelude.Text
associateLambdaFunction_functionArn :: (Text -> f Text)
-> AssociateLambdaFunction -> f AssociateLambdaFunction
associateLambdaFunction_functionArn = (AssociateLambdaFunction -> Text)
-> (AssociateLambdaFunction -> Text -> AssociateLambdaFunction)
-> Lens AssociateLambdaFunction AssociateLambdaFunction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateLambdaFunction' {Text
functionArn :: Text
$sel:functionArn:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
functionArn} -> Text
functionArn) (\s :: AssociateLambdaFunction
s@AssociateLambdaFunction' {} Text
a -> AssociateLambdaFunction
s {$sel:functionArn:AssociateLambdaFunction' :: Text
functionArn = Text
a} :: AssociateLambdaFunction)

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

instance Prelude.Hashable AssociateLambdaFunction

instance Prelude.NFData AssociateLambdaFunction

instance Core.ToHeaders AssociateLambdaFunction where
  toHeaders :: AssociateLambdaFunction -> [Header]
toHeaders =
    [Header] -> AssociateLambdaFunction -> [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 AssociateLambdaFunction where
  toJSON :: AssociateLambdaFunction -> Value
toJSON AssociateLambdaFunction' {Text
functionArn :: Text
instanceId :: Text
$sel:functionArn:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
$sel:instanceId:AssociateLambdaFunction' :: AssociateLambdaFunction -> 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
"FunctionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
functionArn)]
      )

instance Core.ToPath AssociateLambdaFunction where
  toPath :: AssociateLambdaFunction -> ByteString
toPath AssociateLambdaFunction' {Text
functionArn :: Text
instanceId :: Text
$sel:functionArn:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
$sel:instanceId:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
..} =
    [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
"/lambda-function"
      ]

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

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

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

instance
  Prelude.NFData
    AssociateLambdaFunctionResponse