{-# 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.UpdateConfigurationSetEventDestination
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update the configuration of an event destination for a configuration
-- set.
--
-- 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.
module Amazonka.PinpointEmail.UpdateConfigurationSetEventDestination
  ( -- * Creating a Request
    UpdateConfigurationSetEventDestination (..),
    newUpdateConfigurationSetEventDestination,

    -- * Request Lenses
    updateConfigurationSetEventDestination_configurationSetName,
    updateConfigurationSetEventDestination_eventDestinationName,
    updateConfigurationSetEventDestination_eventDestination,

    -- * Destructuring the Response
    UpdateConfigurationSetEventDestinationResponse (..),
    newUpdateConfigurationSetEventDestinationResponse,

    -- * Response Lenses
    updateConfigurationSetEventDestinationResponse_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 change the settings for an event destination for a
-- configuration set.
--
-- /See:/ 'newUpdateConfigurationSetEventDestination' smart constructor.
data UpdateConfigurationSetEventDestination = UpdateConfigurationSetEventDestination'
  { -- | The name of the configuration set that contains the event destination
    -- that you want to modify.
    UpdateConfigurationSetEventDestination -> Text
configurationSetName :: Prelude.Text,
    -- | The name of the event destination that you want to modify.
    UpdateConfigurationSetEventDestination -> Text
eventDestinationName :: Prelude.Text,
    -- | An object that defines the event destination.
    UpdateConfigurationSetEventDestination
-> EventDestinationDefinition
eventDestination :: EventDestinationDefinition
  }
  deriving (UpdateConfigurationSetEventDestination
-> UpdateConfigurationSetEventDestination -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConfigurationSetEventDestination
-> UpdateConfigurationSetEventDestination -> Bool
$c/= :: UpdateConfigurationSetEventDestination
-> UpdateConfigurationSetEventDestination -> Bool
== :: UpdateConfigurationSetEventDestination
-> UpdateConfigurationSetEventDestination -> Bool
$c== :: UpdateConfigurationSetEventDestination
-> UpdateConfigurationSetEventDestination -> Bool
Prelude.Eq, ReadPrec [UpdateConfigurationSetEventDestination]
ReadPrec UpdateConfigurationSetEventDestination
Int -> ReadS UpdateConfigurationSetEventDestination
ReadS [UpdateConfigurationSetEventDestination]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConfigurationSetEventDestination]
$creadListPrec :: ReadPrec [UpdateConfigurationSetEventDestination]
readPrec :: ReadPrec UpdateConfigurationSetEventDestination
$creadPrec :: ReadPrec UpdateConfigurationSetEventDestination
readList :: ReadS [UpdateConfigurationSetEventDestination]
$creadList :: ReadS [UpdateConfigurationSetEventDestination]
readsPrec :: Int -> ReadS UpdateConfigurationSetEventDestination
$creadsPrec :: Int -> ReadS UpdateConfigurationSetEventDestination
Prelude.Read, Int -> UpdateConfigurationSetEventDestination -> ShowS
[UpdateConfigurationSetEventDestination] -> ShowS
UpdateConfigurationSetEventDestination -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConfigurationSetEventDestination] -> ShowS
$cshowList :: [UpdateConfigurationSetEventDestination] -> ShowS
show :: UpdateConfigurationSetEventDestination -> String
$cshow :: UpdateConfigurationSetEventDestination -> String
showsPrec :: Int -> UpdateConfigurationSetEventDestination -> ShowS
$cshowsPrec :: Int -> UpdateConfigurationSetEventDestination -> ShowS
Prelude.Show, forall x.
Rep UpdateConfigurationSetEventDestination x
-> UpdateConfigurationSetEventDestination
forall x.
UpdateConfigurationSetEventDestination
-> Rep UpdateConfigurationSetEventDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateConfigurationSetEventDestination x
-> UpdateConfigurationSetEventDestination
$cfrom :: forall x.
UpdateConfigurationSetEventDestination
-> Rep UpdateConfigurationSetEventDestination x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConfigurationSetEventDestination' 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', 'updateConfigurationSetEventDestination_configurationSetName' - The name of the configuration set that contains the event destination
-- that you want to modify.
--
-- 'eventDestinationName', 'updateConfigurationSetEventDestination_eventDestinationName' - The name of the event destination that you want to modify.
--
-- 'eventDestination', 'updateConfigurationSetEventDestination_eventDestination' - An object that defines the event destination.
newUpdateConfigurationSetEventDestination ::
  -- | 'configurationSetName'
  Prelude.Text ->
  -- | 'eventDestinationName'
  Prelude.Text ->
  -- | 'eventDestination'
  EventDestinationDefinition ->
  UpdateConfigurationSetEventDestination
newUpdateConfigurationSetEventDestination :: Text
-> Text
-> EventDestinationDefinition
-> UpdateConfigurationSetEventDestination
newUpdateConfigurationSetEventDestination
  Text
pConfigurationSetName_
  Text
pEventDestinationName_
  EventDestinationDefinition
pEventDestination_ =
    UpdateConfigurationSetEventDestination'
      { $sel:configurationSetName:UpdateConfigurationSetEventDestination' :: Text
configurationSetName =
          Text
pConfigurationSetName_,
        $sel:eventDestinationName:UpdateConfigurationSetEventDestination' :: Text
eventDestinationName =
          Text
pEventDestinationName_,
        $sel:eventDestination:UpdateConfigurationSetEventDestination' :: EventDestinationDefinition
eventDestination =
          EventDestinationDefinition
pEventDestination_
      }

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

-- | The name of the event destination that you want to modify.
updateConfigurationSetEventDestination_eventDestinationName :: Lens.Lens' UpdateConfigurationSetEventDestination Prelude.Text
updateConfigurationSetEventDestination_eventDestinationName :: Lens' UpdateConfigurationSetEventDestination Text
updateConfigurationSetEventDestination_eventDestinationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfigurationSetEventDestination' {Text
eventDestinationName :: Text
$sel:eventDestinationName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> Text
eventDestinationName} -> Text
eventDestinationName) (\s :: UpdateConfigurationSetEventDestination
s@UpdateConfigurationSetEventDestination' {} Text
a -> UpdateConfigurationSetEventDestination
s {$sel:eventDestinationName:UpdateConfigurationSetEventDestination' :: Text
eventDestinationName = Text
a} :: UpdateConfigurationSetEventDestination)

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

instance
  Core.AWSRequest
    UpdateConfigurationSetEventDestination
  where
  type
    AWSResponse
      UpdateConfigurationSetEventDestination =
      UpdateConfigurationSetEventDestinationResponse
  request :: (Service -> Service)
-> UpdateConfigurationSetEventDestination
-> Request UpdateConfigurationSetEventDestination
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 UpdateConfigurationSetEventDestination
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse UpdateConfigurationSetEventDestination)))
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 -> UpdateConfigurationSetEventDestinationResponse
UpdateConfigurationSetEventDestinationResponse'
            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
    UpdateConfigurationSetEventDestination
  where
  hashWithSalt :: Int -> UpdateConfigurationSetEventDestination -> Int
hashWithSalt
    Int
_salt
    UpdateConfigurationSetEventDestination' {Text
EventDestinationDefinition
eventDestination :: EventDestinationDefinition
eventDestinationName :: Text
configurationSetName :: Text
$sel:eventDestination:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination
-> EventDestinationDefinition
$sel:eventDestinationName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> Text
$sel:configurationSetName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> 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
    UpdateConfigurationSetEventDestination
  where
  rnf :: UpdateConfigurationSetEventDestination -> ()
rnf UpdateConfigurationSetEventDestination' {Text
EventDestinationDefinition
eventDestination :: EventDestinationDefinition
eventDestinationName :: Text
configurationSetName :: Text
$sel:eventDestination:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination
-> EventDestinationDefinition
$sel:eventDestinationName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> Text
$sel:configurationSetName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> 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
    UpdateConfigurationSetEventDestination
  where
  toHeaders :: UpdateConfigurationSetEventDestination -> 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
    UpdateConfigurationSetEventDestination
  where
  toJSON :: UpdateConfigurationSetEventDestination -> Value
toJSON UpdateConfigurationSetEventDestination' {Text
EventDestinationDefinition
eventDestination :: EventDestinationDefinition
eventDestinationName :: Text
configurationSetName :: Text
$sel:eventDestination:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination
-> EventDestinationDefinition
$sel:eventDestinationName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> Text
$sel:configurationSetName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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
    UpdateConfigurationSetEventDestination
  where
  toPath :: UpdateConfigurationSetEventDestination -> ByteString
toPath UpdateConfigurationSetEventDestination' {Text
EventDestinationDefinition
eventDestination :: EventDestinationDefinition
eventDestinationName :: Text
configurationSetName :: Text
$sel:eventDestination:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination
-> EventDestinationDefinition
$sel:eventDestinationName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> Text
$sel:configurationSetName:UpdateConfigurationSetEventDestination' :: UpdateConfigurationSetEventDestination -> 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/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
eventDestinationName
      ]

instance
  Data.ToQuery
    UpdateConfigurationSetEventDestination
  where
  toQuery :: UpdateConfigurationSetEventDestination -> 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:/ 'newUpdateConfigurationSetEventDestinationResponse' smart constructor.
data UpdateConfigurationSetEventDestinationResponse = UpdateConfigurationSetEventDestinationResponse'
  { -- | The response's http status code.
    UpdateConfigurationSetEventDestinationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateConfigurationSetEventDestinationResponse
-> UpdateConfigurationSetEventDestinationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConfigurationSetEventDestinationResponse
-> UpdateConfigurationSetEventDestinationResponse -> Bool
$c/= :: UpdateConfigurationSetEventDestinationResponse
-> UpdateConfigurationSetEventDestinationResponse -> Bool
== :: UpdateConfigurationSetEventDestinationResponse
-> UpdateConfigurationSetEventDestinationResponse -> Bool
$c== :: UpdateConfigurationSetEventDestinationResponse
-> UpdateConfigurationSetEventDestinationResponse -> Bool
Prelude.Eq, ReadPrec [UpdateConfigurationSetEventDestinationResponse]
ReadPrec UpdateConfigurationSetEventDestinationResponse
Int -> ReadS UpdateConfigurationSetEventDestinationResponse
ReadS [UpdateConfigurationSetEventDestinationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConfigurationSetEventDestinationResponse]
$creadListPrec :: ReadPrec [UpdateConfigurationSetEventDestinationResponse]
readPrec :: ReadPrec UpdateConfigurationSetEventDestinationResponse
$creadPrec :: ReadPrec UpdateConfigurationSetEventDestinationResponse
readList :: ReadS [UpdateConfigurationSetEventDestinationResponse]
$creadList :: ReadS [UpdateConfigurationSetEventDestinationResponse]
readsPrec :: Int -> ReadS UpdateConfigurationSetEventDestinationResponse
$creadsPrec :: Int -> ReadS UpdateConfigurationSetEventDestinationResponse
Prelude.Read, Int -> UpdateConfigurationSetEventDestinationResponse -> ShowS
[UpdateConfigurationSetEventDestinationResponse] -> ShowS
UpdateConfigurationSetEventDestinationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConfigurationSetEventDestinationResponse] -> ShowS
$cshowList :: [UpdateConfigurationSetEventDestinationResponse] -> ShowS
show :: UpdateConfigurationSetEventDestinationResponse -> String
$cshow :: UpdateConfigurationSetEventDestinationResponse -> String
showsPrec :: Int -> UpdateConfigurationSetEventDestinationResponse -> ShowS
$cshowsPrec :: Int -> UpdateConfigurationSetEventDestinationResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateConfigurationSetEventDestinationResponse x
-> UpdateConfigurationSetEventDestinationResponse
forall x.
UpdateConfigurationSetEventDestinationResponse
-> Rep UpdateConfigurationSetEventDestinationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateConfigurationSetEventDestinationResponse x
-> UpdateConfigurationSetEventDestinationResponse
$cfrom :: forall x.
UpdateConfigurationSetEventDestinationResponse
-> Rep UpdateConfigurationSetEventDestinationResponse x
Prelude.Generic)

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

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

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