{-# 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.LookoutMetrics.Types.TimestampColumn
-- 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.LookoutMetrics.Types.TimestampColumn where

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

-- | Contains information about the column used to track time in a source
-- data file.
--
-- /See:/ 'newTimestampColumn' smart constructor.
data TimestampColumn = TimestampColumn'
  { -- | The format of the timestamp column.
    TimestampColumn -> Maybe Text
columnFormat :: Prelude.Maybe Prelude.Text,
    -- | The name of the timestamp column.
    TimestampColumn -> Maybe Text
columnName :: Prelude.Maybe Prelude.Text
  }
  deriving (TimestampColumn -> TimestampColumn -> Bool
(TimestampColumn -> TimestampColumn -> Bool)
-> (TimestampColumn -> TimestampColumn -> Bool)
-> Eq TimestampColumn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimestampColumn -> TimestampColumn -> Bool
$c/= :: TimestampColumn -> TimestampColumn -> Bool
== :: TimestampColumn -> TimestampColumn -> Bool
$c== :: TimestampColumn -> TimestampColumn -> Bool
Prelude.Eq, ReadPrec [TimestampColumn]
ReadPrec TimestampColumn
Int -> ReadS TimestampColumn
ReadS [TimestampColumn]
(Int -> ReadS TimestampColumn)
-> ReadS [TimestampColumn]
-> ReadPrec TimestampColumn
-> ReadPrec [TimestampColumn]
-> Read TimestampColumn
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimestampColumn]
$creadListPrec :: ReadPrec [TimestampColumn]
readPrec :: ReadPrec TimestampColumn
$creadPrec :: ReadPrec TimestampColumn
readList :: ReadS [TimestampColumn]
$creadList :: ReadS [TimestampColumn]
readsPrec :: Int -> ReadS TimestampColumn
$creadsPrec :: Int -> ReadS TimestampColumn
Prelude.Read, Int -> TimestampColumn -> ShowS
[TimestampColumn] -> ShowS
TimestampColumn -> String
(Int -> TimestampColumn -> ShowS)
-> (TimestampColumn -> String)
-> ([TimestampColumn] -> ShowS)
-> Show TimestampColumn
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimestampColumn] -> ShowS
$cshowList :: [TimestampColumn] -> ShowS
show :: TimestampColumn -> String
$cshow :: TimestampColumn -> String
showsPrec :: Int -> TimestampColumn -> ShowS
$cshowsPrec :: Int -> TimestampColumn -> ShowS
Prelude.Show, (forall x. TimestampColumn -> Rep TimestampColumn x)
-> (forall x. Rep TimestampColumn x -> TimestampColumn)
-> Generic TimestampColumn
forall x. Rep TimestampColumn x -> TimestampColumn
forall x. TimestampColumn -> Rep TimestampColumn x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimestampColumn x -> TimestampColumn
$cfrom :: forall x. TimestampColumn -> Rep TimestampColumn x
Prelude.Generic)

-- |
-- Create a value of 'TimestampColumn' 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:
--
-- 'columnFormat', 'timestampColumn_columnFormat' - The format of the timestamp column.
--
-- 'columnName', 'timestampColumn_columnName' - The name of the timestamp column.
newTimestampColumn ::
  TimestampColumn
newTimestampColumn :: TimestampColumn
newTimestampColumn =
  TimestampColumn' :: Maybe Text -> Maybe Text -> TimestampColumn
TimestampColumn'
    { $sel:columnFormat:TimestampColumn' :: Maybe Text
columnFormat = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:columnName:TimestampColumn' :: Maybe Text
columnName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The format of the timestamp column.
timestampColumn_columnFormat :: Lens.Lens' TimestampColumn (Prelude.Maybe Prelude.Text)
timestampColumn_columnFormat :: (Maybe Text -> f (Maybe Text))
-> TimestampColumn -> f TimestampColumn
timestampColumn_columnFormat = (TimestampColumn -> Maybe Text)
-> (TimestampColumn -> Maybe Text -> TimestampColumn)
-> Lens TimestampColumn TimestampColumn (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampColumn' {Maybe Text
columnFormat :: Maybe Text
$sel:columnFormat:TimestampColumn' :: TimestampColumn -> Maybe Text
columnFormat} -> Maybe Text
columnFormat) (\s :: TimestampColumn
s@TimestampColumn' {} Maybe Text
a -> TimestampColumn
s {$sel:columnFormat:TimestampColumn' :: Maybe Text
columnFormat = Maybe Text
a} :: TimestampColumn)

-- | The name of the timestamp column.
timestampColumn_columnName :: Lens.Lens' TimestampColumn (Prelude.Maybe Prelude.Text)
timestampColumn_columnName :: (Maybe Text -> f (Maybe Text))
-> TimestampColumn -> f TimestampColumn
timestampColumn_columnName = (TimestampColumn -> Maybe Text)
-> (TimestampColumn -> Maybe Text -> TimestampColumn)
-> Lens TimestampColumn TimestampColumn (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampColumn' {Maybe Text
columnName :: Maybe Text
$sel:columnName:TimestampColumn' :: TimestampColumn -> Maybe Text
columnName} -> Maybe Text
columnName) (\s :: TimestampColumn
s@TimestampColumn' {} Maybe Text
a -> TimestampColumn
s {$sel:columnName:TimestampColumn' :: Maybe Text
columnName = Maybe Text
a} :: TimestampColumn)

instance Core.FromJSON TimestampColumn where
  parseJSON :: Value -> Parser TimestampColumn
parseJSON =
    String
-> (Object -> Parser TimestampColumn)
-> Value
-> Parser TimestampColumn
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TimestampColumn"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> TimestampColumn
TimestampColumn'
            (Maybe Text -> Maybe Text -> TimestampColumn)
-> Parser (Maybe Text) -> Parser (Maybe Text -> TimestampColumn)
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
"ColumnFormat")
            Parser (Maybe Text -> TimestampColumn)
-> Parser (Maybe Text) -> Parser TimestampColumn
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
"ColumnName")
      )

instance Prelude.Hashable TimestampColumn

instance Prelude.NFData TimestampColumn

instance Core.ToJSON TimestampColumn where
  toJSON :: TimestampColumn -> Value
toJSON TimestampColumn' {Maybe Text
columnName :: Maybe Text
columnFormat :: Maybe Text
$sel:columnName:TimestampColumn' :: TimestampColumn -> Maybe Text
$sel:columnFormat:TimestampColumn' :: TimestampColumn -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ColumnFormat" 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
columnFormat,
            (Text
"ColumnName" 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
columnName
          ]
      )