{-# 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.OpsItemDataValue
-- 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.OpsItemDataValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.OpsItemDataType

-- | An object that defines the value of the key and its type in the
-- OperationalData map.
--
-- /See:/ 'newOpsItemDataValue' smart constructor.
data OpsItemDataValue = OpsItemDataValue'
  { -- | The value of the OperationalData key.
    OpsItemDataValue -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The type of key-value pair. Valid types include @SearchableString@ and
    -- @String@.
    OpsItemDataValue -> Maybe OpsItemDataType
type' :: Prelude.Maybe OpsItemDataType
  }
  deriving (OpsItemDataValue -> OpsItemDataValue -> Bool
(OpsItemDataValue -> OpsItemDataValue -> Bool)
-> (OpsItemDataValue -> OpsItemDataValue -> Bool)
-> Eq OpsItemDataValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpsItemDataValue -> OpsItemDataValue -> Bool
$c/= :: OpsItemDataValue -> OpsItemDataValue -> Bool
== :: OpsItemDataValue -> OpsItemDataValue -> Bool
$c== :: OpsItemDataValue -> OpsItemDataValue -> Bool
Prelude.Eq, ReadPrec [OpsItemDataValue]
ReadPrec OpsItemDataValue
Int -> ReadS OpsItemDataValue
ReadS [OpsItemDataValue]
(Int -> ReadS OpsItemDataValue)
-> ReadS [OpsItemDataValue]
-> ReadPrec OpsItemDataValue
-> ReadPrec [OpsItemDataValue]
-> Read OpsItemDataValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpsItemDataValue]
$creadListPrec :: ReadPrec [OpsItemDataValue]
readPrec :: ReadPrec OpsItemDataValue
$creadPrec :: ReadPrec OpsItemDataValue
readList :: ReadS [OpsItemDataValue]
$creadList :: ReadS [OpsItemDataValue]
readsPrec :: Int -> ReadS OpsItemDataValue
$creadsPrec :: Int -> ReadS OpsItemDataValue
Prelude.Read, Int -> OpsItemDataValue -> ShowS
[OpsItemDataValue] -> ShowS
OpsItemDataValue -> String
(Int -> OpsItemDataValue -> ShowS)
-> (OpsItemDataValue -> String)
-> ([OpsItemDataValue] -> ShowS)
-> Show OpsItemDataValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpsItemDataValue] -> ShowS
$cshowList :: [OpsItemDataValue] -> ShowS
show :: OpsItemDataValue -> String
$cshow :: OpsItemDataValue -> String
showsPrec :: Int -> OpsItemDataValue -> ShowS
$cshowsPrec :: Int -> OpsItemDataValue -> ShowS
Prelude.Show, (forall x. OpsItemDataValue -> Rep OpsItemDataValue x)
-> (forall x. Rep OpsItemDataValue x -> OpsItemDataValue)
-> Generic OpsItemDataValue
forall x. Rep OpsItemDataValue x -> OpsItemDataValue
forall x. OpsItemDataValue -> Rep OpsItemDataValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpsItemDataValue x -> OpsItemDataValue
$cfrom :: forall x. OpsItemDataValue -> Rep OpsItemDataValue x
Prelude.Generic)

-- |
-- Create a value of 'OpsItemDataValue' 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', 'opsItemDataValue_value' - The value of the OperationalData key.
--
-- 'type'', 'opsItemDataValue_type' - The type of key-value pair. Valid types include @SearchableString@ and
-- @String@.
newOpsItemDataValue ::
  OpsItemDataValue
newOpsItemDataValue :: OpsItemDataValue
newOpsItemDataValue =
  OpsItemDataValue' :: Maybe Text -> Maybe OpsItemDataType -> OpsItemDataValue
OpsItemDataValue'
    { $sel:value:OpsItemDataValue' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':OpsItemDataValue' :: Maybe OpsItemDataType
type' = Maybe OpsItemDataType
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the OperationalData key.
opsItemDataValue_value :: Lens.Lens' OpsItemDataValue (Prelude.Maybe Prelude.Text)
opsItemDataValue_value :: (Maybe Text -> f (Maybe Text))
-> OpsItemDataValue -> f OpsItemDataValue
opsItemDataValue_value = (OpsItemDataValue -> Maybe Text)
-> (OpsItemDataValue -> Maybe Text -> OpsItemDataValue)
-> Lens OpsItemDataValue OpsItemDataValue (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsItemDataValue' {Maybe Text
value :: Maybe Text
$sel:value:OpsItemDataValue' :: OpsItemDataValue -> Maybe Text
value} -> Maybe Text
value) (\s :: OpsItemDataValue
s@OpsItemDataValue' {} Maybe Text
a -> OpsItemDataValue
s {$sel:value:OpsItemDataValue' :: Maybe Text
value = Maybe Text
a} :: OpsItemDataValue)

-- | The type of key-value pair. Valid types include @SearchableString@ and
-- @String@.
opsItemDataValue_type :: Lens.Lens' OpsItemDataValue (Prelude.Maybe OpsItemDataType)
opsItemDataValue_type :: (Maybe OpsItemDataType -> f (Maybe OpsItemDataType))
-> OpsItemDataValue -> f OpsItemDataValue
opsItemDataValue_type = (OpsItemDataValue -> Maybe OpsItemDataType)
-> (OpsItemDataValue -> Maybe OpsItemDataType -> OpsItemDataValue)
-> Lens
     OpsItemDataValue
     OpsItemDataValue
     (Maybe OpsItemDataType)
     (Maybe OpsItemDataType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsItemDataValue' {Maybe OpsItemDataType
type' :: Maybe OpsItemDataType
$sel:type':OpsItemDataValue' :: OpsItemDataValue -> Maybe OpsItemDataType
type'} -> Maybe OpsItemDataType
type') (\s :: OpsItemDataValue
s@OpsItemDataValue' {} Maybe OpsItemDataType
a -> OpsItemDataValue
s {$sel:type':OpsItemDataValue' :: Maybe OpsItemDataType
type' = Maybe OpsItemDataType
a} :: OpsItemDataValue)

instance Core.FromJSON OpsItemDataValue where
  parseJSON :: Value -> Parser OpsItemDataValue
parseJSON =
    String
-> (Object -> Parser OpsItemDataValue)
-> Value
-> Parser OpsItemDataValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OpsItemDataValue"
      ( \Object
x ->
          Maybe Text -> Maybe OpsItemDataType -> OpsItemDataValue
OpsItemDataValue'
            (Maybe Text -> Maybe OpsItemDataType -> OpsItemDataValue)
-> Parser (Maybe Text)
-> Parser (Maybe OpsItemDataType -> OpsItemDataValue)
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 OpsItemDataType -> OpsItemDataValue)
-> Parser (Maybe OpsItemDataType) -> Parser OpsItemDataValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OpsItemDataType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable OpsItemDataValue

instance Prelude.NFData OpsItemDataValue

instance Core.ToJSON OpsItemDataValue where
  toJSON :: OpsItemDataValue -> Value
toJSON OpsItemDataValue' {Maybe Text
Maybe OpsItemDataType
type' :: Maybe OpsItemDataType
value :: Maybe Text
$sel:type':OpsItemDataValue' :: OpsItemDataValue -> Maybe OpsItemDataType
$sel:value:OpsItemDataValue' :: OpsItemDataValue -> 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,
            (Text
"Type" Text -> OpsItemDataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OpsItemDataType -> Pair) -> Maybe OpsItemDataType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OpsItemDataType
type'
          ]
      )