{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' AssociateLambdaFunction Text
associateLambdaFunction_instanceId = 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 :: Lens' AssociateLambdaFunction Text
associateLambdaFunction_functionArn = 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 :: (Service -> Service)
-> AssociateLambdaFunction -> Request AssociateLambdaFunction
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateLambdaFunction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateLambdaFunction)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AssociateLambdaFunctionResponse
AssociateLambdaFunctionResponse'

instance Prelude.Hashable AssociateLambdaFunction where
  hashWithSalt :: Int -> AssociateLambdaFunction -> Int
hashWithSalt Int
_salt AssociateLambdaFunction' {Text
functionArn :: Text
instanceId :: Text
$sel:functionArn:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
$sel:instanceId:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
functionArn

instance Prelude.NFData AssociateLambdaFunction where
  rnf :: AssociateLambdaFunction -> ()
rnf AssociateLambdaFunction' {Text
functionArn :: Text
instanceId :: Text
$sel:functionArn:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
$sel:instanceId:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
functionArn

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

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"FunctionArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
functionArn)]
      )

instance Data.ToPath AssociateLambdaFunction where
  toPath :: AssociateLambdaFunction -> ByteString
toPath AssociateLambdaFunction' {Text
functionArn :: Text
instanceId :: Text
$sel:functionArn:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
$sel:instanceId:AssociateLambdaFunction' :: AssociateLambdaFunction -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/instance/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
instanceId,
        ByteString
"/lambda-function"
      ]

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

-- | /See:/ 'newAssociateLambdaFunctionResponse' smart constructor.
data AssociateLambdaFunctionResponse = AssociateLambdaFunctionResponse'
  {
  }
  deriving (AssociateLambdaFunctionResponse
-> AssociateLambdaFunctionResponse -> Bool
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]
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
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.
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
  where
  rnf :: AssociateLambdaFunctionResponse -> ()
rnf AssociateLambdaFunctionResponse
_ = ()