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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 value associated with the key.
    ConnectionBodyParameter -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The key for the parameter.
    ConnectionBodyParameter -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (ConnectionBodyParameter -> ConnectionBodyParameter -> Bool
(ConnectionBodyParameter -> ConnectionBodyParameter -> Bool)
-> (ConnectionBodyParameter -> ConnectionBodyParameter -> Bool)
-> Eq ConnectionBodyParameter
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]
(Int -> ReadS ConnectionBodyParameter)
-> ReadS [ConnectionBodyParameter]
-> ReadPrec ConnectionBodyParameter
-> ReadPrec [ConnectionBodyParameter]
-> Read 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
(Int -> ConnectionBodyParameter -> ShowS)
-> (ConnectionBodyParameter -> String)
-> ([ConnectionBodyParameter] -> ShowS)
-> Show ConnectionBodyParameter
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.
 ConnectionBodyParameter -> Rep ConnectionBodyParameter x)
-> (forall x.
    Rep ConnectionBodyParameter x -> ConnectionBodyParameter)
-> Generic ConnectionBodyParameter
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.
--
-- 'value', 'connectionBodyParameter_value' - The value associated with the key.
--
-- 'key', 'connectionBodyParameter_key' - The key for the parameter.
newConnectionBodyParameter ::
  ConnectionBodyParameter
newConnectionBodyParameter :: ConnectionBodyParameter
newConnectionBodyParameter =
  ConnectionBodyParameter' :: Maybe Bool -> Maybe Text -> Maybe Text -> ConnectionBodyParameter
ConnectionBodyParameter'
    { $sel:isValueSecret:ConnectionBodyParameter' :: Maybe Bool
isValueSecret =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:value:ConnectionBodyParameter' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:ConnectionBodyParameter' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Specified whether the value is secret.
connectionBodyParameter_isValueSecret :: Lens.Lens' ConnectionBodyParameter (Prelude.Maybe Prelude.Bool)
connectionBodyParameter_isValueSecret :: (Maybe Bool -> f (Maybe Bool))
-> ConnectionBodyParameter -> f ConnectionBodyParameter
connectionBodyParameter_isValueSecret = (ConnectionBodyParameter -> Maybe Bool)
-> (ConnectionBodyParameter
    -> Maybe Bool -> ConnectionBodyParameter)
-> Lens
     ConnectionBodyParameter
     ConnectionBodyParameter
     (Maybe Bool)
     (Maybe Bool)
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 value associated with the key.
connectionBodyParameter_value :: Lens.Lens' ConnectionBodyParameter (Prelude.Maybe Prelude.Text)
connectionBodyParameter_value :: (Maybe Text -> f (Maybe Text))
-> ConnectionBodyParameter -> f ConnectionBodyParameter
connectionBodyParameter_value = (ConnectionBodyParameter -> Maybe Text)
-> (ConnectionBodyParameter
    -> Maybe Text -> ConnectionBodyParameter)
-> Lens
     ConnectionBodyParameter
     ConnectionBodyParameter
     (Maybe Text)
     (Maybe Text)
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)

-- | The key for the parameter.
connectionBodyParameter_key :: Lens.Lens' ConnectionBodyParameter (Prelude.Maybe Prelude.Text)
connectionBodyParameter_key :: (Maybe Text -> f (Maybe Text))
-> ConnectionBodyParameter -> f ConnectionBodyParameter
connectionBodyParameter_key = (ConnectionBodyParameter -> Maybe Text)
-> (ConnectionBodyParameter
    -> Maybe Text -> ConnectionBodyParameter)
-> Lens
     ConnectionBodyParameter
     ConnectionBodyParameter
     (Maybe Text)
     (Maybe Text)
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)

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

instance Prelude.Hashable ConnectionBodyParameter

instance Prelude.NFData ConnectionBodyParameter

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