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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.GeoSpatialColumnGroup

-- | Groupings of columns that work together in certain Amazon QuickSight
-- features. This is a variant type structure. For this structure to be
-- valid, only one of the attributes can be non-null.
--
-- /See:/ 'newColumnGroup' smart constructor.
data ColumnGroup = ColumnGroup'
  { -- | Geospatial column group that denotes a hierarchy.
    ColumnGroup -> Maybe GeoSpatialColumnGroup
geoSpatialColumnGroup :: Prelude.Maybe GeoSpatialColumnGroup
  }
  deriving (ColumnGroup -> ColumnGroup -> Bool
(ColumnGroup -> ColumnGroup -> Bool)
-> (ColumnGroup -> ColumnGroup -> Bool) -> Eq ColumnGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnGroup -> ColumnGroup -> Bool
$c/= :: ColumnGroup -> ColumnGroup -> Bool
== :: ColumnGroup -> ColumnGroup -> Bool
$c== :: ColumnGroup -> ColumnGroup -> Bool
Prelude.Eq, ReadPrec [ColumnGroup]
ReadPrec ColumnGroup
Int -> ReadS ColumnGroup
ReadS [ColumnGroup]
(Int -> ReadS ColumnGroup)
-> ReadS [ColumnGroup]
-> ReadPrec ColumnGroup
-> ReadPrec [ColumnGroup]
-> Read ColumnGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnGroup]
$creadListPrec :: ReadPrec [ColumnGroup]
readPrec :: ReadPrec ColumnGroup
$creadPrec :: ReadPrec ColumnGroup
readList :: ReadS [ColumnGroup]
$creadList :: ReadS [ColumnGroup]
readsPrec :: Int -> ReadS ColumnGroup
$creadsPrec :: Int -> ReadS ColumnGroup
Prelude.Read, Int -> ColumnGroup -> ShowS
[ColumnGroup] -> ShowS
ColumnGroup -> String
(Int -> ColumnGroup -> ShowS)
-> (ColumnGroup -> String)
-> ([ColumnGroup] -> ShowS)
-> Show ColumnGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnGroup] -> ShowS
$cshowList :: [ColumnGroup] -> ShowS
show :: ColumnGroup -> String
$cshow :: ColumnGroup -> String
showsPrec :: Int -> ColumnGroup -> ShowS
$cshowsPrec :: Int -> ColumnGroup -> ShowS
Prelude.Show, (forall x. ColumnGroup -> Rep ColumnGroup x)
-> (forall x. Rep ColumnGroup x -> ColumnGroup)
-> Generic ColumnGroup
forall x. Rep ColumnGroup x -> ColumnGroup
forall x. ColumnGroup -> Rep ColumnGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnGroup x -> ColumnGroup
$cfrom :: forall x. ColumnGroup -> Rep ColumnGroup x
Prelude.Generic)

-- |
-- Create a value of 'ColumnGroup' 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:
--
-- 'geoSpatialColumnGroup', 'columnGroup_geoSpatialColumnGroup' - Geospatial column group that denotes a hierarchy.
newColumnGroup ::
  ColumnGroup
newColumnGroup :: ColumnGroup
newColumnGroup =
  ColumnGroup' :: Maybe GeoSpatialColumnGroup -> ColumnGroup
ColumnGroup'
    { $sel:geoSpatialColumnGroup:ColumnGroup' :: Maybe GeoSpatialColumnGroup
geoSpatialColumnGroup =
        Maybe GeoSpatialColumnGroup
forall a. Maybe a
Prelude.Nothing
    }

-- | Geospatial column group that denotes a hierarchy.
columnGroup_geoSpatialColumnGroup :: Lens.Lens' ColumnGroup (Prelude.Maybe GeoSpatialColumnGroup)
columnGroup_geoSpatialColumnGroup :: (Maybe GeoSpatialColumnGroup -> f (Maybe GeoSpatialColumnGroup))
-> ColumnGroup -> f ColumnGroup
columnGroup_geoSpatialColumnGroup = (ColumnGroup -> Maybe GeoSpatialColumnGroup)
-> (ColumnGroup -> Maybe GeoSpatialColumnGroup -> ColumnGroup)
-> Lens
     ColumnGroup
     ColumnGroup
     (Maybe GeoSpatialColumnGroup)
     (Maybe GeoSpatialColumnGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnGroup' {Maybe GeoSpatialColumnGroup
geoSpatialColumnGroup :: Maybe GeoSpatialColumnGroup
$sel:geoSpatialColumnGroup:ColumnGroup' :: ColumnGroup -> Maybe GeoSpatialColumnGroup
geoSpatialColumnGroup} -> Maybe GeoSpatialColumnGroup
geoSpatialColumnGroup) (\s :: ColumnGroup
s@ColumnGroup' {} Maybe GeoSpatialColumnGroup
a -> ColumnGroup
s {$sel:geoSpatialColumnGroup:ColumnGroup' :: Maybe GeoSpatialColumnGroup
geoSpatialColumnGroup = Maybe GeoSpatialColumnGroup
a} :: ColumnGroup)

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

instance Prelude.Hashable ColumnGroup

instance Prelude.NFData ColumnGroup

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