{-# 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.AlexaBusiness.AssociateContactWithAddressBook
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates a contact with a given address book.
module Amazonka.AlexaBusiness.AssociateContactWithAddressBook
  ( -- * Creating a Request
    AssociateContactWithAddressBook (..),
    newAssociateContactWithAddressBook,

    -- * Request Lenses
    associateContactWithAddressBook_contactArn,
    associateContactWithAddressBook_addressBookArn,

    -- * Destructuring the Response
    AssociateContactWithAddressBookResponse (..),
    newAssociateContactWithAddressBookResponse,

    -- * Response Lenses
    associateContactWithAddressBookResponse_httpStatus,
  )
where

import Amazonka.AlexaBusiness.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:/ 'newAssociateContactWithAddressBook' smart constructor.
data AssociateContactWithAddressBook = AssociateContactWithAddressBook'
  { -- | The ARN of the contact to associate with an address book.
    AssociateContactWithAddressBook -> Text
contactArn :: Prelude.Text,
    -- | The ARN of the address book with which to associate the contact.
    AssociateContactWithAddressBook -> Text
addressBookArn :: Prelude.Text
  }
  deriving (AssociateContactWithAddressBook
-> AssociateContactWithAddressBook -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateContactWithAddressBook
-> AssociateContactWithAddressBook -> Bool
$c/= :: AssociateContactWithAddressBook
-> AssociateContactWithAddressBook -> Bool
== :: AssociateContactWithAddressBook
-> AssociateContactWithAddressBook -> Bool
$c== :: AssociateContactWithAddressBook
-> AssociateContactWithAddressBook -> Bool
Prelude.Eq, ReadPrec [AssociateContactWithAddressBook]
ReadPrec AssociateContactWithAddressBook
Int -> ReadS AssociateContactWithAddressBook
ReadS [AssociateContactWithAddressBook]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateContactWithAddressBook]
$creadListPrec :: ReadPrec [AssociateContactWithAddressBook]
readPrec :: ReadPrec AssociateContactWithAddressBook
$creadPrec :: ReadPrec AssociateContactWithAddressBook
readList :: ReadS [AssociateContactWithAddressBook]
$creadList :: ReadS [AssociateContactWithAddressBook]
readsPrec :: Int -> ReadS AssociateContactWithAddressBook
$creadsPrec :: Int -> ReadS AssociateContactWithAddressBook
Prelude.Read, Int -> AssociateContactWithAddressBook -> ShowS
[AssociateContactWithAddressBook] -> ShowS
AssociateContactWithAddressBook -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateContactWithAddressBook] -> ShowS
$cshowList :: [AssociateContactWithAddressBook] -> ShowS
show :: AssociateContactWithAddressBook -> String
$cshow :: AssociateContactWithAddressBook -> String
showsPrec :: Int -> AssociateContactWithAddressBook -> ShowS
$cshowsPrec :: Int -> AssociateContactWithAddressBook -> ShowS
Prelude.Show, forall x.
Rep AssociateContactWithAddressBook x
-> AssociateContactWithAddressBook
forall x.
AssociateContactWithAddressBook
-> Rep AssociateContactWithAddressBook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateContactWithAddressBook x
-> AssociateContactWithAddressBook
$cfrom :: forall x.
AssociateContactWithAddressBook
-> Rep AssociateContactWithAddressBook x
Prelude.Generic)

-- |
-- Create a value of 'AssociateContactWithAddressBook' 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:
--
-- 'contactArn', 'associateContactWithAddressBook_contactArn' - The ARN of the contact to associate with an address book.
--
-- 'addressBookArn', 'associateContactWithAddressBook_addressBookArn' - The ARN of the address book with which to associate the contact.
newAssociateContactWithAddressBook ::
  -- | 'contactArn'
  Prelude.Text ->
  -- | 'addressBookArn'
  Prelude.Text ->
  AssociateContactWithAddressBook
newAssociateContactWithAddressBook :: Text -> Text -> AssociateContactWithAddressBook
newAssociateContactWithAddressBook
  Text
pContactArn_
  Text
pAddressBookArn_ =
    AssociateContactWithAddressBook'
      { $sel:contactArn:AssociateContactWithAddressBook' :: Text
contactArn =
          Text
pContactArn_,
        $sel:addressBookArn:AssociateContactWithAddressBook' :: Text
addressBookArn = Text
pAddressBookArn_
      }

-- | The ARN of the contact to associate with an address book.
associateContactWithAddressBook_contactArn :: Lens.Lens' AssociateContactWithAddressBook Prelude.Text
associateContactWithAddressBook_contactArn :: Lens' AssociateContactWithAddressBook Text
associateContactWithAddressBook_contactArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateContactWithAddressBook' {Text
contactArn :: Text
$sel:contactArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
contactArn} -> Text
contactArn) (\s :: AssociateContactWithAddressBook
s@AssociateContactWithAddressBook' {} Text
a -> AssociateContactWithAddressBook
s {$sel:contactArn:AssociateContactWithAddressBook' :: Text
contactArn = Text
a} :: AssociateContactWithAddressBook)

-- | The ARN of the address book with which to associate the contact.
associateContactWithAddressBook_addressBookArn :: Lens.Lens' AssociateContactWithAddressBook Prelude.Text
associateContactWithAddressBook_addressBookArn :: Lens' AssociateContactWithAddressBook Text
associateContactWithAddressBook_addressBookArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateContactWithAddressBook' {Text
addressBookArn :: Text
$sel:addressBookArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
addressBookArn} -> Text
addressBookArn) (\s :: AssociateContactWithAddressBook
s@AssociateContactWithAddressBook' {} Text
a -> AssociateContactWithAddressBook
s {$sel:addressBookArn:AssociateContactWithAddressBook' :: Text
addressBookArn = Text
a} :: AssociateContactWithAddressBook)

instance
  Core.AWSRequest
    AssociateContactWithAddressBook
  where
  type
    AWSResponse AssociateContactWithAddressBook =
      AssociateContactWithAddressBookResponse
  request :: (Service -> Service)
-> AssociateContactWithAddressBook
-> Request AssociateContactWithAddressBook
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateContactWithAddressBook
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateContactWithAddressBook)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateContactWithAddressBookResponse
AssociateContactWithAddressBookResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    AssociateContactWithAddressBook
  where
  hashWithSalt :: Int -> AssociateContactWithAddressBook -> Int
hashWithSalt
    Int
_salt
    AssociateContactWithAddressBook' {Text
addressBookArn :: Text
contactArn :: Text
$sel:addressBookArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
$sel:contactArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactArn
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
addressBookArn

instance
  Prelude.NFData
    AssociateContactWithAddressBook
  where
  rnf :: AssociateContactWithAddressBook -> ()
rnf AssociateContactWithAddressBook' {Text
addressBookArn :: Text
contactArn :: Text
$sel:addressBookArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
$sel:contactArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
contactArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
addressBookArn

instance
  Data.ToHeaders
    AssociateContactWithAddressBook
  where
  toHeaders :: AssociateContactWithAddressBook -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AlexaForBusiness.AssociateContactWithAddressBook" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON AssociateContactWithAddressBook where
  toJSON :: AssociateContactWithAddressBook -> Value
toJSON AssociateContactWithAddressBook' {Text
addressBookArn :: Text
contactArn :: Text
$sel:addressBookArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
$sel:contactArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"ContactArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
contactArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AddressBookArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
addressBookArn)
          ]
      )

instance Data.ToPath AssociateContactWithAddressBook where
  toPath :: AssociateContactWithAddressBook -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance
  Prelude.NFData
    AssociateContactWithAddressBookResponse
  where
  rnf :: AssociateContactWithAddressBookResponse -> ()
rnf AssociateContactWithAddressBookResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateContactWithAddressBookResponse' :: AssociateContactWithAddressBookResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus