{-# 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-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)
--
-- Creates a contact list.
module Amazonka.SESV2.CreateContactList
  ( -- * Creating a Request
    CreateContactList (..),
    newCreateContactList,

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

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

    -- * Response Lenses
    createContactListResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateContactList' smart constructor.
data CreateContactList = CreateContactList'
  { -- | An interest group, theme, or label within a list. A contact list can
    -- have multiple topics.
    CreateContactList -> Maybe [Topic]
topics :: Prelude.Maybe [Topic],
    -- | 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],
    -- | The name of the contact list.
    CreateContactList -> Text
contactListName :: Prelude.Text
  }
  deriving (CreateContactList -> CreateContactList -> Bool
(CreateContactList -> CreateContactList -> Bool)
-> (CreateContactList -> CreateContactList -> Bool)
-> Eq CreateContactList
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]
(Int -> ReadS CreateContactList)
-> ReadS [CreateContactList]
-> ReadPrec CreateContactList
-> ReadPrec [CreateContactList]
-> Read 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
(Int -> CreateContactList -> ShowS)
-> (CreateContactList -> String)
-> ([CreateContactList] -> ShowS)
-> Show CreateContactList
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. CreateContactList -> Rep CreateContactList x)
-> (forall x. Rep CreateContactList x -> CreateContactList)
-> Generic CreateContactList
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:
--
-- 'topics', 'createContactList_topics' - An interest group, theme, or label within a list. A contact list can
-- have multiple topics.
--
-- 'description', 'createContactList_description' - A description of what the contact list is about.
--
-- 'tags', 'createContactList_tags' - The tags associated with a contact list.
--
-- 'contactListName', 'createContactList_contactListName' - The name of the contact list.
newCreateContactList ::
  -- | 'contactListName'
  Prelude.Text ->
  CreateContactList
newCreateContactList :: Text -> CreateContactList
newCreateContactList Text
pContactListName_ =
  CreateContactList' :: Maybe [Topic]
-> Maybe Text -> Maybe [Tag] -> Text -> CreateContactList
CreateContactList'
    { $sel:topics:CreateContactList' :: Maybe [Topic]
topics = Maybe [Topic]
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateContactList' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateContactList' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:contactListName:CreateContactList' :: Text
contactListName = Text
pContactListName_
    }

-- | 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 :: (Maybe [Topic] -> f (Maybe [Topic]))
-> CreateContactList -> f CreateContactList
createContactList_topics = (CreateContactList -> Maybe [Topic])
-> (CreateContactList -> Maybe [Topic] -> CreateContactList)
-> Lens
     CreateContactList CreateContactList (Maybe [Topic]) (Maybe [Topic])
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) ((Maybe [Topic] -> f (Maybe [Topic]))
 -> CreateContactList -> f CreateContactList)
-> ((Maybe [Topic] -> f (Maybe [Topic]))
    -> Maybe [Topic] -> f (Maybe [Topic]))
-> (Maybe [Topic] -> f (Maybe [Topic]))
-> CreateContactList
-> f CreateContactList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Topic] [Topic] [Topic] [Topic]
-> Iso
     (Maybe [Topic]) (Maybe [Topic]) (Maybe [Topic]) (Maybe [Topic])
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 AnIso [Topic] [Topic] [Topic] [Topic]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A description of what the contact list is about.
createContactList_description :: Lens.Lens' CreateContactList (Prelude.Maybe Prelude.Text)
createContactList_description :: (Maybe Text -> f (Maybe Text))
-> CreateContactList -> f CreateContactList
createContactList_description = (CreateContactList -> Maybe Text)
-> (CreateContactList -> Maybe Text -> CreateContactList)
-> Lens
     CreateContactList CreateContactList (Maybe Text) (Maybe Text)
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 :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateContactList -> f CreateContactList
createContactList_tags = (CreateContactList -> Maybe [Tag])
-> (CreateContactList -> Maybe [Tag] -> CreateContactList)
-> Lens
     CreateContactList CreateContactList (Maybe [Tag]) (Maybe [Tag])
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) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateContactList -> f CreateContactList)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateContactList
-> f CreateContactList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 AnIso [Tag] [Tag] [Tag] [Tag]
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 :: (Text -> f Text) -> CreateContactList -> f CreateContactList
createContactList_contactListName = (CreateContactList -> Text)
-> (CreateContactList -> Text -> CreateContactList)
-> Lens CreateContactList CreateContactList Text Text
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 :: CreateContactList -> Request CreateContactList
request = Service -> CreateContactList -> Request CreateContactList
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateContactList
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateContactList)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateContactList))
-> Logger
-> Service
-> Proxy CreateContactList
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateContactList)))
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 -> CreateContactListResponse
CreateContactListResponse'
            (Int -> CreateContactListResponse)
-> Either String Int -> Either String CreateContactListResponse
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 CreateContactList

instance Prelude.NFData CreateContactList

instance Core.ToHeaders CreateContactList where
  toHeaders :: CreateContactList -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateContactList -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 CreateContactList where
  toJSON :: CreateContactList -> Value
toJSON CreateContactList' {Maybe [Tag]
Maybe [Topic]
Maybe Text
Text
contactListName :: Text
tags :: Maybe [Tag]
description :: Maybe Text
topics :: Maybe [Topic]
$sel:contactListName:CreateContactList' :: CreateContactList -> Text
$sel:tags:CreateContactList' :: CreateContactList -> Maybe [Tag]
$sel:description:CreateContactList' :: CreateContactList -> Maybe Text
$sel:topics:CreateContactList' :: CreateContactList -> Maybe [Topic]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Topics" Text -> [Topic] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Topic] -> Pair) -> Maybe [Topic] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Topic]
topics,
            (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,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ContactListName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactListName)
          ]
      )

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

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

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