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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | Optional value for a non-US locale code, needed for correct
    -- interpretation of some date formats.
    DatetimeOptions -> Maybe Text
localeCode :: 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
(DatetimeOptions -> DatetimeOptions -> Bool)
-> (DatetimeOptions -> DatetimeOptions -> Bool)
-> Eq DatetimeOptions
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]
(Int -> ReadS DatetimeOptions)
-> ReadS [DatetimeOptions]
-> ReadPrec DatetimeOptions
-> ReadPrec [DatetimeOptions]
-> Read 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
(Int -> DatetimeOptions -> ShowS)
-> (DatetimeOptions -> String)
-> ([DatetimeOptions] -> ShowS)
-> Show DatetimeOptions
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. DatetimeOptions -> Rep DatetimeOptions x)
-> (forall x. Rep DatetimeOptions x -> DatetimeOptions)
-> Generic DatetimeOptions
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:
--
-- '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.
--
-- 'localeCode', 'datetimeOptions_localeCode' - Optional value for a non-US locale code, needed for correct
-- interpretation of some date formats.
--
-- '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' :: Maybe Text -> Maybe Text -> Text -> DatetimeOptions
DatetimeOptions'
    { $sel:timezoneOffset:DatetimeOptions' :: Maybe Text
timezoneOffset = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:localeCode:DatetimeOptions' :: Maybe Text
localeCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:format:DatetimeOptions' :: Text
format = Text
pFormat_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> DatetimeOptions -> f DatetimeOptions
datetimeOptions_timezoneOffset = (DatetimeOptions -> Maybe Text)
-> (DatetimeOptions -> Maybe Text -> DatetimeOptions)
-> Lens DatetimeOptions DatetimeOptions (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> DatetimeOptions -> f DatetimeOptions
datetimeOptions_localeCode = (DatetimeOptions -> Maybe Text)
-> (DatetimeOptions -> Maybe Text -> DatetimeOptions)
-> Lens DatetimeOptions DatetimeOptions (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable DatetimeOptions

instance Prelude.NFData DatetimeOptions

instance Core.ToJSON DatetimeOptions where
  toJSON :: DatetimeOptions -> Value
toJSON DatetimeOptions' {Maybe Text
Text
format :: Text
localeCode :: Maybe Text
timezoneOffset :: Maybe Text
$sel:format:DatetimeOptions' :: DatetimeOptions -> Text
$sel:localeCode:DatetimeOptions' :: DatetimeOptions -> Maybe Text
$sel:timezoneOffset:DatetimeOptions' :: DatetimeOptions -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TimezoneOffset" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
timezoneOffset,
            (Text
"LocaleCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
localeCode,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Format" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
format)
          ]
      )