{-# 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.ConnectionBodyParameter
-- 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.CloudWatchEvents.Types.ConnectionBodyParameter 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

-- | Additional parameter included in the body. You can include up to 100
-- additional body parameters per request. An event payload cannot exceed
-- 64 KB.
--
-- /See:/ 'newConnectionBodyParameter' smart constructor.
data ConnectionBodyParameter = ConnectionBodyParameter'
  { -- | Specified whether the value is secret.
    ConnectionBodyParameter -> Maybe Bool
isValueSecret :: Prelude.Maybe Prelude.Bool,
    -- | The key for the parameter.
    ConnectionBodyParameter -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | The value associated with the key.
    ConnectionBodyParameter -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (ConnectionBodyParameter -> ConnectionBodyParameter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectionBodyParameter -> ConnectionBodyParameter -> Bool
$c/= :: ConnectionBodyParameter -> ConnectionBodyParameter -> Bool
== :: ConnectionBodyParameter -> ConnectionBodyParameter -> Bool
$c== :: ConnectionBodyParameter -> ConnectionBodyParameter -> Bool
Prelude.Eq, ReadPrec [ConnectionBodyParameter]
ReadPrec ConnectionBodyParameter
Int -> ReadS ConnectionBodyParameter
ReadS [ConnectionBodyParameter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectionBodyParameter]
$creadListPrec :: ReadPrec [ConnectionBodyParameter]
readPrec :: ReadPrec ConnectionBodyParameter
$creadPrec :: ReadPrec ConnectionBodyParameter
readList :: ReadS [ConnectionBodyParameter]
$creadList :: ReadS [ConnectionBodyParameter]
readsPrec :: Int -> ReadS ConnectionBodyParameter
$creadsPrec :: Int -> ReadS ConnectionBodyParameter
Prelude.Read, Int -> ConnectionBodyParameter -> ShowS
[ConnectionBodyParameter] -> ShowS
ConnectionBodyParameter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectionBodyParameter] -> ShowS
$cshowList :: [ConnectionBodyParameter] -> ShowS
show :: ConnectionBodyParameter -> String
$cshow :: ConnectionBodyParameter -> String
showsPrec :: Int -> ConnectionBodyParameter -> ShowS
$cshowsPrec :: Int -> ConnectionBodyParameter -> ShowS
Prelude.Show, forall x. Rep ConnectionBodyParameter x -> ConnectionBodyParameter
forall x. ConnectionBodyParameter -> Rep ConnectionBodyParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectionBodyParameter x -> ConnectionBodyParameter
$cfrom :: forall x. ConnectionBodyParameter -> Rep ConnectionBodyParameter x
Prelude.Generic)

-- |
-- Create a value of 'ConnectionBodyParameter' 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:
--
-- 'isValueSecret', 'connectionBodyParameter_isValueSecret' - Specified whether the value is secret.
--
-- 'key', 'connectionBodyParameter_key' - The key for the parameter.
--
-- 'value', 'connectionBodyParameter_value' - The value associated with the key.
newConnectionBodyParameter ::
  ConnectionBodyParameter
newConnectionBodyParameter :: ConnectionBodyParameter
newConnectionBodyParameter =
  ConnectionBodyParameter'
    { $sel:isValueSecret:ConnectionBodyParameter' :: Maybe Bool
isValueSecret =
        forall a. Maybe a
Prelude.Nothing,
      $sel:key:ConnectionBodyParameter' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ConnectionBodyParameter' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | Specified whether the value is secret.
connectionBodyParameter_isValueSecret :: Lens.Lens' ConnectionBodyParameter (Prelude.Maybe Prelude.Bool)
connectionBodyParameter_isValueSecret :: Lens' ConnectionBodyParameter (Maybe Bool)
connectionBodyParameter_isValueSecret = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionBodyParameter' {Maybe Bool
isValueSecret :: Maybe Bool
$sel:isValueSecret:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Bool
isValueSecret} -> Maybe Bool
isValueSecret) (\s :: ConnectionBodyParameter
s@ConnectionBodyParameter' {} Maybe Bool
a -> ConnectionBodyParameter
s {$sel:isValueSecret:ConnectionBodyParameter' :: Maybe Bool
isValueSecret = Maybe Bool
a} :: ConnectionBodyParameter)

-- | The key for the parameter.
connectionBodyParameter_key :: Lens.Lens' ConnectionBodyParameter (Prelude.Maybe Prelude.Text)
connectionBodyParameter_key :: Lens' ConnectionBodyParameter (Maybe Text)
connectionBodyParameter_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionBodyParameter' {Maybe Text
key :: Maybe Text
$sel:key:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Text
key} -> Maybe Text
key) (\s :: ConnectionBodyParameter
s@ConnectionBodyParameter' {} Maybe Text
a -> ConnectionBodyParameter
s {$sel:key:ConnectionBodyParameter' :: Maybe Text
key = Maybe Text
a} :: ConnectionBodyParameter)

-- | The value associated with the key.
connectionBodyParameter_value :: Lens.Lens' ConnectionBodyParameter (Prelude.Maybe Prelude.Text)
connectionBodyParameter_value :: Lens' ConnectionBodyParameter (Maybe Text)
connectionBodyParameter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionBodyParameter' {Maybe Text
value :: Maybe Text
$sel:value:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Text
value} -> Maybe Text
value) (\s :: ConnectionBodyParameter
s@ConnectionBodyParameter' {} Maybe Text
a -> ConnectionBodyParameter
s {$sel:value:ConnectionBodyParameter' :: Maybe Text
value = Maybe Text
a} :: ConnectionBodyParameter)

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

instance Prelude.Hashable ConnectionBodyParameter where
  hashWithSalt :: Int -> ConnectionBodyParameter -> Int
hashWithSalt Int
_salt ConnectionBodyParameter' {Maybe Bool
Maybe Text
value :: Maybe Text
key :: Maybe Text
isValueSecret :: Maybe Bool
$sel:value:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Text
$sel:key:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Text
$sel:isValueSecret:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isValueSecret
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData ConnectionBodyParameter where
  rnf :: ConnectionBodyParameter -> ()
rnf ConnectionBodyParameter' {Maybe Bool
Maybe Text
value :: Maybe Text
key :: Maybe Text
isValueSecret :: Maybe Bool
$sel:value:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Text
$sel:key:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Text
$sel:isValueSecret:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isValueSecret
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON ConnectionBodyParameter where
  toJSON :: ConnectionBodyParameter -> Value
toJSON ConnectionBodyParameter' {Maybe Bool
Maybe Text
value :: Maybe Text
key :: Maybe Text
isValueSecret :: Maybe Bool
$sel:value:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Text
$sel:key:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Text
$sel:isValueSecret:ConnectionBodyParameter' :: ConnectionBodyParameter -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"IsValueSecret" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
isValueSecret,
            (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key,
            (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
value
          ]
      )