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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ResultRowValue -> ResultRowValue -> Bool)
-> (ResultRowValue -> ResultRowValue -> Bool) -> Eq ResultRowValue
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]
(Int -> ReadS ResultRowValue)
-> ReadS [ResultRowValue]
-> ReadPrec ResultRowValue
-> ReadPrec [ResultRowValue]
-> Read 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
(Int -> ResultRowValue -> ShowS)
-> (ResultRowValue -> String)
-> ([ResultRowValue] -> ShowS)
-> Show ResultRowValue
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. ResultRowValue -> Rep ResultRowValue x)
-> (forall x. Rep ResultRowValue x -> ResultRowValue)
-> Generic ResultRowValue
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' :: Text -> Text -> Text -> ResultRowValue
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 :: (Text -> f Text) -> ResultRowValue -> f ResultRowValue
resultRowValue_type = (ResultRowValue -> Text)
-> (ResultRowValue -> Text -> ResultRowValue)
-> Lens ResultRowValue ResultRowValue Text Text
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 :: (Text -> f Text) -> ResultRowValue -> f ResultRowValue
resultRowValue_value = (ResultRowValue -> Text)
-> (ResultRowValue -> Text -> ResultRowValue)
-> Lens ResultRowValue ResultRowValue Text Text
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 :: (Text -> f Text) -> ResultRowValue -> f ResultRowValue
resultRowValue_key = (ResultRowValue -> Text)
-> (ResultRowValue -> Text -> ResultRowValue)
-> Lens ResultRowValue ResultRowValue Text Text
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 Core.FromJSON ResultRowValue where
  parseJSON :: Value -> Parser ResultRowValue
parseJSON =
    String
-> (Object -> Parser ResultRowValue)
-> Value
-> Parser ResultRowValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResultRowValue"
      ( \Object
x ->
          Text -> Text -> Text -> ResultRowValue
ResultRowValue'
            (Text -> Text -> Text -> ResultRowValue)
-> Parser Text -> Parser (Text -> Text -> ResultRowValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
            Parser (Text -> Text -> ResultRowValue)
-> Parser Text -> Parser (Text -> ResultRowValue)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Value")
            Parser (Text -> ResultRowValue)
-> Parser Text -> Parser ResultRowValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Key")
      )

instance Prelude.Hashable ResultRowValue

instance Prelude.NFData ResultRowValue