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

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.ColumnSelector
import Amazonka.DataBrew.Types.StatisticsConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration for column evaluations for a profile job.
-- ColumnStatisticsConfiguration can be used to select evaluations and
-- override parameters of evaluations for particular columns.
--
-- /See:/ 'newColumnStatisticsConfiguration' smart constructor.
data ColumnStatisticsConfiguration = ColumnStatisticsConfiguration'
  { -- | List of column selectors. Selectors can be used to select columns from
    -- the dataset. When selectors are undefined, configuration will be applied
    -- to all supported columns.
    ColumnStatisticsConfiguration -> Maybe (NonEmpty ColumnSelector)
selectors :: Prelude.Maybe (Prelude.NonEmpty ColumnSelector),
    -- | Configuration for evaluations. Statistics can be used to select
    -- evaluations and override parameters of evaluations.
    ColumnStatisticsConfiguration -> StatisticsConfiguration
statistics :: StatisticsConfiguration
  }
  deriving (ColumnStatisticsConfiguration
-> ColumnStatisticsConfiguration -> Bool
(ColumnStatisticsConfiguration
 -> ColumnStatisticsConfiguration -> Bool)
-> (ColumnStatisticsConfiguration
    -> ColumnStatisticsConfiguration -> Bool)
-> Eq ColumnStatisticsConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnStatisticsConfiguration
-> ColumnStatisticsConfiguration -> Bool
$c/= :: ColumnStatisticsConfiguration
-> ColumnStatisticsConfiguration -> Bool
== :: ColumnStatisticsConfiguration
-> ColumnStatisticsConfiguration -> Bool
$c== :: ColumnStatisticsConfiguration
-> ColumnStatisticsConfiguration -> Bool
Prelude.Eq, ReadPrec [ColumnStatisticsConfiguration]
ReadPrec ColumnStatisticsConfiguration
Int -> ReadS ColumnStatisticsConfiguration
ReadS [ColumnStatisticsConfiguration]
(Int -> ReadS ColumnStatisticsConfiguration)
-> ReadS [ColumnStatisticsConfiguration]
-> ReadPrec ColumnStatisticsConfiguration
-> ReadPrec [ColumnStatisticsConfiguration]
-> Read ColumnStatisticsConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnStatisticsConfiguration]
$creadListPrec :: ReadPrec [ColumnStatisticsConfiguration]
readPrec :: ReadPrec ColumnStatisticsConfiguration
$creadPrec :: ReadPrec ColumnStatisticsConfiguration
readList :: ReadS [ColumnStatisticsConfiguration]
$creadList :: ReadS [ColumnStatisticsConfiguration]
readsPrec :: Int -> ReadS ColumnStatisticsConfiguration
$creadsPrec :: Int -> ReadS ColumnStatisticsConfiguration
Prelude.Read, Int -> ColumnStatisticsConfiguration -> ShowS
[ColumnStatisticsConfiguration] -> ShowS
ColumnStatisticsConfiguration -> String
(Int -> ColumnStatisticsConfiguration -> ShowS)
-> (ColumnStatisticsConfiguration -> String)
-> ([ColumnStatisticsConfiguration] -> ShowS)
-> Show ColumnStatisticsConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnStatisticsConfiguration] -> ShowS
$cshowList :: [ColumnStatisticsConfiguration] -> ShowS
show :: ColumnStatisticsConfiguration -> String
$cshow :: ColumnStatisticsConfiguration -> String
showsPrec :: Int -> ColumnStatisticsConfiguration -> ShowS
$cshowsPrec :: Int -> ColumnStatisticsConfiguration -> ShowS
Prelude.Show, (forall x.
 ColumnStatisticsConfiguration
 -> Rep ColumnStatisticsConfiguration x)
-> (forall x.
    Rep ColumnStatisticsConfiguration x
    -> ColumnStatisticsConfiguration)
-> Generic ColumnStatisticsConfiguration
forall x.
Rep ColumnStatisticsConfiguration x
-> ColumnStatisticsConfiguration
forall x.
ColumnStatisticsConfiguration
-> Rep ColumnStatisticsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ColumnStatisticsConfiguration x
-> ColumnStatisticsConfiguration
$cfrom :: forall x.
ColumnStatisticsConfiguration
-> Rep ColumnStatisticsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ColumnStatisticsConfiguration' 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:
--
-- 'selectors', 'columnStatisticsConfiguration_selectors' - List of column selectors. Selectors can be used to select columns from
-- the dataset. When selectors are undefined, configuration will be applied
-- to all supported columns.
--
-- 'statistics', 'columnStatisticsConfiguration_statistics' - Configuration for evaluations. Statistics can be used to select
-- evaluations and override parameters of evaluations.
newColumnStatisticsConfiguration ::
  -- | 'statistics'
  StatisticsConfiguration ->
  ColumnStatisticsConfiguration
newColumnStatisticsConfiguration :: StatisticsConfiguration -> ColumnStatisticsConfiguration
newColumnStatisticsConfiguration StatisticsConfiguration
pStatistics_ =
  ColumnStatisticsConfiguration' :: Maybe (NonEmpty ColumnSelector)
-> StatisticsConfiguration -> ColumnStatisticsConfiguration
ColumnStatisticsConfiguration'
    { $sel:selectors:ColumnStatisticsConfiguration' :: Maybe (NonEmpty ColumnSelector)
selectors =
        Maybe (NonEmpty ColumnSelector)
forall a. Maybe a
Prelude.Nothing,
      $sel:statistics:ColumnStatisticsConfiguration' :: StatisticsConfiguration
statistics = StatisticsConfiguration
pStatistics_
    }

-- | List of column selectors. Selectors can be used to select columns from
-- the dataset. When selectors are undefined, configuration will be applied
-- to all supported columns.
columnStatisticsConfiguration_selectors :: Lens.Lens' ColumnStatisticsConfiguration (Prelude.Maybe (Prelude.NonEmpty ColumnSelector))
columnStatisticsConfiguration_selectors :: (Maybe (NonEmpty ColumnSelector)
 -> f (Maybe (NonEmpty ColumnSelector)))
-> ColumnStatisticsConfiguration -> f ColumnStatisticsConfiguration
columnStatisticsConfiguration_selectors = (ColumnStatisticsConfiguration -> Maybe (NonEmpty ColumnSelector))
-> (ColumnStatisticsConfiguration
    -> Maybe (NonEmpty ColumnSelector)
    -> ColumnStatisticsConfiguration)
-> Lens
     ColumnStatisticsConfiguration
     ColumnStatisticsConfiguration
     (Maybe (NonEmpty ColumnSelector))
     (Maybe (NonEmpty ColumnSelector))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnStatisticsConfiguration' {Maybe (NonEmpty ColumnSelector)
selectors :: Maybe (NonEmpty ColumnSelector)
$sel:selectors:ColumnStatisticsConfiguration' :: ColumnStatisticsConfiguration -> Maybe (NonEmpty ColumnSelector)
selectors} -> Maybe (NonEmpty ColumnSelector)
selectors) (\s :: ColumnStatisticsConfiguration
s@ColumnStatisticsConfiguration' {} Maybe (NonEmpty ColumnSelector)
a -> ColumnStatisticsConfiguration
s {$sel:selectors:ColumnStatisticsConfiguration' :: Maybe (NonEmpty ColumnSelector)
selectors = Maybe (NonEmpty ColumnSelector)
a} :: ColumnStatisticsConfiguration) ((Maybe (NonEmpty ColumnSelector)
  -> f (Maybe (NonEmpty ColumnSelector)))
 -> ColumnStatisticsConfiguration
 -> f ColumnStatisticsConfiguration)
-> ((Maybe (NonEmpty ColumnSelector)
     -> f (Maybe (NonEmpty ColumnSelector)))
    -> Maybe (NonEmpty ColumnSelector)
    -> f (Maybe (NonEmpty ColumnSelector)))
-> (Maybe (NonEmpty ColumnSelector)
    -> f (Maybe (NonEmpty ColumnSelector)))
-> ColumnStatisticsConfiguration
-> f ColumnStatisticsConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ColumnSelector)
  (NonEmpty ColumnSelector)
  (NonEmpty ColumnSelector)
  (NonEmpty ColumnSelector)
-> Iso
     (Maybe (NonEmpty ColumnSelector))
     (Maybe (NonEmpty ColumnSelector))
     (Maybe (NonEmpty ColumnSelector))
     (Maybe (NonEmpty ColumnSelector))
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 ColumnSelector)
  (NonEmpty ColumnSelector)
  (NonEmpty ColumnSelector)
  (NonEmpty ColumnSelector)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Configuration for evaluations. Statistics can be used to select
-- evaluations and override parameters of evaluations.
columnStatisticsConfiguration_statistics :: Lens.Lens' ColumnStatisticsConfiguration StatisticsConfiguration
columnStatisticsConfiguration_statistics :: (StatisticsConfiguration -> f StatisticsConfiguration)
-> ColumnStatisticsConfiguration -> f ColumnStatisticsConfiguration
columnStatisticsConfiguration_statistics = (ColumnStatisticsConfiguration -> StatisticsConfiguration)
-> (ColumnStatisticsConfiguration
    -> StatisticsConfiguration -> ColumnStatisticsConfiguration)
-> Lens
     ColumnStatisticsConfiguration
     ColumnStatisticsConfiguration
     StatisticsConfiguration
     StatisticsConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnStatisticsConfiguration' {StatisticsConfiguration
statistics :: StatisticsConfiguration
$sel:statistics:ColumnStatisticsConfiguration' :: ColumnStatisticsConfiguration -> StatisticsConfiguration
statistics} -> StatisticsConfiguration
statistics) (\s :: ColumnStatisticsConfiguration
s@ColumnStatisticsConfiguration' {} StatisticsConfiguration
a -> ColumnStatisticsConfiguration
s {$sel:statistics:ColumnStatisticsConfiguration' :: StatisticsConfiguration
statistics = StatisticsConfiguration
a} :: ColumnStatisticsConfiguration)

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

instance
  Prelude.Hashable
    ColumnStatisticsConfiguration

instance Prelude.NFData ColumnStatisticsConfiguration

instance Core.ToJSON ColumnStatisticsConfiguration where
  toJSON :: ColumnStatisticsConfiguration -> Value
toJSON ColumnStatisticsConfiguration' {Maybe (NonEmpty ColumnSelector)
StatisticsConfiguration
statistics :: StatisticsConfiguration
selectors :: Maybe (NonEmpty ColumnSelector)
$sel:statistics:ColumnStatisticsConfiguration' :: ColumnStatisticsConfiguration -> StatisticsConfiguration
$sel:selectors:ColumnStatisticsConfiguration' :: ColumnStatisticsConfiguration -> Maybe (NonEmpty ColumnSelector)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Selectors" Text -> NonEmpty ColumnSelector -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty ColumnSelector -> Pair)
-> Maybe (NonEmpty ColumnSelector) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ColumnSelector)
selectors,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Statistics" Text -> StatisticsConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StatisticsConfiguration
statistics)
          ]
      )