{-# 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.PinpointEmail.CreateConfigurationSetEventDestination
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Create an event destination. In Amazon Pinpoint, /events/ include
-- message sends, deliveries, opens, clicks, bounces, and complaints.
-- /Event destinations/ are places that you can send information about
-- these events to. For example, you can send event data to Amazon SNS to
-- receive notifications when you receive bounces or complaints, or you can
-- use Amazon Kinesis Data Firehose to stream data to Amazon S3 for
-- long-term storage.
--
-- A single configuration set can include more than one event destination.
module Amazonka.PinpointEmail.CreateConfigurationSetEventDestination
  ( -- * Creating a Request
    CreateConfigurationSetEventDestination (..),
    newCreateConfigurationSetEventDestination,

    -- * Request Lenses
    createConfigurationSetEventDestination_configurationSetName,
    createConfigurationSetEventDestination_eventDestinationName,
    createConfigurationSetEventDestination_eventDestination,

    -- * Destructuring the Response
    CreateConfigurationSetEventDestinationResponse (..),
    newCreateConfigurationSetEventDestinationResponse,

    -- * Response Lenses
    createConfigurationSetEventDestinationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.PinpointEmail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | A request to add an event destination to a configuration set.
--
-- /See:/ 'newCreateConfigurationSetEventDestination' smart constructor.
data CreateConfigurationSetEventDestination = CreateConfigurationSetEventDestination'
  { -- | The name of the configuration set that you want to add an event
    -- destination to.
    CreateConfigurationSetEventDestination -> Text
configurationSetName :: Prelude.Text,
    -- | A name that identifies the event destination within the configuration
    -- set.
    CreateConfigurationSetEventDestination -> Text
eventDestinationName :: Prelude.Text,
    -- | An object that defines the event destination.
    CreateConfigurationSetEventDestination
-> EventDestinationDefinition
eventDestination :: EventDestinationDefinition
  }
  deriving (CreateConfigurationSetEventDestination
-> CreateConfigurationSetEventDestination -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateConfigurationSetEventDestination
-> CreateConfigurationSetEventDestination -> Bool
$c/= :: CreateConfigurationSetEventDestination
-> CreateConfigurationSetEventDestination -> Bool
== :: CreateConfigurationSetEventDestination
-> CreateConfigurationSetEventDestination -> Bool
$c== :: CreateConfigurationSetEventDestination
-> CreateConfigurationSetEventDestination -> Bool
Prelude.Eq, ReadPrec [CreateConfigurationSetEventDestination]
ReadPrec CreateConfigurationSetEventDestination
Int -> ReadS CreateConfigurationSetEventDestination
ReadS [CreateConfigurationSetEventDestination]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateConfigurationSetEventDestination]
$creadListPrec :: ReadPrec [CreateConfigurationSetEventDestination]
readPrec :: ReadPrec CreateConfigurationSetEventDestination
$creadPrec :: ReadPrec CreateConfigurationSetEventDestination
readList :: ReadS [CreateConfigurationSetEventDestination]
$creadList :: ReadS [CreateConfigurationSetEventDestination]
readsPrec :: Int -> ReadS CreateConfigurationSetEventDestination
$creadsPrec :: Int -> ReadS CreateConfigurationSetEventDestination
Prelude.Read, Int -> CreateConfigurationSetEventDestination -> ShowS
[CreateConfigurationSetEventDestination] -> ShowS
CreateConfigurationSetEventDestination -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateConfigurationSetEventDestination] -> ShowS
$cshowList :: [CreateConfigurationSetEventDestination] -> ShowS
show :: CreateConfigurationSetEventDestination -> String
$cshow :: CreateConfigurationSetEventDestination -> String
showsPrec :: Int -> CreateConfigurationSetEventDestination -> ShowS
$cshowsPrec :: Int -> CreateConfigurationSetEventDestination -> ShowS
Prelude.Show, forall x.
Rep CreateConfigurationSetEventDestination x
-> CreateConfigurationSetEventDestination
forall x.
CreateConfigurationSetEventDestination
-> Rep CreateConfigurationSetEventDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateConfigurationSetEventDestination x
-> CreateConfigurationSetEventDestination
$cfrom :: forall x.
CreateConfigurationSetEventDestination
-> Rep CreateConfigurationSetEventDestination x
Prelude.Generic)

-- |
-- Create a value of 'CreateConfigurationSetEventDestination' 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', 'createConfigurationSetEventDestination_configurationSetName' - The name of the configuration set that you want to add an event
-- destination to.
--
-- 'eventDestinationName', 'createConfigurationSetEventDestination_eventDestinationName' - A name that identifies the event destination within the configuration
-- set.
--
-- 'eventDestination', 'createConfigurationSetEventDestination_eventDestination' - An object that defines the event destination.
newCreateConfigurationSetEventDestination ::
  -- | 'configurationSetName'
  Prelude.Text ->
  -- | 'eventDestinationName'
  Prelude.Text ->
  -- | 'eventDestination'
  EventDestinationDefinition ->
  CreateConfigurationSetEventDestination
newCreateConfigurationSetEventDestination :: Text
-> Text
-> EventDestinationDefinition
-> CreateConfigurationSetEventDestination
newCreateConfigurationSetEventDestination
  Text
pConfigurationSetName_
  Text
pEventDestinationName_
  EventDestinationDefinition
pEventDestination_ =
    CreateConfigurationSetEventDestination'
      { $sel:configurationSetName:CreateConfigurationSetEventDestination' :: Text
configurationSetName =
          Text
pConfigurationSetName_,
        $sel:eventDestinationName:CreateConfigurationSetEventDestination' :: Text
eventDestinationName =
          Text
pEventDestinationName_,
        $sel:eventDestination:CreateConfigurationSetEventDestination' :: EventDestinationDefinition
eventDestination =
          EventDestinationDefinition
pEventDestination_
      }

-- | The name of the configuration set that you want to add an event
-- destination to.
createConfigurationSetEventDestination_configurationSetName :: Lens.Lens' CreateConfigurationSetEventDestination Prelude.Text
createConfigurationSetEventDestination_configurationSetName :: Lens' CreateConfigurationSetEventDestination Text
createConfigurationSetEventDestination_configurationSetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConfigurationSetEventDestination' {Text
configurationSetName :: Text
$sel:configurationSetName:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination -> Text
configurationSetName} -> Text
configurationSetName) (\s :: CreateConfigurationSetEventDestination
s@CreateConfigurationSetEventDestination' {} Text
a -> CreateConfigurationSetEventDestination
s {$sel:configurationSetName:CreateConfigurationSetEventDestination' :: Text
configurationSetName = Text
a} :: CreateConfigurationSetEventDestination)

-- | A name that identifies the event destination within the configuration
-- set.
createConfigurationSetEventDestination_eventDestinationName :: Lens.Lens' CreateConfigurationSetEventDestination Prelude.Text
createConfigurationSetEventDestination_eventDestinationName :: Lens' CreateConfigurationSetEventDestination Text
createConfigurationSetEventDestination_eventDestinationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConfigurationSetEventDestination' {Text
eventDestinationName :: Text
$sel:eventDestinationName:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination -> Text
eventDestinationName} -> Text
eventDestinationName) (\s :: CreateConfigurationSetEventDestination
s@CreateConfigurationSetEventDestination' {} Text
a -> CreateConfigurationSetEventDestination
s {$sel:eventDestinationName:CreateConfigurationSetEventDestination' :: Text
eventDestinationName = Text
a} :: CreateConfigurationSetEventDestination)

-- | An object that defines the event destination.
createConfigurationSetEventDestination_eventDestination :: Lens.Lens' CreateConfigurationSetEventDestination EventDestinationDefinition
createConfigurationSetEventDestination_eventDestination :: Lens'
  CreateConfigurationSetEventDestination EventDestinationDefinition
createConfigurationSetEventDestination_eventDestination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConfigurationSetEventDestination' {EventDestinationDefinition
eventDestination :: EventDestinationDefinition
$sel:eventDestination:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination
-> EventDestinationDefinition
eventDestination} -> EventDestinationDefinition
eventDestination) (\s :: CreateConfigurationSetEventDestination
s@CreateConfigurationSetEventDestination' {} EventDestinationDefinition
a -> CreateConfigurationSetEventDestination
s {$sel:eventDestination:CreateConfigurationSetEventDestination' :: EventDestinationDefinition
eventDestination = EventDestinationDefinition
a} :: CreateConfigurationSetEventDestination)

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

instance
  Prelude.NFData
    CreateConfigurationSetEventDestination
  where
  rnf :: CreateConfigurationSetEventDestination -> ()
rnf CreateConfigurationSetEventDestination' {Text
EventDestinationDefinition
eventDestination :: EventDestinationDefinition
eventDestinationName :: Text
configurationSetName :: Text
$sel:eventDestination:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination
-> EventDestinationDefinition
$sel:eventDestinationName:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination -> Text
$sel:configurationSetName:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
configurationSetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
eventDestinationName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EventDestinationDefinition
eventDestination

instance
  Data.ToHeaders
    CreateConfigurationSetEventDestination
  where
  toHeaders :: CreateConfigurationSetEventDestination -> 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
    CreateConfigurationSetEventDestination
  where
  toJSON :: CreateConfigurationSetEventDestination -> Value
toJSON CreateConfigurationSetEventDestination' {Text
EventDestinationDefinition
eventDestination :: EventDestinationDefinition
eventDestinationName :: Text
configurationSetName :: Text
$sel:eventDestination:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination
-> EventDestinationDefinition
$sel:eventDestinationName:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination -> Text
$sel:configurationSetName:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"EventDestinationName"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
eventDestinationName
              ),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"EventDestination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EventDestinationDefinition
eventDestination)
          ]
      )

instance
  Data.ToPath
    CreateConfigurationSetEventDestination
  where
  toPath :: CreateConfigurationSetEventDestination -> ByteString
toPath CreateConfigurationSetEventDestination' {Text
EventDestinationDefinition
eventDestination :: EventDestinationDefinition
eventDestinationName :: Text
configurationSetName :: Text
$sel:eventDestination:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination
-> EventDestinationDefinition
$sel:eventDestinationName:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination -> Text
$sel:configurationSetName:CreateConfigurationSetEventDestination' :: CreateConfigurationSetEventDestination -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/email/configuration-sets/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
configurationSetName,
        ByteString
"/event-destinations"
      ]

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

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

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

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

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