{-# 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.DatetimeOptions
-- 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.DatetimeOptions 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 additional options for correct interpretation of datetime
-- parameters used in the Amazon S3 path of a dataset.
--
-- /See:/ 'newDatetimeOptions' smart constructor.
data DatetimeOptions = DatetimeOptions'
  { -- | Optional value for a non-US locale code, needed for correct
    -- interpretation of some date formats.
    DatetimeOptions -> Maybe Text
localeCode :: Prelude.Maybe Prelude.Text,
    -- | Optional value for a timezone offset of the datetime parameter value in
    -- the Amazon S3 path. Shouldn\'t be used if Format for this parameter
    -- includes timezone fields. If no offset specified, UTC is assumed.
    DatetimeOptions -> Maybe Text
timezoneOffset :: Prelude.Maybe Prelude.Text,
    -- | Required option, that defines the datetime format used for a date
    -- parameter in the Amazon S3 path. Should use only supported datetime
    -- specifiers and separation characters, all literal a-z or A-Z characters
    -- should be escaped with single quotes. E.g. \"MM.dd.yyyy-\'at\'-HH:mm\".
    DatetimeOptions -> Text
format :: Prelude.Text
  }
  deriving (DatetimeOptions -> DatetimeOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatetimeOptions -> DatetimeOptions -> Bool
$c/= :: DatetimeOptions -> DatetimeOptions -> Bool
== :: DatetimeOptions -> DatetimeOptions -> Bool
$c== :: DatetimeOptions -> DatetimeOptions -> Bool
Prelude.Eq, ReadPrec [DatetimeOptions]
ReadPrec DatetimeOptions
Int -> ReadS DatetimeOptions
ReadS [DatetimeOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatetimeOptions]
$creadListPrec :: ReadPrec [DatetimeOptions]
readPrec :: ReadPrec DatetimeOptions
$creadPrec :: ReadPrec DatetimeOptions
readList :: ReadS [DatetimeOptions]
$creadList :: ReadS [DatetimeOptions]
readsPrec :: Int -> ReadS DatetimeOptions
$creadsPrec :: Int -> ReadS DatetimeOptions
Prelude.Read, Int -> DatetimeOptions -> ShowS
[DatetimeOptions] -> ShowS
DatetimeOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatetimeOptions] -> ShowS
$cshowList :: [DatetimeOptions] -> ShowS
show :: DatetimeOptions -> String
$cshow :: DatetimeOptions -> String
showsPrec :: Int -> DatetimeOptions -> ShowS
$cshowsPrec :: Int -> DatetimeOptions -> ShowS
Prelude.Show, forall x. Rep DatetimeOptions x -> DatetimeOptions
forall x. DatetimeOptions -> Rep DatetimeOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatetimeOptions x -> DatetimeOptions
$cfrom :: forall x. DatetimeOptions -> Rep DatetimeOptions x
Prelude.Generic)

-- |
-- Create a value of 'DatetimeOptions' 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:
--
-- 'localeCode', 'datetimeOptions_localeCode' - Optional value for a non-US locale code, needed for correct
-- interpretation of some date formats.
--
-- 'timezoneOffset', 'datetimeOptions_timezoneOffset' - Optional value for a timezone offset of the datetime parameter value in
-- the Amazon S3 path. Shouldn\'t be used if Format for this parameter
-- includes timezone fields. If no offset specified, UTC is assumed.
--
-- 'format', 'datetimeOptions_format' - Required option, that defines the datetime format used for a date
-- parameter in the Amazon S3 path. Should use only supported datetime
-- specifiers and separation characters, all literal a-z or A-Z characters
-- should be escaped with single quotes. E.g. \"MM.dd.yyyy-\'at\'-HH:mm\".
newDatetimeOptions ::
  -- | 'format'
  Prelude.Text ->
  DatetimeOptions
newDatetimeOptions :: Text -> DatetimeOptions
newDatetimeOptions Text
pFormat_ =
  DatetimeOptions'
    { $sel:localeCode:DatetimeOptions' :: Maybe Text
localeCode = forall a. Maybe a
Prelude.Nothing,
      $sel:timezoneOffset:DatetimeOptions' :: Maybe Text
timezoneOffset = forall a. Maybe a
Prelude.Nothing,
      $sel:format:DatetimeOptions' :: Text
format = Text
pFormat_
    }

-- | Optional value for a non-US locale code, needed for correct
-- interpretation of some date formats.
datetimeOptions_localeCode :: Lens.Lens' DatetimeOptions (Prelude.Maybe Prelude.Text)
datetimeOptions_localeCode :: Lens' DatetimeOptions (Maybe Text)
datetimeOptions_localeCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatetimeOptions' {Maybe Text
localeCode :: Maybe Text
$sel:localeCode:DatetimeOptions' :: DatetimeOptions -> Maybe Text
localeCode} -> Maybe Text
localeCode) (\s :: DatetimeOptions
s@DatetimeOptions' {} Maybe Text
a -> DatetimeOptions
s {$sel:localeCode:DatetimeOptions' :: Maybe Text
localeCode = Maybe Text
a} :: DatetimeOptions)

-- | Optional value for a timezone offset of the datetime parameter value in
-- the Amazon S3 path. Shouldn\'t be used if Format for this parameter
-- includes timezone fields. If no offset specified, UTC is assumed.
datetimeOptions_timezoneOffset :: Lens.Lens' DatetimeOptions (Prelude.Maybe Prelude.Text)
datetimeOptions_timezoneOffset :: Lens' DatetimeOptions (Maybe Text)
datetimeOptions_timezoneOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatetimeOptions' {Maybe Text
timezoneOffset :: Maybe Text
$sel:timezoneOffset:DatetimeOptions' :: DatetimeOptions -> Maybe Text
timezoneOffset} -> Maybe Text
timezoneOffset) (\s :: DatetimeOptions
s@DatetimeOptions' {} Maybe Text
a -> DatetimeOptions
s {$sel:timezoneOffset:DatetimeOptions' :: Maybe Text
timezoneOffset = Maybe Text
a} :: DatetimeOptions)

-- | Required option, that defines the datetime format used for a date
-- parameter in the Amazon S3 path. Should use only supported datetime
-- specifiers and separation characters, all literal a-z or A-Z characters
-- should be escaped with single quotes. E.g. \"MM.dd.yyyy-\'at\'-HH:mm\".
datetimeOptions_format :: Lens.Lens' DatetimeOptions Prelude.Text
datetimeOptions_format :: Lens' DatetimeOptions Text
datetimeOptions_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatetimeOptions' {Text
format :: Text
$sel:format:DatetimeOptions' :: DatetimeOptions -> Text
format} -> Text
format) (\s :: DatetimeOptions
s@DatetimeOptions' {} Text
a -> DatetimeOptions
s {$sel:format:DatetimeOptions' :: Text
format = Text
a} :: DatetimeOptions)

instance Data.FromJSON DatetimeOptions where
  parseJSON :: Value -> Parser DatetimeOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DatetimeOptions"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> DatetimeOptions
DatetimeOptions'
            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
"LocaleCode")
            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
"TimezoneOffset")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Format")
      )

instance Prelude.Hashable DatetimeOptions where
  hashWithSalt :: Int -> DatetimeOptions -> Int
hashWithSalt Int
_salt DatetimeOptions' {Maybe Text
Text
format :: Text
timezoneOffset :: Maybe Text
localeCode :: Maybe Text
$sel:format:DatetimeOptions' :: DatetimeOptions -> Text
$sel:timezoneOffset:DatetimeOptions' :: DatetimeOptions -> Maybe Text
$sel:localeCode:DatetimeOptions' :: DatetimeOptions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
localeCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
timezoneOffset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
format

instance Prelude.NFData DatetimeOptions where
  rnf :: DatetimeOptions -> ()
rnf DatetimeOptions' {Maybe Text
Text
format :: Text
timezoneOffset :: Maybe Text
localeCode :: Maybe Text
$sel:format:DatetimeOptions' :: DatetimeOptions -> Text
$sel:timezoneOffset:DatetimeOptions' :: DatetimeOptions -> Maybe Text
$sel:localeCode:DatetimeOptions' :: DatetimeOptions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
localeCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
timezoneOffset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
format

instance Data.ToJSON DatetimeOptions where
  toJSON :: DatetimeOptions -> Value
toJSON DatetimeOptions' {Maybe Text
Text
format :: Text
timezoneOffset :: Maybe Text
localeCode :: Maybe Text
$sel:format:DatetimeOptions' :: DatetimeOptions -> Text
$sel:timezoneOffset:DatetimeOptions' :: DatetimeOptions -> Maybe Text
$sel:localeCode:DatetimeOptions' :: DatetimeOptions -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"LocaleCode" 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 Text
localeCode,
            (Key
"TimezoneOffset" 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 Text
timezoneOffset,
            forall a. a -> Maybe a
Prelude.Just (Key
"Format" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
format)
          ]
      )