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

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

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

-- |
-- Create a value of 'ConnectionHeaderParameter' 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', 'connectionHeaderParameter_isValueSecret' - Specified whether the value is a secret.
--
-- 'value', 'connectionHeaderParameter_value' - The value associated with the key.
--
-- 'key', 'connectionHeaderParameter_key' - The key for the parameter.
newConnectionHeaderParameter ::
  ConnectionHeaderParameter
newConnectionHeaderParameter :: ConnectionHeaderParameter
newConnectionHeaderParameter =
  ConnectionHeaderParameter' :: Maybe Bool -> Maybe Text -> Maybe Text -> ConnectionHeaderParameter
ConnectionHeaderParameter'
    { $sel:isValueSecret:ConnectionHeaderParameter' :: Maybe Bool
isValueSecret =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:value:ConnectionHeaderParameter' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:ConnectionHeaderParameter' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Core.FromJSON ConnectionHeaderParameter where
  parseJSON :: Value -> Parser ConnectionHeaderParameter
parseJSON =
    String
-> (Object -> Parser ConnectionHeaderParameter)
-> Value
-> Parser ConnectionHeaderParameter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConnectionHeaderParameter"
      ( \Object
x ->
          Maybe Bool -> Maybe Text -> Maybe Text -> ConnectionHeaderParameter
ConnectionHeaderParameter'
            (Maybe Bool
 -> Maybe Text -> Maybe Text -> ConnectionHeaderParameter)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> Maybe Text -> ConnectionHeaderParameter)
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 -> ConnectionHeaderParameter)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> ConnectionHeaderParameter)
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 -> ConnectionHeaderParameter)
-> Parser (Maybe Text) -> Parser ConnectionHeaderParameter
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 ConnectionHeaderParameter

instance Prelude.NFData ConnectionHeaderParameter

instance Core.ToJSON ConnectionHeaderParameter where
  toJSON :: ConnectionHeaderParameter -> Value
toJSON ConnectionHeaderParameter' {Maybe Bool
Maybe Text
key :: Maybe Text
value :: Maybe Text
isValueSecret :: Maybe Bool
$sel:key:ConnectionHeaderParameter' :: ConnectionHeaderParameter -> Maybe Text
$sel:value:ConnectionHeaderParameter' :: ConnectionHeaderParameter -> Maybe Text
$sel:isValueSecret:ConnectionHeaderParameter' :: ConnectionHeaderParameter -> 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
          ]
      )