{-# 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.TagColumnOperation
-- 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.TagColumnOperation 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.ColumnTag

-- | A transform operation that tags a column with additional information.
--
-- /See:/ 'newTagColumnOperation' smart constructor.
data TagColumnOperation = TagColumnOperation'
  { -- | The column that this operation acts on.
    TagColumnOperation -> Text
columnName :: Prelude.Text,
    -- | The dataset column tag, currently only used for geospatial type tagging.
    --
    -- This is not tags for the Amazon Web Services tagging feature.
    TagColumnOperation -> NonEmpty ColumnTag
tags :: Prelude.NonEmpty ColumnTag
  }
  deriving (TagColumnOperation -> TagColumnOperation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagColumnOperation -> TagColumnOperation -> Bool
$c/= :: TagColumnOperation -> TagColumnOperation -> Bool
== :: TagColumnOperation -> TagColumnOperation -> Bool
$c== :: TagColumnOperation -> TagColumnOperation -> Bool
Prelude.Eq, ReadPrec [TagColumnOperation]
ReadPrec TagColumnOperation
Int -> ReadS TagColumnOperation
ReadS [TagColumnOperation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagColumnOperation]
$creadListPrec :: ReadPrec [TagColumnOperation]
readPrec :: ReadPrec TagColumnOperation
$creadPrec :: ReadPrec TagColumnOperation
readList :: ReadS [TagColumnOperation]
$creadList :: ReadS [TagColumnOperation]
readsPrec :: Int -> ReadS TagColumnOperation
$creadsPrec :: Int -> ReadS TagColumnOperation
Prelude.Read, Int -> TagColumnOperation -> ShowS
[TagColumnOperation] -> ShowS
TagColumnOperation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagColumnOperation] -> ShowS
$cshowList :: [TagColumnOperation] -> ShowS
show :: TagColumnOperation -> String
$cshow :: TagColumnOperation -> String
showsPrec :: Int -> TagColumnOperation -> ShowS
$cshowsPrec :: Int -> TagColumnOperation -> ShowS
Prelude.Show, forall x. Rep TagColumnOperation x -> TagColumnOperation
forall x. TagColumnOperation -> Rep TagColumnOperation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagColumnOperation x -> TagColumnOperation
$cfrom :: forall x. TagColumnOperation -> Rep TagColumnOperation x
Prelude.Generic)

-- |
-- Create a value of 'TagColumnOperation' 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:
--
-- 'columnName', 'tagColumnOperation_columnName' - The column that this operation acts on.
--
-- 'tags', 'tagColumnOperation_tags' - The dataset column tag, currently only used for geospatial type tagging.
--
-- This is not tags for the Amazon Web Services tagging feature.
newTagColumnOperation ::
  -- | 'columnName'
  Prelude.Text ->
  -- | 'tags'
  Prelude.NonEmpty ColumnTag ->
  TagColumnOperation
newTagColumnOperation :: Text -> NonEmpty ColumnTag -> TagColumnOperation
newTagColumnOperation Text
pColumnName_ NonEmpty ColumnTag
pTags_ =
  TagColumnOperation'
    { $sel:columnName:TagColumnOperation' :: Text
columnName = Text
pColumnName_,
      $sel:tags:TagColumnOperation' :: NonEmpty ColumnTag
tags = 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 ColumnTag
pTags_
    }

-- | The column that this operation acts on.
tagColumnOperation_columnName :: Lens.Lens' TagColumnOperation Prelude.Text
tagColumnOperation_columnName :: Lens' TagColumnOperation Text
tagColumnOperation_columnName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagColumnOperation' {Text
columnName :: Text
$sel:columnName:TagColumnOperation' :: TagColumnOperation -> Text
columnName} -> Text
columnName) (\s :: TagColumnOperation
s@TagColumnOperation' {} Text
a -> TagColumnOperation
s {$sel:columnName:TagColumnOperation' :: Text
columnName = Text
a} :: TagColumnOperation)

-- | The dataset column tag, currently only used for geospatial type tagging.
--
-- This is not tags for the Amazon Web Services tagging feature.
tagColumnOperation_tags :: Lens.Lens' TagColumnOperation (Prelude.NonEmpty ColumnTag)
tagColumnOperation_tags :: Lens' TagColumnOperation (NonEmpty ColumnTag)
tagColumnOperation_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagColumnOperation' {NonEmpty ColumnTag
tags :: NonEmpty ColumnTag
$sel:tags:TagColumnOperation' :: TagColumnOperation -> NonEmpty ColumnTag
tags} -> NonEmpty ColumnTag
tags) (\s :: TagColumnOperation
s@TagColumnOperation' {} NonEmpty ColumnTag
a -> TagColumnOperation
s {$sel:tags:TagColumnOperation' :: NonEmpty ColumnTag
tags = NonEmpty ColumnTag
a} :: TagColumnOperation) 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 TagColumnOperation where
  parseJSON :: Value -> Parser TagColumnOperation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TagColumnOperation"
      ( \Object
x ->
          Text -> NonEmpty ColumnTag -> TagColumnOperation
TagColumnOperation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ColumnName")
            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
"Tags")
      )

instance Prelude.Hashable TagColumnOperation where
  hashWithSalt :: Int -> TagColumnOperation -> Int
hashWithSalt Int
_salt TagColumnOperation' {NonEmpty ColumnTag
Text
tags :: NonEmpty ColumnTag
columnName :: Text
$sel:tags:TagColumnOperation' :: TagColumnOperation -> NonEmpty ColumnTag
$sel:columnName:TagColumnOperation' :: TagColumnOperation -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
columnName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty ColumnTag
tags

instance Prelude.NFData TagColumnOperation where
  rnf :: TagColumnOperation -> ()
rnf TagColumnOperation' {NonEmpty ColumnTag
Text
tags :: NonEmpty ColumnTag
columnName :: Text
$sel:tags:TagColumnOperation' :: TagColumnOperation -> NonEmpty ColumnTag
$sel:columnName:TagColumnOperation' :: TagColumnOperation -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
columnName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty ColumnTag
tags

instance Data.ToJSON TagColumnOperation where
  toJSON :: TagColumnOperation -> Value
toJSON TagColumnOperation' {NonEmpty ColumnTag
Text
tags :: NonEmpty ColumnTag
columnName :: Text
$sel:tags:TagColumnOperation' :: TagColumnOperation -> NonEmpty ColumnTag
$sel:columnName:TagColumnOperation' :: TagColumnOperation -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"ColumnName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
columnName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty ColumnTag
tags)
          ]
      )