{-# 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.Glue.Types.MetadataKeyValuePair
-- 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.Glue.Types.MetadataKeyValuePair where

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

-- | A structure containing a key value pair for metadata.
--
-- /See:/ 'newMetadataKeyValuePair' smart constructor.
data MetadataKeyValuePair = MetadataKeyValuePair'
  { -- | A metadata key.
    MetadataKeyValuePair -> Maybe Text
metadataKey :: Prelude.Maybe Prelude.Text,
    -- | A metadata key’s corresponding value.
    MetadataKeyValuePair -> Maybe Text
metadataValue :: Prelude.Maybe Prelude.Text
  }
  deriving (MetadataKeyValuePair -> MetadataKeyValuePair -> Bool
(MetadataKeyValuePair -> MetadataKeyValuePair -> Bool)
-> (MetadataKeyValuePair -> MetadataKeyValuePair -> Bool)
-> Eq MetadataKeyValuePair
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetadataKeyValuePair -> MetadataKeyValuePair -> Bool
$c/= :: MetadataKeyValuePair -> MetadataKeyValuePair -> Bool
== :: MetadataKeyValuePair -> MetadataKeyValuePair -> Bool
$c== :: MetadataKeyValuePair -> MetadataKeyValuePair -> Bool
Prelude.Eq, ReadPrec [MetadataKeyValuePair]
ReadPrec MetadataKeyValuePair
Int -> ReadS MetadataKeyValuePair
ReadS [MetadataKeyValuePair]
(Int -> ReadS MetadataKeyValuePair)
-> ReadS [MetadataKeyValuePair]
-> ReadPrec MetadataKeyValuePair
-> ReadPrec [MetadataKeyValuePair]
-> Read MetadataKeyValuePair
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetadataKeyValuePair]
$creadListPrec :: ReadPrec [MetadataKeyValuePair]
readPrec :: ReadPrec MetadataKeyValuePair
$creadPrec :: ReadPrec MetadataKeyValuePair
readList :: ReadS [MetadataKeyValuePair]
$creadList :: ReadS [MetadataKeyValuePair]
readsPrec :: Int -> ReadS MetadataKeyValuePair
$creadsPrec :: Int -> ReadS MetadataKeyValuePair
Prelude.Read, Int -> MetadataKeyValuePair -> ShowS
[MetadataKeyValuePair] -> ShowS
MetadataKeyValuePair -> String
(Int -> MetadataKeyValuePair -> ShowS)
-> (MetadataKeyValuePair -> String)
-> ([MetadataKeyValuePair] -> ShowS)
-> Show MetadataKeyValuePair
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetadataKeyValuePair] -> ShowS
$cshowList :: [MetadataKeyValuePair] -> ShowS
show :: MetadataKeyValuePair -> String
$cshow :: MetadataKeyValuePair -> String
showsPrec :: Int -> MetadataKeyValuePair -> ShowS
$cshowsPrec :: Int -> MetadataKeyValuePair -> ShowS
Prelude.Show, (forall x. MetadataKeyValuePair -> Rep MetadataKeyValuePair x)
-> (forall x. Rep MetadataKeyValuePair x -> MetadataKeyValuePair)
-> Generic MetadataKeyValuePair
forall x. Rep MetadataKeyValuePair x -> MetadataKeyValuePair
forall x. MetadataKeyValuePair -> Rep MetadataKeyValuePair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetadataKeyValuePair x -> MetadataKeyValuePair
$cfrom :: forall x. MetadataKeyValuePair -> Rep MetadataKeyValuePair x
Prelude.Generic)

-- |
-- Create a value of 'MetadataKeyValuePair' 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:
--
-- 'metadataKey', 'metadataKeyValuePair_metadataKey' - A metadata key.
--
-- 'metadataValue', 'metadataKeyValuePair_metadataValue' - A metadata key’s corresponding value.
newMetadataKeyValuePair ::
  MetadataKeyValuePair
newMetadataKeyValuePair :: MetadataKeyValuePair
newMetadataKeyValuePair =
  MetadataKeyValuePair' :: Maybe Text -> Maybe Text -> MetadataKeyValuePair
MetadataKeyValuePair'
    { $sel:metadataKey:MetadataKeyValuePair' :: Maybe Text
metadataKey =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metadataValue:MetadataKeyValuePair' :: Maybe Text
metadataValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A metadata key.
metadataKeyValuePair_metadataKey :: Lens.Lens' MetadataKeyValuePair (Prelude.Maybe Prelude.Text)
metadataKeyValuePair_metadataKey :: (Maybe Text -> f (Maybe Text))
-> MetadataKeyValuePair -> f MetadataKeyValuePair
metadataKeyValuePair_metadataKey = (MetadataKeyValuePair -> Maybe Text)
-> (MetadataKeyValuePair -> Maybe Text -> MetadataKeyValuePair)
-> Lens
     MetadataKeyValuePair MetadataKeyValuePair (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetadataKeyValuePair' {Maybe Text
metadataKey :: Maybe Text
$sel:metadataKey:MetadataKeyValuePair' :: MetadataKeyValuePair -> Maybe Text
metadataKey} -> Maybe Text
metadataKey) (\s :: MetadataKeyValuePair
s@MetadataKeyValuePair' {} Maybe Text
a -> MetadataKeyValuePair
s {$sel:metadataKey:MetadataKeyValuePair' :: Maybe Text
metadataKey = Maybe Text
a} :: MetadataKeyValuePair)

-- | A metadata key’s corresponding value.
metadataKeyValuePair_metadataValue :: Lens.Lens' MetadataKeyValuePair (Prelude.Maybe Prelude.Text)
metadataKeyValuePair_metadataValue :: (Maybe Text -> f (Maybe Text))
-> MetadataKeyValuePair -> f MetadataKeyValuePair
metadataKeyValuePair_metadataValue = (MetadataKeyValuePair -> Maybe Text)
-> (MetadataKeyValuePair -> Maybe Text -> MetadataKeyValuePair)
-> Lens
     MetadataKeyValuePair MetadataKeyValuePair (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetadataKeyValuePair' {Maybe Text
metadataValue :: Maybe Text
$sel:metadataValue:MetadataKeyValuePair' :: MetadataKeyValuePair -> Maybe Text
metadataValue} -> Maybe Text
metadataValue) (\s :: MetadataKeyValuePair
s@MetadataKeyValuePair' {} Maybe Text
a -> MetadataKeyValuePair
s {$sel:metadataValue:MetadataKeyValuePair' :: Maybe Text
metadataValue = Maybe Text
a} :: MetadataKeyValuePair)

instance Prelude.Hashable MetadataKeyValuePair

instance Prelude.NFData MetadataKeyValuePair

instance Core.ToJSON MetadataKeyValuePair where
  toJSON :: MetadataKeyValuePair -> Value
toJSON MetadataKeyValuePair' {Maybe Text
metadataValue :: Maybe Text
metadataKey :: Maybe Text
$sel:metadataValue:MetadataKeyValuePair' :: MetadataKeyValuePair -> Maybe Text
$sel:metadataKey:MetadataKeyValuePair' :: MetadataKeyValuePair -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MetadataKey" 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
metadataKey,
            (Text
"MetadataValue" 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
metadataValue
          ]
      )