{-# 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.Pinpoint.Types.ResultRowValue
-- 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.Pinpoint.Types.ResultRowValue 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

-- | Provides a single value and metadata about that value as part of an
-- array of query results for a standard metric that applies to an
-- application, campaign, or journey.
--
-- /See:/ 'newResultRowValue' smart constructor.
data ResultRowValue = ResultRowValue'
  { -- | The data type of the value specified by the Value property.
    ResultRowValue -> Text
type' :: Prelude.Text,
    -- | In a Values object, the value for the metric that the query retrieved
    -- data for. In a GroupedBys object, the value for the field that was used
    -- to group data in a result set that contains multiple results (Values
    -- objects).
    ResultRowValue -> Text
value :: Prelude.Text,
    -- | The friendly name of the metric whose value is specified by the Value
    -- property.
    ResultRowValue -> Text
key :: Prelude.Text
  }
  deriving (ResultRowValue -> ResultRowValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultRowValue -> ResultRowValue -> Bool
$c/= :: ResultRowValue -> ResultRowValue -> Bool
== :: ResultRowValue -> ResultRowValue -> Bool
$c== :: ResultRowValue -> ResultRowValue -> Bool
Prelude.Eq, ReadPrec [ResultRowValue]
ReadPrec ResultRowValue
Int -> ReadS ResultRowValue
ReadS [ResultRowValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResultRowValue]
$creadListPrec :: ReadPrec [ResultRowValue]
readPrec :: ReadPrec ResultRowValue
$creadPrec :: ReadPrec ResultRowValue
readList :: ReadS [ResultRowValue]
$creadList :: ReadS [ResultRowValue]
readsPrec :: Int -> ReadS ResultRowValue
$creadsPrec :: Int -> ReadS ResultRowValue
Prelude.Read, Int -> ResultRowValue -> ShowS
[ResultRowValue] -> ShowS
ResultRowValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultRowValue] -> ShowS
$cshowList :: [ResultRowValue] -> ShowS
show :: ResultRowValue -> String
$cshow :: ResultRowValue -> String
showsPrec :: Int -> ResultRowValue -> ShowS
$cshowsPrec :: Int -> ResultRowValue -> ShowS
Prelude.Show, forall x. Rep ResultRowValue x -> ResultRowValue
forall x. ResultRowValue -> Rep ResultRowValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultRowValue x -> ResultRowValue
$cfrom :: forall x. ResultRowValue -> Rep ResultRowValue x
Prelude.Generic)

-- |
-- Create a value of 'ResultRowValue' 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'', 'resultRowValue_type' - The data type of the value specified by the Value property.
--
-- 'value', 'resultRowValue_value' - In a Values object, the value for the metric that the query retrieved
-- data for. In a GroupedBys object, the value for the field that was used
-- to group data in a result set that contains multiple results (Values
-- objects).
--
-- 'key', 'resultRowValue_key' - The friendly name of the metric whose value is specified by the Value
-- property.
newResultRowValue ::
  -- | 'type''
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  ResultRowValue
newResultRowValue :: Text -> Text -> Text -> ResultRowValue
newResultRowValue Text
pType_ Text
pValue_ Text
pKey_ =
  ResultRowValue'
    { $sel:type':ResultRowValue' :: Text
type' = Text
pType_,
      $sel:value:ResultRowValue' :: Text
value = Text
pValue_,
      $sel:key:ResultRowValue' :: Text
key = Text
pKey_
    }

-- | The data type of the value specified by the Value property.
resultRowValue_type :: Lens.Lens' ResultRowValue Prelude.Text
resultRowValue_type :: Lens' ResultRowValue Text
resultRowValue_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRowValue' {Text
type' :: Text
$sel:type':ResultRowValue' :: ResultRowValue -> Text
type'} -> Text
type') (\s :: ResultRowValue
s@ResultRowValue' {} Text
a -> ResultRowValue
s {$sel:type':ResultRowValue' :: Text
type' = Text
a} :: ResultRowValue)

-- | In a Values object, the value for the metric that the query retrieved
-- data for. In a GroupedBys object, the value for the field that was used
-- to group data in a result set that contains multiple results (Values
-- objects).
resultRowValue_value :: Lens.Lens' ResultRowValue Prelude.Text
resultRowValue_value :: Lens' ResultRowValue Text
resultRowValue_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRowValue' {Text
value :: Text
$sel:value:ResultRowValue' :: ResultRowValue -> Text
value} -> Text
value) (\s :: ResultRowValue
s@ResultRowValue' {} Text
a -> ResultRowValue
s {$sel:value:ResultRowValue' :: Text
value = Text
a} :: ResultRowValue)

-- | The friendly name of the metric whose value is specified by the Value
-- property.
resultRowValue_key :: Lens.Lens' ResultRowValue Prelude.Text
resultRowValue_key :: Lens' ResultRowValue Text
resultRowValue_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRowValue' {Text
key :: Text
$sel:key:ResultRowValue' :: ResultRowValue -> Text
key} -> Text
key) (\s :: ResultRowValue
s@ResultRowValue' {} Text
a -> ResultRowValue
s {$sel:key:ResultRowValue' :: Text
key = Text
a} :: ResultRowValue)

instance Data.FromJSON ResultRowValue where
  parseJSON :: Value -> Parser ResultRowValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResultRowValue"
      ( \Object
x ->
          Text -> Text -> Text -> ResultRowValue
ResultRowValue'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"Value")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Key")
      )

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

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