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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.ResultRowValue
import qualified Amazonka.Prelude as Prelude

-- | Provides the results of a query that retrieved the data for a standard
-- metric that applies to an application, campaign, or journey.
--
-- /See:/ 'newResultRow' smart constructor.
data ResultRow = ResultRow'
  { -- | An array of objects that defines the field and field values that were
    -- used to group data in a result set that contains multiple results. This
    -- value is null if the data in a result set isn’t grouped.
    ResultRow -> [ResultRowValue]
groupedBys :: [ResultRowValue],
    -- | An array of objects that provides pre-aggregated values for a standard
    -- metric that applies to an application, campaign, or journey.
    ResultRow -> [ResultRowValue]
values :: [ResultRowValue]
  }
  deriving (ResultRow -> ResultRow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultRow -> ResultRow -> Bool
$c/= :: ResultRow -> ResultRow -> Bool
== :: ResultRow -> ResultRow -> Bool
$c== :: ResultRow -> ResultRow -> Bool
Prelude.Eq, ReadPrec [ResultRow]
ReadPrec ResultRow
Int -> ReadS ResultRow
ReadS [ResultRow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResultRow]
$creadListPrec :: ReadPrec [ResultRow]
readPrec :: ReadPrec ResultRow
$creadPrec :: ReadPrec ResultRow
readList :: ReadS [ResultRow]
$creadList :: ReadS [ResultRow]
readsPrec :: Int -> ReadS ResultRow
$creadsPrec :: Int -> ReadS ResultRow
Prelude.Read, Int -> ResultRow -> ShowS
[ResultRow] -> ShowS
ResultRow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultRow] -> ShowS
$cshowList :: [ResultRow] -> ShowS
show :: ResultRow -> String
$cshow :: ResultRow -> String
showsPrec :: Int -> ResultRow -> ShowS
$cshowsPrec :: Int -> ResultRow -> ShowS
Prelude.Show, forall x. Rep ResultRow x -> ResultRow
forall x. ResultRow -> Rep ResultRow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultRow x -> ResultRow
$cfrom :: forall x. ResultRow -> Rep ResultRow x
Prelude.Generic)

-- |
-- Create a value of 'ResultRow' 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:
--
-- 'groupedBys', 'resultRow_groupedBys' - An array of objects that defines the field and field values that were
-- used to group data in a result set that contains multiple results. This
-- value is null if the data in a result set isn’t grouped.
--
-- 'values', 'resultRow_values' - An array of objects that provides pre-aggregated values for a standard
-- metric that applies to an application, campaign, or journey.
newResultRow ::
  ResultRow
newResultRow :: ResultRow
newResultRow =
  ResultRow'
    { $sel:groupedBys:ResultRow' :: [ResultRowValue]
groupedBys = forall a. Monoid a => a
Prelude.mempty,
      $sel:values:ResultRow' :: [ResultRowValue]
values = forall a. Monoid a => a
Prelude.mempty
    }

-- | An array of objects that defines the field and field values that were
-- used to group data in a result set that contains multiple results. This
-- value is null if the data in a result set isn’t grouped.
resultRow_groupedBys :: Lens.Lens' ResultRow [ResultRowValue]
resultRow_groupedBys :: Lens' ResultRow [ResultRowValue]
resultRow_groupedBys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRow' {[ResultRowValue]
groupedBys :: [ResultRowValue]
$sel:groupedBys:ResultRow' :: ResultRow -> [ResultRowValue]
groupedBys} -> [ResultRowValue]
groupedBys) (\s :: ResultRow
s@ResultRow' {} [ResultRowValue]
a -> ResultRow
s {$sel:groupedBys:ResultRow' :: [ResultRowValue]
groupedBys = [ResultRowValue]
a} :: ResultRow) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of objects that provides pre-aggregated values for a standard
-- metric that applies to an application, campaign, or journey.
resultRow_values :: Lens.Lens' ResultRow [ResultRowValue]
resultRow_values :: Lens' ResultRow [ResultRowValue]
resultRow_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRow' {[ResultRowValue]
values :: [ResultRowValue]
$sel:values:ResultRow' :: ResultRow -> [ResultRowValue]
values} -> [ResultRowValue]
values) (\s :: ResultRow
s@ResultRow' {} [ResultRowValue]
a -> ResultRow
s {$sel:values:ResultRow' :: [ResultRowValue]
values = [ResultRowValue]
a} :: ResultRow) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ResultRow where
  parseJSON :: Value -> Parser ResultRow
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResultRow"
      ( \Object
x ->
          [ResultRowValue] -> [ResultRowValue] -> ResultRow
ResultRow'
            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
"GroupedBys" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResultRow where
  hashWithSalt :: Int -> ResultRow -> Int
hashWithSalt Int
_salt ResultRow' {[ResultRowValue]
values :: [ResultRowValue]
groupedBys :: [ResultRowValue]
$sel:values:ResultRow' :: ResultRow -> [ResultRowValue]
$sel:groupedBys:ResultRow' :: ResultRow -> [ResultRowValue]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ResultRowValue]
groupedBys
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ResultRowValue]
values

instance Prelude.NFData ResultRow where
  rnf :: ResultRow -> ()
rnf ResultRow' {[ResultRowValue]
values :: [ResultRowValue]
groupedBys :: [ResultRowValue]
$sel:values:ResultRow' :: ResultRow -> [ResultRowValue]
$sel:groupedBys:ResultRow' :: ResultRow -> [ResultRowValue]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [ResultRowValue]
groupedBys
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [ResultRowValue]
values