{-# 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.CreateContactList
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a contact list.
module Amazonka.SESV2.CreateContactList
  ( -- * Creating a Request
    CreateContactList (..),
    newCreateContactList,

    -- * Request Lenses
    createContactList_description,
    createContactList_tags,
    createContactList_topics,
    createContactList_contactListName,

    -- * Destructuring the Response
    CreateContactListResponse (..),
    newCreateContactListResponse,

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

-- |
-- Create a value of 'CreateContactList' 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', 'createContactList_description' - A description of what the contact list is about.
--
-- 'tags', 'createContactList_tags' - The tags associated with a contact list.
--
-- 'topics', 'createContactList_topics' - An interest group, theme, or label within a list. A contact list can
-- have multiple topics.
--
-- 'contactListName', 'createContactList_contactListName' - The name of the contact list.
newCreateContactList ::
  -- | 'contactListName'
  Prelude.Text ->
  CreateContactList
newCreateContactList :: Text -> CreateContactList
newCreateContactList Text
pContactListName_ =
  CreateContactList'
    { $sel:description:CreateContactList' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateContactList' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:topics:CreateContactList' :: Maybe [Topic]
topics = forall a. Maybe a
Prelude.Nothing,
      $sel:contactListName:CreateContactList' :: Text
contactListName = Text
pContactListName_
    }

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

-- | The tags associated with a contact list.
createContactList_tags :: Lens.Lens' CreateContactList (Prelude.Maybe [Tag])
createContactList_tags :: Lens' CreateContactList (Maybe [Tag])
createContactList_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactList' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateContactList' :: CreateContactList -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateContactList
s@CreateContactList' {} Maybe [Tag]
a -> CreateContactList
s {$sel:tags:CreateContactList' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateContactList) 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

-- | An interest group, theme, or label within a list. A contact list can
-- have multiple topics.
createContactList_topics :: Lens.Lens' CreateContactList (Prelude.Maybe [Topic])
createContactList_topics :: Lens' CreateContactList (Maybe [Topic])
createContactList_topics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactList' {Maybe [Topic]
topics :: Maybe [Topic]
$sel:topics:CreateContactList' :: CreateContactList -> Maybe [Topic]
topics} -> Maybe [Topic]
topics) (\s :: CreateContactList
s@CreateContactList' {} Maybe [Topic]
a -> CreateContactList
s {$sel:topics:CreateContactList' :: Maybe [Topic]
topics = Maybe [Topic]
a} :: CreateContactList) 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.
createContactList_contactListName :: Lens.Lens' CreateContactList Prelude.Text
createContactList_contactListName :: Lens' CreateContactList Text
createContactList_contactListName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactList' {Text
contactListName :: Text
$sel:contactListName:CreateContactList' :: CreateContactList -> Text
contactListName} -> Text
contactListName) (\s :: CreateContactList
s@CreateContactList' {} Text
a -> CreateContactList
s {$sel:contactListName:CreateContactList' :: Text
contactListName = Text
a} :: CreateContactList)

instance Core.AWSRequest CreateContactList where
  type
    AWSResponse CreateContactList =
      CreateContactListResponse
  request :: (Service -> Service)
-> CreateContactList -> Request CreateContactList
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 CreateContactList
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateContactList)))
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 -> CreateContactListResponse
CreateContactListResponse'
            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 CreateContactList where
  hashWithSalt :: Int -> CreateContactList -> Int
hashWithSalt Int
_salt CreateContactList' {Maybe [Tag]
Maybe [Topic]
Maybe Text
Text
contactListName :: Text
topics :: Maybe [Topic]
tags :: Maybe [Tag]
description :: Maybe Text
$sel:contactListName:CreateContactList' :: CreateContactList -> Text
$sel:topics:CreateContactList' :: CreateContactList -> Maybe [Topic]
$sel:tags:CreateContactList' :: CreateContactList -> Maybe [Tag]
$sel:description:CreateContactList' :: CreateContactList -> 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 [Tag]
tags
      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 CreateContactList where
  rnf :: CreateContactList -> ()
rnf CreateContactList' {Maybe [Tag]
Maybe [Topic]
Maybe Text
Text
contactListName :: Text
topics :: Maybe [Topic]
tags :: Maybe [Tag]
description :: Maybe Text
$sel:contactListName:CreateContactList' :: CreateContactList -> Text
$sel:topics:CreateContactList' :: CreateContactList -> Maybe [Topic]
$sel:tags:CreateContactList' :: CreateContactList -> Maybe [Tag]
$sel:description:CreateContactList' :: CreateContactList -> 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 [Tag]
tags
      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 CreateContactList where
  toHeaders :: CreateContactList -> 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 CreateContactList where
  toJSON :: CreateContactList -> Value
toJSON CreateContactList' {Maybe [Tag]
Maybe [Topic]
Maybe Text
Text
contactListName :: Text
topics :: Maybe [Topic]
tags :: Maybe [Tag]
description :: Maybe Text
$sel:contactListName:CreateContactList' :: CreateContactList -> Text
$sel:topics:CreateContactList' :: CreateContactList -> Maybe [Topic]
$sel:tags:CreateContactList' :: CreateContactList -> Maybe [Tag]
$sel:description:CreateContactList' :: CreateContactList -> 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
"Tags" 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 [Tag]
tags,
            (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,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ContactListName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
contactListName)
          ]
      )

instance Data.ToPath CreateContactList where
  toPath :: CreateContactList -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/contact-lists"

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

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

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

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

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