{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataBrew.Types.ColumnStatisticsConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataBrew.Types.ColumnSelector
import Amazonka.DataBrew.Types.StatisticsConfiguration
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
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]
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
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.
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'
    { $sel:selectors:ColumnStatisticsConfiguration' :: Maybe (NonEmpty ColumnSelector)
selectors =
        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 :: Lens'
  ColumnStatisticsConfiguration (Maybe (NonEmpty ColumnSelector))
columnStatisticsConfiguration_selectors = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' ColumnStatisticsConfiguration StatisticsConfiguration
columnStatisticsConfiguration_statistics = 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 Data.FromJSON ColumnStatisticsConfiguration where
  parseJSON :: Value -> Parser ColumnStatisticsConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnStatisticsConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty ColumnSelector)
-> StatisticsConfiguration -> ColumnStatisticsConfiguration
ColumnStatisticsConfiguration'
            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
"Selectors")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Statistics")
      )

instance
  Prelude.Hashable
    ColumnStatisticsConfiguration
  where
  hashWithSalt :: Int -> ColumnStatisticsConfiguration -> Int
hashWithSalt Int
_salt ColumnStatisticsConfiguration' {Maybe (NonEmpty ColumnSelector)
StatisticsConfiguration
statistics :: StatisticsConfiguration
selectors :: Maybe (NonEmpty ColumnSelector)
$sel:statistics:ColumnStatisticsConfiguration' :: ColumnStatisticsConfiguration -> StatisticsConfiguration
$sel:selectors:ColumnStatisticsConfiguration' :: ColumnStatisticsConfiguration -> Maybe (NonEmpty ColumnSelector)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty ColumnSelector)
selectors
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StatisticsConfiguration
statistics

instance Prelude.NFData ColumnStatisticsConfiguration where
  rnf :: ColumnStatisticsConfiguration -> ()
rnf ColumnStatisticsConfiguration' {Maybe (NonEmpty ColumnSelector)
StatisticsConfiguration
statistics :: StatisticsConfiguration
selectors :: Maybe (NonEmpty ColumnSelector)
$sel:statistics:ColumnStatisticsConfiguration' :: ColumnStatisticsConfiguration -> StatisticsConfiguration
$sel:selectors:ColumnStatisticsConfiguration' :: ColumnStatisticsConfiguration -> Maybe (NonEmpty ColumnSelector)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty ColumnSelector)
selectors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf StatisticsConfiguration
statistics

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Selectors" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ColumnSelector)
selectors,
            forall a. a -> Maybe a
Prelude.Just (Key
"Statistics" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= StatisticsConfiguration
statistics)
          ]
      )