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

import Amazonka.CloudWatchEvents.Types.ConnectionBodyParameter
import Amazonka.CloudWatchEvents.Types.ConnectionHeaderParameter
import Amazonka.CloudWatchEvents.Types.ConnectionQueryStringParameter
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains additional parameters for the connection.
--
-- /See:/ 'newConnectionHttpParameters' smart constructor.
data ConnectionHttpParameters = ConnectionHttpParameters'
  { -- | Contains additional query string parameters for the connection.
    ConnectionHttpParameters -> Maybe [ConnectionQueryStringParameter]
queryStringParameters :: Prelude.Maybe [ConnectionQueryStringParameter],
    -- | Contains additional header parameters for the connection.
    ConnectionHttpParameters -> Maybe [ConnectionHeaderParameter]
headerParameters :: Prelude.Maybe [ConnectionHeaderParameter],
    -- | Contains additional body string parameters for the connection.
    ConnectionHttpParameters -> Maybe [ConnectionBodyParameter]
bodyParameters :: Prelude.Maybe [ConnectionBodyParameter]
  }
  deriving (ConnectionHttpParameters -> ConnectionHttpParameters -> Bool
(ConnectionHttpParameters -> ConnectionHttpParameters -> Bool)
-> (ConnectionHttpParameters -> ConnectionHttpParameters -> Bool)
-> Eq ConnectionHttpParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectionHttpParameters -> ConnectionHttpParameters -> Bool
$c/= :: ConnectionHttpParameters -> ConnectionHttpParameters -> Bool
== :: ConnectionHttpParameters -> ConnectionHttpParameters -> Bool
$c== :: ConnectionHttpParameters -> ConnectionHttpParameters -> Bool
Prelude.Eq, ReadPrec [ConnectionHttpParameters]
ReadPrec ConnectionHttpParameters
Int -> ReadS ConnectionHttpParameters
ReadS [ConnectionHttpParameters]
(Int -> ReadS ConnectionHttpParameters)
-> ReadS [ConnectionHttpParameters]
-> ReadPrec ConnectionHttpParameters
-> ReadPrec [ConnectionHttpParameters]
-> Read ConnectionHttpParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectionHttpParameters]
$creadListPrec :: ReadPrec [ConnectionHttpParameters]
readPrec :: ReadPrec ConnectionHttpParameters
$creadPrec :: ReadPrec ConnectionHttpParameters
readList :: ReadS [ConnectionHttpParameters]
$creadList :: ReadS [ConnectionHttpParameters]
readsPrec :: Int -> ReadS ConnectionHttpParameters
$creadsPrec :: Int -> ReadS ConnectionHttpParameters
Prelude.Read, Int -> ConnectionHttpParameters -> ShowS
[ConnectionHttpParameters] -> ShowS
ConnectionHttpParameters -> String
(Int -> ConnectionHttpParameters -> ShowS)
-> (ConnectionHttpParameters -> String)
-> ([ConnectionHttpParameters] -> ShowS)
-> Show ConnectionHttpParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectionHttpParameters] -> ShowS
$cshowList :: [ConnectionHttpParameters] -> ShowS
show :: ConnectionHttpParameters -> String
$cshow :: ConnectionHttpParameters -> String
showsPrec :: Int -> ConnectionHttpParameters -> ShowS
$cshowsPrec :: Int -> ConnectionHttpParameters -> ShowS
Prelude.Show, (forall x.
 ConnectionHttpParameters -> Rep ConnectionHttpParameters x)
-> (forall x.
    Rep ConnectionHttpParameters x -> ConnectionHttpParameters)
-> Generic ConnectionHttpParameters
forall x.
Rep ConnectionHttpParameters x -> ConnectionHttpParameters
forall x.
ConnectionHttpParameters -> Rep ConnectionHttpParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConnectionHttpParameters x -> ConnectionHttpParameters
$cfrom :: forall x.
ConnectionHttpParameters -> Rep ConnectionHttpParameters x
Prelude.Generic)

-- |
-- Create a value of 'ConnectionHttpParameters' 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:
--
-- 'queryStringParameters', 'connectionHttpParameters_queryStringParameters' - Contains additional query string parameters for the connection.
--
-- 'headerParameters', 'connectionHttpParameters_headerParameters' - Contains additional header parameters for the connection.
--
-- 'bodyParameters', 'connectionHttpParameters_bodyParameters' - Contains additional body string parameters for the connection.
newConnectionHttpParameters ::
  ConnectionHttpParameters
newConnectionHttpParameters :: ConnectionHttpParameters
newConnectionHttpParameters =
  ConnectionHttpParameters' :: Maybe [ConnectionQueryStringParameter]
-> Maybe [ConnectionHeaderParameter]
-> Maybe [ConnectionBodyParameter]
-> ConnectionHttpParameters
ConnectionHttpParameters'
    { $sel:queryStringParameters:ConnectionHttpParameters' :: Maybe [ConnectionQueryStringParameter]
queryStringParameters =
        Maybe [ConnectionQueryStringParameter]
forall a. Maybe a
Prelude.Nothing,
      $sel:headerParameters:ConnectionHttpParameters' :: Maybe [ConnectionHeaderParameter]
headerParameters = Maybe [ConnectionHeaderParameter]
forall a. Maybe a
Prelude.Nothing,
      $sel:bodyParameters:ConnectionHttpParameters' :: Maybe [ConnectionBodyParameter]
bodyParameters = Maybe [ConnectionBodyParameter]
forall a. Maybe a
Prelude.Nothing
    }

-- | Contains additional query string parameters for the connection.
connectionHttpParameters_queryStringParameters :: Lens.Lens' ConnectionHttpParameters (Prelude.Maybe [ConnectionQueryStringParameter])
connectionHttpParameters_queryStringParameters :: (Maybe [ConnectionQueryStringParameter]
 -> f (Maybe [ConnectionQueryStringParameter]))
-> ConnectionHttpParameters -> f ConnectionHttpParameters
connectionHttpParameters_queryStringParameters = (ConnectionHttpParameters
 -> Maybe [ConnectionQueryStringParameter])
-> (ConnectionHttpParameters
    -> Maybe [ConnectionQueryStringParameter]
    -> ConnectionHttpParameters)
-> Lens
     ConnectionHttpParameters
     ConnectionHttpParameters
     (Maybe [ConnectionQueryStringParameter])
     (Maybe [ConnectionQueryStringParameter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionHttpParameters' {Maybe [ConnectionQueryStringParameter]
queryStringParameters :: Maybe [ConnectionQueryStringParameter]
$sel:queryStringParameters:ConnectionHttpParameters' :: ConnectionHttpParameters -> Maybe [ConnectionQueryStringParameter]
queryStringParameters} -> Maybe [ConnectionQueryStringParameter]
queryStringParameters) (\s :: ConnectionHttpParameters
s@ConnectionHttpParameters' {} Maybe [ConnectionQueryStringParameter]
a -> ConnectionHttpParameters
s {$sel:queryStringParameters:ConnectionHttpParameters' :: Maybe [ConnectionQueryStringParameter]
queryStringParameters = Maybe [ConnectionQueryStringParameter]
a} :: ConnectionHttpParameters) ((Maybe [ConnectionQueryStringParameter]
  -> f (Maybe [ConnectionQueryStringParameter]))
 -> ConnectionHttpParameters -> f ConnectionHttpParameters)
-> ((Maybe [ConnectionQueryStringParameter]
     -> f (Maybe [ConnectionQueryStringParameter]))
    -> Maybe [ConnectionQueryStringParameter]
    -> f (Maybe [ConnectionQueryStringParameter]))
-> (Maybe [ConnectionQueryStringParameter]
    -> f (Maybe [ConnectionQueryStringParameter]))
-> ConnectionHttpParameters
-> f ConnectionHttpParameters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ConnectionQueryStringParameter]
  [ConnectionQueryStringParameter]
  [ConnectionQueryStringParameter]
  [ConnectionQueryStringParameter]
-> Iso
     (Maybe [ConnectionQueryStringParameter])
     (Maybe [ConnectionQueryStringParameter])
     (Maybe [ConnectionQueryStringParameter])
     (Maybe [ConnectionQueryStringParameter])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ConnectionQueryStringParameter]
  [ConnectionQueryStringParameter]
  [ConnectionQueryStringParameter]
  [ConnectionQueryStringParameter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Contains additional header parameters for the connection.
connectionHttpParameters_headerParameters :: Lens.Lens' ConnectionHttpParameters (Prelude.Maybe [ConnectionHeaderParameter])
connectionHttpParameters_headerParameters :: (Maybe [ConnectionHeaderParameter]
 -> f (Maybe [ConnectionHeaderParameter]))
-> ConnectionHttpParameters -> f ConnectionHttpParameters
connectionHttpParameters_headerParameters = (ConnectionHttpParameters -> Maybe [ConnectionHeaderParameter])
-> (ConnectionHttpParameters
    -> Maybe [ConnectionHeaderParameter] -> ConnectionHttpParameters)
-> Lens
     ConnectionHttpParameters
     ConnectionHttpParameters
     (Maybe [ConnectionHeaderParameter])
     (Maybe [ConnectionHeaderParameter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionHttpParameters' {Maybe [ConnectionHeaderParameter]
headerParameters :: Maybe [ConnectionHeaderParameter]
$sel:headerParameters:ConnectionHttpParameters' :: ConnectionHttpParameters -> Maybe [ConnectionHeaderParameter]
headerParameters} -> Maybe [ConnectionHeaderParameter]
headerParameters) (\s :: ConnectionHttpParameters
s@ConnectionHttpParameters' {} Maybe [ConnectionHeaderParameter]
a -> ConnectionHttpParameters
s {$sel:headerParameters:ConnectionHttpParameters' :: Maybe [ConnectionHeaderParameter]
headerParameters = Maybe [ConnectionHeaderParameter]
a} :: ConnectionHttpParameters) ((Maybe [ConnectionHeaderParameter]
  -> f (Maybe [ConnectionHeaderParameter]))
 -> ConnectionHttpParameters -> f ConnectionHttpParameters)
-> ((Maybe [ConnectionHeaderParameter]
     -> f (Maybe [ConnectionHeaderParameter]))
    -> Maybe [ConnectionHeaderParameter]
    -> f (Maybe [ConnectionHeaderParameter]))
-> (Maybe [ConnectionHeaderParameter]
    -> f (Maybe [ConnectionHeaderParameter]))
-> ConnectionHttpParameters
-> f ConnectionHttpParameters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ConnectionHeaderParameter]
  [ConnectionHeaderParameter]
  [ConnectionHeaderParameter]
  [ConnectionHeaderParameter]
-> Iso
     (Maybe [ConnectionHeaderParameter])
     (Maybe [ConnectionHeaderParameter])
     (Maybe [ConnectionHeaderParameter])
     (Maybe [ConnectionHeaderParameter])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ConnectionHeaderParameter]
  [ConnectionHeaderParameter]
  [ConnectionHeaderParameter]
  [ConnectionHeaderParameter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Contains additional body string parameters for the connection.
connectionHttpParameters_bodyParameters :: Lens.Lens' ConnectionHttpParameters (Prelude.Maybe [ConnectionBodyParameter])
connectionHttpParameters_bodyParameters :: (Maybe [ConnectionBodyParameter]
 -> f (Maybe [ConnectionBodyParameter]))
-> ConnectionHttpParameters -> f ConnectionHttpParameters
connectionHttpParameters_bodyParameters = (ConnectionHttpParameters -> Maybe [ConnectionBodyParameter])
-> (ConnectionHttpParameters
    -> Maybe [ConnectionBodyParameter] -> ConnectionHttpParameters)
-> Lens
     ConnectionHttpParameters
     ConnectionHttpParameters
     (Maybe [ConnectionBodyParameter])
     (Maybe [ConnectionBodyParameter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionHttpParameters' {Maybe [ConnectionBodyParameter]
bodyParameters :: Maybe [ConnectionBodyParameter]
$sel:bodyParameters:ConnectionHttpParameters' :: ConnectionHttpParameters -> Maybe [ConnectionBodyParameter]
bodyParameters} -> Maybe [ConnectionBodyParameter]
bodyParameters) (\s :: ConnectionHttpParameters
s@ConnectionHttpParameters' {} Maybe [ConnectionBodyParameter]
a -> ConnectionHttpParameters
s {$sel:bodyParameters:ConnectionHttpParameters' :: Maybe [ConnectionBodyParameter]
bodyParameters = Maybe [ConnectionBodyParameter]
a} :: ConnectionHttpParameters) ((Maybe [ConnectionBodyParameter]
  -> f (Maybe [ConnectionBodyParameter]))
 -> ConnectionHttpParameters -> f ConnectionHttpParameters)
-> ((Maybe [ConnectionBodyParameter]
     -> f (Maybe [ConnectionBodyParameter]))
    -> Maybe [ConnectionBodyParameter]
    -> f (Maybe [ConnectionBodyParameter]))
-> (Maybe [ConnectionBodyParameter]
    -> f (Maybe [ConnectionBodyParameter]))
-> ConnectionHttpParameters
-> f ConnectionHttpParameters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ConnectionBodyParameter]
  [ConnectionBodyParameter]
  [ConnectionBodyParameter]
  [ConnectionBodyParameter]
-> Iso
     (Maybe [ConnectionBodyParameter])
     (Maybe [ConnectionBodyParameter])
     (Maybe [ConnectionBodyParameter])
     (Maybe [ConnectionBodyParameter])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ConnectionBodyParameter]
  [ConnectionBodyParameter]
  [ConnectionBodyParameter]
  [ConnectionBodyParameter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ConnectionHttpParameters where
  parseJSON :: Value -> Parser ConnectionHttpParameters
parseJSON =
    String
-> (Object -> Parser ConnectionHttpParameters)
-> Value
-> Parser ConnectionHttpParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConnectionHttpParameters"
      ( \Object
x ->
          Maybe [ConnectionQueryStringParameter]
-> Maybe [ConnectionHeaderParameter]
-> Maybe [ConnectionBodyParameter]
-> ConnectionHttpParameters
ConnectionHttpParameters'
            (Maybe [ConnectionQueryStringParameter]
 -> Maybe [ConnectionHeaderParameter]
 -> Maybe [ConnectionBodyParameter]
 -> ConnectionHttpParameters)
-> Parser (Maybe [ConnectionQueryStringParameter])
-> Parser
     (Maybe [ConnectionHeaderParameter]
      -> Maybe [ConnectionBodyParameter] -> ConnectionHttpParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [ConnectionQueryStringParameter]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"QueryStringParameters"
                            Parser (Maybe (Maybe [ConnectionQueryStringParameter]))
-> Maybe [ConnectionQueryStringParameter]
-> Parser (Maybe [ConnectionQueryStringParameter])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ConnectionQueryStringParameter]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [ConnectionHeaderParameter]
   -> Maybe [ConnectionBodyParameter] -> ConnectionHttpParameters)
-> Parser (Maybe [ConnectionHeaderParameter])
-> Parser
     (Maybe [ConnectionBodyParameter] -> ConnectionHttpParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [ConnectionHeaderParameter]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"HeaderParameters"
                            Parser (Maybe (Maybe [ConnectionHeaderParameter]))
-> Maybe [ConnectionHeaderParameter]
-> Parser (Maybe [ConnectionHeaderParameter])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ConnectionHeaderParameter]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [ConnectionBodyParameter] -> ConnectionHttpParameters)
-> Parser (Maybe [ConnectionBodyParameter])
-> Parser ConnectionHttpParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ConnectionBodyParameter]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BodyParameters"
                            Parser (Maybe (Maybe [ConnectionBodyParameter]))
-> Maybe [ConnectionBodyParameter]
-> Parser (Maybe [ConnectionBodyParameter])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ConnectionBodyParameter]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ConnectionHttpParameters

instance Prelude.NFData ConnectionHttpParameters

instance Core.ToJSON ConnectionHttpParameters where
  toJSON :: ConnectionHttpParameters -> Value
toJSON ConnectionHttpParameters' {Maybe [ConnectionBodyParameter]
Maybe [ConnectionHeaderParameter]
Maybe [ConnectionQueryStringParameter]
bodyParameters :: Maybe [ConnectionBodyParameter]
headerParameters :: Maybe [ConnectionHeaderParameter]
queryStringParameters :: Maybe [ConnectionQueryStringParameter]
$sel:bodyParameters:ConnectionHttpParameters' :: ConnectionHttpParameters -> Maybe [ConnectionBodyParameter]
$sel:headerParameters:ConnectionHttpParameters' :: ConnectionHttpParameters -> Maybe [ConnectionHeaderParameter]
$sel:queryStringParameters:ConnectionHttpParameters' :: ConnectionHttpParameters -> Maybe [ConnectionQueryStringParameter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"QueryStringParameters" Text -> [ConnectionQueryStringParameter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ConnectionQueryStringParameter] -> Pair)
-> Maybe [ConnectionQueryStringParameter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ConnectionQueryStringParameter]
queryStringParameters,
            (Text
"HeaderParameters" Text -> [ConnectionHeaderParameter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ConnectionHeaderParameter] -> Pair)
-> Maybe [ConnectionHeaderParameter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ConnectionHeaderParameter]
headerParameters,
            (Text
"BodyParameters" Text -> [ConnectionBodyParameter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ConnectionBodyParameter] -> Pair)
-> Maybe [ConnectionBodyParameter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ConnectionBodyParameter]
bodyParameters
          ]
      )