{-# 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.ColumnTag
-- 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.ColumnTag 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.ColumnDescription
import Amazonka.QuickSight.Types.GeoSpatialDataRole

-- | A tag for a column in a
-- @ @<https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TagColumnOperation.html TagColumnOperation>@ @
-- structure. This is a variant type structure. For this structure to be
-- valid, only one of the attributes can be non-null.
--
-- /See:/ 'newColumnTag' smart constructor.
data ColumnTag = ColumnTag'
  { -- | A description for a column.
    ColumnTag -> Maybe ColumnDescription
columnDescription :: Prelude.Maybe ColumnDescription,
    -- | A geospatial role for a column.
    ColumnTag -> Maybe GeoSpatialDataRole
columnGeographicRole :: Prelude.Maybe GeoSpatialDataRole
  }
  deriving (ColumnTag -> ColumnTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnTag -> ColumnTag -> Bool
$c/= :: ColumnTag -> ColumnTag -> Bool
== :: ColumnTag -> ColumnTag -> Bool
$c== :: ColumnTag -> ColumnTag -> Bool
Prelude.Eq, ReadPrec [ColumnTag]
ReadPrec ColumnTag
Int -> ReadS ColumnTag
ReadS [ColumnTag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnTag]
$creadListPrec :: ReadPrec [ColumnTag]
readPrec :: ReadPrec ColumnTag
$creadPrec :: ReadPrec ColumnTag
readList :: ReadS [ColumnTag]
$creadList :: ReadS [ColumnTag]
readsPrec :: Int -> ReadS ColumnTag
$creadsPrec :: Int -> ReadS ColumnTag
Prelude.Read, Int -> ColumnTag -> ShowS
[ColumnTag] -> ShowS
ColumnTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnTag] -> ShowS
$cshowList :: [ColumnTag] -> ShowS
show :: ColumnTag -> String
$cshow :: ColumnTag -> String
showsPrec :: Int -> ColumnTag -> ShowS
$cshowsPrec :: Int -> ColumnTag -> ShowS
Prelude.Show, forall x. Rep ColumnTag x -> ColumnTag
forall x. ColumnTag -> Rep ColumnTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnTag x -> ColumnTag
$cfrom :: forall x. ColumnTag -> Rep ColumnTag x
Prelude.Generic)

-- |
-- Create a value of 'ColumnTag' 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:
--
-- 'columnDescription', 'columnTag_columnDescription' - A description for a column.
--
-- 'columnGeographicRole', 'columnTag_columnGeographicRole' - A geospatial role for a column.
newColumnTag ::
  ColumnTag
newColumnTag :: ColumnTag
newColumnTag =
  ColumnTag'
    { $sel:columnDescription:ColumnTag' :: Maybe ColumnDescription
columnDescription = forall a. Maybe a
Prelude.Nothing,
      $sel:columnGeographicRole:ColumnTag' :: Maybe GeoSpatialDataRole
columnGeographicRole = forall a. Maybe a
Prelude.Nothing
    }

-- | A description for a column.
columnTag_columnDescription :: Lens.Lens' ColumnTag (Prelude.Maybe ColumnDescription)
columnTag_columnDescription :: Lens' ColumnTag (Maybe ColumnDescription)
columnTag_columnDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnTag' {Maybe ColumnDescription
columnDescription :: Maybe ColumnDescription
$sel:columnDescription:ColumnTag' :: ColumnTag -> Maybe ColumnDescription
columnDescription} -> Maybe ColumnDescription
columnDescription) (\s :: ColumnTag
s@ColumnTag' {} Maybe ColumnDescription
a -> ColumnTag
s {$sel:columnDescription:ColumnTag' :: Maybe ColumnDescription
columnDescription = Maybe ColumnDescription
a} :: ColumnTag)

-- | A geospatial role for a column.
columnTag_columnGeographicRole :: Lens.Lens' ColumnTag (Prelude.Maybe GeoSpatialDataRole)
columnTag_columnGeographicRole :: Lens' ColumnTag (Maybe GeoSpatialDataRole)
columnTag_columnGeographicRole = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnTag' {Maybe GeoSpatialDataRole
columnGeographicRole :: Maybe GeoSpatialDataRole
$sel:columnGeographicRole:ColumnTag' :: ColumnTag -> Maybe GeoSpatialDataRole
columnGeographicRole} -> Maybe GeoSpatialDataRole
columnGeographicRole) (\s :: ColumnTag
s@ColumnTag' {} Maybe GeoSpatialDataRole
a -> ColumnTag
s {$sel:columnGeographicRole:ColumnTag' :: Maybe GeoSpatialDataRole
columnGeographicRole = Maybe GeoSpatialDataRole
a} :: ColumnTag)

instance Data.FromJSON ColumnTag where
  parseJSON :: Value -> Parser ColumnTag
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnTag"
      ( \Object
x ->
          Maybe ColumnDescription -> Maybe GeoSpatialDataRole -> ColumnTag
ColumnTag'
            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
"ColumnDescription")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ColumnGeographicRole")
      )

instance Prelude.Hashable ColumnTag where
  hashWithSalt :: Int -> ColumnTag -> Int
hashWithSalt Int
_salt ColumnTag' {Maybe ColumnDescription
Maybe GeoSpatialDataRole
columnGeographicRole :: Maybe GeoSpatialDataRole
columnDescription :: Maybe ColumnDescription
$sel:columnGeographicRole:ColumnTag' :: ColumnTag -> Maybe GeoSpatialDataRole
$sel:columnDescription:ColumnTag' :: ColumnTag -> Maybe ColumnDescription
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ColumnDescription
columnDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GeoSpatialDataRole
columnGeographicRole

instance Prelude.NFData ColumnTag where
  rnf :: ColumnTag -> ()
rnf ColumnTag' {Maybe ColumnDescription
Maybe GeoSpatialDataRole
columnGeographicRole :: Maybe GeoSpatialDataRole
columnDescription :: Maybe ColumnDescription
$sel:columnGeographicRole:ColumnTag' :: ColumnTag -> Maybe GeoSpatialDataRole
$sel:columnDescription:ColumnTag' :: ColumnTag -> Maybe ColumnDescription
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ColumnDescription
columnDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe GeoSpatialDataRole
columnGeographicRole

instance Data.ToJSON ColumnTag where
  toJSON :: ColumnTag -> Value
toJSON ColumnTag' {Maybe ColumnDescription
Maybe GeoSpatialDataRole
columnGeographicRole :: Maybe GeoSpatialDataRole
columnDescription :: Maybe ColumnDescription
$sel:columnGeographicRole:ColumnTag' :: ColumnTag -> Maybe GeoSpatialDataRole
$sel:columnDescription:ColumnTag' :: ColumnTag -> Maybe ColumnDescription
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ColumnDescription" 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 ColumnDescription
columnDescription,
            (Key
"ColumnGeographicRole" 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 GeoSpatialDataRole
columnGeographicRole
          ]
      )