{-# 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.SSM.Types.MetadataValue
-- 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.SSM.Types.MetadataValue where

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

-- | Metadata to assign to an Application Manager application.
--
-- /See:/ 'newMetadataValue' smart constructor.
data MetadataValue = MetadataValue'
  { -- | Metadata value to assign to an Application Manager application.
    MetadataValue -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (MetadataValue -> MetadataValue -> Bool
(MetadataValue -> MetadataValue -> Bool)
-> (MetadataValue -> MetadataValue -> Bool) -> Eq MetadataValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetadataValue -> MetadataValue -> Bool
$c/= :: MetadataValue -> MetadataValue -> Bool
== :: MetadataValue -> MetadataValue -> Bool
$c== :: MetadataValue -> MetadataValue -> Bool
Prelude.Eq, ReadPrec [MetadataValue]
ReadPrec MetadataValue
Int -> ReadS MetadataValue
ReadS [MetadataValue]
(Int -> ReadS MetadataValue)
-> ReadS [MetadataValue]
-> ReadPrec MetadataValue
-> ReadPrec [MetadataValue]
-> Read MetadataValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetadataValue]
$creadListPrec :: ReadPrec [MetadataValue]
readPrec :: ReadPrec MetadataValue
$creadPrec :: ReadPrec MetadataValue
readList :: ReadS [MetadataValue]
$creadList :: ReadS [MetadataValue]
readsPrec :: Int -> ReadS MetadataValue
$creadsPrec :: Int -> ReadS MetadataValue
Prelude.Read, Int -> MetadataValue -> ShowS
[MetadataValue] -> ShowS
MetadataValue -> String
(Int -> MetadataValue -> ShowS)
-> (MetadataValue -> String)
-> ([MetadataValue] -> ShowS)
-> Show MetadataValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetadataValue] -> ShowS
$cshowList :: [MetadataValue] -> ShowS
show :: MetadataValue -> String
$cshow :: MetadataValue -> String
showsPrec :: Int -> MetadataValue -> ShowS
$cshowsPrec :: Int -> MetadataValue -> ShowS
Prelude.Show, (forall x. MetadataValue -> Rep MetadataValue x)
-> (forall x. Rep MetadataValue x -> MetadataValue)
-> Generic MetadataValue
forall x. Rep MetadataValue x -> MetadataValue
forall x. MetadataValue -> Rep MetadataValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetadataValue x -> MetadataValue
$cfrom :: forall x. MetadataValue -> Rep MetadataValue x
Prelude.Generic)

-- |
-- Create a value of 'MetadataValue' 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', 'metadataValue_value' - Metadata value to assign to an Application Manager application.
newMetadataValue ::
  MetadataValue
newMetadataValue :: MetadataValue
newMetadataValue =
  MetadataValue' :: Maybe Text -> MetadataValue
MetadataValue' {$sel:value:MetadataValue' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | Metadata value to assign to an Application Manager application.
metadataValue_value :: Lens.Lens' MetadataValue (Prelude.Maybe Prelude.Text)
metadataValue_value :: (Maybe Text -> f (Maybe Text)) -> MetadataValue -> f MetadataValue
metadataValue_value = (MetadataValue -> Maybe Text)
-> (MetadataValue -> Maybe Text -> MetadataValue)
-> Lens MetadataValue MetadataValue (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetadataValue' {Maybe Text
value :: Maybe Text
$sel:value:MetadataValue' :: MetadataValue -> Maybe Text
value} -> Maybe Text
value) (\s :: MetadataValue
s@MetadataValue' {} Maybe Text
a -> MetadataValue
s {$sel:value:MetadataValue' :: Maybe Text
value = Maybe Text
a} :: MetadataValue)

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

instance Prelude.Hashable MetadataValue

instance Prelude.NFData MetadataValue

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