{-# 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.GeoSpatialColumnGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.GeoSpatialColumnGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.GeoSpatialCountryCode

-- | Geospatial column group that denotes a hierarchy.
--
-- /See:/ 'newGeoSpatialColumnGroup' smart constructor.
data GeoSpatialColumnGroup = GeoSpatialColumnGroup'
  { -- | Country code.
    GeoSpatialColumnGroup -> Maybe GeoSpatialCountryCode
countryCode :: Prelude.Maybe GeoSpatialCountryCode,
    -- | A display name for the hierarchy.
    GeoSpatialColumnGroup -> Text
name :: Prelude.Text,
    -- | Columns in this hierarchy.
    GeoSpatialColumnGroup -> NonEmpty Text
columns :: Prelude.NonEmpty Prelude.Text
  }
  deriving (GeoSpatialColumnGroup -> GeoSpatialColumnGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeoSpatialColumnGroup -> GeoSpatialColumnGroup -> Bool
$c/= :: GeoSpatialColumnGroup -> GeoSpatialColumnGroup -> Bool
== :: GeoSpatialColumnGroup -> GeoSpatialColumnGroup -> Bool
$c== :: GeoSpatialColumnGroup -> GeoSpatialColumnGroup -> Bool
Prelude.Eq, ReadPrec [GeoSpatialColumnGroup]
ReadPrec GeoSpatialColumnGroup
Int -> ReadS GeoSpatialColumnGroup
ReadS [GeoSpatialColumnGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeoSpatialColumnGroup]
$creadListPrec :: ReadPrec [GeoSpatialColumnGroup]
readPrec :: ReadPrec GeoSpatialColumnGroup
$creadPrec :: ReadPrec GeoSpatialColumnGroup
readList :: ReadS [GeoSpatialColumnGroup]
$creadList :: ReadS [GeoSpatialColumnGroup]
readsPrec :: Int -> ReadS GeoSpatialColumnGroup
$creadsPrec :: Int -> ReadS GeoSpatialColumnGroup
Prelude.Read, Int -> GeoSpatialColumnGroup -> ShowS
[GeoSpatialColumnGroup] -> ShowS
GeoSpatialColumnGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeoSpatialColumnGroup] -> ShowS
$cshowList :: [GeoSpatialColumnGroup] -> ShowS
show :: GeoSpatialColumnGroup -> String
$cshow :: GeoSpatialColumnGroup -> String
showsPrec :: Int -> GeoSpatialColumnGroup -> ShowS
$cshowsPrec :: Int -> GeoSpatialColumnGroup -> ShowS
Prelude.Show, forall x. Rep GeoSpatialColumnGroup x -> GeoSpatialColumnGroup
forall x. GeoSpatialColumnGroup -> Rep GeoSpatialColumnGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GeoSpatialColumnGroup x -> GeoSpatialColumnGroup
$cfrom :: forall x. GeoSpatialColumnGroup -> Rep GeoSpatialColumnGroup x
Prelude.Generic)

-- |
-- Create a value of 'GeoSpatialColumnGroup' 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:
--
-- 'countryCode', 'geoSpatialColumnGroup_countryCode' - Country code.
--
-- 'name', 'geoSpatialColumnGroup_name' - A display name for the hierarchy.
--
-- 'columns', 'geoSpatialColumnGroup_columns' - Columns in this hierarchy.
newGeoSpatialColumnGroup ::
  -- | 'name'
  Prelude.Text ->
  -- | 'columns'
  Prelude.NonEmpty Prelude.Text ->
  GeoSpatialColumnGroup
newGeoSpatialColumnGroup :: Text -> NonEmpty Text -> GeoSpatialColumnGroup
newGeoSpatialColumnGroup Text
pName_ NonEmpty Text
pColumns_ =
  GeoSpatialColumnGroup'
    { $sel:countryCode:GeoSpatialColumnGroup' :: Maybe GeoSpatialCountryCode
countryCode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:GeoSpatialColumnGroup' :: Text
name = Text
pName_,
      $sel:columns:GeoSpatialColumnGroup' :: NonEmpty Text
columns = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pColumns_
    }

-- | Country code.
geoSpatialColumnGroup_countryCode :: Lens.Lens' GeoSpatialColumnGroup (Prelude.Maybe GeoSpatialCountryCode)
geoSpatialColumnGroup_countryCode :: Lens' GeoSpatialColumnGroup (Maybe GeoSpatialCountryCode)
geoSpatialColumnGroup_countryCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoSpatialColumnGroup' {Maybe GeoSpatialCountryCode
countryCode :: Maybe GeoSpatialCountryCode
$sel:countryCode:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> Maybe GeoSpatialCountryCode
countryCode} -> Maybe GeoSpatialCountryCode
countryCode) (\s :: GeoSpatialColumnGroup
s@GeoSpatialColumnGroup' {} Maybe GeoSpatialCountryCode
a -> GeoSpatialColumnGroup
s {$sel:countryCode:GeoSpatialColumnGroup' :: Maybe GeoSpatialCountryCode
countryCode = Maybe GeoSpatialCountryCode
a} :: GeoSpatialColumnGroup)

-- | A display name for the hierarchy.
geoSpatialColumnGroup_name :: Lens.Lens' GeoSpatialColumnGroup Prelude.Text
geoSpatialColumnGroup_name :: Lens' GeoSpatialColumnGroup Text
geoSpatialColumnGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoSpatialColumnGroup' {Text
name :: Text
$sel:name:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> Text
name} -> Text
name) (\s :: GeoSpatialColumnGroup
s@GeoSpatialColumnGroup' {} Text
a -> GeoSpatialColumnGroup
s {$sel:name:GeoSpatialColumnGroup' :: Text
name = Text
a} :: GeoSpatialColumnGroup)

-- | Columns in this hierarchy.
geoSpatialColumnGroup_columns :: Lens.Lens' GeoSpatialColumnGroup (Prelude.NonEmpty Prelude.Text)
geoSpatialColumnGroup_columns :: Lens' GeoSpatialColumnGroup (NonEmpty Text)
geoSpatialColumnGroup_columns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoSpatialColumnGroup' {NonEmpty Text
columns :: NonEmpty Text
$sel:columns:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> NonEmpty Text
columns} -> NonEmpty Text
columns) (\s :: GeoSpatialColumnGroup
s@GeoSpatialColumnGroup' {} NonEmpty Text
a -> GeoSpatialColumnGroup
s {$sel:columns:GeoSpatialColumnGroup' :: NonEmpty Text
columns = NonEmpty Text
a} :: GeoSpatialColumnGroup) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON GeoSpatialColumnGroup where
  parseJSON :: Value -> Parser GeoSpatialColumnGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GeoSpatialColumnGroup"
      ( \Object
x ->
          Maybe GeoSpatialCountryCode
-> Text -> NonEmpty Text -> GeoSpatialColumnGroup
GeoSpatialColumnGroup'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CountryCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Columns")
      )

instance Prelude.Hashable GeoSpatialColumnGroup where
  hashWithSalt :: Int -> GeoSpatialColumnGroup -> Int
hashWithSalt Int
_salt GeoSpatialColumnGroup' {Maybe GeoSpatialCountryCode
NonEmpty Text
Text
columns :: NonEmpty Text
name :: Text
countryCode :: Maybe GeoSpatialCountryCode
$sel:columns:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> NonEmpty Text
$sel:name:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> Text
$sel:countryCode:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> Maybe GeoSpatialCountryCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GeoSpatialCountryCode
countryCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
columns

instance Prelude.NFData GeoSpatialColumnGroup where
  rnf :: GeoSpatialColumnGroup -> ()
rnf GeoSpatialColumnGroup' {Maybe GeoSpatialCountryCode
NonEmpty Text
Text
columns :: NonEmpty Text
name :: Text
countryCode :: Maybe GeoSpatialCountryCode
$sel:columns:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> NonEmpty Text
$sel:name:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> Text
$sel:countryCode:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> Maybe GeoSpatialCountryCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe GeoSpatialCountryCode
countryCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
columns

instance Data.ToJSON GeoSpatialColumnGroup where
  toJSON :: GeoSpatialColumnGroup -> Value
toJSON GeoSpatialColumnGroup' {Maybe GeoSpatialCountryCode
NonEmpty Text
Text
columns :: NonEmpty Text
name :: Text
countryCode :: Maybe GeoSpatialCountryCode
$sel:columns:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> NonEmpty Text
$sel:name:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> Text
$sel:countryCode:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> Maybe GeoSpatialCountryCode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CountryCode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GeoSpatialCountryCode
countryCode,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Columns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
columns)
          ]
      )