{-# 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.CloudWatchEvents.Types.SqsParameters
-- 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)
module Amazonka.CloudWatchEvents.Types.SqsParameters where

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

-- | This structure includes the custom parameter to be used when the target
-- is an SQS FIFO queue.
--
-- /See:/ 'newSqsParameters' smart constructor.
data SqsParameters = SqsParameters'
  { -- | The FIFO message group ID to use as the target.
    SqsParameters -> Maybe Text
messageGroupId :: Prelude.Maybe Prelude.Text
  }
  deriving (SqsParameters -> SqsParameters -> Bool
(SqsParameters -> SqsParameters -> Bool)
-> (SqsParameters -> SqsParameters -> Bool) -> Eq SqsParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SqsParameters -> SqsParameters -> Bool
$c/= :: SqsParameters -> SqsParameters -> Bool
== :: SqsParameters -> SqsParameters -> Bool
$c== :: SqsParameters -> SqsParameters -> Bool
Prelude.Eq, ReadPrec [SqsParameters]
ReadPrec SqsParameters
Int -> ReadS SqsParameters
ReadS [SqsParameters]
(Int -> ReadS SqsParameters)
-> ReadS [SqsParameters]
-> ReadPrec SqsParameters
-> ReadPrec [SqsParameters]
-> Read SqsParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SqsParameters]
$creadListPrec :: ReadPrec [SqsParameters]
readPrec :: ReadPrec SqsParameters
$creadPrec :: ReadPrec SqsParameters
readList :: ReadS [SqsParameters]
$creadList :: ReadS [SqsParameters]
readsPrec :: Int -> ReadS SqsParameters
$creadsPrec :: Int -> ReadS SqsParameters
Prelude.Read, Int -> SqsParameters -> ShowS
[SqsParameters] -> ShowS
SqsParameters -> String
(Int -> SqsParameters -> ShowS)
-> (SqsParameters -> String)
-> ([SqsParameters] -> ShowS)
-> Show SqsParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqsParameters] -> ShowS
$cshowList :: [SqsParameters] -> ShowS
show :: SqsParameters -> String
$cshow :: SqsParameters -> String
showsPrec :: Int -> SqsParameters -> ShowS
$cshowsPrec :: Int -> SqsParameters -> ShowS
Prelude.Show, (forall x. SqsParameters -> Rep SqsParameters x)
-> (forall x. Rep SqsParameters x -> SqsParameters)
-> Generic SqsParameters
forall x. Rep SqsParameters x -> SqsParameters
forall x. SqsParameters -> Rep SqsParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SqsParameters x -> SqsParameters
$cfrom :: forall x. SqsParameters -> Rep SqsParameters x
Prelude.Generic)

-- |
-- Create a value of 'SqsParameters' 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:
--
-- 'messageGroupId', 'sqsParameters_messageGroupId' - The FIFO message group ID to use as the target.
newSqsParameters ::
  SqsParameters
newSqsParameters :: SqsParameters
newSqsParameters =
  SqsParameters' :: Maybe Text -> SqsParameters
SqsParameters' {$sel:messageGroupId:SqsParameters' :: Maybe Text
messageGroupId = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The FIFO message group ID to use as the target.
sqsParameters_messageGroupId :: Lens.Lens' SqsParameters (Prelude.Maybe Prelude.Text)
sqsParameters_messageGroupId :: (Maybe Text -> f (Maybe Text)) -> SqsParameters -> f SqsParameters
sqsParameters_messageGroupId = (SqsParameters -> Maybe Text)
-> (SqsParameters -> Maybe Text -> SqsParameters)
-> Lens SqsParameters SqsParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SqsParameters' {Maybe Text
messageGroupId :: Maybe Text
$sel:messageGroupId:SqsParameters' :: SqsParameters -> Maybe Text
messageGroupId} -> Maybe Text
messageGroupId) (\s :: SqsParameters
s@SqsParameters' {} Maybe Text
a -> SqsParameters
s {$sel:messageGroupId:SqsParameters' :: Maybe Text
messageGroupId = Maybe Text
a} :: SqsParameters)

instance Core.FromJSON SqsParameters where
  parseJSON :: Value -> Parser SqsParameters
parseJSON =
    String
-> (Object -> Parser SqsParameters)
-> Value
-> Parser SqsParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SqsParameters"
      ( \Object
x ->
          Maybe Text -> SqsParameters
SqsParameters'
            (Maybe Text -> SqsParameters)
-> Parser (Maybe Text) -> Parser SqsParameters
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MessageGroupId")
      )

instance Prelude.Hashable SqsParameters

instance Prelude.NFData SqsParameters

instance Core.ToJSON SqsParameters where
  toJSON :: SqsParameters -> Value
toJSON SqsParameters' {Maybe Text
messageGroupId :: Maybe Text
$sel:messageGroupId:SqsParameters' :: SqsParameters -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MessageGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
messageGroupId
          ]
      )