{-# 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.Firehose.Types.HttpEndpointRequestConfiguration
-- 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.Firehose.Types.HttpEndpointRequestConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.ContentEncoding
import Amazonka.Firehose.Types.HttpEndpointCommonAttribute
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration of the HTTP endpoint request.
--
-- /See:/ 'newHttpEndpointRequestConfiguration' smart constructor.
data HttpEndpointRequestConfiguration = HttpEndpointRequestConfiguration'
  { -- | Describes the metadata sent to the HTTP endpoint destination.
    HttpEndpointRequestConfiguration
-> Maybe [HttpEndpointCommonAttribute]
commonAttributes :: Prelude.Maybe [HttpEndpointCommonAttribute],
    -- | Kinesis Data Firehose uses the content encoding to compress the body of
    -- a request before sending the request to the destination. For more
    -- information, see
    -- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding Content-Encoding>
    -- in MDN Web Docs, the official Mozilla documentation.
    HttpEndpointRequestConfiguration -> Maybe ContentEncoding
contentEncoding :: Prelude.Maybe ContentEncoding
  }
  deriving (HttpEndpointRequestConfiguration
-> HttpEndpointRequestConfiguration -> Bool
(HttpEndpointRequestConfiguration
 -> HttpEndpointRequestConfiguration -> Bool)
-> (HttpEndpointRequestConfiguration
    -> HttpEndpointRequestConfiguration -> Bool)
-> Eq HttpEndpointRequestConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpEndpointRequestConfiguration
-> HttpEndpointRequestConfiguration -> Bool
$c/= :: HttpEndpointRequestConfiguration
-> HttpEndpointRequestConfiguration -> Bool
== :: HttpEndpointRequestConfiguration
-> HttpEndpointRequestConfiguration -> Bool
$c== :: HttpEndpointRequestConfiguration
-> HttpEndpointRequestConfiguration -> Bool
Prelude.Eq, Int -> HttpEndpointRequestConfiguration -> ShowS
[HttpEndpointRequestConfiguration] -> ShowS
HttpEndpointRequestConfiguration -> String
(Int -> HttpEndpointRequestConfiguration -> ShowS)
-> (HttpEndpointRequestConfiguration -> String)
-> ([HttpEndpointRequestConfiguration] -> ShowS)
-> Show HttpEndpointRequestConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpEndpointRequestConfiguration] -> ShowS
$cshowList :: [HttpEndpointRequestConfiguration] -> ShowS
show :: HttpEndpointRequestConfiguration -> String
$cshow :: HttpEndpointRequestConfiguration -> String
showsPrec :: Int -> HttpEndpointRequestConfiguration -> ShowS
$cshowsPrec :: Int -> HttpEndpointRequestConfiguration -> ShowS
Prelude.Show, (forall x.
 HttpEndpointRequestConfiguration
 -> Rep HttpEndpointRequestConfiguration x)
-> (forall x.
    Rep HttpEndpointRequestConfiguration x
    -> HttpEndpointRequestConfiguration)
-> Generic HttpEndpointRequestConfiguration
forall x.
Rep HttpEndpointRequestConfiguration x
-> HttpEndpointRequestConfiguration
forall x.
HttpEndpointRequestConfiguration
-> Rep HttpEndpointRequestConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HttpEndpointRequestConfiguration x
-> HttpEndpointRequestConfiguration
$cfrom :: forall x.
HttpEndpointRequestConfiguration
-> Rep HttpEndpointRequestConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'HttpEndpointRequestConfiguration' 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:
--
-- 'commonAttributes', 'httpEndpointRequestConfiguration_commonAttributes' - Describes the metadata sent to the HTTP endpoint destination.
--
-- 'contentEncoding', 'httpEndpointRequestConfiguration_contentEncoding' - Kinesis Data Firehose uses the content encoding to compress the body of
-- a request before sending the request to the destination. For more
-- information, see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding Content-Encoding>
-- in MDN Web Docs, the official Mozilla documentation.
newHttpEndpointRequestConfiguration ::
  HttpEndpointRequestConfiguration
newHttpEndpointRequestConfiguration :: HttpEndpointRequestConfiguration
newHttpEndpointRequestConfiguration =
  HttpEndpointRequestConfiguration' :: Maybe [HttpEndpointCommonAttribute]
-> Maybe ContentEncoding -> HttpEndpointRequestConfiguration
HttpEndpointRequestConfiguration'
    { $sel:commonAttributes:HttpEndpointRequestConfiguration' :: Maybe [HttpEndpointCommonAttribute]
commonAttributes =
        Maybe [HttpEndpointCommonAttribute]
forall a. Maybe a
Prelude.Nothing,
      $sel:contentEncoding:HttpEndpointRequestConfiguration' :: Maybe ContentEncoding
contentEncoding = Maybe ContentEncoding
forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the metadata sent to the HTTP endpoint destination.
httpEndpointRequestConfiguration_commonAttributes :: Lens.Lens' HttpEndpointRequestConfiguration (Prelude.Maybe [HttpEndpointCommonAttribute])
httpEndpointRequestConfiguration_commonAttributes :: (Maybe [HttpEndpointCommonAttribute]
 -> f (Maybe [HttpEndpointCommonAttribute]))
-> HttpEndpointRequestConfiguration
-> f HttpEndpointRequestConfiguration
httpEndpointRequestConfiguration_commonAttributes = (HttpEndpointRequestConfiguration
 -> Maybe [HttpEndpointCommonAttribute])
-> (HttpEndpointRequestConfiguration
    -> Maybe [HttpEndpointCommonAttribute]
    -> HttpEndpointRequestConfiguration)
-> Lens
     HttpEndpointRequestConfiguration
     HttpEndpointRequestConfiguration
     (Maybe [HttpEndpointCommonAttribute])
     (Maybe [HttpEndpointCommonAttribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpEndpointRequestConfiguration' {Maybe [HttpEndpointCommonAttribute]
commonAttributes :: Maybe [HttpEndpointCommonAttribute]
$sel:commonAttributes:HttpEndpointRequestConfiguration' :: HttpEndpointRequestConfiguration
-> Maybe [HttpEndpointCommonAttribute]
commonAttributes} -> Maybe [HttpEndpointCommonAttribute]
commonAttributes) (\s :: HttpEndpointRequestConfiguration
s@HttpEndpointRequestConfiguration' {} Maybe [HttpEndpointCommonAttribute]
a -> HttpEndpointRequestConfiguration
s {$sel:commonAttributes:HttpEndpointRequestConfiguration' :: Maybe [HttpEndpointCommonAttribute]
commonAttributes = Maybe [HttpEndpointCommonAttribute]
a} :: HttpEndpointRequestConfiguration) ((Maybe [HttpEndpointCommonAttribute]
  -> f (Maybe [HttpEndpointCommonAttribute]))
 -> HttpEndpointRequestConfiguration
 -> f HttpEndpointRequestConfiguration)
-> ((Maybe [HttpEndpointCommonAttribute]
     -> f (Maybe [HttpEndpointCommonAttribute]))
    -> Maybe [HttpEndpointCommonAttribute]
    -> f (Maybe [HttpEndpointCommonAttribute]))
-> (Maybe [HttpEndpointCommonAttribute]
    -> f (Maybe [HttpEndpointCommonAttribute]))
-> HttpEndpointRequestConfiguration
-> f HttpEndpointRequestConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HttpEndpointCommonAttribute]
  [HttpEndpointCommonAttribute]
  [HttpEndpointCommonAttribute]
  [HttpEndpointCommonAttribute]
-> Iso
     (Maybe [HttpEndpointCommonAttribute])
     (Maybe [HttpEndpointCommonAttribute])
     (Maybe [HttpEndpointCommonAttribute])
     (Maybe [HttpEndpointCommonAttribute])
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
  [HttpEndpointCommonAttribute]
  [HttpEndpointCommonAttribute]
  [HttpEndpointCommonAttribute]
  [HttpEndpointCommonAttribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Kinesis Data Firehose uses the content encoding to compress the body of
-- a request before sending the request to the destination. For more
-- information, see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding Content-Encoding>
-- in MDN Web Docs, the official Mozilla documentation.
httpEndpointRequestConfiguration_contentEncoding :: Lens.Lens' HttpEndpointRequestConfiguration (Prelude.Maybe ContentEncoding)
httpEndpointRequestConfiguration_contentEncoding :: (Maybe ContentEncoding -> f (Maybe ContentEncoding))
-> HttpEndpointRequestConfiguration
-> f HttpEndpointRequestConfiguration
httpEndpointRequestConfiguration_contentEncoding = (HttpEndpointRequestConfiguration -> Maybe ContentEncoding)
-> (HttpEndpointRequestConfiguration
    -> Maybe ContentEncoding -> HttpEndpointRequestConfiguration)
-> Lens
     HttpEndpointRequestConfiguration
     HttpEndpointRequestConfiguration
     (Maybe ContentEncoding)
     (Maybe ContentEncoding)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpEndpointRequestConfiguration' {Maybe ContentEncoding
contentEncoding :: Maybe ContentEncoding
$sel:contentEncoding:HttpEndpointRequestConfiguration' :: HttpEndpointRequestConfiguration -> Maybe ContentEncoding
contentEncoding} -> Maybe ContentEncoding
contentEncoding) (\s :: HttpEndpointRequestConfiguration
s@HttpEndpointRequestConfiguration' {} Maybe ContentEncoding
a -> HttpEndpointRequestConfiguration
s {$sel:contentEncoding:HttpEndpointRequestConfiguration' :: Maybe ContentEncoding
contentEncoding = Maybe ContentEncoding
a} :: HttpEndpointRequestConfiguration)

instance
  Core.FromJSON
    HttpEndpointRequestConfiguration
  where
  parseJSON :: Value -> Parser HttpEndpointRequestConfiguration
parseJSON =
    String
-> (Object -> Parser HttpEndpointRequestConfiguration)
-> Value
-> Parser HttpEndpointRequestConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpEndpointRequestConfiguration"
      ( \Object
x ->
          Maybe [HttpEndpointCommonAttribute]
-> Maybe ContentEncoding -> HttpEndpointRequestConfiguration
HttpEndpointRequestConfiguration'
            (Maybe [HttpEndpointCommonAttribute]
 -> Maybe ContentEncoding -> HttpEndpointRequestConfiguration)
-> Parser (Maybe [HttpEndpointCommonAttribute])
-> Parser
     (Maybe ContentEncoding -> HttpEndpointRequestConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [HttpEndpointCommonAttribute]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CommonAttributes"
                            Parser (Maybe (Maybe [HttpEndpointCommonAttribute]))
-> Maybe [HttpEndpointCommonAttribute]
-> Parser (Maybe [HttpEndpointCommonAttribute])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [HttpEndpointCommonAttribute]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe ContentEncoding -> HttpEndpointRequestConfiguration)
-> Parser (Maybe ContentEncoding)
-> Parser HttpEndpointRequestConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ContentEncoding)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ContentEncoding")
      )

instance
  Prelude.Hashable
    HttpEndpointRequestConfiguration

instance
  Prelude.NFData
    HttpEndpointRequestConfiguration

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