{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types
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
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]
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
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. 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'
    { $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 :: Lens' PutNotificationChannel Text
putNotificationChannel_snsTopicArn = 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 :: Lens' PutNotificationChannel Text
putNotificationChannel_snsRoleName = 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 :: (Service -> Service)
-> PutNotificationChannel -> Request PutNotificationChannel
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 PutNotificationChannel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutNotificationChannel)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      PutNotificationChannelResponse
PutNotificationChannelResponse'

instance Prelude.Hashable PutNotificationChannel where
  hashWithSalt :: Int -> PutNotificationChannel -> Int
hashWithSalt Int
_salt PutNotificationChannel' {Text
snsRoleName :: Text
snsTopicArn :: Text
$sel:snsRoleName:PutNotificationChannel' :: PutNotificationChannel -> Text
$sel:snsTopicArn:PutNotificationChannel' :: PutNotificationChannel -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
snsTopicArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
snsRoleName

instance Prelude.NFData PutNotificationChannel where
  rnf :: PutNotificationChannel -> ()
rnf PutNotificationChannel' {Text
snsRoleName :: Text
snsTopicArn :: Text
$sel:snsRoleName:PutNotificationChannel' :: PutNotificationChannel -> Text
$sel:snsTopicArn:PutNotificationChannel' :: PutNotificationChannel -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
snsTopicArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
snsRoleName

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

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"SnsTopicArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
snsTopicArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"SnsRoleName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
snsRoleName)
          ]
      )

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

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

-- | /See:/ 'newPutNotificationChannelResponse' smart constructor.
data PutNotificationChannelResponse = PutNotificationChannelResponse'
  {
  }
  deriving (PutNotificationChannelResponse
-> PutNotificationChannelResponse -> Bool
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]
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
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.
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
  where
  rnf :: PutNotificationChannelResponse -> ()
rnf PutNotificationChannelResponse
_ = ()