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

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

-- | Properties associated with the columns participating in a join.
--
-- /See:/ 'newJoinKeyProperties' smart constructor.
data JoinKeyProperties = JoinKeyProperties'
  { -- | A value that indicates that a row in a table is uniquely identified by
    -- the columns in a join key. This is used by Amazon QuickSight to optimize
    -- query performance.
    JoinKeyProperties -> Maybe Bool
uniqueKey :: Prelude.Maybe Prelude.Bool
  }
  deriving (JoinKeyProperties -> JoinKeyProperties -> Bool
(JoinKeyProperties -> JoinKeyProperties -> Bool)
-> (JoinKeyProperties -> JoinKeyProperties -> Bool)
-> Eq JoinKeyProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JoinKeyProperties -> JoinKeyProperties -> Bool
$c/= :: JoinKeyProperties -> JoinKeyProperties -> Bool
== :: JoinKeyProperties -> JoinKeyProperties -> Bool
$c== :: JoinKeyProperties -> JoinKeyProperties -> Bool
Prelude.Eq, ReadPrec [JoinKeyProperties]
ReadPrec JoinKeyProperties
Int -> ReadS JoinKeyProperties
ReadS [JoinKeyProperties]
(Int -> ReadS JoinKeyProperties)
-> ReadS [JoinKeyProperties]
-> ReadPrec JoinKeyProperties
-> ReadPrec [JoinKeyProperties]
-> Read JoinKeyProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JoinKeyProperties]
$creadListPrec :: ReadPrec [JoinKeyProperties]
readPrec :: ReadPrec JoinKeyProperties
$creadPrec :: ReadPrec JoinKeyProperties
readList :: ReadS [JoinKeyProperties]
$creadList :: ReadS [JoinKeyProperties]
readsPrec :: Int -> ReadS JoinKeyProperties
$creadsPrec :: Int -> ReadS JoinKeyProperties
Prelude.Read, Int -> JoinKeyProperties -> ShowS
[JoinKeyProperties] -> ShowS
JoinKeyProperties -> String
(Int -> JoinKeyProperties -> ShowS)
-> (JoinKeyProperties -> String)
-> ([JoinKeyProperties] -> ShowS)
-> Show JoinKeyProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JoinKeyProperties] -> ShowS
$cshowList :: [JoinKeyProperties] -> ShowS
show :: JoinKeyProperties -> String
$cshow :: JoinKeyProperties -> String
showsPrec :: Int -> JoinKeyProperties -> ShowS
$cshowsPrec :: Int -> JoinKeyProperties -> ShowS
Prelude.Show, (forall x. JoinKeyProperties -> Rep JoinKeyProperties x)
-> (forall x. Rep JoinKeyProperties x -> JoinKeyProperties)
-> Generic JoinKeyProperties
forall x. Rep JoinKeyProperties x -> JoinKeyProperties
forall x. JoinKeyProperties -> Rep JoinKeyProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JoinKeyProperties x -> JoinKeyProperties
$cfrom :: forall x. JoinKeyProperties -> Rep JoinKeyProperties x
Prelude.Generic)

-- |
-- Create a value of 'JoinKeyProperties' 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:
--
-- 'uniqueKey', 'joinKeyProperties_uniqueKey' - A value that indicates that a row in a table is uniquely identified by
-- the columns in a join key. This is used by Amazon QuickSight to optimize
-- query performance.
newJoinKeyProperties ::
  JoinKeyProperties
newJoinKeyProperties :: JoinKeyProperties
newJoinKeyProperties =
  JoinKeyProperties' :: Maybe Bool -> JoinKeyProperties
JoinKeyProperties' {$sel:uniqueKey:JoinKeyProperties' :: Maybe Bool
uniqueKey = Maybe Bool
forall a. Maybe a
Prelude.Nothing}

-- | A value that indicates that a row in a table is uniquely identified by
-- the columns in a join key. This is used by Amazon QuickSight to optimize
-- query performance.
joinKeyProperties_uniqueKey :: Lens.Lens' JoinKeyProperties (Prelude.Maybe Prelude.Bool)
joinKeyProperties_uniqueKey :: (Maybe Bool -> f (Maybe Bool))
-> JoinKeyProperties -> f JoinKeyProperties
joinKeyProperties_uniqueKey = (JoinKeyProperties -> Maybe Bool)
-> (JoinKeyProperties -> Maybe Bool -> JoinKeyProperties)
-> Lens
     JoinKeyProperties JoinKeyProperties (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JoinKeyProperties' {Maybe Bool
uniqueKey :: Maybe Bool
$sel:uniqueKey:JoinKeyProperties' :: JoinKeyProperties -> Maybe Bool
uniqueKey} -> Maybe Bool
uniqueKey) (\s :: JoinKeyProperties
s@JoinKeyProperties' {} Maybe Bool
a -> JoinKeyProperties
s {$sel:uniqueKey:JoinKeyProperties' :: Maybe Bool
uniqueKey = Maybe Bool
a} :: JoinKeyProperties)

instance Core.FromJSON JoinKeyProperties where
  parseJSON :: Value -> Parser JoinKeyProperties
parseJSON =
    String
-> (Object -> Parser JoinKeyProperties)
-> Value
-> Parser JoinKeyProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JoinKeyProperties"
      ( \Object
x ->
          Maybe Bool -> JoinKeyProperties
JoinKeyProperties'
            (Maybe Bool -> JoinKeyProperties)
-> Parser (Maybe Bool) -> Parser JoinKeyProperties
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UniqueKey")
      )

instance Prelude.Hashable JoinKeyProperties

instance Prelude.NFData JoinKeyProperties

instance Core.ToJSON JoinKeyProperties where
  toJSON :: JoinKeyProperties -> Value
toJSON JoinKeyProperties' {Maybe Bool
uniqueKey :: Maybe Bool
$sel:uniqueKey:JoinKeyProperties' :: JoinKeyProperties -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"UniqueKey" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
uniqueKey]
      )