{-# 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-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)
--
-- 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.Lens as Lens
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
(AssociateContactWithAddressBook
 -> AssociateContactWithAddressBook -> Bool)
-> (AssociateContactWithAddressBook
    -> AssociateContactWithAddressBook -> Bool)
-> Eq AssociateContactWithAddressBook
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]
(Int -> ReadS AssociateContactWithAddressBook)
-> ReadS [AssociateContactWithAddressBook]
-> ReadPrec AssociateContactWithAddressBook
-> ReadPrec [AssociateContactWithAddressBook]
-> Read 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
(Int -> AssociateContactWithAddressBook -> ShowS)
-> (AssociateContactWithAddressBook -> String)
-> ([AssociateContactWithAddressBook] -> ShowS)
-> Show AssociateContactWithAddressBook
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.
 AssociateContactWithAddressBook
 -> Rep AssociateContactWithAddressBook x)
-> (forall x.
    Rep AssociateContactWithAddressBook x
    -> AssociateContactWithAddressBook)
-> Generic AssociateContactWithAddressBook
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' :: Text -> Text -> AssociateContactWithAddressBook
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 :: (Text -> f Text)
-> AssociateContactWithAddressBook
-> f AssociateContactWithAddressBook
associateContactWithAddressBook_contactArn = (AssociateContactWithAddressBook -> Text)
-> (AssociateContactWithAddressBook
    -> Text -> AssociateContactWithAddressBook)
-> Lens
     AssociateContactWithAddressBook
     AssociateContactWithAddressBook
     Text
     Text
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 :: (Text -> f Text)
-> AssociateContactWithAddressBook
-> f AssociateContactWithAddressBook
associateContactWithAddressBook_addressBookArn = (AssociateContactWithAddressBook -> Text)
-> (AssociateContactWithAddressBook
    -> Text -> AssociateContactWithAddressBook)
-> Lens
     AssociateContactWithAddressBook
     AssociateContactWithAddressBook
     Text
     Text
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 :: AssociateContactWithAddressBook
-> Request AssociateContactWithAddressBook
request = Service
-> AssociateContactWithAddressBook
-> Request AssociateContactWithAddressBook
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateContactWithAddressBook
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateContactWithAddressBook)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateContactWithAddressBook))
-> Logger
-> Service
-> Proxy AssociateContactWithAddressBook
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateContactWithAddressBook)))
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 -> AssociateContactWithAddressBookResponse
AssociateContactWithAddressBookResponse'
            (Int -> AssociateContactWithAddressBookResponse)
-> Either String Int
-> Either String AssociateContactWithAddressBookResponse
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
    AssociateContactWithAddressBook

instance
  Prelude.NFData
    AssociateContactWithAddressBook

instance
  Core.ToHeaders
    AssociateContactWithAddressBook
  where
  toHeaders :: AssociateContactWithAddressBook -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> AssociateContactWithAddressBook -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AlexaForBusiness.AssociateContactWithAddressBook" ::
                          Prelude.ByteString
                      ),
            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 AssociateContactWithAddressBook where
  toJSON :: AssociateContactWithAddressBook -> Value
toJSON AssociateContactWithAddressBook' {Text
addressBookArn :: Text
contactArn :: Text
$sel:addressBookArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> Text
$sel:contactArn:AssociateContactWithAddressBook' :: AssociateContactWithAddressBook -> 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
"ContactArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AddressBookArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
addressBookArn)
          ]
      )

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

instance Core.ToQuery AssociateContactWithAddressBook where
  toQuery :: AssociateContactWithAddressBook -> QueryString
toQuery = QueryString -> AssociateContactWithAddressBook -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(AssociateContactWithAddressBookResponse
 -> AssociateContactWithAddressBookResponse -> Bool)
-> (AssociateContactWithAddressBookResponse
    -> AssociateContactWithAddressBookResponse -> Bool)
-> Eq AssociateContactWithAddressBookResponse
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]
(Int -> ReadS AssociateContactWithAddressBookResponse)
-> ReadS [AssociateContactWithAddressBookResponse]
-> ReadPrec AssociateContactWithAddressBookResponse
-> ReadPrec [AssociateContactWithAddressBookResponse]
-> Read 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
(Int -> AssociateContactWithAddressBookResponse -> ShowS)
-> (AssociateContactWithAddressBookResponse -> String)
-> ([AssociateContactWithAddressBookResponse] -> ShowS)
-> Show AssociateContactWithAddressBookResponse
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.
 AssociateContactWithAddressBookResponse
 -> Rep AssociateContactWithAddressBookResponse x)
-> (forall x.
    Rep AssociateContactWithAddressBookResponse x
    -> AssociateContactWithAddressBookResponse)
-> Generic AssociateContactWithAddressBookResponse
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' :: Int -> AssociateContactWithAddressBookResponse
AssociateContactWithAddressBookResponse'
      { $sel:httpStatus:AssociateContactWithAddressBookResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

-- | The response's http status code.
associateContactWithAddressBookResponse_httpStatus :: Lens.Lens' AssociateContactWithAddressBookResponse Prelude.Int
associateContactWithAddressBookResponse_httpStatus :: (Int -> f Int)
-> AssociateContactWithAddressBookResponse
-> f AssociateContactWithAddressBookResponse
associateContactWithAddressBookResponse_httpStatus = (AssociateContactWithAddressBookResponse -> Int)
-> (AssociateContactWithAddressBookResponse
    -> Int -> AssociateContactWithAddressBookResponse)
-> Lens
     AssociateContactWithAddressBookResponse
     AssociateContactWithAddressBookResponse
     Int
     Int
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