{-# 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.Inspector.UnsubscribeFromEvent
-- 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)
--
-- Disables the process of sending Amazon Simple Notification Service (SNS)
-- notifications about a specified event to a specified SNS topic.
module Amazonka.Inspector.UnsubscribeFromEvent
  ( -- * Creating a Request
    UnsubscribeFromEvent (..),
    newUnsubscribeFromEvent,

    -- * Request Lenses
    unsubscribeFromEvent_resourceArn,
    unsubscribeFromEvent_event,
    unsubscribeFromEvent_topicArn,

    -- * Destructuring the Response
    UnsubscribeFromEventResponse (..),
    newUnsubscribeFromEventResponse,
  )
where

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

-- | /See:/ 'newUnsubscribeFromEvent' smart constructor.
data UnsubscribeFromEvent = UnsubscribeFromEvent'
  { -- | The ARN of the assessment template that is used during the event for
    -- which you want to stop receiving SNS notifications.
    UnsubscribeFromEvent -> Text
resourceArn :: Prelude.Text,
    -- | The event for which you want to stop receiving SNS notifications.
    UnsubscribeFromEvent -> InspectorEvent
event :: InspectorEvent,
    -- | The ARN of the SNS topic to which SNS notifications are sent.
    UnsubscribeFromEvent -> Text
topicArn :: Prelude.Text
  }
  deriving (UnsubscribeFromEvent -> UnsubscribeFromEvent -> Bool
(UnsubscribeFromEvent -> UnsubscribeFromEvent -> Bool)
-> (UnsubscribeFromEvent -> UnsubscribeFromEvent -> Bool)
-> Eq UnsubscribeFromEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnsubscribeFromEvent -> UnsubscribeFromEvent -> Bool
$c/= :: UnsubscribeFromEvent -> UnsubscribeFromEvent -> Bool
== :: UnsubscribeFromEvent -> UnsubscribeFromEvent -> Bool
$c== :: UnsubscribeFromEvent -> UnsubscribeFromEvent -> Bool
Prelude.Eq, ReadPrec [UnsubscribeFromEvent]
ReadPrec UnsubscribeFromEvent
Int -> ReadS UnsubscribeFromEvent
ReadS [UnsubscribeFromEvent]
(Int -> ReadS UnsubscribeFromEvent)
-> ReadS [UnsubscribeFromEvent]
-> ReadPrec UnsubscribeFromEvent
-> ReadPrec [UnsubscribeFromEvent]
-> Read UnsubscribeFromEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnsubscribeFromEvent]
$creadListPrec :: ReadPrec [UnsubscribeFromEvent]
readPrec :: ReadPrec UnsubscribeFromEvent
$creadPrec :: ReadPrec UnsubscribeFromEvent
readList :: ReadS [UnsubscribeFromEvent]
$creadList :: ReadS [UnsubscribeFromEvent]
readsPrec :: Int -> ReadS UnsubscribeFromEvent
$creadsPrec :: Int -> ReadS UnsubscribeFromEvent
Prelude.Read, Int -> UnsubscribeFromEvent -> ShowS
[UnsubscribeFromEvent] -> ShowS
UnsubscribeFromEvent -> String
(Int -> UnsubscribeFromEvent -> ShowS)
-> (UnsubscribeFromEvent -> String)
-> ([UnsubscribeFromEvent] -> ShowS)
-> Show UnsubscribeFromEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnsubscribeFromEvent] -> ShowS
$cshowList :: [UnsubscribeFromEvent] -> ShowS
show :: UnsubscribeFromEvent -> String
$cshow :: UnsubscribeFromEvent -> String
showsPrec :: Int -> UnsubscribeFromEvent -> ShowS
$cshowsPrec :: Int -> UnsubscribeFromEvent -> ShowS
Prelude.Show, (forall x. UnsubscribeFromEvent -> Rep UnsubscribeFromEvent x)
-> (forall x. Rep UnsubscribeFromEvent x -> UnsubscribeFromEvent)
-> Generic UnsubscribeFromEvent
forall x. Rep UnsubscribeFromEvent x -> UnsubscribeFromEvent
forall x. UnsubscribeFromEvent -> Rep UnsubscribeFromEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnsubscribeFromEvent x -> UnsubscribeFromEvent
$cfrom :: forall x. UnsubscribeFromEvent -> Rep UnsubscribeFromEvent x
Prelude.Generic)

-- |
-- Create a value of 'UnsubscribeFromEvent' 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:
--
-- 'resourceArn', 'unsubscribeFromEvent_resourceArn' - The ARN of the assessment template that is used during the event for
-- which you want to stop receiving SNS notifications.
--
-- 'event', 'unsubscribeFromEvent_event' - The event for which you want to stop receiving SNS notifications.
--
-- 'topicArn', 'unsubscribeFromEvent_topicArn' - The ARN of the SNS topic to which SNS notifications are sent.
newUnsubscribeFromEvent ::
  -- | 'resourceArn'
  Prelude.Text ->
  -- | 'event'
  InspectorEvent ->
  -- | 'topicArn'
  Prelude.Text ->
  UnsubscribeFromEvent
newUnsubscribeFromEvent :: Text -> InspectorEvent -> Text -> UnsubscribeFromEvent
newUnsubscribeFromEvent
  Text
pResourceArn_
  InspectorEvent
pEvent_
  Text
pTopicArn_ =
    UnsubscribeFromEvent' :: Text -> InspectorEvent -> Text -> UnsubscribeFromEvent
UnsubscribeFromEvent'
      { $sel:resourceArn:UnsubscribeFromEvent' :: Text
resourceArn = Text
pResourceArn_,
        $sel:event:UnsubscribeFromEvent' :: InspectorEvent
event = InspectorEvent
pEvent_,
        $sel:topicArn:UnsubscribeFromEvent' :: Text
topicArn = Text
pTopicArn_
      }

-- | The ARN of the assessment template that is used during the event for
-- which you want to stop receiving SNS notifications.
unsubscribeFromEvent_resourceArn :: Lens.Lens' UnsubscribeFromEvent Prelude.Text
unsubscribeFromEvent_resourceArn :: (Text -> f Text) -> UnsubscribeFromEvent -> f UnsubscribeFromEvent
unsubscribeFromEvent_resourceArn = (UnsubscribeFromEvent -> Text)
-> (UnsubscribeFromEvent -> Text -> UnsubscribeFromEvent)
-> Lens UnsubscribeFromEvent UnsubscribeFromEvent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeFromEvent' {Text
resourceArn :: Text
$sel:resourceArn:UnsubscribeFromEvent' :: UnsubscribeFromEvent -> Text
resourceArn} -> Text
resourceArn) (\s :: UnsubscribeFromEvent
s@UnsubscribeFromEvent' {} Text
a -> UnsubscribeFromEvent
s {$sel:resourceArn:UnsubscribeFromEvent' :: Text
resourceArn = Text
a} :: UnsubscribeFromEvent)

-- | The event for which you want to stop receiving SNS notifications.
unsubscribeFromEvent_event :: Lens.Lens' UnsubscribeFromEvent InspectorEvent
unsubscribeFromEvent_event :: (InspectorEvent -> f InspectorEvent)
-> UnsubscribeFromEvent -> f UnsubscribeFromEvent
unsubscribeFromEvent_event = (UnsubscribeFromEvent -> InspectorEvent)
-> (UnsubscribeFromEvent -> InspectorEvent -> UnsubscribeFromEvent)
-> Lens
     UnsubscribeFromEvent
     UnsubscribeFromEvent
     InspectorEvent
     InspectorEvent
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeFromEvent' {InspectorEvent
event :: InspectorEvent
$sel:event:UnsubscribeFromEvent' :: UnsubscribeFromEvent -> InspectorEvent
event} -> InspectorEvent
event) (\s :: UnsubscribeFromEvent
s@UnsubscribeFromEvent' {} InspectorEvent
a -> UnsubscribeFromEvent
s {$sel:event:UnsubscribeFromEvent' :: InspectorEvent
event = InspectorEvent
a} :: UnsubscribeFromEvent)

-- | The ARN of the SNS topic to which SNS notifications are sent.
unsubscribeFromEvent_topicArn :: Lens.Lens' UnsubscribeFromEvent Prelude.Text
unsubscribeFromEvent_topicArn :: (Text -> f Text) -> UnsubscribeFromEvent -> f UnsubscribeFromEvent
unsubscribeFromEvent_topicArn = (UnsubscribeFromEvent -> Text)
-> (UnsubscribeFromEvent -> Text -> UnsubscribeFromEvent)
-> Lens UnsubscribeFromEvent UnsubscribeFromEvent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeFromEvent' {Text
topicArn :: Text
$sel:topicArn:UnsubscribeFromEvent' :: UnsubscribeFromEvent -> Text
topicArn} -> Text
topicArn) (\s :: UnsubscribeFromEvent
s@UnsubscribeFromEvent' {} Text
a -> UnsubscribeFromEvent
s {$sel:topicArn:UnsubscribeFromEvent' :: Text
topicArn = Text
a} :: UnsubscribeFromEvent)

instance Core.AWSRequest UnsubscribeFromEvent where
  type
    AWSResponse UnsubscribeFromEvent =
      UnsubscribeFromEventResponse
  request :: UnsubscribeFromEvent -> Request UnsubscribeFromEvent
request = Service -> UnsubscribeFromEvent -> Request UnsubscribeFromEvent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UnsubscribeFromEvent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UnsubscribeFromEvent)))
response =
    AWSResponse UnsubscribeFromEvent
-> Logger
-> Service
-> Proxy UnsubscribeFromEvent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UnsubscribeFromEvent)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UnsubscribeFromEvent
UnsubscribeFromEventResponse
UnsubscribeFromEventResponse'

instance Prelude.Hashable UnsubscribeFromEvent

instance Prelude.NFData UnsubscribeFromEvent

instance Core.ToHeaders UnsubscribeFromEvent where
  toHeaders :: UnsubscribeFromEvent -> [Header]
toHeaders =
    [Header] -> UnsubscribeFromEvent -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"InspectorService.UnsubscribeFromEvent" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UnsubscribeFromEvent where
  toJSON :: UnsubscribeFromEvent -> Value
toJSON UnsubscribeFromEvent' {Text
InspectorEvent
topicArn :: Text
event :: InspectorEvent
resourceArn :: Text
$sel:topicArn:UnsubscribeFromEvent' :: UnsubscribeFromEvent -> Text
$sel:event:UnsubscribeFromEvent' :: UnsubscribeFromEvent -> InspectorEvent
$sel:resourceArn:UnsubscribeFromEvent' :: UnsubscribeFromEvent -> Text
..} =
    [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
"resourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"event" Text -> InspectorEvent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InspectorEvent
event),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"topicArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
topicArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'UnsubscribeFromEventResponse' 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.
newUnsubscribeFromEventResponse ::
  UnsubscribeFromEventResponse
newUnsubscribeFromEventResponse :: UnsubscribeFromEventResponse
newUnsubscribeFromEventResponse =
  UnsubscribeFromEventResponse
UnsubscribeFromEventResponse'

instance Prelude.NFData UnsubscribeFromEventResponse