{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SSM.Types.OpsItemDataValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 type of key-value pair. Valid types include @SearchableString@ and
    -- @String@.
    OpsItemDataValue -> Maybe OpsItemDataType
type' :: Prelude.Maybe OpsItemDataType,
    -- | The value of the OperationalData key.
    OpsItemDataValue -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (OpsItemDataValue -> OpsItemDataValue -> Bool
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]
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
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. 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:
--
-- 'type'', 'opsItemDataValue_type' - The type of key-value pair. Valid types include @SearchableString@ and
-- @String@.
--
-- 'value', 'opsItemDataValue_value' - The value of the OperationalData key.
newOpsItemDataValue ::
  OpsItemDataValue
newOpsItemDataValue :: OpsItemDataValue
newOpsItemDataValue =
  OpsItemDataValue'
    { $sel:type':OpsItemDataValue' :: Maybe OpsItemDataType
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:value:OpsItemDataValue' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The type of key-value pair. Valid types include @SearchableString@ and
-- @String@.
opsItemDataValue_type :: Lens.Lens' OpsItemDataValue (Prelude.Maybe OpsItemDataType)
opsItemDataValue_type :: Lens' OpsItemDataValue (Maybe OpsItemDataType)
opsItemDataValue_type = 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)

-- | The value of the OperationalData key.
opsItemDataValue_value :: Lens.Lens' OpsItemDataValue (Prelude.Maybe Prelude.Text)
opsItemDataValue_value :: Lens' OpsItemDataValue (Maybe Text)
opsItemDataValue_value = 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)

instance Data.FromJSON OpsItemDataValue where
  parseJSON :: Value -> Parser OpsItemDataValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OpsItemDataValue"
      ( \Object
x ->
          Maybe OpsItemDataType -> Maybe Text -> OpsItemDataValue
OpsItemDataValue'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Value")
      )

instance Prelude.Hashable OpsItemDataValue where
  hashWithSalt :: Int -> OpsItemDataValue -> Int
hashWithSalt Int
_salt OpsItemDataValue' {Maybe Text
Maybe OpsItemDataType
value :: Maybe Text
type' :: Maybe OpsItemDataType
$sel:value:OpsItemDataValue' :: OpsItemDataValue -> Maybe Text
$sel:type':OpsItemDataValue' :: OpsItemDataValue -> Maybe OpsItemDataType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OpsItemDataType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData OpsItemDataValue where
  rnf :: OpsItemDataValue -> ()
rnf OpsItemDataValue' {Maybe Text
Maybe OpsItemDataType
value :: Maybe Text
type' :: Maybe OpsItemDataType
$sel:value:OpsItemDataValue' :: OpsItemDataValue -> Maybe Text
$sel:type':OpsItemDataValue' :: OpsItemDataValue -> Maybe OpsItemDataType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe OpsItemDataType
type' seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON OpsItemDataValue where
  toJSON :: OpsItemDataValue -> Value
toJSON OpsItemDataValue' {Maybe Text
Maybe OpsItemDataType
value :: Maybe Text
type' :: Maybe OpsItemDataType
$sel:value:OpsItemDataValue' :: OpsItemDataValue -> Maybe Text
$sel:type':OpsItemDataValue' :: OpsItemDataValue -> Maybe OpsItemDataType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OpsItemDataType
type',
            (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
value
          ]
      )