{-# 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.ServiceCatalog.Types.RecordTag
-- 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.ServiceCatalog.Types.RecordTag where

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

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

-- |
-- Create a value of 'RecordTag' 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', 'recordTag_value' - The value for this tag.
--
-- 'key', 'recordTag_key' - The key for this tag.
newRecordTag ::
  RecordTag
newRecordTag :: RecordTag
newRecordTag =
  RecordTag' :: Maybe Text -> Maybe Text -> RecordTag
RecordTag'
    { $sel:value:RecordTag' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:RecordTag' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The key for this tag.
recordTag_key :: Lens.Lens' RecordTag (Prelude.Maybe Prelude.Text)
recordTag_key :: (Maybe Text -> f (Maybe Text)) -> RecordTag -> f RecordTag
recordTag_key = (RecordTag -> Maybe Text)
-> (RecordTag -> Maybe Text -> RecordTag)
-> Lens RecordTag RecordTag (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecordTag' {Maybe Text
key :: Maybe Text
$sel:key:RecordTag' :: RecordTag -> Maybe Text
key} -> Maybe Text
key) (\s :: RecordTag
s@RecordTag' {} Maybe Text
a -> RecordTag
s {$sel:key:RecordTag' :: Maybe Text
key = Maybe Text
a} :: RecordTag)

instance Core.FromJSON RecordTag where
  parseJSON :: Value -> Parser RecordTag
parseJSON =
    String -> (Object -> Parser RecordTag) -> Value -> Parser RecordTag
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecordTag"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> RecordTag
RecordTag'
            (Maybe Text -> Maybe Text -> RecordTag)
-> Parser (Maybe Text) -> Parser (Maybe Text -> RecordTag)
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 -> RecordTag)
-> Parser (Maybe Text) -> Parser RecordTag
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 RecordTag

instance Prelude.NFData RecordTag