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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ResultRow -> ResultRow -> Bool)
-> (ResultRow -> ResultRow -> Bool) -> Eq ResultRow
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]
(Int -> ReadS ResultRow)
-> ReadS [ResultRow]
-> ReadPrec ResultRow
-> ReadPrec [ResultRow]
-> Read 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
(Int -> ResultRow -> ShowS)
-> (ResultRow -> String)
-> ([ResultRow] -> ShowS)
-> Show ResultRow
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. ResultRow -> Rep ResultRow x)
-> (forall x. Rep ResultRow x -> ResultRow) -> Generic ResultRow
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' :: [ResultRowValue] -> [ResultRowValue] -> ResultRow
ResultRow'
    { $sel:groupedBys:ResultRow' :: [ResultRowValue]
groupedBys = [ResultRowValue]
forall a. Monoid a => a
Prelude.mempty,
      $sel:values:ResultRow' :: [ResultRowValue]
values = [ResultRowValue]
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 :: ([ResultRowValue] -> f [ResultRowValue])
-> ResultRow -> f ResultRow
resultRow_groupedBys = (ResultRow -> [ResultRowValue])
-> (ResultRow -> [ResultRowValue] -> ResultRow)
-> Lens ResultRow ResultRow [ResultRowValue] [ResultRowValue]
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) (([ResultRowValue] -> f [ResultRowValue])
 -> ResultRow -> f ResultRow)
-> (([ResultRowValue] -> f [ResultRowValue])
    -> [ResultRowValue] -> f [ResultRowValue])
-> ([ResultRowValue] -> f [ResultRowValue])
-> ResultRow
-> f ResultRow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ResultRowValue] -> f [ResultRowValue])
-> [ResultRowValue] -> f [ResultRowValue]
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 :: ([ResultRowValue] -> f [ResultRowValue])
-> ResultRow -> f ResultRow
resultRow_values = (ResultRow -> [ResultRowValue])
-> (ResultRow -> [ResultRowValue] -> ResultRow)
-> Lens ResultRow ResultRow [ResultRowValue] [ResultRowValue]
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) (([ResultRowValue] -> f [ResultRowValue])
 -> ResultRow -> f ResultRow)
-> (([ResultRowValue] -> f [ResultRowValue])
    -> [ResultRowValue] -> f [ResultRowValue])
-> ([ResultRowValue] -> f [ResultRowValue])
-> ResultRow
-> f ResultRow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ResultRowValue] -> f [ResultRowValue])
-> [ResultRowValue] -> f [ResultRowValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ResultRow where
  parseJSON :: Value -> Parser ResultRow
parseJSON =
    String -> (Object -> Parser ResultRow) -> Value -> Parser ResultRow
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResultRow"
      ( \Object
x ->
          [ResultRowValue] -> [ResultRowValue] -> ResultRow
ResultRow'
            ([ResultRowValue] -> [ResultRowValue] -> ResultRow)
-> Parser [ResultRowValue]
-> Parser ([ResultRowValue] -> ResultRow)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe [ResultRowValue])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GroupedBys" Parser (Maybe [ResultRowValue])
-> [ResultRowValue] -> Parser [ResultRowValue]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [ResultRowValue]
forall a. Monoid a => a
Prelude.mempty)
            Parser ([ResultRowValue] -> ResultRow)
-> Parser [ResultRowValue] -> Parser ResultRow
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [ResultRowValue])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Values" Parser (Maybe [ResultRowValue])
-> [ResultRowValue] -> Parser [ResultRowValue]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [ResultRowValue]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResultRow

instance Prelude.NFData ResultRow