{-# 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.MacieV2.Types.KeyValuePair
-- 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.MacieV2.Types.KeyValuePair where

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

-- | Provides information about the tags that are associated with an S3
-- bucket or object. Each tag consists of a required tag key and an
-- associated tag value.
--
-- /See:/ 'newKeyValuePair' smart constructor.
data KeyValuePair = KeyValuePair'
  { -- | One part of a key-value pair that comprises a tag. A tag value acts as a
    -- descriptor for a tag key. A tag value can be an empty string.
    KeyValuePair -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | One part of a key-value pair that comprises a tag. A tag key is a
    -- general label that acts as a category for more specific tag values.
    KeyValuePair -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (KeyValuePair -> KeyValuePair -> Bool
(KeyValuePair -> KeyValuePair -> Bool)
-> (KeyValuePair -> KeyValuePair -> Bool) -> Eq KeyValuePair
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyValuePair -> KeyValuePair -> Bool
$c/= :: KeyValuePair -> KeyValuePair -> Bool
== :: KeyValuePair -> KeyValuePair -> Bool
$c== :: KeyValuePair -> KeyValuePair -> Bool
Prelude.Eq, ReadPrec [KeyValuePair]
ReadPrec KeyValuePair
Int -> ReadS KeyValuePair
ReadS [KeyValuePair]
(Int -> ReadS KeyValuePair)
-> ReadS [KeyValuePair]
-> ReadPrec KeyValuePair
-> ReadPrec [KeyValuePair]
-> Read KeyValuePair
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeyValuePair]
$creadListPrec :: ReadPrec [KeyValuePair]
readPrec :: ReadPrec KeyValuePair
$creadPrec :: ReadPrec KeyValuePair
readList :: ReadS [KeyValuePair]
$creadList :: ReadS [KeyValuePair]
readsPrec :: Int -> ReadS KeyValuePair
$creadsPrec :: Int -> ReadS KeyValuePair
Prelude.Read, Int -> KeyValuePair -> ShowS
[KeyValuePair] -> ShowS
KeyValuePair -> String
(Int -> KeyValuePair -> ShowS)
-> (KeyValuePair -> String)
-> ([KeyValuePair] -> ShowS)
-> Show KeyValuePair
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyValuePair] -> ShowS
$cshowList :: [KeyValuePair] -> ShowS
show :: KeyValuePair -> String
$cshow :: KeyValuePair -> String
showsPrec :: Int -> KeyValuePair -> ShowS
$cshowsPrec :: Int -> KeyValuePair -> ShowS
Prelude.Show, (forall x. KeyValuePair -> Rep KeyValuePair x)
-> (forall x. Rep KeyValuePair x -> KeyValuePair)
-> Generic KeyValuePair
forall x. Rep KeyValuePair x -> KeyValuePair
forall x. KeyValuePair -> Rep KeyValuePair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeyValuePair x -> KeyValuePair
$cfrom :: forall x. KeyValuePair -> Rep KeyValuePair x
Prelude.Generic)

-- |
-- Create a value of 'KeyValuePair' 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', 'keyValuePair_value' - One part of a key-value pair that comprises a tag. A tag value acts as a
-- descriptor for a tag key. A tag value can be an empty string.
--
-- 'key', 'keyValuePair_key' - One part of a key-value pair that comprises a tag. A tag key is a
-- general label that acts as a category for more specific tag values.
newKeyValuePair ::
  KeyValuePair
newKeyValuePair :: KeyValuePair
newKeyValuePair =
  KeyValuePair' :: Maybe Text -> Maybe Text -> KeyValuePair
KeyValuePair'
    { $sel:value:KeyValuePair' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:KeyValuePair' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | One part of a key-value pair that comprises a tag. A tag value acts as a
-- descriptor for a tag key. A tag value can be an empty string.
keyValuePair_value :: Lens.Lens' KeyValuePair (Prelude.Maybe Prelude.Text)
keyValuePair_value :: (Maybe Text -> f (Maybe Text)) -> KeyValuePair -> f KeyValuePair
keyValuePair_value = (KeyValuePair -> Maybe Text)
-> (KeyValuePair -> Maybe Text -> KeyValuePair)
-> Lens KeyValuePair KeyValuePair (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyValuePair' {Maybe Text
value :: Maybe Text
$sel:value:KeyValuePair' :: KeyValuePair -> Maybe Text
value} -> Maybe Text
value) (\s :: KeyValuePair
s@KeyValuePair' {} Maybe Text
a -> KeyValuePair
s {$sel:value:KeyValuePair' :: Maybe Text
value = Maybe Text
a} :: KeyValuePair)

-- | One part of a key-value pair that comprises a tag. A tag key is a
-- general label that acts as a category for more specific tag values.
keyValuePair_key :: Lens.Lens' KeyValuePair (Prelude.Maybe Prelude.Text)
keyValuePair_key :: (Maybe Text -> f (Maybe Text)) -> KeyValuePair -> f KeyValuePair
keyValuePair_key = (KeyValuePair -> Maybe Text)
-> (KeyValuePair -> Maybe Text -> KeyValuePair)
-> Lens KeyValuePair KeyValuePair (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyValuePair' {Maybe Text
key :: Maybe Text
$sel:key:KeyValuePair' :: KeyValuePair -> Maybe Text
key} -> Maybe Text
key) (\s :: KeyValuePair
s@KeyValuePair' {} Maybe Text
a -> KeyValuePair
s {$sel:key:KeyValuePair' :: Maybe Text
key = Maybe Text
a} :: KeyValuePair)

instance Core.FromJSON KeyValuePair where
  parseJSON :: Value -> Parser KeyValuePair
parseJSON =
    String
-> (Object -> Parser KeyValuePair) -> Value -> Parser KeyValuePair
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"KeyValuePair"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> KeyValuePair
KeyValuePair'
            (Maybe Text -> Maybe Text -> KeyValuePair)
-> Parser (Maybe Text) -> Parser (Maybe Text -> KeyValuePair)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"value") Parser (Maybe Text -> KeyValuePair)
-> Parser (Maybe Text) -> Parser KeyValuePair
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"key")
      )

instance Prelude.Hashable KeyValuePair

instance Prelude.NFData KeyValuePair