{-# 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.QuickSight.Types.DateTimeParameter
-- 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.QuickSight.Types.DateTimeParameter where

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

-- | A date-time parameter.
--
-- /See:/ 'newDateTimeParameter' smart constructor.
data DateTimeParameter = DateTimeParameter'
  { -- | A display name for the date-time parameter.
    DateTimeParameter -> Text
name :: Prelude.Text,
    -- | The values for the date-time parameter.
    DateTimeParameter -> [POSIX]
values :: [Core.POSIX]
  }
  deriving (DateTimeParameter -> DateTimeParameter -> Bool
(DateTimeParameter -> DateTimeParameter -> Bool)
-> (DateTimeParameter -> DateTimeParameter -> Bool)
-> Eq DateTimeParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DateTimeParameter -> DateTimeParameter -> Bool
$c/= :: DateTimeParameter -> DateTimeParameter -> Bool
== :: DateTimeParameter -> DateTimeParameter -> Bool
$c== :: DateTimeParameter -> DateTimeParameter -> Bool
Prelude.Eq, ReadPrec [DateTimeParameter]
ReadPrec DateTimeParameter
Int -> ReadS DateTimeParameter
ReadS [DateTimeParameter]
(Int -> ReadS DateTimeParameter)
-> ReadS [DateTimeParameter]
-> ReadPrec DateTimeParameter
-> ReadPrec [DateTimeParameter]
-> Read DateTimeParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DateTimeParameter]
$creadListPrec :: ReadPrec [DateTimeParameter]
readPrec :: ReadPrec DateTimeParameter
$creadPrec :: ReadPrec DateTimeParameter
readList :: ReadS [DateTimeParameter]
$creadList :: ReadS [DateTimeParameter]
readsPrec :: Int -> ReadS DateTimeParameter
$creadsPrec :: Int -> ReadS DateTimeParameter
Prelude.Read, Int -> DateTimeParameter -> ShowS
[DateTimeParameter] -> ShowS
DateTimeParameter -> String
(Int -> DateTimeParameter -> ShowS)
-> (DateTimeParameter -> String)
-> ([DateTimeParameter] -> ShowS)
-> Show DateTimeParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DateTimeParameter] -> ShowS
$cshowList :: [DateTimeParameter] -> ShowS
show :: DateTimeParameter -> String
$cshow :: DateTimeParameter -> String
showsPrec :: Int -> DateTimeParameter -> ShowS
$cshowsPrec :: Int -> DateTimeParameter -> ShowS
Prelude.Show, (forall x. DateTimeParameter -> Rep DateTimeParameter x)
-> (forall x. Rep DateTimeParameter x -> DateTimeParameter)
-> Generic DateTimeParameter
forall x. Rep DateTimeParameter x -> DateTimeParameter
forall x. DateTimeParameter -> Rep DateTimeParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DateTimeParameter x -> DateTimeParameter
$cfrom :: forall x. DateTimeParameter -> Rep DateTimeParameter x
Prelude.Generic)

-- |
-- Create a value of 'DateTimeParameter' 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:
--
-- 'name', 'dateTimeParameter_name' - A display name for the date-time parameter.
--
-- 'values', 'dateTimeParameter_values' - The values for the date-time parameter.
newDateTimeParameter ::
  -- | 'name'
  Prelude.Text ->
  DateTimeParameter
newDateTimeParameter :: Text -> DateTimeParameter
newDateTimeParameter Text
pName_ =
  DateTimeParameter' :: Text -> [POSIX] -> DateTimeParameter
DateTimeParameter'
    { $sel:name:DateTimeParameter' :: Text
name = Text
pName_,
      $sel:values:DateTimeParameter' :: [POSIX]
values = [POSIX]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A display name for the date-time parameter.
dateTimeParameter_name :: Lens.Lens' DateTimeParameter Prelude.Text
dateTimeParameter_name :: (Text -> f Text) -> DateTimeParameter -> f DateTimeParameter
dateTimeParameter_name = (DateTimeParameter -> Text)
-> (DateTimeParameter -> Text -> DateTimeParameter)
-> Lens DateTimeParameter DateTimeParameter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateTimeParameter' {Text
name :: Text
$sel:name:DateTimeParameter' :: DateTimeParameter -> Text
name} -> Text
name) (\s :: DateTimeParameter
s@DateTimeParameter' {} Text
a -> DateTimeParameter
s {$sel:name:DateTimeParameter' :: Text
name = Text
a} :: DateTimeParameter)

-- | The values for the date-time parameter.
dateTimeParameter_values :: Lens.Lens' DateTimeParameter [Prelude.UTCTime]
dateTimeParameter_values :: ([UTCTime] -> f [UTCTime])
-> DateTimeParameter -> f DateTimeParameter
dateTimeParameter_values = (DateTimeParameter -> [POSIX])
-> (DateTimeParameter -> [POSIX] -> DateTimeParameter)
-> Lens DateTimeParameter DateTimeParameter [POSIX] [POSIX]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateTimeParameter' {[POSIX]
values :: [POSIX]
$sel:values:DateTimeParameter' :: DateTimeParameter -> [POSIX]
values} -> [POSIX]
values) (\s :: DateTimeParameter
s@DateTimeParameter' {} [POSIX]
a -> DateTimeParameter
s {$sel:values:DateTimeParameter' :: [POSIX]
values = [POSIX]
a} :: DateTimeParameter) (([POSIX] -> f [POSIX])
 -> DateTimeParameter -> f DateTimeParameter)
-> (([UTCTime] -> f [UTCTime]) -> [POSIX] -> f [POSIX])
-> ([UTCTime] -> f [UTCTime])
-> DateTimeParameter
-> f DateTimeParameter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UTCTime] -> f [UTCTime]) -> [POSIX] -> f [POSIX]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable DateTimeParameter

instance Prelude.NFData DateTimeParameter

instance Core.ToJSON DateTimeParameter where
  toJSON :: DateTimeParameter -> Value
toJSON DateTimeParameter' {[POSIX]
Text
values :: [POSIX]
name :: Text
$sel:values:DateTimeParameter' :: DateTimeParameter -> [POSIX]
$sel:name:DateTimeParameter' :: DateTimeParameter -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> [POSIX] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [POSIX]
values)
          ]
      )