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

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.Order
import Amazonka.DataBrew.Types.OrderedBy
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a limit imposed on number of Amazon S3 files that should be
-- selected for a dataset from a connected Amazon S3 path.
--
-- /See:/ 'newFilesLimit' smart constructor.
data FilesLimit = FilesLimit'
  { -- | A criteria to use for Amazon S3 files sorting before their selection. By
    -- default uses LAST_MODIFIED_DATE as a sorting criteria. Currently it\'s
    -- the only allowed value.
    FilesLimit -> Maybe OrderedBy
orderedBy :: Prelude.Maybe OrderedBy,
    -- | A criteria to use for Amazon S3 files sorting before their selection. By
    -- default uses DESCENDING order, i.e. most recent files are selected
    -- first. Anotherpossible value is ASCENDING.
    FilesLimit -> Maybe Order
order :: Prelude.Maybe Order,
    -- | The number of Amazon S3 files to select.
    FilesLimit -> Natural
maxFiles :: Prelude.Natural
  }
  deriving (FilesLimit -> FilesLimit -> Bool
(FilesLimit -> FilesLimit -> Bool)
-> (FilesLimit -> FilesLimit -> Bool) -> Eq FilesLimit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FilesLimit -> FilesLimit -> Bool
$c/= :: FilesLimit -> FilesLimit -> Bool
== :: FilesLimit -> FilesLimit -> Bool
$c== :: FilesLimit -> FilesLimit -> Bool
Prelude.Eq, ReadPrec [FilesLimit]
ReadPrec FilesLimit
Int -> ReadS FilesLimit
ReadS [FilesLimit]
(Int -> ReadS FilesLimit)
-> ReadS [FilesLimit]
-> ReadPrec FilesLimit
-> ReadPrec [FilesLimit]
-> Read FilesLimit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FilesLimit]
$creadListPrec :: ReadPrec [FilesLimit]
readPrec :: ReadPrec FilesLimit
$creadPrec :: ReadPrec FilesLimit
readList :: ReadS [FilesLimit]
$creadList :: ReadS [FilesLimit]
readsPrec :: Int -> ReadS FilesLimit
$creadsPrec :: Int -> ReadS FilesLimit
Prelude.Read, Int -> FilesLimit -> ShowS
[FilesLimit] -> ShowS
FilesLimit -> String
(Int -> FilesLimit -> ShowS)
-> (FilesLimit -> String)
-> ([FilesLimit] -> ShowS)
-> Show FilesLimit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FilesLimit] -> ShowS
$cshowList :: [FilesLimit] -> ShowS
show :: FilesLimit -> String
$cshow :: FilesLimit -> String
showsPrec :: Int -> FilesLimit -> ShowS
$cshowsPrec :: Int -> FilesLimit -> ShowS
Prelude.Show, (forall x. FilesLimit -> Rep FilesLimit x)
-> (forall x. Rep FilesLimit x -> FilesLimit) -> Generic FilesLimit
forall x. Rep FilesLimit x -> FilesLimit
forall x. FilesLimit -> Rep FilesLimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FilesLimit x -> FilesLimit
$cfrom :: forall x. FilesLimit -> Rep FilesLimit x
Prelude.Generic)

-- |
-- Create a value of 'FilesLimit' 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:
--
-- 'orderedBy', 'filesLimit_orderedBy' - A criteria to use for Amazon S3 files sorting before their selection. By
-- default uses LAST_MODIFIED_DATE as a sorting criteria. Currently it\'s
-- the only allowed value.
--
-- 'order', 'filesLimit_order' - A criteria to use for Amazon S3 files sorting before their selection. By
-- default uses DESCENDING order, i.e. most recent files are selected
-- first. Anotherpossible value is ASCENDING.
--
-- 'maxFiles', 'filesLimit_maxFiles' - The number of Amazon S3 files to select.
newFilesLimit ::
  -- | 'maxFiles'
  Prelude.Natural ->
  FilesLimit
newFilesLimit :: Natural -> FilesLimit
newFilesLimit Natural
pMaxFiles_ =
  FilesLimit' :: Maybe OrderedBy -> Maybe Order -> Natural -> FilesLimit
FilesLimit'
    { $sel:orderedBy:FilesLimit' :: Maybe OrderedBy
orderedBy = Maybe OrderedBy
forall a. Maybe a
Prelude.Nothing,
      $sel:order:FilesLimit' :: Maybe Order
order = Maybe Order
forall a. Maybe a
Prelude.Nothing,
      $sel:maxFiles:FilesLimit' :: Natural
maxFiles = Natural
pMaxFiles_
    }

-- | A criteria to use for Amazon S3 files sorting before their selection. By
-- default uses LAST_MODIFIED_DATE as a sorting criteria. Currently it\'s
-- the only allowed value.
filesLimit_orderedBy :: Lens.Lens' FilesLimit (Prelude.Maybe OrderedBy)
filesLimit_orderedBy :: (Maybe OrderedBy -> f (Maybe OrderedBy))
-> FilesLimit -> f FilesLimit
filesLimit_orderedBy = (FilesLimit -> Maybe OrderedBy)
-> (FilesLimit -> Maybe OrderedBy -> FilesLimit)
-> Lens FilesLimit FilesLimit (Maybe OrderedBy) (Maybe OrderedBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilesLimit' {Maybe OrderedBy
orderedBy :: Maybe OrderedBy
$sel:orderedBy:FilesLimit' :: FilesLimit -> Maybe OrderedBy
orderedBy} -> Maybe OrderedBy
orderedBy) (\s :: FilesLimit
s@FilesLimit' {} Maybe OrderedBy
a -> FilesLimit
s {$sel:orderedBy:FilesLimit' :: Maybe OrderedBy
orderedBy = Maybe OrderedBy
a} :: FilesLimit)

-- | A criteria to use for Amazon S3 files sorting before their selection. By
-- default uses DESCENDING order, i.e. most recent files are selected
-- first. Anotherpossible value is ASCENDING.
filesLimit_order :: Lens.Lens' FilesLimit (Prelude.Maybe Order)
filesLimit_order :: (Maybe Order -> f (Maybe Order)) -> FilesLimit -> f FilesLimit
filesLimit_order = (FilesLimit -> Maybe Order)
-> (FilesLimit -> Maybe Order -> FilesLimit)
-> Lens FilesLimit FilesLimit (Maybe Order) (Maybe Order)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilesLimit' {Maybe Order
order :: Maybe Order
$sel:order:FilesLimit' :: FilesLimit -> Maybe Order
order} -> Maybe Order
order) (\s :: FilesLimit
s@FilesLimit' {} Maybe Order
a -> FilesLimit
s {$sel:order:FilesLimit' :: Maybe Order
order = Maybe Order
a} :: FilesLimit)

-- | The number of Amazon S3 files to select.
filesLimit_maxFiles :: Lens.Lens' FilesLimit Prelude.Natural
filesLimit_maxFiles :: (Natural -> f Natural) -> FilesLimit -> f FilesLimit
filesLimit_maxFiles = (FilesLimit -> Natural)
-> (FilesLimit -> Natural -> FilesLimit)
-> Lens FilesLimit FilesLimit Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilesLimit' {Natural
maxFiles :: Natural
$sel:maxFiles:FilesLimit' :: FilesLimit -> Natural
maxFiles} -> Natural
maxFiles) (\s :: FilesLimit
s@FilesLimit' {} Natural
a -> FilesLimit
s {$sel:maxFiles:FilesLimit' :: Natural
maxFiles = Natural
a} :: FilesLimit)

instance Core.FromJSON FilesLimit where
  parseJSON :: Value -> Parser FilesLimit
parseJSON =
    String
-> (Object -> Parser FilesLimit) -> Value -> Parser FilesLimit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FilesLimit"
      ( \Object
x ->
          Maybe OrderedBy -> Maybe Order -> Natural -> FilesLimit
FilesLimit'
            (Maybe OrderedBy -> Maybe Order -> Natural -> FilesLimit)
-> Parser (Maybe OrderedBy)
-> Parser (Maybe Order -> Natural -> FilesLimit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe OrderedBy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OrderedBy")
            Parser (Maybe Order -> Natural -> FilesLimit)
-> Parser (Maybe Order) -> Parser (Natural -> FilesLimit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Order)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Order")
            Parser (Natural -> FilesLimit)
-> Parser Natural -> Parser FilesLimit
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxFiles")
      )

instance Prelude.Hashable FilesLimit

instance Prelude.NFData FilesLimit

instance Core.ToJSON FilesLimit where
  toJSON :: FilesLimit -> Value
toJSON FilesLimit' {Natural
Maybe Order
Maybe OrderedBy
maxFiles :: Natural
order :: Maybe Order
orderedBy :: Maybe OrderedBy
$sel:maxFiles:FilesLimit' :: FilesLimit -> Natural
$sel:order:FilesLimit' :: FilesLimit -> Maybe Order
$sel:orderedBy:FilesLimit' :: FilesLimit -> Maybe OrderedBy
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OrderedBy" Text -> OrderedBy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OrderedBy -> Pair) -> Maybe OrderedBy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OrderedBy
orderedBy,
            (Text
"Order" Text -> Order -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Order -> Pair) -> Maybe Order -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Order
order,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MaxFiles" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maxFiles)
          ]
      )