{-# 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.UpdateAddressBook
-- 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)
--
-- Updates address book details by the address book ARN.
module Amazonka.AlexaBusiness.UpdateAddressBook
  ( -- * Creating a Request
    UpdateAddressBook (..),
    newUpdateAddressBook,

    -- * Request Lenses
    updateAddressBook_name,
    updateAddressBook_description,
    updateAddressBook_addressBookArn,

    -- * Destructuring the Response
    UpdateAddressBookResponse (..),
    newUpdateAddressBookResponse,

    -- * Response Lenses
    updateAddressBookResponse_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:/ 'newUpdateAddressBook' smart constructor.
data UpdateAddressBook = UpdateAddressBook'
  { -- | The updated name of the room.
    UpdateAddressBook -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The updated description of the room.
    UpdateAddressBook -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the room to update.
    UpdateAddressBook -> Text
addressBookArn :: Prelude.Text
  }
  deriving (UpdateAddressBook -> UpdateAddressBook -> Bool
(UpdateAddressBook -> UpdateAddressBook -> Bool)
-> (UpdateAddressBook -> UpdateAddressBook -> Bool)
-> Eq UpdateAddressBook
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAddressBook -> UpdateAddressBook -> Bool
$c/= :: UpdateAddressBook -> UpdateAddressBook -> Bool
== :: UpdateAddressBook -> UpdateAddressBook -> Bool
$c== :: UpdateAddressBook -> UpdateAddressBook -> Bool
Prelude.Eq, ReadPrec [UpdateAddressBook]
ReadPrec UpdateAddressBook
Int -> ReadS UpdateAddressBook
ReadS [UpdateAddressBook]
(Int -> ReadS UpdateAddressBook)
-> ReadS [UpdateAddressBook]
-> ReadPrec UpdateAddressBook
-> ReadPrec [UpdateAddressBook]
-> Read UpdateAddressBook
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAddressBook]
$creadListPrec :: ReadPrec [UpdateAddressBook]
readPrec :: ReadPrec UpdateAddressBook
$creadPrec :: ReadPrec UpdateAddressBook
readList :: ReadS [UpdateAddressBook]
$creadList :: ReadS [UpdateAddressBook]
readsPrec :: Int -> ReadS UpdateAddressBook
$creadsPrec :: Int -> ReadS UpdateAddressBook
Prelude.Read, Int -> UpdateAddressBook -> ShowS
[UpdateAddressBook] -> ShowS
UpdateAddressBook -> String
(Int -> UpdateAddressBook -> ShowS)
-> (UpdateAddressBook -> String)
-> ([UpdateAddressBook] -> ShowS)
-> Show UpdateAddressBook
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAddressBook] -> ShowS
$cshowList :: [UpdateAddressBook] -> ShowS
show :: UpdateAddressBook -> String
$cshow :: UpdateAddressBook -> String
showsPrec :: Int -> UpdateAddressBook -> ShowS
$cshowsPrec :: Int -> UpdateAddressBook -> ShowS
Prelude.Show, (forall x. UpdateAddressBook -> Rep UpdateAddressBook x)
-> (forall x. Rep UpdateAddressBook x -> UpdateAddressBook)
-> Generic UpdateAddressBook
forall x. Rep UpdateAddressBook x -> UpdateAddressBook
forall x. UpdateAddressBook -> Rep UpdateAddressBook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAddressBook x -> UpdateAddressBook
$cfrom :: forall x. UpdateAddressBook -> Rep UpdateAddressBook x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAddressBook' 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:
--
-- 'name', 'updateAddressBook_name' - The updated name of the room.
--
-- 'description', 'updateAddressBook_description' - The updated description of the room.
--
-- 'addressBookArn', 'updateAddressBook_addressBookArn' - The ARN of the room to update.
newUpdateAddressBook ::
  -- | 'addressBookArn'
  Prelude.Text ->
  UpdateAddressBook
newUpdateAddressBook :: Text -> UpdateAddressBook
newUpdateAddressBook Text
pAddressBookArn_ =
  UpdateAddressBook' :: Maybe Text -> Maybe Text -> Text -> UpdateAddressBook
UpdateAddressBook'
    { $sel:name:UpdateAddressBook' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateAddressBook' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:addressBookArn:UpdateAddressBook' :: Text
addressBookArn = Text
pAddressBookArn_
    }

-- | The updated name of the room.
updateAddressBook_name :: Lens.Lens' UpdateAddressBook (Prelude.Maybe Prelude.Text)
updateAddressBook_name :: (Maybe Text -> f (Maybe Text))
-> UpdateAddressBook -> f UpdateAddressBook
updateAddressBook_name = (UpdateAddressBook -> Maybe Text)
-> (UpdateAddressBook -> Maybe Text -> UpdateAddressBook)
-> Lens
     UpdateAddressBook UpdateAddressBook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAddressBook' {Maybe Text
name :: Maybe Text
$sel:name:UpdateAddressBook' :: UpdateAddressBook -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateAddressBook
s@UpdateAddressBook' {} Maybe Text
a -> UpdateAddressBook
s {$sel:name:UpdateAddressBook' :: Maybe Text
name = Maybe Text
a} :: UpdateAddressBook)

-- | The updated description of the room.
updateAddressBook_description :: Lens.Lens' UpdateAddressBook (Prelude.Maybe Prelude.Text)
updateAddressBook_description :: (Maybe Text -> f (Maybe Text))
-> UpdateAddressBook -> f UpdateAddressBook
updateAddressBook_description = (UpdateAddressBook -> Maybe Text)
-> (UpdateAddressBook -> Maybe Text -> UpdateAddressBook)
-> Lens
     UpdateAddressBook UpdateAddressBook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAddressBook' {Maybe Text
description :: Maybe Text
$sel:description:UpdateAddressBook' :: UpdateAddressBook -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateAddressBook
s@UpdateAddressBook' {} Maybe Text
a -> UpdateAddressBook
s {$sel:description:UpdateAddressBook' :: Maybe Text
description = Maybe Text
a} :: UpdateAddressBook)

-- | The ARN of the room to update.
updateAddressBook_addressBookArn :: Lens.Lens' UpdateAddressBook Prelude.Text
updateAddressBook_addressBookArn :: (Text -> f Text) -> UpdateAddressBook -> f UpdateAddressBook
updateAddressBook_addressBookArn = (UpdateAddressBook -> Text)
-> (UpdateAddressBook -> Text -> UpdateAddressBook)
-> Lens UpdateAddressBook UpdateAddressBook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAddressBook' {Text
addressBookArn :: Text
$sel:addressBookArn:UpdateAddressBook' :: UpdateAddressBook -> Text
addressBookArn} -> Text
addressBookArn) (\s :: UpdateAddressBook
s@UpdateAddressBook' {} Text
a -> UpdateAddressBook
s {$sel:addressBookArn:UpdateAddressBook' :: Text
addressBookArn = Text
a} :: UpdateAddressBook)

instance Core.AWSRequest UpdateAddressBook where
  type
    AWSResponse UpdateAddressBook =
      UpdateAddressBookResponse
  request :: UpdateAddressBook -> Request UpdateAddressBook
request = Service -> UpdateAddressBook -> Request UpdateAddressBook
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateAddressBook
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAddressBook)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateAddressBook))
-> Logger
-> Service
-> Proxy UpdateAddressBook
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAddressBook)))
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 -> UpdateAddressBookResponse
UpdateAddressBookResponse'
            (Int -> UpdateAddressBookResponse)
-> Either String Int -> Either String UpdateAddressBookResponse
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 UpdateAddressBook

instance Prelude.NFData UpdateAddressBook

instance Core.ToHeaders UpdateAddressBook where
  toHeaders :: UpdateAddressBook -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateAddressBook -> 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.UpdateAddressBook" ::
                          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 UpdateAddressBook where
  toJSON :: UpdateAddressBook -> Value
toJSON UpdateAddressBook' {Maybe Text
Text
addressBookArn :: Text
description :: Maybe Text
name :: Maybe Text
$sel:addressBookArn:UpdateAddressBook' :: UpdateAddressBook -> Text
$sel:description:UpdateAddressBook' :: UpdateAddressBook -> Maybe Text
$sel:name:UpdateAddressBook' :: UpdateAddressBook -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            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 UpdateAddressBook where
  toPath :: UpdateAddressBook -> ByteString
toPath = ByteString -> UpdateAddressBook -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData UpdateAddressBookResponse