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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.ResultRow
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:/ 'newBaseKpiResult' smart constructor.
data BaseKpiResult = BaseKpiResult'
  { -- | An array of objects that provides the results of a query that retrieved
    -- the data for a standard metric that applies to an application, campaign,
    -- or journey.
    BaseKpiResult -> [ResultRow]
rows :: [ResultRow]
  }
  deriving (BaseKpiResult -> BaseKpiResult -> Bool
(BaseKpiResult -> BaseKpiResult -> Bool)
-> (BaseKpiResult -> BaseKpiResult -> Bool) -> Eq BaseKpiResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BaseKpiResult -> BaseKpiResult -> Bool
$c/= :: BaseKpiResult -> BaseKpiResult -> Bool
== :: BaseKpiResult -> BaseKpiResult -> Bool
$c== :: BaseKpiResult -> BaseKpiResult -> Bool
Prelude.Eq, ReadPrec [BaseKpiResult]
ReadPrec BaseKpiResult
Int -> ReadS BaseKpiResult
ReadS [BaseKpiResult]
(Int -> ReadS BaseKpiResult)
-> ReadS [BaseKpiResult]
-> ReadPrec BaseKpiResult
-> ReadPrec [BaseKpiResult]
-> Read BaseKpiResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BaseKpiResult]
$creadListPrec :: ReadPrec [BaseKpiResult]
readPrec :: ReadPrec BaseKpiResult
$creadPrec :: ReadPrec BaseKpiResult
readList :: ReadS [BaseKpiResult]
$creadList :: ReadS [BaseKpiResult]
readsPrec :: Int -> ReadS BaseKpiResult
$creadsPrec :: Int -> ReadS BaseKpiResult
Prelude.Read, Int -> BaseKpiResult -> ShowS
[BaseKpiResult] -> ShowS
BaseKpiResult -> String
(Int -> BaseKpiResult -> ShowS)
-> (BaseKpiResult -> String)
-> ([BaseKpiResult] -> ShowS)
-> Show BaseKpiResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BaseKpiResult] -> ShowS
$cshowList :: [BaseKpiResult] -> ShowS
show :: BaseKpiResult -> String
$cshow :: BaseKpiResult -> String
showsPrec :: Int -> BaseKpiResult -> ShowS
$cshowsPrec :: Int -> BaseKpiResult -> ShowS
Prelude.Show, (forall x. BaseKpiResult -> Rep BaseKpiResult x)
-> (forall x. Rep BaseKpiResult x -> BaseKpiResult)
-> Generic BaseKpiResult
forall x. Rep BaseKpiResult x -> BaseKpiResult
forall x. BaseKpiResult -> Rep BaseKpiResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BaseKpiResult x -> BaseKpiResult
$cfrom :: forall x. BaseKpiResult -> Rep BaseKpiResult x
Prelude.Generic)

-- |
-- Create a value of 'BaseKpiResult' 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:
--
-- 'rows', 'baseKpiResult_rows' - An array of objects that provides the results of a query that retrieved
-- the data for a standard metric that applies to an application, campaign,
-- or journey.
newBaseKpiResult ::
  BaseKpiResult
newBaseKpiResult :: BaseKpiResult
newBaseKpiResult =
  BaseKpiResult' :: [ResultRow] -> BaseKpiResult
BaseKpiResult' {$sel:rows:BaseKpiResult' :: [ResultRow]
rows = [ResultRow]
forall a. Monoid a => a
Prelude.mempty}

-- | An array of objects that provides the results of a query that retrieved
-- the data for a standard metric that applies to an application, campaign,
-- or journey.
baseKpiResult_rows :: Lens.Lens' BaseKpiResult [ResultRow]
baseKpiResult_rows :: ([ResultRow] -> f [ResultRow]) -> BaseKpiResult -> f BaseKpiResult
baseKpiResult_rows = (BaseKpiResult -> [ResultRow])
-> (BaseKpiResult -> [ResultRow] -> BaseKpiResult)
-> Lens BaseKpiResult BaseKpiResult [ResultRow] [ResultRow]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BaseKpiResult' {[ResultRow]
rows :: [ResultRow]
$sel:rows:BaseKpiResult' :: BaseKpiResult -> [ResultRow]
rows} -> [ResultRow]
rows) (\s :: BaseKpiResult
s@BaseKpiResult' {} [ResultRow]
a -> BaseKpiResult
s {$sel:rows:BaseKpiResult' :: [ResultRow]
rows = [ResultRow]
a} :: BaseKpiResult) (([ResultRow] -> f [ResultRow])
 -> BaseKpiResult -> f BaseKpiResult)
-> (([ResultRow] -> f [ResultRow]) -> [ResultRow] -> f [ResultRow])
-> ([ResultRow] -> f [ResultRow])
-> BaseKpiResult
-> f BaseKpiResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ResultRow] -> f [ResultRow]) -> [ResultRow] -> f [ResultRow]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable BaseKpiResult

instance Prelude.NFData BaseKpiResult