{-# 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.MechanicalTurk.SendTestEventNotification
-- 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)
--
-- The @SendTestEventNotification@ operation causes Amazon Mechanical Turk
-- to send a notification message as if a HIT event occurred, according to
-- the provided notification specification. This allows you to test
-- notifications without setting up notifications for a real HIT type and
-- trying to trigger them using the website. When you call this operation,
-- the service attempts to send the test notification immediately.
module Amazonka.MechanicalTurk.SendTestEventNotification
  ( -- * Creating a Request
    SendTestEventNotification (..),
    newSendTestEventNotification,

    -- * Request Lenses
    sendTestEventNotification_notification,
    sendTestEventNotification_testEventType,

    -- * Destructuring the Response
    SendTestEventNotificationResponse (..),
    newSendTestEventNotificationResponse,

    -- * Response Lenses
    sendTestEventNotificationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MechanicalTurk.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newSendTestEventNotification' smart constructor.
data SendTestEventNotification = SendTestEventNotification'
  { -- | The notification specification to test. This value is identical to the
    -- value you would provide to the UpdateNotificationSettings operation when
    -- you establish the notification specification for a HIT type.
    SendTestEventNotification -> NotificationSpecification
notification :: NotificationSpecification,
    -- | The event to simulate to test the notification specification. This event
    -- is included in the test message even if the notification specification
    -- does not include the event type. The notification specification does not
    -- filter out the test event.
    SendTestEventNotification -> EventType
testEventType :: EventType
  }
  deriving (SendTestEventNotification -> SendTestEventNotification -> Bool
(SendTestEventNotification -> SendTestEventNotification -> Bool)
-> (SendTestEventNotification -> SendTestEventNotification -> Bool)
-> Eq SendTestEventNotification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendTestEventNotification -> SendTestEventNotification -> Bool
$c/= :: SendTestEventNotification -> SendTestEventNotification -> Bool
== :: SendTestEventNotification -> SendTestEventNotification -> Bool
$c== :: SendTestEventNotification -> SendTestEventNotification -> Bool
Prelude.Eq, ReadPrec [SendTestEventNotification]
ReadPrec SendTestEventNotification
Int -> ReadS SendTestEventNotification
ReadS [SendTestEventNotification]
(Int -> ReadS SendTestEventNotification)
-> ReadS [SendTestEventNotification]
-> ReadPrec SendTestEventNotification
-> ReadPrec [SendTestEventNotification]
-> Read SendTestEventNotification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendTestEventNotification]
$creadListPrec :: ReadPrec [SendTestEventNotification]
readPrec :: ReadPrec SendTestEventNotification
$creadPrec :: ReadPrec SendTestEventNotification
readList :: ReadS [SendTestEventNotification]
$creadList :: ReadS [SendTestEventNotification]
readsPrec :: Int -> ReadS SendTestEventNotification
$creadsPrec :: Int -> ReadS SendTestEventNotification
Prelude.Read, Int -> SendTestEventNotification -> ShowS
[SendTestEventNotification] -> ShowS
SendTestEventNotification -> String
(Int -> SendTestEventNotification -> ShowS)
-> (SendTestEventNotification -> String)
-> ([SendTestEventNotification] -> ShowS)
-> Show SendTestEventNotification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendTestEventNotification] -> ShowS
$cshowList :: [SendTestEventNotification] -> ShowS
show :: SendTestEventNotification -> String
$cshow :: SendTestEventNotification -> String
showsPrec :: Int -> SendTestEventNotification -> ShowS
$cshowsPrec :: Int -> SendTestEventNotification -> ShowS
Prelude.Show, (forall x.
 SendTestEventNotification -> Rep SendTestEventNotification x)
-> (forall x.
    Rep SendTestEventNotification x -> SendTestEventNotification)
-> Generic SendTestEventNotification
forall x.
Rep SendTestEventNotification x -> SendTestEventNotification
forall x.
SendTestEventNotification -> Rep SendTestEventNotification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SendTestEventNotification x -> SendTestEventNotification
$cfrom :: forall x.
SendTestEventNotification -> Rep SendTestEventNotification x
Prelude.Generic)

-- |
-- Create a value of 'SendTestEventNotification' 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:
--
-- 'notification', 'sendTestEventNotification_notification' - The notification specification to test. This value is identical to the
-- value you would provide to the UpdateNotificationSettings operation when
-- you establish the notification specification for a HIT type.
--
-- 'testEventType', 'sendTestEventNotification_testEventType' - The event to simulate to test the notification specification. This event
-- is included in the test message even if the notification specification
-- does not include the event type. The notification specification does not
-- filter out the test event.
newSendTestEventNotification ::
  -- | 'notification'
  NotificationSpecification ->
  -- | 'testEventType'
  EventType ->
  SendTestEventNotification
newSendTestEventNotification :: NotificationSpecification -> EventType -> SendTestEventNotification
newSendTestEventNotification
  NotificationSpecification
pNotification_
  EventType
pTestEventType_ =
    SendTestEventNotification' :: NotificationSpecification -> EventType -> SendTestEventNotification
SendTestEventNotification'
      { $sel:notification:SendTestEventNotification' :: NotificationSpecification
notification =
          NotificationSpecification
pNotification_,
        $sel:testEventType:SendTestEventNotification' :: EventType
testEventType = EventType
pTestEventType_
      }

-- | The notification specification to test. This value is identical to the
-- value you would provide to the UpdateNotificationSettings operation when
-- you establish the notification specification for a HIT type.
sendTestEventNotification_notification :: Lens.Lens' SendTestEventNotification NotificationSpecification
sendTestEventNotification_notification :: (NotificationSpecification -> f NotificationSpecification)
-> SendTestEventNotification -> f SendTestEventNotification
sendTestEventNotification_notification = (SendTestEventNotification -> NotificationSpecification)
-> (SendTestEventNotification
    -> NotificationSpecification -> SendTestEventNotification)
-> Lens
     SendTestEventNotification
     SendTestEventNotification
     NotificationSpecification
     NotificationSpecification
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendTestEventNotification' {NotificationSpecification
notification :: NotificationSpecification
$sel:notification:SendTestEventNotification' :: SendTestEventNotification -> NotificationSpecification
notification} -> NotificationSpecification
notification) (\s :: SendTestEventNotification
s@SendTestEventNotification' {} NotificationSpecification
a -> SendTestEventNotification
s {$sel:notification:SendTestEventNotification' :: NotificationSpecification
notification = NotificationSpecification
a} :: SendTestEventNotification)

-- | The event to simulate to test the notification specification. This event
-- is included in the test message even if the notification specification
-- does not include the event type. The notification specification does not
-- filter out the test event.
sendTestEventNotification_testEventType :: Lens.Lens' SendTestEventNotification EventType
sendTestEventNotification_testEventType :: (EventType -> f EventType)
-> SendTestEventNotification -> f SendTestEventNotification
sendTestEventNotification_testEventType = (SendTestEventNotification -> EventType)
-> (SendTestEventNotification
    -> EventType -> SendTestEventNotification)
-> Lens
     SendTestEventNotification
     SendTestEventNotification
     EventType
     EventType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendTestEventNotification' {EventType
testEventType :: EventType
$sel:testEventType:SendTestEventNotification' :: SendTestEventNotification -> EventType
testEventType} -> EventType
testEventType) (\s :: SendTestEventNotification
s@SendTestEventNotification' {} EventType
a -> SendTestEventNotification
s {$sel:testEventType:SendTestEventNotification' :: EventType
testEventType = EventType
a} :: SendTestEventNotification)

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

instance Prelude.NFData SendTestEventNotification

instance Core.ToHeaders SendTestEventNotification where
  toHeaders :: SendTestEventNotification -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SendTestEventNotification -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"MTurkRequesterServiceV20170117.SendTestEventNotification" ::
                          Prelude.ByteString
                      ),
            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 SendTestEventNotification where
  toJSON :: SendTestEventNotification -> Value
toJSON SendTestEventNotification' {EventType
NotificationSpecification
testEventType :: EventType
notification :: NotificationSpecification
$sel:testEventType:SendTestEventNotification' :: SendTestEventNotification -> EventType
$sel:notification:SendTestEventNotification' :: SendTestEventNotification -> NotificationSpecification
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Notification" Text -> NotificationSpecification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NotificationSpecification
notification),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TestEventType" Text -> EventType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EventType
testEventType)
          ]
      )

instance Core.ToPath SendTestEventNotification where
  toPath :: SendTestEventNotification -> ByteString
toPath = ByteString -> SendTestEventNotification -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newSendTestEventNotificationResponse' smart constructor.
data SendTestEventNotificationResponse = SendTestEventNotificationResponse'
  { -- | The response's http status code.
    SendTestEventNotificationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SendTestEventNotificationResponse
-> SendTestEventNotificationResponse -> Bool
(SendTestEventNotificationResponse
 -> SendTestEventNotificationResponse -> Bool)
-> (SendTestEventNotificationResponse
    -> SendTestEventNotificationResponse -> Bool)
-> Eq SendTestEventNotificationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendTestEventNotificationResponse
-> SendTestEventNotificationResponse -> Bool
$c/= :: SendTestEventNotificationResponse
-> SendTestEventNotificationResponse -> Bool
== :: SendTestEventNotificationResponse
-> SendTestEventNotificationResponse -> Bool
$c== :: SendTestEventNotificationResponse
-> SendTestEventNotificationResponse -> Bool
Prelude.Eq, ReadPrec [SendTestEventNotificationResponse]
ReadPrec SendTestEventNotificationResponse
Int -> ReadS SendTestEventNotificationResponse
ReadS [SendTestEventNotificationResponse]
(Int -> ReadS SendTestEventNotificationResponse)
-> ReadS [SendTestEventNotificationResponse]
-> ReadPrec SendTestEventNotificationResponse
-> ReadPrec [SendTestEventNotificationResponse]
-> Read SendTestEventNotificationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendTestEventNotificationResponse]
$creadListPrec :: ReadPrec [SendTestEventNotificationResponse]
readPrec :: ReadPrec SendTestEventNotificationResponse
$creadPrec :: ReadPrec SendTestEventNotificationResponse
readList :: ReadS [SendTestEventNotificationResponse]
$creadList :: ReadS [SendTestEventNotificationResponse]
readsPrec :: Int -> ReadS SendTestEventNotificationResponse
$creadsPrec :: Int -> ReadS SendTestEventNotificationResponse
Prelude.Read, Int -> SendTestEventNotificationResponse -> ShowS
[SendTestEventNotificationResponse] -> ShowS
SendTestEventNotificationResponse -> String
(Int -> SendTestEventNotificationResponse -> ShowS)
-> (SendTestEventNotificationResponse -> String)
-> ([SendTestEventNotificationResponse] -> ShowS)
-> Show SendTestEventNotificationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendTestEventNotificationResponse] -> ShowS
$cshowList :: [SendTestEventNotificationResponse] -> ShowS
show :: SendTestEventNotificationResponse -> String
$cshow :: SendTestEventNotificationResponse -> String
showsPrec :: Int -> SendTestEventNotificationResponse -> ShowS
$cshowsPrec :: Int -> SendTestEventNotificationResponse -> ShowS
Prelude.Show, (forall x.
 SendTestEventNotificationResponse
 -> Rep SendTestEventNotificationResponse x)
-> (forall x.
    Rep SendTestEventNotificationResponse x
    -> SendTestEventNotificationResponse)
-> Generic SendTestEventNotificationResponse
forall x.
Rep SendTestEventNotificationResponse x
-> SendTestEventNotificationResponse
forall x.
SendTestEventNotificationResponse
-> Rep SendTestEventNotificationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SendTestEventNotificationResponse x
-> SendTestEventNotificationResponse
$cfrom :: forall x.
SendTestEventNotificationResponse
-> Rep SendTestEventNotificationResponse x
Prelude.Generic)

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

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

instance
  Prelude.NFData
    SendTestEventNotificationResponse