{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataBrew.Types.ExcelOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | 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,
    -- | 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)
  }
  deriving (ExcelOptions -> ExcelOptions -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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.
newExcelOptions ::
  ExcelOptions
newExcelOptions :: ExcelOptions
newExcelOptions =
  ExcelOptions'
    { $sel:headerRow:ExcelOptions' :: Maybe Bool
headerRow = forall a. Maybe a
Prelude.Nothing,
      $sel:sheetIndexes:ExcelOptions' :: Maybe (NonEmpty Natural)
sheetIndexes = forall a. Maybe a
Prelude.Nothing,
      $sel:sheetNames:ExcelOptions' :: Maybe (NonEmpty Text)
sheetNames = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' ExcelOptions (Maybe Bool)
excelOptions_headerRow = 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)

-- | 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 :: Lens' ExcelOptions (Maybe (NonEmpty Natural))
excelOptions_sheetIndexes = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' ExcelOptions (Maybe (NonEmpty Text))
excelOptions_sheetNames = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ExcelOptions where
  hashWithSalt :: Int -> ExcelOptions -> Int
hashWithSalt Int
_salt ExcelOptions' {Maybe Bool
Maybe (NonEmpty Natural)
Maybe (NonEmpty Text)
sheetNames :: Maybe (NonEmpty Text)
sheetIndexes :: Maybe (NonEmpty Natural)
headerRow :: Maybe Bool
$sel:sheetNames:ExcelOptions' :: ExcelOptions -> Maybe (NonEmpty Text)
$sel:sheetIndexes:ExcelOptions' :: ExcelOptions -> Maybe (NonEmpty Natural)
$sel:headerRow:ExcelOptions' :: ExcelOptions -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
headerRow
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Natural)
sheetIndexes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
sheetNames

instance Prelude.NFData ExcelOptions where
  rnf :: ExcelOptions -> ()
rnf ExcelOptions' {Maybe Bool
Maybe (NonEmpty Natural)
Maybe (NonEmpty Text)
sheetNames :: Maybe (NonEmpty Text)
sheetIndexes :: Maybe (NonEmpty Natural)
headerRow :: Maybe Bool
$sel:sheetNames:ExcelOptions' :: ExcelOptions -> Maybe (NonEmpty Text)
$sel:sheetIndexes:ExcelOptions' :: ExcelOptions -> Maybe (NonEmpty Natural)
$sel:headerRow:ExcelOptions' :: ExcelOptions -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
headerRow
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Natural)
sheetIndexes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
sheetNames

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