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

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.DatasetParameter
import Amazonka.DataBrew.Types.FilesLimit
import Amazonka.DataBrew.Types.FilterExpression
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a set of options that define how DataBrew selects files for a
-- given Amazon S3 path in a dataset.
--
-- /See:/ 'newPathOptions' smart constructor.
data PathOptions = PathOptions'
  { -- | If provided, this structure defines a date range for matching Amazon S3
    -- objects based on their LastModifiedDate attribute in Amazon S3.
    PathOptions -> Maybe FilterExpression
lastModifiedDateCondition :: Prelude.Maybe FilterExpression,
    -- | A structure that maps names of parameters used in the Amazon S3 path of
    -- a dataset to their definitions.
    PathOptions -> Maybe (HashMap Text DatasetParameter)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text DatasetParameter),
    -- | If provided, this structure imposes a limit on a number of files that
    -- should be selected.
    PathOptions -> Maybe FilesLimit
filesLimit :: Prelude.Maybe FilesLimit
  }
  deriving (PathOptions -> PathOptions -> Bool
(PathOptions -> PathOptions -> Bool)
-> (PathOptions -> PathOptions -> Bool) -> Eq PathOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PathOptions -> PathOptions -> Bool
$c/= :: PathOptions -> PathOptions -> Bool
== :: PathOptions -> PathOptions -> Bool
$c== :: PathOptions -> PathOptions -> Bool
Prelude.Eq, ReadPrec [PathOptions]
ReadPrec PathOptions
Int -> ReadS PathOptions
ReadS [PathOptions]
(Int -> ReadS PathOptions)
-> ReadS [PathOptions]
-> ReadPrec PathOptions
-> ReadPrec [PathOptions]
-> Read PathOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PathOptions]
$creadListPrec :: ReadPrec [PathOptions]
readPrec :: ReadPrec PathOptions
$creadPrec :: ReadPrec PathOptions
readList :: ReadS [PathOptions]
$creadList :: ReadS [PathOptions]
readsPrec :: Int -> ReadS PathOptions
$creadsPrec :: Int -> ReadS PathOptions
Prelude.Read, Int -> PathOptions -> ShowS
[PathOptions] -> ShowS
PathOptions -> String
(Int -> PathOptions -> ShowS)
-> (PathOptions -> String)
-> ([PathOptions] -> ShowS)
-> Show PathOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PathOptions] -> ShowS
$cshowList :: [PathOptions] -> ShowS
show :: PathOptions -> String
$cshow :: PathOptions -> String
showsPrec :: Int -> PathOptions -> ShowS
$cshowsPrec :: Int -> PathOptions -> ShowS
Prelude.Show, (forall x. PathOptions -> Rep PathOptions x)
-> (forall x. Rep PathOptions x -> PathOptions)
-> Generic PathOptions
forall x. Rep PathOptions x -> PathOptions
forall x. PathOptions -> Rep PathOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PathOptions x -> PathOptions
$cfrom :: forall x. PathOptions -> Rep PathOptions x
Prelude.Generic)

-- |
-- Create a value of 'PathOptions' 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:
--
-- 'lastModifiedDateCondition', 'pathOptions_lastModifiedDateCondition' - If provided, this structure defines a date range for matching Amazon S3
-- objects based on their LastModifiedDate attribute in Amazon S3.
--
-- 'parameters', 'pathOptions_parameters' - A structure that maps names of parameters used in the Amazon S3 path of
-- a dataset to their definitions.
--
-- 'filesLimit', 'pathOptions_filesLimit' - If provided, this structure imposes a limit on a number of files that
-- should be selected.
newPathOptions ::
  PathOptions
newPathOptions :: PathOptions
newPathOptions =
  PathOptions' :: Maybe FilterExpression
-> Maybe (HashMap Text DatasetParameter)
-> Maybe FilesLimit
-> PathOptions
PathOptions'
    { $sel:lastModifiedDateCondition:PathOptions' :: Maybe FilterExpression
lastModifiedDateCondition =
        Maybe FilterExpression
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:PathOptions' :: Maybe (HashMap Text DatasetParameter)
parameters = Maybe (HashMap Text DatasetParameter)
forall a. Maybe a
Prelude.Nothing,
      $sel:filesLimit:PathOptions' :: Maybe FilesLimit
filesLimit = Maybe FilesLimit
forall a. Maybe a
Prelude.Nothing
    }

-- | If provided, this structure defines a date range for matching Amazon S3
-- objects based on their LastModifiedDate attribute in Amazon S3.
pathOptions_lastModifiedDateCondition :: Lens.Lens' PathOptions (Prelude.Maybe FilterExpression)
pathOptions_lastModifiedDateCondition :: (Maybe FilterExpression -> f (Maybe FilterExpression))
-> PathOptions -> f PathOptions
pathOptions_lastModifiedDateCondition = (PathOptions -> Maybe FilterExpression)
-> (PathOptions -> Maybe FilterExpression -> PathOptions)
-> Lens
     PathOptions
     PathOptions
     (Maybe FilterExpression)
     (Maybe FilterExpression)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PathOptions' {Maybe FilterExpression
lastModifiedDateCondition :: Maybe FilterExpression
$sel:lastModifiedDateCondition:PathOptions' :: PathOptions -> Maybe FilterExpression
lastModifiedDateCondition} -> Maybe FilterExpression
lastModifiedDateCondition) (\s :: PathOptions
s@PathOptions' {} Maybe FilterExpression
a -> PathOptions
s {$sel:lastModifiedDateCondition:PathOptions' :: Maybe FilterExpression
lastModifiedDateCondition = Maybe FilterExpression
a} :: PathOptions)

-- | A structure that maps names of parameters used in the Amazon S3 path of
-- a dataset to their definitions.
pathOptions_parameters :: Lens.Lens' PathOptions (Prelude.Maybe (Prelude.HashMap Prelude.Text DatasetParameter))
pathOptions_parameters :: (Maybe (HashMap Text DatasetParameter)
 -> f (Maybe (HashMap Text DatasetParameter)))
-> PathOptions -> f PathOptions
pathOptions_parameters = (PathOptions -> Maybe (HashMap Text DatasetParameter))
-> (PathOptions
    -> Maybe (HashMap Text DatasetParameter) -> PathOptions)
-> Lens
     PathOptions
     PathOptions
     (Maybe (HashMap Text DatasetParameter))
     (Maybe (HashMap Text DatasetParameter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PathOptions' {Maybe (HashMap Text DatasetParameter)
parameters :: Maybe (HashMap Text DatasetParameter)
$sel:parameters:PathOptions' :: PathOptions -> Maybe (HashMap Text DatasetParameter)
parameters} -> Maybe (HashMap Text DatasetParameter)
parameters) (\s :: PathOptions
s@PathOptions' {} Maybe (HashMap Text DatasetParameter)
a -> PathOptions
s {$sel:parameters:PathOptions' :: Maybe (HashMap Text DatasetParameter)
parameters = Maybe (HashMap Text DatasetParameter)
a} :: PathOptions) ((Maybe (HashMap Text DatasetParameter)
  -> f (Maybe (HashMap Text DatasetParameter)))
 -> PathOptions -> f PathOptions)
-> ((Maybe (HashMap Text DatasetParameter)
     -> f (Maybe (HashMap Text DatasetParameter)))
    -> Maybe (HashMap Text DatasetParameter)
    -> f (Maybe (HashMap Text DatasetParameter)))
-> (Maybe (HashMap Text DatasetParameter)
    -> f (Maybe (HashMap Text DatasetParameter)))
-> PathOptions
-> f PathOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text DatasetParameter)
  (HashMap Text DatasetParameter)
  (HashMap Text DatasetParameter)
  (HashMap Text DatasetParameter)
-> Iso
     (Maybe (HashMap Text DatasetParameter))
     (Maybe (HashMap Text DatasetParameter))
     (Maybe (HashMap Text DatasetParameter))
     (Maybe (HashMap Text DatasetParameter))
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
  (HashMap Text DatasetParameter)
  (HashMap Text DatasetParameter)
  (HashMap Text DatasetParameter)
  (HashMap Text DatasetParameter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If provided, this structure imposes a limit on a number of files that
-- should be selected.
pathOptions_filesLimit :: Lens.Lens' PathOptions (Prelude.Maybe FilesLimit)
pathOptions_filesLimit :: (Maybe FilesLimit -> f (Maybe FilesLimit))
-> PathOptions -> f PathOptions
pathOptions_filesLimit = (PathOptions -> Maybe FilesLimit)
-> (PathOptions -> Maybe FilesLimit -> PathOptions)
-> Lens
     PathOptions PathOptions (Maybe FilesLimit) (Maybe FilesLimit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PathOptions' {Maybe FilesLimit
filesLimit :: Maybe FilesLimit
$sel:filesLimit:PathOptions' :: PathOptions -> Maybe FilesLimit
filesLimit} -> Maybe FilesLimit
filesLimit) (\s :: PathOptions
s@PathOptions' {} Maybe FilesLimit
a -> PathOptions
s {$sel:filesLimit:PathOptions' :: Maybe FilesLimit
filesLimit = Maybe FilesLimit
a} :: PathOptions)

instance Core.FromJSON PathOptions where
  parseJSON :: Value -> Parser PathOptions
parseJSON =
    String
-> (Object -> Parser PathOptions) -> Value -> Parser PathOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PathOptions"
      ( \Object
x ->
          Maybe FilterExpression
-> Maybe (HashMap Text DatasetParameter)
-> Maybe FilesLimit
-> PathOptions
PathOptions'
            (Maybe FilterExpression
 -> Maybe (HashMap Text DatasetParameter)
 -> Maybe FilesLimit
 -> PathOptions)
-> Parser (Maybe FilterExpression)
-> Parser
     (Maybe (HashMap Text DatasetParameter)
      -> Maybe FilesLimit -> PathOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FilterExpression)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastModifiedDateCondition")
            Parser
  (Maybe (HashMap Text DatasetParameter)
   -> Maybe FilesLimit -> PathOptions)
-> Parser (Maybe (HashMap Text DatasetParameter))
-> Parser (Maybe FilesLimit -> PathOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text DatasetParameter)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters" Parser (Maybe (Maybe (HashMap Text DatasetParameter)))
-> Maybe (HashMap Text DatasetParameter)
-> Parser (Maybe (HashMap Text DatasetParameter))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text DatasetParameter)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe FilesLimit -> PathOptions)
-> Parser (Maybe FilesLimit) -> Parser PathOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FilesLimit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FilesLimit")
      )

instance Prelude.Hashable PathOptions

instance Prelude.NFData PathOptions

instance Core.ToJSON PathOptions where
  toJSON :: PathOptions -> Value
toJSON PathOptions' {Maybe (HashMap Text DatasetParameter)
Maybe FilterExpression
Maybe FilesLimit
filesLimit :: Maybe FilesLimit
parameters :: Maybe (HashMap Text DatasetParameter)
lastModifiedDateCondition :: Maybe FilterExpression
$sel:filesLimit:PathOptions' :: PathOptions -> Maybe FilesLimit
$sel:parameters:PathOptions' :: PathOptions -> Maybe (HashMap Text DatasetParameter)
$sel:lastModifiedDateCondition:PathOptions' :: PathOptions -> Maybe FilterExpression
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LastModifiedDateCondition" Text -> FilterExpression -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FilterExpression -> Pair) -> Maybe FilterExpression -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FilterExpression
lastModifiedDateCondition,
            (Text
"Parameters" Text -> HashMap Text DatasetParameter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text DatasetParameter -> Pair)
-> Maybe (HashMap Text DatasetParameter) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text DatasetParameter)
parameters,
            (Text
"FilesLimit" Text -> FilesLimit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FilesLimit -> Pair) -> Maybe FilesLimit -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FilesLimit
filesLimit
          ]
      )