{-# 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.DataBrew.Types.StatisticsConfiguration
-- 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.DataBrew.Types.StatisticsConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.StatisticOverride
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration of evaluations for a profile job. This configuration can
-- be used to select evaluations and override the parameters of selected
-- evaluations.
--
-- /See:/ 'newStatisticsConfiguration' smart constructor.
data StatisticsConfiguration = StatisticsConfiguration'
  { -- | List of overrides for evaluations.
    StatisticsConfiguration -> Maybe (NonEmpty StatisticOverride)
overrides :: Prelude.Maybe (Prelude.NonEmpty StatisticOverride),
    -- | List of included evaluations. When the list is undefined, all supported
    -- evaluations will be included.
    StatisticsConfiguration -> Maybe (NonEmpty Text)
includedStatistics :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (StatisticsConfiguration -> StatisticsConfiguration -> Bool
(StatisticsConfiguration -> StatisticsConfiguration -> Bool)
-> (StatisticsConfiguration -> StatisticsConfiguration -> Bool)
-> Eq StatisticsConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatisticsConfiguration -> StatisticsConfiguration -> Bool
$c/= :: StatisticsConfiguration -> StatisticsConfiguration -> Bool
== :: StatisticsConfiguration -> StatisticsConfiguration -> Bool
$c== :: StatisticsConfiguration -> StatisticsConfiguration -> Bool
Prelude.Eq, ReadPrec [StatisticsConfiguration]
ReadPrec StatisticsConfiguration
Int -> ReadS StatisticsConfiguration
ReadS [StatisticsConfiguration]
(Int -> ReadS StatisticsConfiguration)
-> ReadS [StatisticsConfiguration]
-> ReadPrec StatisticsConfiguration
-> ReadPrec [StatisticsConfiguration]
-> Read StatisticsConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatisticsConfiguration]
$creadListPrec :: ReadPrec [StatisticsConfiguration]
readPrec :: ReadPrec StatisticsConfiguration
$creadPrec :: ReadPrec StatisticsConfiguration
readList :: ReadS [StatisticsConfiguration]
$creadList :: ReadS [StatisticsConfiguration]
readsPrec :: Int -> ReadS StatisticsConfiguration
$creadsPrec :: Int -> ReadS StatisticsConfiguration
Prelude.Read, Int -> StatisticsConfiguration -> ShowS
[StatisticsConfiguration] -> ShowS
StatisticsConfiguration -> String
(Int -> StatisticsConfiguration -> ShowS)
-> (StatisticsConfiguration -> String)
-> ([StatisticsConfiguration] -> ShowS)
-> Show StatisticsConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatisticsConfiguration] -> ShowS
$cshowList :: [StatisticsConfiguration] -> ShowS
show :: StatisticsConfiguration -> String
$cshow :: StatisticsConfiguration -> String
showsPrec :: Int -> StatisticsConfiguration -> ShowS
$cshowsPrec :: Int -> StatisticsConfiguration -> ShowS
Prelude.Show, (forall x.
 StatisticsConfiguration -> Rep StatisticsConfiguration x)
-> (forall x.
    Rep StatisticsConfiguration x -> StatisticsConfiguration)
-> Generic StatisticsConfiguration
forall x. Rep StatisticsConfiguration x -> StatisticsConfiguration
forall x. StatisticsConfiguration -> Rep StatisticsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatisticsConfiguration x -> StatisticsConfiguration
$cfrom :: forall x. StatisticsConfiguration -> Rep StatisticsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'StatisticsConfiguration' 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:
--
-- 'overrides', 'statisticsConfiguration_overrides' - List of overrides for evaluations.
--
-- 'includedStatistics', 'statisticsConfiguration_includedStatistics' - List of included evaluations. When the list is undefined, all supported
-- evaluations will be included.
newStatisticsConfiguration ::
  StatisticsConfiguration
newStatisticsConfiguration :: StatisticsConfiguration
newStatisticsConfiguration =
  StatisticsConfiguration' :: Maybe (NonEmpty StatisticOverride)
-> Maybe (NonEmpty Text) -> StatisticsConfiguration
StatisticsConfiguration'
    { $sel:overrides:StatisticsConfiguration' :: Maybe (NonEmpty StatisticOverride)
overrides =
        Maybe (NonEmpty StatisticOverride)
forall a. Maybe a
Prelude.Nothing,
      $sel:includedStatistics:StatisticsConfiguration' :: Maybe (NonEmpty Text)
includedStatistics = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | List of overrides for evaluations.
statisticsConfiguration_overrides :: Lens.Lens' StatisticsConfiguration (Prelude.Maybe (Prelude.NonEmpty StatisticOverride))
statisticsConfiguration_overrides :: (Maybe (NonEmpty StatisticOverride)
 -> f (Maybe (NonEmpty StatisticOverride)))
-> StatisticsConfiguration -> f StatisticsConfiguration
statisticsConfiguration_overrides = (StatisticsConfiguration -> Maybe (NonEmpty StatisticOverride))
-> (StatisticsConfiguration
    -> Maybe (NonEmpty StatisticOverride) -> StatisticsConfiguration)
-> Lens
     StatisticsConfiguration
     StatisticsConfiguration
     (Maybe (NonEmpty StatisticOverride))
     (Maybe (NonEmpty StatisticOverride))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatisticsConfiguration' {Maybe (NonEmpty StatisticOverride)
overrides :: Maybe (NonEmpty StatisticOverride)
$sel:overrides:StatisticsConfiguration' :: StatisticsConfiguration -> Maybe (NonEmpty StatisticOverride)
overrides} -> Maybe (NonEmpty StatisticOverride)
overrides) (\s :: StatisticsConfiguration
s@StatisticsConfiguration' {} Maybe (NonEmpty StatisticOverride)
a -> StatisticsConfiguration
s {$sel:overrides:StatisticsConfiguration' :: Maybe (NonEmpty StatisticOverride)
overrides = Maybe (NonEmpty StatisticOverride)
a} :: StatisticsConfiguration) ((Maybe (NonEmpty StatisticOverride)
  -> f (Maybe (NonEmpty StatisticOverride)))
 -> StatisticsConfiguration -> f StatisticsConfiguration)
-> ((Maybe (NonEmpty StatisticOverride)
     -> f (Maybe (NonEmpty StatisticOverride)))
    -> Maybe (NonEmpty StatisticOverride)
    -> f (Maybe (NonEmpty StatisticOverride)))
-> (Maybe (NonEmpty StatisticOverride)
    -> f (Maybe (NonEmpty StatisticOverride)))
-> StatisticsConfiguration
-> f StatisticsConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty StatisticOverride)
  (NonEmpty StatisticOverride)
  (NonEmpty StatisticOverride)
  (NonEmpty StatisticOverride)
-> Iso
     (Maybe (NonEmpty StatisticOverride))
     (Maybe (NonEmpty StatisticOverride))
     (Maybe (NonEmpty StatisticOverride))
     (Maybe (NonEmpty StatisticOverride))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty StatisticOverride)
  (NonEmpty StatisticOverride)
  (NonEmpty StatisticOverride)
  (NonEmpty StatisticOverride)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | List of included evaluations. When the list is undefined, all supported
-- evaluations will be included.
statisticsConfiguration_includedStatistics :: Lens.Lens' StatisticsConfiguration (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
statisticsConfiguration_includedStatistics :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> StatisticsConfiguration -> f StatisticsConfiguration
statisticsConfiguration_includedStatistics = (StatisticsConfiguration -> Maybe (NonEmpty Text))
-> (StatisticsConfiguration
    -> Maybe (NonEmpty Text) -> StatisticsConfiguration)
-> Lens
     StatisticsConfiguration
     StatisticsConfiguration
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatisticsConfiguration' {Maybe (NonEmpty Text)
includedStatistics :: Maybe (NonEmpty Text)
$sel:includedStatistics:StatisticsConfiguration' :: StatisticsConfiguration -> Maybe (NonEmpty Text)
includedStatistics} -> Maybe (NonEmpty Text)
includedStatistics) (\s :: StatisticsConfiguration
s@StatisticsConfiguration' {} Maybe (NonEmpty Text)
a -> StatisticsConfiguration
s {$sel:includedStatistics:StatisticsConfiguration' :: Maybe (NonEmpty Text)
includedStatistics = Maybe (NonEmpty Text)
a} :: StatisticsConfiguration) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> StatisticsConfiguration -> f StatisticsConfiguration)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> StatisticsConfiguration
-> f StatisticsConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON StatisticsConfiguration where
  parseJSON :: Value -> Parser StatisticsConfiguration
parseJSON =
    String
-> (Object -> Parser StatisticsConfiguration)
-> Value
-> Parser StatisticsConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StatisticsConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty StatisticOverride)
-> Maybe (NonEmpty Text) -> StatisticsConfiguration
StatisticsConfiguration'
            (Maybe (NonEmpty StatisticOverride)
 -> Maybe (NonEmpty Text) -> StatisticsConfiguration)
-> Parser (Maybe (NonEmpty StatisticOverride))
-> Parser (Maybe (NonEmpty Text) -> StatisticsConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty StatisticOverride))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Overrides")
            Parser (Maybe (NonEmpty Text) -> StatisticsConfiguration)
-> Parser (Maybe (NonEmpty Text)) -> Parser StatisticsConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IncludedStatistics")
      )

instance Prelude.Hashable StatisticsConfiguration

instance Prelude.NFData StatisticsConfiguration

instance Core.ToJSON StatisticsConfiguration where
  toJSON :: StatisticsConfiguration -> Value
toJSON StatisticsConfiguration' {Maybe (NonEmpty Text)
Maybe (NonEmpty StatisticOverride)
includedStatistics :: Maybe (NonEmpty Text)
overrides :: Maybe (NonEmpty StatisticOverride)
$sel:includedStatistics:StatisticsConfiguration' :: StatisticsConfiguration -> Maybe (NonEmpty Text)
$sel:overrides:StatisticsConfiguration' :: StatisticsConfiguration -> Maybe (NonEmpty StatisticOverride)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Overrides" Text -> NonEmpty StatisticOverride -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty StatisticOverride -> Pair)
-> Maybe (NonEmpty StatisticOverride) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty StatisticOverride)
overrides,
            (Text
"IncludedStatistics" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
includedStatistics
          ]
      )