{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoT.Types.PublishFindingToSnsParams
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.PublishFindingToSnsParams where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Parameters to define a mitigation action that publishes findings to
-- Amazon SNS. You can implement your own custom actions in response to the
-- Amazon SNS messages.
--
-- /See:/ 'newPublishFindingToSnsParams' smart constructor.
data PublishFindingToSnsParams = PublishFindingToSnsParams'
  { -- | The ARN of the topic to which you want to publish the findings.
    PublishFindingToSnsParams -> Text
topicArn :: Prelude.Text
  }
  deriving (PublishFindingToSnsParams -> PublishFindingToSnsParams -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PublishFindingToSnsParams -> PublishFindingToSnsParams -> Bool
$c/= :: PublishFindingToSnsParams -> PublishFindingToSnsParams -> Bool
== :: PublishFindingToSnsParams -> PublishFindingToSnsParams -> Bool
$c== :: PublishFindingToSnsParams -> PublishFindingToSnsParams -> Bool
Prelude.Eq, ReadPrec [PublishFindingToSnsParams]
ReadPrec PublishFindingToSnsParams
Int -> ReadS PublishFindingToSnsParams
ReadS [PublishFindingToSnsParams]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PublishFindingToSnsParams]
$creadListPrec :: ReadPrec [PublishFindingToSnsParams]
readPrec :: ReadPrec PublishFindingToSnsParams
$creadPrec :: ReadPrec PublishFindingToSnsParams
readList :: ReadS [PublishFindingToSnsParams]
$creadList :: ReadS [PublishFindingToSnsParams]
readsPrec :: Int -> ReadS PublishFindingToSnsParams
$creadsPrec :: Int -> ReadS PublishFindingToSnsParams
Prelude.Read, Int -> PublishFindingToSnsParams -> ShowS
[PublishFindingToSnsParams] -> ShowS
PublishFindingToSnsParams -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PublishFindingToSnsParams] -> ShowS
$cshowList :: [PublishFindingToSnsParams] -> ShowS
show :: PublishFindingToSnsParams -> String
$cshow :: PublishFindingToSnsParams -> String
showsPrec :: Int -> PublishFindingToSnsParams -> ShowS
$cshowsPrec :: Int -> PublishFindingToSnsParams -> ShowS
Prelude.Show, forall x.
Rep PublishFindingToSnsParams x -> PublishFindingToSnsParams
forall x.
PublishFindingToSnsParams -> Rep PublishFindingToSnsParams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PublishFindingToSnsParams x -> PublishFindingToSnsParams
$cfrom :: forall x.
PublishFindingToSnsParams -> Rep PublishFindingToSnsParams x
Prelude.Generic)

-- |
-- Create a value of 'PublishFindingToSnsParams' 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:
--
-- 'topicArn', 'publishFindingToSnsParams_topicArn' - The ARN of the topic to which you want to publish the findings.
newPublishFindingToSnsParams ::
  -- | 'topicArn'
  Prelude.Text ->
  PublishFindingToSnsParams
newPublishFindingToSnsParams :: Text -> PublishFindingToSnsParams
newPublishFindingToSnsParams Text
pTopicArn_ =
  PublishFindingToSnsParams' {$sel:topicArn:PublishFindingToSnsParams' :: Text
topicArn = Text
pTopicArn_}

-- | The ARN of the topic to which you want to publish the findings.
publishFindingToSnsParams_topicArn :: Lens.Lens' PublishFindingToSnsParams Prelude.Text
publishFindingToSnsParams_topicArn :: Lens' PublishFindingToSnsParams Text
publishFindingToSnsParams_topicArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublishFindingToSnsParams' {Text
topicArn :: Text
$sel:topicArn:PublishFindingToSnsParams' :: PublishFindingToSnsParams -> Text
topicArn} -> Text
topicArn) (\s :: PublishFindingToSnsParams
s@PublishFindingToSnsParams' {} Text
a -> PublishFindingToSnsParams
s {$sel:topicArn:PublishFindingToSnsParams' :: Text
topicArn = Text
a} :: PublishFindingToSnsParams)

instance Data.FromJSON PublishFindingToSnsParams where
  parseJSON :: Value -> Parser PublishFindingToSnsParams
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PublishFindingToSnsParams"
      ( \Object
x ->
          Text -> PublishFindingToSnsParams
PublishFindingToSnsParams'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"topicArn")
      )

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

instance Prelude.NFData PublishFindingToSnsParams where
  rnf :: PublishFindingToSnsParams -> ()
rnf PublishFindingToSnsParams' {Text
topicArn :: Text
$sel:topicArn:PublishFindingToSnsParams' :: PublishFindingToSnsParams -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
topicArn

instance Data.ToJSON PublishFindingToSnsParams where
  toJSON :: PublishFindingToSnsParams -> Value
toJSON PublishFindingToSnsParams' {Text
topicArn :: Text
$sel:topicArn:PublishFindingToSnsParams' :: PublishFindingToSnsParams -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"topicArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
topicArn)]
      )