{-# 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.FMS.PutNotificationChannel
-- 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)
--
-- Designates the IAM role and Amazon Simple Notification Service (SNS)
-- topic that Firewall Manager uses to record SNS logs.
--
-- To perform this action outside of the console, you must configure the
-- SNS topic to allow the Firewall Manager role @AWSServiceRoleForFMS@ to
-- publish SNS logs. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/fms-api-permissions-ref.html Firewall Manager required permissions for API actions>
-- in the /Firewall Manager Developer Guide/.
module Amazonka.FMS.PutNotificationChannel
  ( -- * Creating a Request
    PutNotificationChannel (..),
    newPutNotificationChannel,

    -- * Request Lenses
    putNotificationChannel_snsTopicArn,
    putNotificationChannel_snsRoleName,

    -- * Destructuring the Response
    PutNotificationChannelResponse (..),
    newPutNotificationChannelResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.FMS.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:/ 'newPutNotificationChannel' smart constructor.
data PutNotificationChannel = PutNotificationChannel'
  { -- | The Amazon Resource Name (ARN) of the SNS topic that collects
    -- notifications from Firewall Manager.
    PutNotificationChannel -> Text
snsTopicArn :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM role that allows Amazon SNS to
    -- record Firewall Manager activity.
    PutNotificationChannel -> Text
snsRoleName :: Prelude.Text
  }
  deriving (PutNotificationChannel -> PutNotificationChannel -> Bool
(PutNotificationChannel -> PutNotificationChannel -> Bool)
-> (PutNotificationChannel -> PutNotificationChannel -> Bool)
-> Eq PutNotificationChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutNotificationChannel -> PutNotificationChannel -> Bool
$c/= :: PutNotificationChannel -> PutNotificationChannel -> Bool
== :: PutNotificationChannel -> PutNotificationChannel -> Bool
$c== :: PutNotificationChannel -> PutNotificationChannel -> Bool
Prelude.Eq, ReadPrec [PutNotificationChannel]
ReadPrec PutNotificationChannel
Int -> ReadS PutNotificationChannel
ReadS [PutNotificationChannel]
(Int -> ReadS PutNotificationChannel)
-> ReadS [PutNotificationChannel]
-> ReadPrec PutNotificationChannel
-> ReadPrec [PutNotificationChannel]
-> Read PutNotificationChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutNotificationChannel]
$creadListPrec :: ReadPrec [PutNotificationChannel]
readPrec :: ReadPrec PutNotificationChannel
$creadPrec :: ReadPrec PutNotificationChannel
readList :: ReadS [PutNotificationChannel]
$creadList :: ReadS [PutNotificationChannel]
readsPrec :: Int -> ReadS PutNotificationChannel
$creadsPrec :: Int -> ReadS PutNotificationChannel
Prelude.Read, Int -> PutNotificationChannel -> ShowS
[PutNotificationChannel] -> ShowS
PutNotificationChannel -> String
(Int -> PutNotificationChannel -> ShowS)
-> (PutNotificationChannel -> String)
-> ([PutNotificationChannel] -> ShowS)
-> Show PutNotificationChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutNotificationChannel] -> ShowS
$cshowList :: [PutNotificationChannel] -> ShowS
show :: PutNotificationChannel -> String
$cshow :: PutNotificationChannel -> String
showsPrec :: Int -> PutNotificationChannel -> ShowS
$cshowsPrec :: Int -> PutNotificationChannel -> ShowS
Prelude.Show, (forall x. PutNotificationChannel -> Rep PutNotificationChannel x)
-> (forall x.
    Rep PutNotificationChannel x -> PutNotificationChannel)
-> Generic PutNotificationChannel
forall x. Rep PutNotificationChannel x -> PutNotificationChannel
forall x. PutNotificationChannel -> Rep PutNotificationChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutNotificationChannel x -> PutNotificationChannel
$cfrom :: forall x. PutNotificationChannel -> Rep PutNotificationChannel x
Prelude.Generic)

-- |
-- Create a value of 'PutNotificationChannel' 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:
--
-- 'snsTopicArn', 'putNotificationChannel_snsTopicArn' - The Amazon Resource Name (ARN) of the SNS topic that collects
-- notifications from Firewall Manager.
--
-- 'snsRoleName', 'putNotificationChannel_snsRoleName' - The Amazon Resource Name (ARN) of the IAM role that allows Amazon SNS to
-- record Firewall Manager activity.
newPutNotificationChannel ::
  -- | 'snsTopicArn'
  Prelude.Text ->
  -- | 'snsRoleName'
  Prelude.Text ->
  PutNotificationChannel
newPutNotificationChannel :: Text -> Text -> PutNotificationChannel
newPutNotificationChannel Text
pSnsTopicArn_ Text
pSnsRoleName_ =
  PutNotificationChannel' :: Text -> Text -> PutNotificationChannel
PutNotificationChannel'
    { $sel:snsTopicArn:PutNotificationChannel' :: Text
snsTopicArn =
        Text
pSnsTopicArn_,
      $sel:snsRoleName:PutNotificationChannel' :: Text
snsRoleName = Text
pSnsRoleName_
    }

-- | The Amazon Resource Name (ARN) of the SNS topic that collects
-- notifications from Firewall Manager.
putNotificationChannel_snsTopicArn :: Lens.Lens' PutNotificationChannel Prelude.Text
putNotificationChannel_snsTopicArn :: (Text -> f Text)
-> PutNotificationChannel -> f PutNotificationChannel
putNotificationChannel_snsTopicArn = (PutNotificationChannel -> Text)
-> (PutNotificationChannel -> Text -> PutNotificationChannel)
-> Lens PutNotificationChannel PutNotificationChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutNotificationChannel' {Text
snsTopicArn :: Text
$sel:snsTopicArn:PutNotificationChannel' :: PutNotificationChannel -> Text
snsTopicArn} -> Text
snsTopicArn) (\s :: PutNotificationChannel
s@PutNotificationChannel' {} Text
a -> PutNotificationChannel
s {$sel:snsTopicArn:PutNotificationChannel' :: Text
snsTopicArn = Text
a} :: PutNotificationChannel)

-- | The Amazon Resource Name (ARN) of the IAM role that allows Amazon SNS to
-- record Firewall Manager activity.
putNotificationChannel_snsRoleName :: Lens.Lens' PutNotificationChannel Prelude.Text
putNotificationChannel_snsRoleName :: (Text -> f Text)
-> PutNotificationChannel -> f PutNotificationChannel
putNotificationChannel_snsRoleName = (PutNotificationChannel -> Text)
-> (PutNotificationChannel -> Text -> PutNotificationChannel)
-> Lens PutNotificationChannel PutNotificationChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutNotificationChannel' {Text
snsRoleName :: Text
$sel:snsRoleName:PutNotificationChannel' :: PutNotificationChannel -> Text
snsRoleName} -> Text
snsRoleName) (\s :: PutNotificationChannel
s@PutNotificationChannel' {} Text
a -> PutNotificationChannel
s {$sel:snsRoleName:PutNotificationChannel' :: Text
snsRoleName = Text
a} :: PutNotificationChannel)

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

instance Prelude.Hashable PutNotificationChannel

instance Prelude.NFData PutNotificationChannel

instance Core.ToHeaders PutNotificationChannel where
  toHeaders :: PutNotificationChannel -> [Header]
toHeaders =
    [Header] -> PutNotificationChannel -> [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
"AWSFMS_20180101.PutNotificationChannel" ::
                          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 PutNotificationChannel where
  toJSON :: PutNotificationChannel -> Value
toJSON PutNotificationChannel' {Text
snsRoleName :: Text
snsTopicArn :: Text
$sel:snsRoleName:PutNotificationChannel' :: PutNotificationChannel -> Text
$sel:snsTopicArn:PutNotificationChannel' :: PutNotificationChannel -> 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
"SnsTopicArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
snsTopicArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SnsRoleName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
snsRoleName)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    PutNotificationChannelResponse