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

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

-- | A sample configuration for profile jobs only, which determines the
-- number of rows on which the profile job is run. If a @JobSample@ value
-- isn\'t provided, the default is used. The default value is CUSTOM_ROWS
-- for the mode parameter and 20,000 for the size parameter.
--
-- /See:/ 'newJobSample' smart constructor.
data JobSample = JobSample'
  { -- | The @Size@ parameter is only required when the mode is CUSTOM_ROWS. The
    -- profile job is run on the specified number of rows. The maximum value
    -- for size is Long.MAX_VALUE.
    --
    -- Long.MAX_VALUE = 9223372036854775807
    JobSample -> Maybe Integer
size :: Prelude.Maybe Prelude.Integer,
    -- | A value that determines whether the profile job is run on the entire
    -- dataset or a specified number of rows. This value must be one of the
    -- following:
    --
    -- -   FULL_DATASET - The profile job is run on the entire dataset.
    --
    -- -   CUSTOM_ROWS - The profile job is run on the number of rows specified
    --     in the @Size@ parameter.
    JobSample -> Maybe SampleMode
mode :: Prelude.Maybe SampleMode
  }
  deriving (JobSample -> JobSample -> Bool
(JobSample -> JobSample -> Bool)
-> (JobSample -> JobSample -> Bool) -> Eq JobSample
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobSample -> JobSample -> Bool
$c/= :: JobSample -> JobSample -> Bool
== :: JobSample -> JobSample -> Bool
$c== :: JobSample -> JobSample -> Bool
Prelude.Eq, ReadPrec [JobSample]
ReadPrec JobSample
Int -> ReadS JobSample
ReadS [JobSample]
(Int -> ReadS JobSample)
-> ReadS [JobSample]
-> ReadPrec JobSample
-> ReadPrec [JobSample]
-> Read JobSample
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobSample]
$creadListPrec :: ReadPrec [JobSample]
readPrec :: ReadPrec JobSample
$creadPrec :: ReadPrec JobSample
readList :: ReadS [JobSample]
$creadList :: ReadS [JobSample]
readsPrec :: Int -> ReadS JobSample
$creadsPrec :: Int -> ReadS JobSample
Prelude.Read, Int -> JobSample -> ShowS
[JobSample] -> ShowS
JobSample -> String
(Int -> JobSample -> ShowS)
-> (JobSample -> String)
-> ([JobSample] -> ShowS)
-> Show JobSample
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobSample] -> ShowS
$cshowList :: [JobSample] -> ShowS
show :: JobSample -> String
$cshow :: JobSample -> String
showsPrec :: Int -> JobSample -> ShowS
$cshowsPrec :: Int -> JobSample -> ShowS
Prelude.Show, (forall x. JobSample -> Rep JobSample x)
-> (forall x. Rep JobSample x -> JobSample) -> Generic JobSample
forall x. Rep JobSample x -> JobSample
forall x. JobSample -> Rep JobSample x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobSample x -> JobSample
$cfrom :: forall x. JobSample -> Rep JobSample x
Prelude.Generic)

-- |
-- Create a value of 'JobSample' 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:
--
-- 'size', 'jobSample_size' - The @Size@ parameter is only required when the mode is CUSTOM_ROWS. The
-- profile job is run on the specified number of rows. The maximum value
-- for size is Long.MAX_VALUE.
--
-- Long.MAX_VALUE = 9223372036854775807
--
-- 'mode', 'jobSample_mode' - A value that determines whether the profile job is run on the entire
-- dataset or a specified number of rows. This value must be one of the
-- following:
--
-- -   FULL_DATASET - The profile job is run on the entire dataset.
--
-- -   CUSTOM_ROWS - The profile job is run on the number of rows specified
--     in the @Size@ parameter.
newJobSample ::
  JobSample
newJobSample :: JobSample
newJobSample =
  JobSample' :: Maybe Integer -> Maybe SampleMode -> JobSample
JobSample'
    { $sel:size:JobSample' :: Maybe Integer
size = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:mode:JobSample' :: Maybe SampleMode
mode = Maybe SampleMode
forall a. Maybe a
Prelude.Nothing
    }

-- | The @Size@ parameter is only required when the mode is CUSTOM_ROWS. The
-- profile job is run on the specified number of rows. The maximum value
-- for size is Long.MAX_VALUE.
--
-- Long.MAX_VALUE = 9223372036854775807
jobSample_size :: Lens.Lens' JobSample (Prelude.Maybe Prelude.Integer)
jobSample_size :: (Maybe Integer -> f (Maybe Integer)) -> JobSample -> f JobSample
jobSample_size = (JobSample -> Maybe Integer)
-> (JobSample -> Maybe Integer -> JobSample)
-> Lens JobSample JobSample (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSample' {Maybe Integer
size :: Maybe Integer
$sel:size:JobSample' :: JobSample -> Maybe Integer
size} -> Maybe Integer
size) (\s :: JobSample
s@JobSample' {} Maybe Integer
a -> JobSample
s {$sel:size:JobSample' :: Maybe Integer
size = Maybe Integer
a} :: JobSample)

-- | A value that determines whether the profile job is run on the entire
-- dataset or a specified number of rows. This value must be one of the
-- following:
--
-- -   FULL_DATASET - The profile job is run on the entire dataset.
--
-- -   CUSTOM_ROWS - The profile job is run on the number of rows specified
--     in the @Size@ parameter.
jobSample_mode :: Lens.Lens' JobSample (Prelude.Maybe SampleMode)
jobSample_mode :: (Maybe SampleMode -> f (Maybe SampleMode))
-> JobSample -> f JobSample
jobSample_mode = (JobSample -> Maybe SampleMode)
-> (JobSample -> Maybe SampleMode -> JobSample)
-> Lens JobSample JobSample (Maybe SampleMode) (Maybe SampleMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSample' {Maybe SampleMode
mode :: Maybe SampleMode
$sel:mode:JobSample' :: JobSample -> Maybe SampleMode
mode} -> Maybe SampleMode
mode) (\s :: JobSample
s@JobSample' {} Maybe SampleMode
a -> JobSample
s {$sel:mode:JobSample' :: Maybe SampleMode
mode = Maybe SampleMode
a} :: JobSample)

instance Core.FromJSON JobSample where
  parseJSON :: Value -> Parser JobSample
parseJSON =
    String -> (Object -> Parser JobSample) -> Value -> Parser JobSample
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JobSample"
      ( \Object
x ->
          Maybe Integer -> Maybe SampleMode -> JobSample
JobSample'
            (Maybe Integer -> Maybe SampleMode -> JobSample)
-> Parser (Maybe Integer) -> Parser (Maybe SampleMode -> JobSample)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Size") Parser (Maybe SampleMode -> JobSample)
-> Parser (Maybe SampleMode) -> Parser JobSample
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SampleMode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Mode")
      )

instance Prelude.Hashable JobSample

instance Prelude.NFData JobSample

instance Core.ToJSON JobSample where
  toJSON :: JobSample -> Value
toJSON JobSample' {Maybe Integer
Maybe SampleMode
mode :: Maybe SampleMode
size :: Maybe Integer
$sel:mode:JobSample' :: JobSample -> Maybe SampleMode
$sel:size:JobSample' :: JobSample -> Maybe Integer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Size" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
size,
            (Text
"Mode" Text -> SampleMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SampleMode -> Pair) -> Maybe SampleMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SampleMode
mode
          ]
      )