{-# 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.SESV2.UpdateContactList
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates contact list metadata. This operation does a complete
-- replacement.
module Amazonka.SESV2.UpdateContactList
  ( -- * Creating a Request
    UpdateContactList (..),
    newUpdateContactList,

    -- * Request Lenses
    updateContactList_description,
    updateContactList_topics,
    updateContactList_contactListName,

    -- * Destructuring the Response
    UpdateContactListResponse (..),
    newUpdateContactListResponse,

    -- * Response Lenses
    updateContactListResponse_httpStatus,
  )
where

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
import Amazonka.SESV2.Types

-- | /See:/ 'newUpdateContactList' smart constructor.
data UpdateContactList = UpdateContactList'
  { -- | A description of what the contact list is about.
    UpdateContactList -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | An interest group, theme, or label within a list. A contact list can
    -- have multiple topics.
    UpdateContactList -> Maybe [Topic]
topics :: Prelude.Maybe [Topic],
    -- | The name of the contact list.
    UpdateContactList -> Text
contactListName :: Prelude.Text
  }
  deriving (UpdateContactList -> UpdateContactList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateContactList -> UpdateContactList -> Bool
$c/= :: UpdateContactList -> UpdateContactList -> Bool
== :: UpdateContactList -> UpdateContactList -> Bool
$c== :: UpdateContactList -> UpdateContactList -> Bool
Prelude.Eq, ReadPrec [UpdateContactList]
ReadPrec UpdateContactList
Int -> ReadS UpdateContactList
ReadS [UpdateContactList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateContactList]
$creadListPrec :: ReadPrec [UpdateContactList]
readPrec :: ReadPrec UpdateContactList
$creadPrec :: ReadPrec UpdateContactList
readList :: ReadS [UpdateContactList]
$creadList :: ReadS [UpdateContactList]
readsPrec :: Int -> ReadS UpdateContactList
$creadsPrec :: Int -> ReadS UpdateContactList
Prelude.Read, Int -> UpdateContactList -> ShowS
[UpdateContactList] -> ShowS
UpdateContactList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateContactList] -> ShowS
$cshowList :: [UpdateContactList] -> ShowS
show :: UpdateContactList -> String
$cshow :: UpdateContactList -> String
showsPrec :: Int -> UpdateContactList -> ShowS
$cshowsPrec :: Int -> UpdateContactList -> ShowS
Prelude.Show, forall x. Rep UpdateContactList x -> UpdateContactList
forall x. UpdateContactList -> Rep UpdateContactList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateContactList x -> UpdateContactList
$cfrom :: forall x. UpdateContactList -> Rep UpdateContactList x
Prelude.Generic)

-- |
-- Create a value of 'UpdateContactList' 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:
--
-- 'description', 'updateContactList_description' - A description of what the contact list is about.
--
-- 'topics', 'updateContactList_topics' - An interest group, theme, or label within a list. A contact list can
-- have multiple topics.
--
-- 'contactListName', 'updateContactList_contactListName' - The name of the contact list.
newUpdateContactList ::
  -- | 'contactListName'
  Prelude.Text ->
  UpdateContactList
newUpdateContactList :: Text -> UpdateContactList
newUpdateContactList Text
pContactListName_ =
  UpdateContactList'
    { $sel:description:UpdateContactList' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:topics:UpdateContactList' :: Maybe [Topic]
topics = forall a. Maybe a
Prelude.Nothing,
      $sel:contactListName:UpdateContactList' :: Text
contactListName = Text
pContactListName_
    }

-- | A description of what the contact list is about.
updateContactList_description :: Lens.Lens' UpdateContactList (Prelude.Maybe Prelude.Text)
updateContactList_description :: Lens' UpdateContactList (Maybe Text)
updateContactList_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactList' {Maybe Text
description :: Maybe Text
$sel:description:UpdateContactList' :: UpdateContactList -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateContactList
s@UpdateContactList' {} Maybe Text
a -> UpdateContactList
s {$sel:description:UpdateContactList' :: Maybe Text
description = Maybe Text
a} :: UpdateContactList)

-- | An interest group, theme, or label within a list. A contact list can
-- have multiple topics.
updateContactList_topics :: Lens.Lens' UpdateContactList (Prelude.Maybe [Topic])
updateContactList_topics :: Lens' UpdateContactList (Maybe [Topic])
updateContactList_topics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactList' {Maybe [Topic]
topics :: Maybe [Topic]
$sel:topics:UpdateContactList' :: UpdateContactList -> Maybe [Topic]
topics} -> Maybe [Topic]
topics) (\s :: UpdateContactList
s@UpdateContactList' {} Maybe [Topic]
a -> UpdateContactList
s {$sel:topics:UpdateContactList' :: Maybe [Topic]
topics = Maybe [Topic]
a} :: UpdateContactList) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the contact list.
updateContactList_contactListName :: Lens.Lens' UpdateContactList Prelude.Text
updateContactList_contactListName :: Lens' UpdateContactList Text
updateContactList_contactListName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactList' {Text
contactListName :: Text
$sel:contactListName:UpdateContactList' :: UpdateContactList -> Text
contactListName} -> Text
contactListName) (\s :: UpdateContactList
s@UpdateContactList' {} Text
a -> UpdateContactList
s {$sel:contactListName:UpdateContactList' :: Text
contactListName = Text
a} :: UpdateContactList)

instance Core.AWSRequest UpdateContactList where
  type
    AWSResponse UpdateContactList =
      UpdateContactListResponse
  request :: (Service -> Service)
-> UpdateContactList -> Request UpdateContactList
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 UpdateContactList
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateContactList)))
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 -> UpdateContactListResponse
UpdateContactListResponse'
            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 UpdateContactList where
  hashWithSalt :: Int -> UpdateContactList -> Int
hashWithSalt Int
_salt UpdateContactList' {Maybe [Topic]
Maybe Text
Text
contactListName :: Text
topics :: Maybe [Topic]
description :: Maybe Text
$sel:contactListName:UpdateContactList' :: UpdateContactList -> Text
$sel:topics:UpdateContactList' :: UpdateContactList -> Maybe [Topic]
$sel:description:UpdateContactList' :: UpdateContactList -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Topic]
topics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactListName

instance Prelude.NFData UpdateContactList where
  rnf :: UpdateContactList -> ()
rnf UpdateContactList' {Maybe [Topic]
Maybe Text
Text
contactListName :: Text
topics :: Maybe [Topic]
description :: Maybe Text
$sel:contactListName:UpdateContactList' :: UpdateContactList -> Text
$sel:topics:UpdateContactList' :: UpdateContactList -> Maybe [Topic]
$sel:description:UpdateContactList' :: UpdateContactList -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Topic]
topics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
contactListName

instance Data.ToHeaders UpdateContactList where
  toHeaders :: UpdateContactList -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateContactList where
  toJSON :: UpdateContactList -> Value
toJSON UpdateContactList' {Maybe [Topic]
Maybe Text
Text
contactListName :: Text
topics :: Maybe [Topic]
description :: Maybe Text
$sel:contactListName:UpdateContactList' :: UpdateContactList -> Text
$sel:topics:UpdateContactList' :: UpdateContactList -> Maybe [Topic]
$sel:description:UpdateContactList' :: UpdateContactList -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"Topics" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Topic]
topics
          ]
      )

instance Data.ToPath UpdateContactList where
  toPath :: UpdateContactList -> ByteString
toPath UpdateContactList' {Maybe [Topic]
Maybe Text
Text
contactListName :: Text
topics :: Maybe [Topic]
description :: Maybe Text
$sel:contactListName:UpdateContactList' :: UpdateContactList -> Text
$sel:topics:UpdateContactList' :: UpdateContactList -> Maybe [Topic]
$sel:description:UpdateContactList' :: UpdateContactList -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v2/email/contact-lists/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
contactListName
      ]

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

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

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

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

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