{-# 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.PutConfigurationSetTrackingOptions
-- 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)
--
-- Specify a custom domain to use for open and click tracking elements in
-- email that you send.
module Amazonka.SESV2.PutConfigurationSetTrackingOptions
  ( -- * Creating a Request
    PutConfigurationSetTrackingOptions (..),
    newPutConfigurationSetTrackingOptions,

    -- * Request Lenses
    putConfigurationSetTrackingOptions_customRedirectDomain,
    putConfigurationSetTrackingOptions_configurationSetName,

    -- * Destructuring the Response
    PutConfigurationSetTrackingOptionsResponse (..),
    newPutConfigurationSetTrackingOptionsResponse,

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

-- | A request to add a custom domain for tracking open and click events to a
-- configuration set.
--
-- /See:/ 'newPutConfigurationSetTrackingOptions' smart constructor.
data PutConfigurationSetTrackingOptions = PutConfigurationSetTrackingOptions'
  { -- | The domain to use to track open and click events.
    PutConfigurationSetTrackingOptions -> Maybe Text
customRedirectDomain :: Prelude.Maybe Prelude.Text,
    -- | The name of the configuration set.
    PutConfigurationSetTrackingOptions -> Text
configurationSetName :: Prelude.Text
  }
  deriving (PutConfigurationSetTrackingOptions
-> PutConfigurationSetTrackingOptions -> Bool
(PutConfigurationSetTrackingOptions
 -> PutConfigurationSetTrackingOptions -> Bool)
-> (PutConfigurationSetTrackingOptions
    -> PutConfigurationSetTrackingOptions -> Bool)
-> Eq PutConfigurationSetTrackingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutConfigurationSetTrackingOptions
-> PutConfigurationSetTrackingOptions -> Bool
$c/= :: PutConfigurationSetTrackingOptions
-> PutConfigurationSetTrackingOptions -> Bool
== :: PutConfigurationSetTrackingOptions
-> PutConfigurationSetTrackingOptions -> Bool
$c== :: PutConfigurationSetTrackingOptions
-> PutConfigurationSetTrackingOptions -> Bool
Prelude.Eq, ReadPrec [PutConfigurationSetTrackingOptions]
ReadPrec PutConfigurationSetTrackingOptions
Int -> ReadS PutConfigurationSetTrackingOptions
ReadS [PutConfigurationSetTrackingOptions]
(Int -> ReadS PutConfigurationSetTrackingOptions)
-> ReadS [PutConfigurationSetTrackingOptions]
-> ReadPrec PutConfigurationSetTrackingOptions
-> ReadPrec [PutConfigurationSetTrackingOptions]
-> Read PutConfigurationSetTrackingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutConfigurationSetTrackingOptions]
$creadListPrec :: ReadPrec [PutConfigurationSetTrackingOptions]
readPrec :: ReadPrec PutConfigurationSetTrackingOptions
$creadPrec :: ReadPrec PutConfigurationSetTrackingOptions
readList :: ReadS [PutConfigurationSetTrackingOptions]
$creadList :: ReadS [PutConfigurationSetTrackingOptions]
readsPrec :: Int -> ReadS PutConfigurationSetTrackingOptions
$creadsPrec :: Int -> ReadS PutConfigurationSetTrackingOptions
Prelude.Read, Int -> PutConfigurationSetTrackingOptions -> ShowS
[PutConfigurationSetTrackingOptions] -> ShowS
PutConfigurationSetTrackingOptions -> String
(Int -> PutConfigurationSetTrackingOptions -> ShowS)
-> (PutConfigurationSetTrackingOptions -> String)
-> ([PutConfigurationSetTrackingOptions] -> ShowS)
-> Show PutConfigurationSetTrackingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutConfigurationSetTrackingOptions] -> ShowS
$cshowList :: [PutConfigurationSetTrackingOptions] -> ShowS
show :: PutConfigurationSetTrackingOptions -> String
$cshow :: PutConfigurationSetTrackingOptions -> String
showsPrec :: Int -> PutConfigurationSetTrackingOptions -> ShowS
$cshowsPrec :: Int -> PutConfigurationSetTrackingOptions -> ShowS
Prelude.Show, (forall x.
 PutConfigurationSetTrackingOptions
 -> Rep PutConfigurationSetTrackingOptions x)
-> (forall x.
    Rep PutConfigurationSetTrackingOptions x
    -> PutConfigurationSetTrackingOptions)
-> Generic PutConfigurationSetTrackingOptions
forall x.
Rep PutConfigurationSetTrackingOptions x
-> PutConfigurationSetTrackingOptions
forall x.
PutConfigurationSetTrackingOptions
-> Rep PutConfigurationSetTrackingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutConfigurationSetTrackingOptions x
-> PutConfigurationSetTrackingOptions
$cfrom :: forall x.
PutConfigurationSetTrackingOptions
-> Rep PutConfigurationSetTrackingOptions x
Prelude.Generic)

-- |
-- Create a value of 'PutConfigurationSetTrackingOptions' 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:
--
-- 'customRedirectDomain', 'putConfigurationSetTrackingOptions_customRedirectDomain' - The domain to use to track open and click events.
--
-- 'configurationSetName', 'putConfigurationSetTrackingOptions_configurationSetName' - The name of the configuration set.
newPutConfigurationSetTrackingOptions ::
  -- | 'configurationSetName'
  Prelude.Text ->
  PutConfigurationSetTrackingOptions
newPutConfigurationSetTrackingOptions :: Text -> PutConfigurationSetTrackingOptions
newPutConfigurationSetTrackingOptions
  Text
pConfigurationSetName_ =
    PutConfigurationSetTrackingOptions' :: Maybe Text -> Text -> PutConfigurationSetTrackingOptions
PutConfigurationSetTrackingOptions'
      { $sel:customRedirectDomain:PutConfigurationSetTrackingOptions' :: Maybe Text
customRedirectDomain =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:configurationSetName:PutConfigurationSetTrackingOptions' :: Text
configurationSetName =
          Text
pConfigurationSetName_
      }

-- | The domain to use to track open and click events.
putConfigurationSetTrackingOptions_customRedirectDomain :: Lens.Lens' PutConfigurationSetTrackingOptions (Prelude.Maybe Prelude.Text)
putConfigurationSetTrackingOptions_customRedirectDomain :: (Maybe Text -> f (Maybe Text))
-> PutConfigurationSetTrackingOptions
-> f PutConfigurationSetTrackingOptions
putConfigurationSetTrackingOptions_customRedirectDomain = (PutConfigurationSetTrackingOptions -> Maybe Text)
-> (PutConfigurationSetTrackingOptions
    -> Maybe Text -> PutConfigurationSetTrackingOptions)
-> Lens
     PutConfigurationSetTrackingOptions
     PutConfigurationSetTrackingOptions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutConfigurationSetTrackingOptions' {Maybe Text
customRedirectDomain :: Maybe Text
$sel:customRedirectDomain:PutConfigurationSetTrackingOptions' :: PutConfigurationSetTrackingOptions -> Maybe Text
customRedirectDomain} -> Maybe Text
customRedirectDomain) (\s :: PutConfigurationSetTrackingOptions
s@PutConfigurationSetTrackingOptions' {} Maybe Text
a -> PutConfigurationSetTrackingOptions
s {$sel:customRedirectDomain:PutConfigurationSetTrackingOptions' :: Maybe Text
customRedirectDomain = Maybe Text
a} :: PutConfigurationSetTrackingOptions)

-- | The name of the configuration set.
putConfigurationSetTrackingOptions_configurationSetName :: Lens.Lens' PutConfigurationSetTrackingOptions Prelude.Text
putConfigurationSetTrackingOptions_configurationSetName :: (Text -> f Text)
-> PutConfigurationSetTrackingOptions
-> f PutConfigurationSetTrackingOptions
putConfigurationSetTrackingOptions_configurationSetName = (PutConfigurationSetTrackingOptions -> Text)
-> (PutConfigurationSetTrackingOptions
    -> Text -> PutConfigurationSetTrackingOptions)
-> Lens
     PutConfigurationSetTrackingOptions
     PutConfigurationSetTrackingOptions
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutConfigurationSetTrackingOptions' {Text
configurationSetName :: Text
$sel:configurationSetName:PutConfigurationSetTrackingOptions' :: PutConfigurationSetTrackingOptions -> Text
configurationSetName} -> Text
configurationSetName) (\s :: PutConfigurationSetTrackingOptions
s@PutConfigurationSetTrackingOptions' {} Text
a -> PutConfigurationSetTrackingOptions
s {$sel:configurationSetName:PutConfigurationSetTrackingOptions' :: Text
configurationSetName = Text
a} :: PutConfigurationSetTrackingOptions)

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

instance
  Prelude.NFData
    PutConfigurationSetTrackingOptions

instance
  Core.ToHeaders
    PutConfigurationSetTrackingOptions
  where
  toHeaders :: PutConfigurationSetTrackingOptions -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> PutConfigurationSetTrackingOptions -> 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
    PutConfigurationSetTrackingOptions
  where
  toJSON :: PutConfigurationSetTrackingOptions -> Value
toJSON PutConfigurationSetTrackingOptions' {Maybe Text
Text
configurationSetName :: Text
customRedirectDomain :: Maybe Text
$sel:configurationSetName:PutConfigurationSetTrackingOptions' :: PutConfigurationSetTrackingOptions -> Text
$sel:customRedirectDomain:PutConfigurationSetTrackingOptions' :: PutConfigurationSetTrackingOptions -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CustomRedirectDomain" 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
customRedirectDomain
          ]
      )

instance
  Core.ToPath
    PutConfigurationSetTrackingOptions
  where
  toPath :: PutConfigurationSetTrackingOptions -> ByteString
toPath PutConfigurationSetTrackingOptions' {Maybe Text
Text
configurationSetName :: Text
customRedirectDomain :: Maybe Text
$sel:configurationSetName:PutConfigurationSetTrackingOptions' :: PutConfigurationSetTrackingOptions -> Text
$sel:customRedirectDomain:PutConfigurationSetTrackingOptions' :: PutConfigurationSetTrackingOptions -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v2/email/configuration-sets/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
configurationSetName,
        ByteString
"/tracking-options"
      ]

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

-- | An HTTP 200 response if the request succeeds, or an error message if the
-- request fails.
--
-- /See:/ 'newPutConfigurationSetTrackingOptionsResponse' smart constructor.
data PutConfigurationSetTrackingOptionsResponse = PutConfigurationSetTrackingOptionsResponse'
  { -- | The response's http status code.
    PutConfigurationSetTrackingOptionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutConfigurationSetTrackingOptionsResponse
-> PutConfigurationSetTrackingOptionsResponse -> Bool
(PutConfigurationSetTrackingOptionsResponse
 -> PutConfigurationSetTrackingOptionsResponse -> Bool)
-> (PutConfigurationSetTrackingOptionsResponse
    -> PutConfigurationSetTrackingOptionsResponse -> Bool)
-> Eq PutConfigurationSetTrackingOptionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutConfigurationSetTrackingOptionsResponse
-> PutConfigurationSetTrackingOptionsResponse -> Bool
$c/= :: PutConfigurationSetTrackingOptionsResponse
-> PutConfigurationSetTrackingOptionsResponse -> Bool
== :: PutConfigurationSetTrackingOptionsResponse
-> PutConfigurationSetTrackingOptionsResponse -> Bool
$c== :: PutConfigurationSetTrackingOptionsResponse
-> PutConfigurationSetTrackingOptionsResponse -> Bool
Prelude.Eq, ReadPrec [PutConfigurationSetTrackingOptionsResponse]
ReadPrec PutConfigurationSetTrackingOptionsResponse
Int -> ReadS PutConfigurationSetTrackingOptionsResponse
ReadS [PutConfigurationSetTrackingOptionsResponse]
(Int -> ReadS PutConfigurationSetTrackingOptionsResponse)
-> ReadS [PutConfigurationSetTrackingOptionsResponse]
-> ReadPrec PutConfigurationSetTrackingOptionsResponse
-> ReadPrec [PutConfigurationSetTrackingOptionsResponse]
-> Read PutConfigurationSetTrackingOptionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutConfigurationSetTrackingOptionsResponse]
$creadListPrec :: ReadPrec [PutConfigurationSetTrackingOptionsResponse]
readPrec :: ReadPrec PutConfigurationSetTrackingOptionsResponse
$creadPrec :: ReadPrec PutConfigurationSetTrackingOptionsResponse
readList :: ReadS [PutConfigurationSetTrackingOptionsResponse]
$creadList :: ReadS [PutConfigurationSetTrackingOptionsResponse]
readsPrec :: Int -> ReadS PutConfigurationSetTrackingOptionsResponse
$creadsPrec :: Int -> ReadS PutConfigurationSetTrackingOptionsResponse
Prelude.Read, Int -> PutConfigurationSetTrackingOptionsResponse -> ShowS
[PutConfigurationSetTrackingOptionsResponse] -> ShowS
PutConfigurationSetTrackingOptionsResponse -> String
(Int -> PutConfigurationSetTrackingOptionsResponse -> ShowS)
-> (PutConfigurationSetTrackingOptionsResponse -> String)
-> ([PutConfigurationSetTrackingOptionsResponse] -> ShowS)
-> Show PutConfigurationSetTrackingOptionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutConfigurationSetTrackingOptionsResponse] -> ShowS
$cshowList :: [PutConfigurationSetTrackingOptionsResponse] -> ShowS
show :: PutConfigurationSetTrackingOptionsResponse -> String
$cshow :: PutConfigurationSetTrackingOptionsResponse -> String
showsPrec :: Int -> PutConfigurationSetTrackingOptionsResponse -> ShowS
$cshowsPrec :: Int -> PutConfigurationSetTrackingOptionsResponse -> ShowS
Prelude.Show, (forall x.
 PutConfigurationSetTrackingOptionsResponse
 -> Rep PutConfigurationSetTrackingOptionsResponse x)
-> (forall x.
    Rep PutConfigurationSetTrackingOptionsResponse x
    -> PutConfigurationSetTrackingOptionsResponse)
-> Generic PutConfigurationSetTrackingOptionsResponse
forall x.
Rep PutConfigurationSetTrackingOptionsResponse x
-> PutConfigurationSetTrackingOptionsResponse
forall x.
PutConfigurationSetTrackingOptionsResponse
-> Rep PutConfigurationSetTrackingOptionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutConfigurationSetTrackingOptionsResponse x
-> PutConfigurationSetTrackingOptionsResponse
$cfrom :: forall x.
PutConfigurationSetTrackingOptionsResponse
-> Rep PutConfigurationSetTrackingOptionsResponse x
Prelude.Generic)

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

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

instance
  Prelude.NFData
    PutConfigurationSetTrackingOptionsResponse