{-# 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.ELBV2.Types.QueryStringKeyValuePair
-- 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.ELBV2.Types.QueryStringKeyValuePair where

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

-- | Information about a key\/value pair.
--
-- /See:/ 'newQueryStringKeyValuePair' smart constructor.
data QueryStringKeyValuePair = QueryStringKeyValuePair'
  { -- | The value.
    QueryStringKeyValuePair -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The key. You can omit the key.
    QueryStringKeyValuePair -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (QueryStringKeyValuePair -> QueryStringKeyValuePair -> Bool
(QueryStringKeyValuePair -> QueryStringKeyValuePair -> Bool)
-> (QueryStringKeyValuePair -> QueryStringKeyValuePair -> Bool)
-> Eq QueryStringKeyValuePair
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryStringKeyValuePair -> QueryStringKeyValuePair -> Bool
$c/= :: QueryStringKeyValuePair -> QueryStringKeyValuePair -> Bool
== :: QueryStringKeyValuePair -> QueryStringKeyValuePair -> Bool
$c== :: QueryStringKeyValuePair -> QueryStringKeyValuePair -> Bool
Prelude.Eq, ReadPrec [QueryStringKeyValuePair]
ReadPrec QueryStringKeyValuePair
Int -> ReadS QueryStringKeyValuePair
ReadS [QueryStringKeyValuePair]
(Int -> ReadS QueryStringKeyValuePair)
-> ReadS [QueryStringKeyValuePair]
-> ReadPrec QueryStringKeyValuePair
-> ReadPrec [QueryStringKeyValuePair]
-> Read QueryStringKeyValuePair
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QueryStringKeyValuePair]
$creadListPrec :: ReadPrec [QueryStringKeyValuePair]
readPrec :: ReadPrec QueryStringKeyValuePair
$creadPrec :: ReadPrec QueryStringKeyValuePair
readList :: ReadS [QueryStringKeyValuePair]
$creadList :: ReadS [QueryStringKeyValuePair]
readsPrec :: Int -> ReadS QueryStringKeyValuePair
$creadsPrec :: Int -> ReadS QueryStringKeyValuePair
Prelude.Read, Int -> QueryStringKeyValuePair -> ShowS
[QueryStringKeyValuePair] -> ShowS
QueryStringKeyValuePair -> String
(Int -> QueryStringKeyValuePair -> ShowS)
-> (QueryStringKeyValuePair -> String)
-> ([QueryStringKeyValuePair] -> ShowS)
-> Show QueryStringKeyValuePair
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryStringKeyValuePair] -> ShowS
$cshowList :: [QueryStringKeyValuePair] -> ShowS
show :: QueryStringKeyValuePair -> String
$cshow :: QueryStringKeyValuePair -> String
showsPrec :: Int -> QueryStringKeyValuePair -> ShowS
$cshowsPrec :: Int -> QueryStringKeyValuePair -> ShowS
Prelude.Show, (forall x.
 QueryStringKeyValuePair -> Rep QueryStringKeyValuePair x)
-> (forall x.
    Rep QueryStringKeyValuePair x -> QueryStringKeyValuePair)
-> Generic QueryStringKeyValuePair
forall x. Rep QueryStringKeyValuePair x -> QueryStringKeyValuePair
forall x. QueryStringKeyValuePair -> Rep QueryStringKeyValuePair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryStringKeyValuePair x -> QueryStringKeyValuePair
$cfrom :: forall x. QueryStringKeyValuePair -> Rep QueryStringKeyValuePair x
Prelude.Generic)

-- |
-- Create a value of 'QueryStringKeyValuePair' 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:
--
-- 'value', 'queryStringKeyValuePair_value' - The value.
--
-- 'key', 'queryStringKeyValuePair_key' - The key. You can omit the key.
newQueryStringKeyValuePair ::
  QueryStringKeyValuePair
newQueryStringKeyValuePair :: QueryStringKeyValuePair
newQueryStringKeyValuePair =
  QueryStringKeyValuePair' :: Maybe Text -> Maybe Text -> QueryStringKeyValuePair
QueryStringKeyValuePair'
    { $sel:value:QueryStringKeyValuePair' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:QueryStringKeyValuePair' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value.
queryStringKeyValuePair_value :: Lens.Lens' QueryStringKeyValuePair (Prelude.Maybe Prelude.Text)
queryStringKeyValuePair_value :: (Maybe Text -> f (Maybe Text))
-> QueryStringKeyValuePair -> f QueryStringKeyValuePair
queryStringKeyValuePair_value = (QueryStringKeyValuePair -> Maybe Text)
-> (QueryStringKeyValuePair
    -> Maybe Text -> QueryStringKeyValuePair)
-> Lens
     QueryStringKeyValuePair
     QueryStringKeyValuePair
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryStringKeyValuePair' {Maybe Text
value :: Maybe Text
$sel:value:QueryStringKeyValuePair' :: QueryStringKeyValuePair -> Maybe Text
value} -> Maybe Text
value) (\s :: QueryStringKeyValuePair
s@QueryStringKeyValuePair' {} Maybe Text
a -> QueryStringKeyValuePair
s {$sel:value:QueryStringKeyValuePair' :: Maybe Text
value = Maybe Text
a} :: QueryStringKeyValuePair)

-- | The key. You can omit the key.
queryStringKeyValuePair_key :: Lens.Lens' QueryStringKeyValuePair (Prelude.Maybe Prelude.Text)
queryStringKeyValuePair_key :: (Maybe Text -> f (Maybe Text))
-> QueryStringKeyValuePair -> f QueryStringKeyValuePair
queryStringKeyValuePair_key = (QueryStringKeyValuePair -> Maybe Text)
-> (QueryStringKeyValuePair
    -> Maybe Text -> QueryStringKeyValuePair)
-> Lens
     QueryStringKeyValuePair
     QueryStringKeyValuePair
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryStringKeyValuePair' {Maybe Text
key :: Maybe Text
$sel:key:QueryStringKeyValuePair' :: QueryStringKeyValuePair -> Maybe Text
key} -> Maybe Text
key) (\s :: QueryStringKeyValuePair
s@QueryStringKeyValuePair' {} Maybe Text
a -> QueryStringKeyValuePair
s {$sel:key:QueryStringKeyValuePair' :: Maybe Text
key = Maybe Text
a} :: QueryStringKeyValuePair)

instance Core.FromXML QueryStringKeyValuePair where
  parseXML :: [Node] -> Either String QueryStringKeyValuePair
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> QueryStringKeyValuePair
QueryStringKeyValuePair'
      (Maybe Text -> Maybe Text -> QueryStringKeyValuePair)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> QueryStringKeyValuePair)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Value") Either String (Maybe Text -> QueryStringKeyValuePair)
-> Either String (Maybe Text)
-> Either String QueryStringKeyValuePair
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Key")

instance Prelude.Hashable QueryStringKeyValuePair

instance Prelude.NFData QueryStringKeyValuePair

instance Core.ToQuery QueryStringKeyValuePair where
  toQuery :: QueryStringKeyValuePair -> QueryString
toQuery QueryStringKeyValuePair' {Maybe Text
key :: Maybe Text
value :: Maybe Text
$sel:key:QueryStringKeyValuePair' :: QueryStringKeyValuePair -> Maybe Text
$sel:value:QueryStringKeyValuePair' :: QueryStringKeyValuePair -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Value" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
value, ByteString
"Key" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
key]