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

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.DatetimeOptions
import Amazonka.DataBrew.Types.FilterExpression
import Amazonka.DataBrew.Types.ParameterType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a dataset paramater that defines type and conditions for a
-- parameter in the Amazon S3 path of the dataset.
--
-- /See:/ 'newDatasetParameter' smart constructor.
data DatasetParameter = DatasetParameter'
  { -- | Optional boolean value that defines whether the captured value of this
    -- parameter should be used to create a new column in a dataset.
    DatasetParameter -> Maybe Bool
createColumn :: Prelude.Maybe Prelude.Bool,
    -- | The optional filter expression structure to apply additional matching
    -- criteria to the parameter.
    DatasetParameter -> Maybe FilterExpression
filter' :: Prelude.Maybe FilterExpression,
    -- | Additional parameter options such as a format and a timezone. Required
    -- for datetime parameters.
    DatasetParameter -> Maybe DatetimeOptions
datetimeOptions :: Prelude.Maybe DatetimeOptions,
    -- | The name of the parameter that is used in the dataset\'s Amazon S3 path.
    DatasetParameter -> Text
name :: Prelude.Text,
    -- | The type of the dataset parameter, can be one of a \'String\',
    -- \'Number\' or \'Datetime\'.
    DatasetParameter -> ParameterType
type' :: ParameterType
  }
  deriving (DatasetParameter -> DatasetParameter -> Bool
(DatasetParameter -> DatasetParameter -> Bool)
-> (DatasetParameter -> DatasetParameter -> Bool)
-> Eq DatasetParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatasetParameter -> DatasetParameter -> Bool
$c/= :: DatasetParameter -> DatasetParameter -> Bool
== :: DatasetParameter -> DatasetParameter -> Bool
$c== :: DatasetParameter -> DatasetParameter -> Bool
Prelude.Eq, ReadPrec [DatasetParameter]
ReadPrec DatasetParameter
Int -> ReadS DatasetParameter
ReadS [DatasetParameter]
(Int -> ReadS DatasetParameter)
-> ReadS [DatasetParameter]
-> ReadPrec DatasetParameter
-> ReadPrec [DatasetParameter]
-> Read DatasetParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatasetParameter]
$creadListPrec :: ReadPrec [DatasetParameter]
readPrec :: ReadPrec DatasetParameter
$creadPrec :: ReadPrec DatasetParameter
readList :: ReadS [DatasetParameter]
$creadList :: ReadS [DatasetParameter]
readsPrec :: Int -> ReadS DatasetParameter
$creadsPrec :: Int -> ReadS DatasetParameter
Prelude.Read, Int -> DatasetParameter -> ShowS
[DatasetParameter] -> ShowS
DatasetParameter -> String
(Int -> DatasetParameter -> ShowS)
-> (DatasetParameter -> String)
-> ([DatasetParameter] -> ShowS)
-> Show DatasetParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatasetParameter] -> ShowS
$cshowList :: [DatasetParameter] -> ShowS
show :: DatasetParameter -> String
$cshow :: DatasetParameter -> String
showsPrec :: Int -> DatasetParameter -> ShowS
$cshowsPrec :: Int -> DatasetParameter -> ShowS
Prelude.Show, (forall x. DatasetParameter -> Rep DatasetParameter x)
-> (forall x. Rep DatasetParameter x -> DatasetParameter)
-> Generic DatasetParameter
forall x. Rep DatasetParameter x -> DatasetParameter
forall x. DatasetParameter -> Rep DatasetParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatasetParameter x -> DatasetParameter
$cfrom :: forall x. DatasetParameter -> Rep DatasetParameter x
Prelude.Generic)

-- |
-- Create a value of 'DatasetParameter' 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:
--
-- 'createColumn', 'datasetParameter_createColumn' - Optional boolean value that defines whether the captured value of this
-- parameter should be used to create a new column in a dataset.
--
-- 'filter'', 'datasetParameter_filter' - The optional filter expression structure to apply additional matching
-- criteria to the parameter.
--
-- 'datetimeOptions', 'datasetParameter_datetimeOptions' - Additional parameter options such as a format and a timezone. Required
-- for datetime parameters.
--
-- 'name', 'datasetParameter_name' - The name of the parameter that is used in the dataset\'s Amazon S3 path.
--
-- 'type'', 'datasetParameter_type' - The type of the dataset parameter, can be one of a \'String\',
-- \'Number\' or \'Datetime\'.
newDatasetParameter ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  ParameterType ->
  DatasetParameter
newDatasetParameter :: Text -> ParameterType -> DatasetParameter
newDatasetParameter Text
pName_ ParameterType
pType_ =
  DatasetParameter' :: Maybe Bool
-> Maybe FilterExpression
-> Maybe DatetimeOptions
-> Text
-> ParameterType
-> DatasetParameter
DatasetParameter'
    { $sel:createColumn:DatasetParameter' :: Maybe Bool
createColumn = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':DatasetParameter' :: Maybe FilterExpression
filter' = Maybe FilterExpression
forall a. Maybe a
Prelude.Nothing,
      $sel:datetimeOptions:DatasetParameter' :: Maybe DatetimeOptions
datetimeOptions = Maybe DatetimeOptions
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DatasetParameter' :: Text
name = Text
pName_,
      $sel:type':DatasetParameter' :: ParameterType
type' = ParameterType
pType_
    }

-- | Optional boolean value that defines whether the captured value of this
-- parameter should be used to create a new column in a dataset.
datasetParameter_createColumn :: Lens.Lens' DatasetParameter (Prelude.Maybe Prelude.Bool)
datasetParameter_createColumn :: (Maybe Bool -> f (Maybe Bool))
-> DatasetParameter -> f DatasetParameter
datasetParameter_createColumn = (DatasetParameter -> Maybe Bool)
-> (DatasetParameter -> Maybe Bool -> DatasetParameter)
-> Lens DatasetParameter DatasetParameter (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetParameter' {Maybe Bool
createColumn :: Maybe Bool
$sel:createColumn:DatasetParameter' :: DatasetParameter -> Maybe Bool
createColumn} -> Maybe Bool
createColumn) (\s :: DatasetParameter
s@DatasetParameter' {} Maybe Bool
a -> DatasetParameter
s {$sel:createColumn:DatasetParameter' :: Maybe Bool
createColumn = Maybe Bool
a} :: DatasetParameter)

-- | The optional filter expression structure to apply additional matching
-- criteria to the parameter.
datasetParameter_filter :: Lens.Lens' DatasetParameter (Prelude.Maybe FilterExpression)
datasetParameter_filter :: (Maybe FilterExpression -> f (Maybe FilterExpression))
-> DatasetParameter -> f DatasetParameter
datasetParameter_filter = (DatasetParameter -> Maybe FilterExpression)
-> (DatasetParameter -> Maybe FilterExpression -> DatasetParameter)
-> Lens
     DatasetParameter
     DatasetParameter
     (Maybe FilterExpression)
     (Maybe FilterExpression)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetParameter' {Maybe FilterExpression
filter' :: Maybe FilterExpression
$sel:filter':DatasetParameter' :: DatasetParameter -> Maybe FilterExpression
filter'} -> Maybe FilterExpression
filter') (\s :: DatasetParameter
s@DatasetParameter' {} Maybe FilterExpression
a -> DatasetParameter
s {$sel:filter':DatasetParameter' :: Maybe FilterExpression
filter' = Maybe FilterExpression
a} :: DatasetParameter)

-- | Additional parameter options such as a format and a timezone. Required
-- for datetime parameters.
datasetParameter_datetimeOptions :: Lens.Lens' DatasetParameter (Prelude.Maybe DatetimeOptions)
datasetParameter_datetimeOptions :: (Maybe DatetimeOptions -> f (Maybe DatetimeOptions))
-> DatasetParameter -> f DatasetParameter
datasetParameter_datetimeOptions = (DatasetParameter -> Maybe DatetimeOptions)
-> (DatasetParameter -> Maybe DatetimeOptions -> DatasetParameter)
-> Lens
     DatasetParameter
     DatasetParameter
     (Maybe DatetimeOptions)
     (Maybe DatetimeOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetParameter' {Maybe DatetimeOptions
datetimeOptions :: Maybe DatetimeOptions
$sel:datetimeOptions:DatasetParameter' :: DatasetParameter -> Maybe DatetimeOptions
datetimeOptions} -> Maybe DatetimeOptions
datetimeOptions) (\s :: DatasetParameter
s@DatasetParameter' {} Maybe DatetimeOptions
a -> DatasetParameter
s {$sel:datetimeOptions:DatasetParameter' :: Maybe DatetimeOptions
datetimeOptions = Maybe DatetimeOptions
a} :: DatasetParameter)

-- | The name of the parameter that is used in the dataset\'s Amazon S3 path.
datasetParameter_name :: Lens.Lens' DatasetParameter Prelude.Text
datasetParameter_name :: (Text -> f Text) -> DatasetParameter -> f DatasetParameter
datasetParameter_name = (DatasetParameter -> Text)
-> (DatasetParameter -> Text -> DatasetParameter)
-> Lens DatasetParameter DatasetParameter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetParameter' {Text
name :: Text
$sel:name:DatasetParameter' :: DatasetParameter -> Text
name} -> Text
name) (\s :: DatasetParameter
s@DatasetParameter' {} Text
a -> DatasetParameter
s {$sel:name:DatasetParameter' :: Text
name = Text
a} :: DatasetParameter)

-- | The type of the dataset parameter, can be one of a \'String\',
-- \'Number\' or \'Datetime\'.
datasetParameter_type :: Lens.Lens' DatasetParameter ParameterType
datasetParameter_type :: (ParameterType -> f ParameterType)
-> DatasetParameter -> f DatasetParameter
datasetParameter_type = (DatasetParameter -> ParameterType)
-> (DatasetParameter -> ParameterType -> DatasetParameter)
-> Lens
     DatasetParameter DatasetParameter ParameterType ParameterType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetParameter' {ParameterType
type' :: ParameterType
$sel:type':DatasetParameter' :: DatasetParameter -> ParameterType
type'} -> ParameterType
type') (\s :: DatasetParameter
s@DatasetParameter' {} ParameterType
a -> DatasetParameter
s {$sel:type':DatasetParameter' :: ParameterType
type' = ParameterType
a} :: DatasetParameter)

instance Core.FromJSON DatasetParameter where
  parseJSON :: Value -> Parser DatasetParameter
parseJSON =
    String
-> (Object -> Parser DatasetParameter)
-> Value
-> Parser DatasetParameter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DatasetParameter"
      ( \Object
x ->
          Maybe Bool
-> Maybe FilterExpression
-> Maybe DatetimeOptions
-> Text
-> ParameterType
-> DatasetParameter
DatasetParameter'
            (Maybe Bool
 -> Maybe FilterExpression
 -> Maybe DatetimeOptions
 -> Text
 -> ParameterType
 -> DatasetParameter)
-> Parser (Maybe Bool)
-> Parser
     (Maybe FilterExpression
      -> Maybe DatetimeOptions
      -> Text
      -> ParameterType
      -> DatasetParameter)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreateColumn")
            Parser
  (Maybe FilterExpression
   -> Maybe DatetimeOptions
   -> Text
   -> ParameterType
   -> DatasetParameter)
-> Parser (Maybe FilterExpression)
-> Parser
     (Maybe DatetimeOptions
      -> Text -> ParameterType -> DatasetParameter)
forall (f :: * -> *) a b. Applicative f => 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
"Filter")
            Parser
  (Maybe DatetimeOptions
   -> Text -> ParameterType -> DatasetParameter)
-> Parser (Maybe DatetimeOptions)
-> Parser (Text -> ParameterType -> DatasetParameter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DatetimeOptions)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DatetimeOptions")
            Parser (Text -> ParameterType -> DatasetParameter)
-> Parser Text -> Parser (ParameterType -> DatasetParameter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser (ParameterType -> DatasetParameter)
-> Parser ParameterType -> Parser DatasetParameter
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ParameterType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
      )

instance Prelude.Hashable DatasetParameter

instance Prelude.NFData DatasetParameter

instance Core.ToJSON DatasetParameter where
  toJSON :: DatasetParameter -> Value
toJSON DatasetParameter' {Maybe Bool
Maybe DatetimeOptions
Maybe FilterExpression
Text
ParameterType
type' :: ParameterType
name :: Text
datetimeOptions :: Maybe DatetimeOptions
filter' :: Maybe FilterExpression
createColumn :: Maybe Bool
$sel:type':DatasetParameter' :: DatasetParameter -> ParameterType
$sel:name:DatasetParameter' :: DatasetParameter -> Text
$sel:datetimeOptions:DatasetParameter' :: DatasetParameter -> Maybe DatetimeOptions
$sel:filter':DatasetParameter' :: DatasetParameter -> Maybe FilterExpression
$sel:createColumn:DatasetParameter' :: DatasetParameter -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CreateColumn" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
createColumn,
            (Text
"Filter" 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
filter',
            (Text
"DatetimeOptions" Text -> DatetimeOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DatetimeOptions -> Pair) -> Maybe DatetimeOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DatetimeOptions
datetimeOptions,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> ParameterType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ParameterType
type')
          ]
      )