{-# 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.PutEmailIdentityConfigurationSetAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Used to associate a configuration set with an email identity.
module Amazonka.SESV2.PutEmailIdentityConfigurationSetAttributes
  ( -- * Creating a Request
    PutEmailIdentityConfigurationSetAttributes (..),
    newPutEmailIdentityConfigurationSetAttributes,

    -- * Request Lenses
    putEmailIdentityConfigurationSetAttributes_configurationSetName,
    putEmailIdentityConfigurationSetAttributes_emailIdentity,

    -- * Destructuring the Response
    PutEmailIdentityConfigurationSetAttributesResponse (..),
    newPutEmailIdentityConfigurationSetAttributesResponse,

    -- * Response Lenses
    putEmailIdentityConfigurationSetAttributesResponse_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

-- | A request to associate a configuration set with an email identity.
--
-- /See:/ 'newPutEmailIdentityConfigurationSetAttributes' smart constructor.
data PutEmailIdentityConfigurationSetAttributes = PutEmailIdentityConfigurationSetAttributes'
  { -- | The configuration set to associate with an email identity.
    PutEmailIdentityConfigurationSetAttributes -> Maybe Text
configurationSetName :: Prelude.Maybe Prelude.Text,
    -- | The email address or domain to associate with a configuration set.
    PutEmailIdentityConfigurationSetAttributes -> Text
emailIdentity :: Prelude.Text
  }
  deriving (PutEmailIdentityConfigurationSetAttributes
-> PutEmailIdentityConfigurationSetAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEmailIdentityConfigurationSetAttributes
-> PutEmailIdentityConfigurationSetAttributes -> Bool
$c/= :: PutEmailIdentityConfigurationSetAttributes
-> PutEmailIdentityConfigurationSetAttributes -> Bool
== :: PutEmailIdentityConfigurationSetAttributes
-> PutEmailIdentityConfigurationSetAttributes -> Bool
$c== :: PutEmailIdentityConfigurationSetAttributes
-> PutEmailIdentityConfigurationSetAttributes -> Bool
Prelude.Eq, ReadPrec [PutEmailIdentityConfigurationSetAttributes]
ReadPrec PutEmailIdentityConfigurationSetAttributes
Int -> ReadS PutEmailIdentityConfigurationSetAttributes
ReadS [PutEmailIdentityConfigurationSetAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEmailIdentityConfigurationSetAttributes]
$creadListPrec :: ReadPrec [PutEmailIdentityConfigurationSetAttributes]
readPrec :: ReadPrec PutEmailIdentityConfigurationSetAttributes
$creadPrec :: ReadPrec PutEmailIdentityConfigurationSetAttributes
readList :: ReadS [PutEmailIdentityConfigurationSetAttributes]
$creadList :: ReadS [PutEmailIdentityConfigurationSetAttributes]
readsPrec :: Int -> ReadS PutEmailIdentityConfigurationSetAttributes
$creadsPrec :: Int -> ReadS PutEmailIdentityConfigurationSetAttributes
Prelude.Read, Int -> PutEmailIdentityConfigurationSetAttributes -> ShowS
[PutEmailIdentityConfigurationSetAttributes] -> ShowS
PutEmailIdentityConfigurationSetAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEmailIdentityConfigurationSetAttributes] -> ShowS
$cshowList :: [PutEmailIdentityConfigurationSetAttributes] -> ShowS
show :: PutEmailIdentityConfigurationSetAttributes -> String
$cshow :: PutEmailIdentityConfigurationSetAttributes -> String
showsPrec :: Int -> PutEmailIdentityConfigurationSetAttributes -> ShowS
$cshowsPrec :: Int -> PutEmailIdentityConfigurationSetAttributes -> ShowS
Prelude.Show, forall x.
Rep PutEmailIdentityConfigurationSetAttributes x
-> PutEmailIdentityConfigurationSetAttributes
forall x.
PutEmailIdentityConfigurationSetAttributes
-> Rep PutEmailIdentityConfigurationSetAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutEmailIdentityConfigurationSetAttributes x
-> PutEmailIdentityConfigurationSetAttributes
$cfrom :: forall x.
PutEmailIdentityConfigurationSetAttributes
-> Rep PutEmailIdentityConfigurationSetAttributes x
Prelude.Generic)

-- |
-- Create a value of 'PutEmailIdentityConfigurationSetAttributes' 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:
--
-- 'configurationSetName', 'putEmailIdentityConfigurationSetAttributes_configurationSetName' - The configuration set to associate with an email identity.
--
-- 'emailIdentity', 'putEmailIdentityConfigurationSetAttributes_emailIdentity' - The email address or domain to associate with a configuration set.
newPutEmailIdentityConfigurationSetAttributes ::
  -- | 'emailIdentity'
  Prelude.Text ->
  PutEmailIdentityConfigurationSetAttributes
newPutEmailIdentityConfigurationSetAttributes :: Text -> PutEmailIdentityConfigurationSetAttributes
newPutEmailIdentityConfigurationSetAttributes
  Text
pEmailIdentity_ =
    PutEmailIdentityConfigurationSetAttributes'
      { $sel:configurationSetName:PutEmailIdentityConfigurationSetAttributes' :: Maybe Text
configurationSetName =
          forall a. Maybe a
Prelude.Nothing,
        $sel:emailIdentity:PutEmailIdentityConfigurationSetAttributes' :: Text
emailIdentity = Text
pEmailIdentity_
      }

-- | The configuration set to associate with an email identity.
putEmailIdentityConfigurationSetAttributes_configurationSetName :: Lens.Lens' PutEmailIdentityConfigurationSetAttributes (Prelude.Maybe Prelude.Text)
putEmailIdentityConfigurationSetAttributes_configurationSetName :: Lens' PutEmailIdentityConfigurationSetAttributes (Maybe Text)
putEmailIdentityConfigurationSetAttributes_configurationSetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailIdentityConfigurationSetAttributes' {Maybe Text
configurationSetName :: Maybe Text
$sel:configurationSetName:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Maybe Text
configurationSetName} -> Maybe Text
configurationSetName) (\s :: PutEmailIdentityConfigurationSetAttributes
s@PutEmailIdentityConfigurationSetAttributes' {} Maybe Text
a -> PutEmailIdentityConfigurationSetAttributes
s {$sel:configurationSetName:PutEmailIdentityConfigurationSetAttributes' :: Maybe Text
configurationSetName = Maybe Text
a} :: PutEmailIdentityConfigurationSetAttributes)

-- | The email address or domain to associate with a configuration set.
putEmailIdentityConfigurationSetAttributes_emailIdentity :: Lens.Lens' PutEmailIdentityConfigurationSetAttributes Prelude.Text
putEmailIdentityConfigurationSetAttributes_emailIdentity :: Lens' PutEmailIdentityConfigurationSetAttributes Text
putEmailIdentityConfigurationSetAttributes_emailIdentity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailIdentityConfigurationSetAttributes' {Text
emailIdentity :: Text
$sel:emailIdentity:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Text
emailIdentity} -> Text
emailIdentity) (\s :: PutEmailIdentityConfigurationSetAttributes
s@PutEmailIdentityConfigurationSetAttributes' {} Text
a -> PutEmailIdentityConfigurationSetAttributes
s {$sel:emailIdentity:PutEmailIdentityConfigurationSetAttributes' :: Text
emailIdentity = Text
a} :: PutEmailIdentityConfigurationSetAttributes)

instance
  Core.AWSRequest
    PutEmailIdentityConfigurationSetAttributes
  where
  type
    AWSResponse
      PutEmailIdentityConfigurationSetAttributes =
      PutEmailIdentityConfigurationSetAttributesResponse
  request :: (Service -> Service)
-> PutEmailIdentityConfigurationSetAttributes
-> Request PutEmailIdentityConfigurationSetAttributes
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 PutEmailIdentityConfigurationSetAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse PutEmailIdentityConfigurationSetAttributes)))
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 -> PutEmailIdentityConfigurationSetAttributesResponse
PutEmailIdentityConfigurationSetAttributesResponse'
            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
    PutEmailIdentityConfigurationSetAttributes
  where
  hashWithSalt :: Int -> PutEmailIdentityConfigurationSetAttributes -> Int
hashWithSalt
    Int
_salt
    PutEmailIdentityConfigurationSetAttributes' {Maybe Text
Text
emailIdentity :: Text
configurationSetName :: Maybe Text
$sel:emailIdentity:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Text
$sel:configurationSetName:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
configurationSetName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
emailIdentity

instance
  Prelude.NFData
    PutEmailIdentityConfigurationSetAttributes
  where
  rnf :: PutEmailIdentityConfigurationSetAttributes -> ()
rnf PutEmailIdentityConfigurationSetAttributes' {Maybe Text
Text
emailIdentity :: Text
configurationSetName :: Maybe Text
$sel:emailIdentity:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Text
$sel:configurationSetName:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
configurationSetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
emailIdentity

instance
  Data.ToHeaders
    PutEmailIdentityConfigurationSetAttributes
  where
  toHeaders :: PutEmailIdentityConfigurationSetAttributes -> 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
    PutEmailIdentityConfigurationSetAttributes
  where
  toJSON :: PutEmailIdentityConfigurationSetAttributes -> Value
toJSON
    PutEmailIdentityConfigurationSetAttributes' {Maybe Text
Text
emailIdentity :: Text
configurationSetName :: Maybe Text
$sel:emailIdentity:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Text
$sel:configurationSetName:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Maybe Text
..} =
      [Pair] -> Value
Data.object
        ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Key
"ConfigurationSetName" 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
configurationSetName
            ]
        )

instance
  Data.ToPath
    PutEmailIdentityConfigurationSetAttributes
  where
  toPath :: PutEmailIdentityConfigurationSetAttributes -> ByteString
toPath
    PutEmailIdentityConfigurationSetAttributes' {Maybe Text
Text
emailIdentity :: Text
configurationSetName :: Maybe Text
$sel:emailIdentity:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Text
$sel:configurationSetName:PutEmailIdentityConfigurationSetAttributes' :: PutEmailIdentityConfigurationSetAttributes -> Maybe Text
..} =
      forall a. Monoid a => [a] -> a
Prelude.mconcat
        [ ByteString
"/v2/email/identities/",
          forall a. ToByteString a => a -> ByteString
Data.toBS Text
emailIdentity,
          ByteString
"/configuration-set"
        ]

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

-- | If the action is successful, the service sends back an HTTP 200 response
-- with an empty HTTP body.
--
-- /See:/ 'newPutEmailIdentityConfigurationSetAttributesResponse' smart constructor.
data PutEmailIdentityConfigurationSetAttributesResponse = PutEmailIdentityConfigurationSetAttributesResponse'
  { -- | The response's http status code.
    PutEmailIdentityConfigurationSetAttributesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutEmailIdentityConfigurationSetAttributesResponse
-> PutEmailIdentityConfigurationSetAttributesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEmailIdentityConfigurationSetAttributesResponse
-> PutEmailIdentityConfigurationSetAttributesResponse -> Bool
$c/= :: PutEmailIdentityConfigurationSetAttributesResponse
-> PutEmailIdentityConfigurationSetAttributesResponse -> Bool
== :: PutEmailIdentityConfigurationSetAttributesResponse
-> PutEmailIdentityConfigurationSetAttributesResponse -> Bool
$c== :: PutEmailIdentityConfigurationSetAttributesResponse
-> PutEmailIdentityConfigurationSetAttributesResponse -> Bool
Prelude.Eq, ReadPrec [PutEmailIdentityConfigurationSetAttributesResponse]
ReadPrec PutEmailIdentityConfigurationSetAttributesResponse
Int -> ReadS PutEmailIdentityConfigurationSetAttributesResponse
ReadS [PutEmailIdentityConfigurationSetAttributesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEmailIdentityConfigurationSetAttributesResponse]
$creadListPrec :: ReadPrec [PutEmailIdentityConfigurationSetAttributesResponse]
readPrec :: ReadPrec PutEmailIdentityConfigurationSetAttributesResponse
$creadPrec :: ReadPrec PutEmailIdentityConfigurationSetAttributesResponse
readList :: ReadS [PutEmailIdentityConfigurationSetAttributesResponse]
$creadList :: ReadS [PutEmailIdentityConfigurationSetAttributesResponse]
readsPrec :: Int -> ReadS PutEmailIdentityConfigurationSetAttributesResponse
$creadsPrec :: Int -> ReadS PutEmailIdentityConfigurationSetAttributesResponse
Prelude.Read, Int -> PutEmailIdentityConfigurationSetAttributesResponse -> ShowS
[PutEmailIdentityConfigurationSetAttributesResponse] -> ShowS
PutEmailIdentityConfigurationSetAttributesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEmailIdentityConfigurationSetAttributesResponse] -> ShowS
$cshowList :: [PutEmailIdentityConfigurationSetAttributesResponse] -> ShowS
show :: PutEmailIdentityConfigurationSetAttributesResponse -> String
$cshow :: PutEmailIdentityConfigurationSetAttributesResponse -> String
showsPrec :: Int -> PutEmailIdentityConfigurationSetAttributesResponse -> ShowS
$cshowsPrec :: Int -> PutEmailIdentityConfigurationSetAttributesResponse -> ShowS
Prelude.Show, forall x.
Rep PutEmailIdentityConfigurationSetAttributesResponse x
-> PutEmailIdentityConfigurationSetAttributesResponse
forall x.
PutEmailIdentityConfigurationSetAttributesResponse
-> Rep PutEmailIdentityConfigurationSetAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutEmailIdentityConfigurationSetAttributesResponse x
-> PutEmailIdentityConfigurationSetAttributesResponse
$cfrom :: forall x.
PutEmailIdentityConfigurationSetAttributesResponse
-> Rep PutEmailIdentityConfigurationSetAttributesResponse x
Prelude.Generic)

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

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

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