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

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

-- | Describes the metadata that\'s delivered to the specified HTTP endpoint
-- destination.
--
-- /See:/ 'newHttpEndpointCommonAttribute' smart constructor.
data HttpEndpointCommonAttribute = HttpEndpointCommonAttribute'
  { -- | The name of the HTTP endpoint common attribute.
    HttpEndpointCommonAttribute -> Sensitive Text
attributeName :: Core.Sensitive Prelude.Text,
    -- | The value of the HTTP endpoint common attribute.
    HttpEndpointCommonAttribute -> Sensitive Text
attributeValue :: Core.Sensitive Prelude.Text
  }
  deriving (HttpEndpointCommonAttribute -> HttpEndpointCommonAttribute -> Bool
(HttpEndpointCommonAttribute
 -> HttpEndpointCommonAttribute -> Bool)
-> (HttpEndpointCommonAttribute
    -> HttpEndpointCommonAttribute -> Bool)
-> Eq HttpEndpointCommonAttribute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpEndpointCommonAttribute -> HttpEndpointCommonAttribute -> Bool
$c/= :: HttpEndpointCommonAttribute -> HttpEndpointCommonAttribute -> Bool
== :: HttpEndpointCommonAttribute -> HttpEndpointCommonAttribute -> Bool
$c== :: HttpEndpointCommonAttribute -> HttpEndpointCommonAttribute -> Bool
Prelude.Eq, Int -> HttpEndpointCommonAttribute -> ShowS
[HttpEndpointCommonAttribute] -> ShowS
HttpEndpointCommonAttribute -> String
(Int -> HttpEndpointCommonAttribute -> ShowS)
-> (HttpEndpointCommonAttribute -> String)
-> ([HttpEndpointCommonAttribute] -> ShowS)
-> Show HttpEndpointCommonAttribute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpEndpointCommonAttribute] -> ShowS
$cshowList :: [HttpEndpointCommonAttribute] -> ShowS
show :: HttpEndpointCommonAttribute -> String
$cshow :: HttpEndpointCommonAttribute -> String
showsPrec :: Int -> HttpEndpointCommonAttribute -> ShowS
$cshowsPrec :: Int -> HttpEndpointCommonAttribute -> ShowS
Prelude.Show, (forall x.
 HttpEndpointCommonAttribute -> Rep HttpEndpointCommonAttribute x)
-> (forall x.
    Rep HttpEndpointCommonAttribute x -> HttpEndpointCommonAttribute)
-> Generic HttpEndpointCommonAttribute
forall x.
Rep HttpEndpointCommonAttribute x -> HttpEndpointCommonAttribute
forall x.
HttpEndpointCommonAttribute -> Rep HttpEndpointCommonAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HttpEndpointCommonAttribute x -> HttpEndpointCommonAttribute
$cfrom :: forall x.
HttpEndpointCommonAttribute -> Rep HttpEndpointCommonAttribute x
Prelude.Generic)

-- |
-- Create a value of 'HttpEndpointCommonAttribute' 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:
--
-- 'attributeName', 'httpEndpointCommonAttribute_attributeName' - The name of the HTTP endpoint common attribute.
--
-- 'attributeValue', 'httpEndpointCommonAttribute_attributeValue' - The value of the HTTP endpoint common attribute.
newHttpEndpointCommonAttribute ::
  -- | 'attributeName'
  Prelude.Text ->
  -- | 'attributeValue'
  Prelude.Text ->
  HttpEndpointCommonAttribute
newHttpEndpointCommonAttribute :: Text -> Text -> HttpEndpointCommonAttribute
newHttpEndpointCommonAttribute
  Text
pAttributeName_
  Text
pAttributeValue_ =
    HttpEndpointCommonAttribute' :: Sensitive Text -> Sensitive Text -> HttpEndpointCommonAttribute
HttpEndpointCommonAttribute'
      { $sel:attributeName:HttpEndpointCommonAttribute' :: Sensitive Text
attributeName =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pAttributeName_,
        $sel:attributeValue:HttpEndpointCommonAttribute' :: Sensitive Text
attributeValue =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pAttributeValue_
      }

-- | The name of the HTTP endpoint common attribute.
httpEndpointCommonAttribute_attributeName :: Lens.Lens' HttpEndpointCommonAttribute Prelude.Text
httpEndpointCommonAttribute_attributeName :: (Text -> f Text)
-> HttpEndpointCommonAttribute -> f HttpEndpointCommonAttribute
httpEndpointCommonAttribute_attributeName = (HttpEndpointCommonAttribute -> Sensitive Text)
-> (HttpEndpointCommonAttribute
    -> Sensitive Text -> HttpEndpointCommonAttribute)
-> Lens
     HttpEndpointCommonAttribute
     HttpEndpointCommonAttribute
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpEndpointCommonAttribute' {Sensitive Text
attributeName :: Sensitive Text
$sel:attributeName:HttpEndpointCommonAttribute' :: HttpEndpointCommonAttribute -> Sensitive Text
attributeName} -> Sensitive Text
attributeName) (\s :: HttpEndpointCommonAttribute
s@HttpEndpointCommonAttribute' {} Sensitive Text
a -> HttpEndpointCommonAttribute
s {$sel:attributeName:HttpEndpointCommonAttribute' :: Sensitive Text
attributeName = Sensitive Text
a} :: HttpEndpointCommonAttribute) ((Sensitive Text -> f (Sensitive Text))
 -> HttpEndpointCommonAttribute -> f HttpEndpointCommonAttribute)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> HttpEndpointCommonAttribute
-> f HttpEndpointCommonAttribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The value of the HTTP endpoint common attribute.
httpEndpointCommonAttribute_attributeValue :: Lens.Lens' HttpEndpointCommonAttribute Prelude.Text
httpEndpointCommonAttribute_attributeValue :: (Text -> f Text)
-> HttpEndpointCommonAttribute -> f HttpEndpointCommonAttribute
httpEndpointCommonAttribute_attributeValue = (HttpEndpointCommonAttribute -> Sensitive Text)
-> (HttpEndpointCommonAttribute
    -> Sensitive Text -> HttpEndpointCommonAttribute)
-> Lens
     HttpEndpointCommonAttribute
     HttpEndpointCommonAttribute
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpEndpointCommonAttribute' {Sensitive Text
attributeValue :: Sensitive Text
$sel:attributeValue:HttpEndpointCommonAttribute' :: HttpEndpointCommonAttribute -> Sensitive Text
attributeValue} -> Sensitive Text
attributeValue) (\s :: HttpEndpointCommonAttribute
s@HttpEndpointCommonAttribute' {} Sensitive Text
a -> HttpEndpointCommonAttribute
s {$sel:attributeValue:HttpEndpointCommonAttribute' :: Sensitive Text
attributeValue = Sensitive Text
a} :: HttpEndpointCommonAttribute) ((Sensitive Text -> f (Sensitive Text))
 -> HttpEndpointCommonAttribute -> f HttpEndpointCommonAttribute)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> HttpEndpointCommonAttribute
-> f HttpEndpointCommonAttribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.FromJSON HttpEndpointCommonAttribute where
  parseJSON :: Value -> Parser HttpEndpointCommonAttribute
parseJSON =
    String
-> (Object -> Parser HttpEndpointCommonAttribute)
-> Value
-> Parser HttpEndpointCommonAttribute
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpEndpointCommonAttribute"
      ( \Object
x ->
          Sensitive Text -> Sensitive Text -> HttpEndpointCommonAttribute
HttpEndpointCommonAttribute'
            (Sensitive Text -> Sensitive Text -> HttpEndpointCommonAttribute)
-> Parser (Sensitive Text)
-> Parser (Sensitive Text -> HttpEndpointCommonAttribute)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AttributeName")
            Parser (Sensitive Text -> HttpEndpointCommonAttribute)
-> Parser (Sensitive Text) -> Parser HttpEndpointCommonAttribute
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AttributeValue")
      )

instance Prelude.Hashable HttpEndpointCommonAttribute

instance Prelude.NFData HttpEndpointCommonAttribute

instance Core.ToJSON HttpEndpointCommonAttribute where
  toJSON :: HttpEndpointCommonAttribute -> Value
toJSON HttpEndpointCommonAttribute' {Sensitive Text
attributeValue :: Sensitive Text
attributeName :: Sensitive Text
$sel:attributeValue:HttpEndpointCommonAttribute' :: HttpEndpointCommonAttribute -> Sensitive Text
$sel:attributeName:HttpEndpointCommonAttribute' :: HttpEndpointCommonAttribute -> Sensitive Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AttributeName" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
attributeName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AttributeValue" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
attributeValue)
          ]
      )