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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | A display name for the hierarchy.
    GeoSpatialColumnGroup -> Text
name :: Prelude.Text,
    -- | Country code.
    GeoSpatialColumnGroup -> GeoSpatialCountryCode
countryCode :: GeoSpatialCountryCode,
    -- | Columns in this hierarchy.
    GeoSpatialColumnGroup -> NonEmpty Text
columns :: Prelude.NonEmpty Prelude.Text
  }
  deriving (GeoSpatialColumnGroup -> GeoSpatialColumnGroup -> Bool
(GeoSpatialColumnGroup -> GeoSpatialColumnGroup -> Bool)
-> (GeoSpatialColumnGroup -> GeoSpatialColumnGroup -> Bool)
-> Eq GeoSpatialColumnGroup
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]
(Int -> ReadS GeoSpatialColumnGroup)
-> ReadS [GeoSpatialColumnGroup]
-> ReadPrec GeoSpatialColumnGroup
-> ReadPrec [GeoSpatialColumnGroup]
-> Read 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
(Int -> GeoSpatialColumnGroup -> ShowS)
-> (GeoSpatialColumnGroup -> String)
-> ([GeoSpatialColumnGroup] -> ShowS)
-> Show GeoSpatialColumnGroup
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. GeoSpatialColumnGroup -> Rep GeoSpatialColumnGroup x)
-> (forall x. Rep GeoSpatialColumnGroup x -> GeoSpatialColumnGroup)
-> Generic GeoSpatialColumnGroup
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:
--
-- 'name', 'geoSpatialColumnGroup_name' - A display name for the hierarchy.
--
-- 'countryCode', 'geoSpatialColumnGroup_countryCode' - Country code.
--
-- 'columns', 'geoSpatialColumnGroup_columns' - Columns in this hierarchy.
newGeoSpatialColumnGroup ::
  -- | 'name'
  Prelude.Text ->
  -- | 'countryCode'
  GeoSpatialCountryCode ->
  -- | 'columns'
  Prelude.NonEmpty Prelude.Text ->
  GeoSpatialColumnGroup
newGeoSpatialColumnGroup :: Text
-> GeoSpatialCountryCode -> NonEmpty Text -> GeoSpatialColumnGroup
newGeoSpatialColumnGroup
  Text
pName_
  GeoSpatialCountryCode
pCountryCode_
  NonEmpty Text
pColumns_ =
    GeoSpatialColumnGroup' :: Text
-> GeoSpatialCountryCode -> NonEmpty Text -> GeoSpatialColumnGroup
GeoSpatialColumnGroup'
      { $sel:name:GeoSpatialColumnGroup' :: Text
name = Text
pName_,
        $sel:countryCode:GeoSpatialColumnGroup' :: GeoSpatialCountryCode
countryCode = GeoSpatialCountryCode
pCountryCode_,
        $sel:columns:GeoSpatialColumnGroup' :: NonEmpty Text
columns = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pColumns_
      }

-- | A display name for the hierarchy.
geoSpatialColumnGroup_name :: Lens.Lens' GeoSpatialColumnGroup Prelude.Text
geoSpatialColumnGroup_name :: (Text -> f Text)
-> GeoSpatialColumnGroup -> f GeoSpatialColumnGroup
geoSpatialColumnGroup_name = (GeoSpatialColumnGroup -> Text)
-> (GeoSpatialColumnGroup -> Text -> GeoSpatialColumnGroup)
-> Lens GeoSpatialColumnGroup GeoSpatialColumnGroup Text Text
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)

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

-- | Columns in this hierarchy.
geoSpatialColumnGroup_columns :: Lens.Lens' GeoSpatialColumnGroup (Prelude.NonEmpty Prelude.Text)
geoSpatialColumnGroup_columns :: (NonEmpty Text -> f (NonEmpty Text))
-> GeoSpatialColumnGroup -> f GeoSpatialColumnGroup
geoSpatialColumnGroup_columns = (GeoSpatialColumnGroup -> NonEmpty Text)
-> (GeoSpatialColumnGroup
    -> NonEmpty Text -> GeoSpatialColumnGroup)
-> Lens
     GeoSpatialColumnGroup
     GeoSpatialColumnGroup
     (NonEmpty Text)
     (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> GeoSpatialColumnGroup -> f GeoSpatialColumnGroup)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> GeoSpatialColumnGroup
-> f GeoSpatialColumnGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable GeoSpatialColumnGroup

instance Prelude.NFData GeoSpatialColumnGroup

instance Core.ToJSON GeoSpatialColumnGroup where
  toJSON :: GeoSpatialColumnGroup -> Value
toJSON GeoSpatialColumnGroup' {NonEmpty Text
Text
GeoSpatialCountryCode
columns :: NonEmpty Text
countryCode :: GeoSpatialCountryCode
name :: Text
$sel:columns:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> NonEmpty Text
$sel:countryCode:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> GeoSpatialCountryCode
$sel:name:GeoSpatialColumnGroup' :: GeoSpatialColumnGroup -> 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
"CountryCode" Text -> GeoSpatialCountryCode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= GeoSpatialCountryCode
countryCode),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Columns" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
columns)
          ]
      )