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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a set of options that define how DataBrew will interpret a
-- Microsoft Excel file when creating a dataset from that file.
--
-- /See:/ 'newExcelOptions' smart constructor.
data ExcelOptions = ExcelOptions'
  { -- | One or more sheet numbers in the Excel file that will be included in the
    -- dataset.
    ExcelOptions -> Maybe (NonEmpty Natural)
sheetIndexes :: Prelude.Maybe (Prelude.NonEmpty Prelude.Natural),
    -- | One or more named sheets in the Excel file that will be included in the
    -- dataset.
    ExcelOptions -> Maybe (NonEmpty Text)
sheetNames :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | A variable that specifies whether the first row in the file is parsed as
    -- the header. If this value is false, column names are auto-generated.
    ExcelOptions -> Maybe Bool
headerRow :: Prelude.Maybe Prelude.Bool
  }
  deriving (ExcelOptions -> ExcelOptions -> Bool
(ExcelOptions -> ExcelOptions -> Bool)
-> (ExcelOptions -> ExcelOptions -> Bool) -> Eq ExcelOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExcelOptions -> ExcelOptions -> Bool
$c/= :: ExcelOptions -> ExcelOptions -> Bool
== :: ExcelOptions -> ExcelOptions -> Bool
$c== :: ExcelOptions -> ExcelOptions -> Bool
Prelude.Eq, ReadPrec [ExcelOptions]
ReadPrec ExcelOptions
Int -> ReadS ExcelOptions
ReadS [ExcelOptions]
(Int -> ReadS ExcelOptions)
-> ReadS [ExcelOptions]
-> ReadPrec ExcelOptions
-> ReadPrec [ExcelOptions]
-> Read ExcelOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExcelOptions]
$creadListPrec :: ReadPrec [ExcelOptions]
readPrec :: ReadPrec ExcelOptions
$creadPrec :: ReadPrec ExcelOptions
readList :: ReadS [ExcelOptions]
$creadList :: ReadS [ExcelOptions]
readsPrec :: Int -> ReadS ExcelOptions
$creadsPrec :: Int -> ReadS ExcelOptions
Prelude.Read, Int -> ExcelOptions -> ShowS
[ExcelOptions] -> ShowS
ExcelOptions -> String
(Int -> ExcelOptions -> ShowS)
-> (ExcelOptions -> String)
-> ([ExcelOptions] -> ShowS)
-> Show ExcelOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExcelOptions] -> ShowS
$cshowList :: [ExcelOptions] -> ShowS
show :: ExcelOptions -> String
$cshow :: ExcelOptions -> String
showsPrec :: Int -> ExcelOptions -> ShowS
$cshowsPrec :: Int -> ExcelOptions -> ShowS
Prelude.Show, (forall x. ExcelOptions -> Rep ExcelOptions x)
-> (forall x. Rep ExcelOptions x -> ExcelOptions)
-> Generic ExcelOptions
forall x. Rep ExcelOptions x -> ExcelOptions
forall x. ExcelOptions -> Rep ExcelOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExcelOptions x -> ExcelOptions
$cfrom :: forall x. ExcelOptions -> Rep ExcelOptions x
Prelude.Generic)

-- |
-- Create a value of 'ExcelOptions' 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:
--
-- 'sheetIndexes', 'excelOptions_sheetIndexes' - One or more sheet numbers in the Excel file that will be included in the
-- dataset.
--
-- 'sheetNames', 'excelOptions_sheetNames' - One or more named sheets in the Excel file that will be included in the
-- dataset.
--
-- 'headerRow', 'excelOptions_headerRow' - A variable that specifies whether the first row in the file is parsed as
-- the header. If this value is false, column names are auto-generated.
newExcelOptions ::
  ExcelOptions
newExcelOptions :: ExcelOptions
newExcelOptions =
  ExcelOptions' :: Maybe (NonEmpty Natural)
-> Maybe (NonEmpty Text) -> Maybe Bool -> ExcelOptions
ExcelOptions'
    { $sel:sheetIndexes:ExcelOptions' :: Maybe (NonEmpty Natural)
sheetIndexes = Maybe (NonEmpty Natural)
forall a. Maybe a
Prelude.Nothing,
      $sel:sheetNames:ExcelOptions' :: Maybe (NonEmpty Text)
sheetNames = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:headerRow:ExcelOptions' :: Maybe Bool
headerRow = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | One or more sheet numbers in the Excel file that will be included in the
-- dataset.
excelOptions_sheetIndexes :: Lens.Lens' ExcelOptions (Prelude.Maybe (Prelude.NonEmpty Prelude.Natural))
excelOptions_sheetIndexes :: (Maybe (NonEmpty Natural) -> f (Maybe (NonEmpty Natural)))
-> ExcelOptions -> f ExcelOptions
excelOptions_sheetIndexes = (ExcelOptions -> Maybe (NonEmpty Natural))
-> (ExcelOptions -> Maybe (NonEmpty Natural) -> ExcelOptions)
-> Lens
     ExcelOptions
     ExcelOptions
     (Maybe (NonEmpty Natural))
     (Maybe (NonEmpty Natural))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExcelOptions' {Maybe (NonEmpty Natural)
sheetIndexes :: Maybe (NonEmpty Natural)
$sel:sheetIndexes:ExcelOptions' :: ExcelOptions -> Maybe (NonEmpty Natural)
sheetIndexes} -> Maybe (NonEmpty Natural)
sheetIndexes) (\s :: ExcelOptions
s@ExcelOptions' {} Maybe (NonEmpty Natural)
a -> ExcelOptions
s {$sel:sheetIndexes:ExcelOptions' :: Maybe (NonEmpty Natural)
sheetIndexes = Maybe (NonEmpty Natural)
a} :: ExcelOptions) ((Maybe (NonEmpty Natural) -> f (Maybe (NonEmpty Natural)))
 -> ExcelOptions -> f ExcelOptions)
-> ((Maybe (NonEmpty Natural) -> f (Maybe (NonEmpty Natural)))
    -> Maybe (NonEmpty Natural) -> f (Maybe (NonEmpty Natural)))
-> (Maybe (NonEmpty Natural) -> f (Maybe (NonEmpty Natural)))
-> ExcelOptions
-> f ExcelOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Natural)
  (NonEmpty Natural)
  (NonEmpty Natural)
  (NonEmpty Natural)
-> Iso
     (Maybe (NonEmpty Natural))
     (Maybe (NonEmpty Natural))
     (Maybe (NonEmpty Natural))
     (Maybe (NonEmpty Natural))
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
  (NonEmpty Natural)
  (NonEmpty Natural)
  (NonEmpty Natural)
  (NonEmpty Natural)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | One or more named sheets in the Excel file that will be included in the
-- dataset.
excelOptions_sheetNames :: Lens.Lens' ExcelOptions (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
excelOptions_sheetNames :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ExcelOptions -> f ExcelOptions
excelOptions_sheetNames = (ExcelOptions -> Maybe (NonEmpty Text))
-> (ExcelOptions -> Maybe (NonEmpty Text) -> ExcelOptions)
-> Lens
     ExcelOptions
     ExcelOptions
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExcelOptions' {Maybe (NonEmpty Text)
sheetNames :: Maybe (NonEmpty Text)
$sel:sheetNames:ExcelOptions' :: ExcelOptions -> Maybe (NonEmpty Text)
sheetNames} -> Maybe (NonEmpty Text)
sheetNames) (\s :: ExcelOptions
s@ExcelOptions' {} Maybe (NonEmpty Text)
a -> ExcelOptions
s {$sel:sheetNames:ExcelOptions' :: Maybe (NonEmpty Text)
sheetNames = Maybe (NonEmpty Text)
a} :: ExcelOptions) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> ExcelOptions -> f ExcelOptions)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ExcelOptions
-> f ExcelOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A variable that specifies whether the first row in the file is parsed as
-- the header. If this value is false, column names are auto-generated.
excelOptions_headerRow :: Lens.Lens' ExcelOptions (Prelude.Maybe Prelude.Bool)
excelOptions_headerRow :: (Maybe Bool -> f (Maybe Bool)) -> ExcelOptions -> f ExcelOptions
excelOptions_headerRow = (ExcelOptions -> Maybe Bool)
-> (ExcelOptions -> Maybe Bool -> ExcelOptions)
-> Lens ExcelOptions ExcelOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExcelOptions' {Maybe Bool
headerRow :: Maybe Bool
$sel:headerRow:ExcelOptions' :: ExcelOptions -> Maybe Bool
headerRow} -> Maybe Bool
headerRow) (\s :: ExcelOptions
s@ExcelOptions' {} Maybe Bool
a -> ExcelOptions
s {$sel:headerRow:ExcelOptions' :: Maybe Bool
headerRow = Maybe Bool
a} :: ExcelOptions)

instance Core.FromJSON ExcelOptions where
  parseJSON :: Value -> Parser ExcelOptions
parseJSON =
    String
-> (Object -> Parser ExcelOptions) -> Value -> Parser ExcelOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExcelOptions"
      ( \Object
x ->
          Maybe (NonEmpty Natural)
-> Maybe (NonEmpty Text) -> Maybe Bool -> ExcelOptions
ExcelOptions'
            (Maybe (NonEmpty Natural)
 -> Maybe (NonEmpty Text) -> Maybe Bool -> ExcelOptions)
-> Parser (Maybe (NonEmpty Natural))
-> Parser (Maybe (NonEmpty Text) -> Maybe Bool -> ExcelOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Natural))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SheetIndexes")
            Parser (Maybe (NonEmpty Text) -> Maybe Bool -> ExcelOptions)
-> Parser (Maybe (NonEmpty Text))
-> Parser (Maybe Bool -> ExcelOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SheetNames")
            Parser (Maybe Bool -> ExcelOptions)
-> Parser (Maybe Bool) -> Parser ExcelOptions
forall (f :: * -> *) a b. Applicative f => 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
"HeaderRow")
      )

instance Prelude.Hashable ExcelOptions

instance Prelude.NFData ExcelOptions

instance Core.ToJSON ExcelOptions where
  toJSON :: ExcelOptions -> Value
toJSON ExcelOptions' {Maybe Bool
Maybe (NonEmpty Natural)
Maybe (NonEmpty Text)
headerRow :: Maybe Bool
sheetNames :: Maybe (NonEmpty Text)
sheetIndexes :: Maybe (NonEmpty Natural)
$sel:headerRow:ExcelOptions' :: ExcelOptions -> Maybe Bool
$sel:sheetNames:ExcelOptions' :: ExcelOptions -> Maybe (NonEmpty Text)
$sel:sheetIndexes:ExcelOptions' :: ExcelOptions -> Maybe (NonEmpty Natural)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SheetIndexes" Text -> NonEmpty Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Natural -> Pair)
-> Maybe (NonEmpty Natural) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Natural)
sheetIndexes,
            (Text
"SheetNames" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
sheetNames,
            (Text
"HeaderRow" 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
headerRow
          ]
      )