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

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

-- | A transform operation that removes tags associated with a column.
--
-- /See:/ 'newUntagColumnOperation' smart constructor.
data UntagColumnOperation = UntagColumnOperation'
  { -- | The column that this operation acts on.
    UntagColumnOperation -> Text
columnName :: Prelude.Text,
    -- | The column tags to remove from this column.
    UntagColumnOperation -> [ColumnTagName]
tagNames :: [ColumnTagName]
  }
  deriving (UntagColumnOperation -> UntagColumnOperation -> Bool
(UntagColumnOperation -> UntagColumnOperation -> Bool)
-> (UntagColumnOperation -> UntagColumnOperation -> Bool)
-> Eq UntagColumnOperation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UntagColumnOperation -> UntagColumnOperation -> Bool
$c/= :: UntagColumnOperation -> UntagColumnOperation -> Bool
== :: UntagColumnOperation -> UntagColumnOperation -> Bool
$c== :: UntagColumnOperation -> UntagColumnOperation -> Bool
Prelude.Eq, ReadPrec [UntagColumnOperation]
ReadPrec UntagColumnOperation
Int -> ReadS UntagColumnOperation
ReadS [UntagColumnOperation]
(Int -> ReadS UntagColumnOperation)
-> ReadS [UntagColumnOperation]
-> ReadPrec UntagColumnOperation
-> ReadPrec [UntagColumnOperation]
-> Read UntagColumnOperation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UntagColumnOperation]
$creadListPrec :: ReadPrec [UntagColumnOperation]
readPrec :: ReadPrec UntagColumnOperation
$creadPrec :: ReadPrec UntagColumnOperation
readList :: ReadS [UntagColumnOperation]
$creadList :: ReadS [UntagColumnOperation]
readsPrec :: Int -> ReadS UntagColumnOperation
$creadsPrec :: Int -> ReadS UntagColumnOperation
Prelude.Read, Int -> UntagColumnOperation -> ShowS
[UntagColumnOperation] -> ShowS
UntagColumnOperation -> String
(Int -> UntagColumnOperation -> ShowS)
-> (UntagColumnOperation -> String)
-> ([UntagColumnOperation] -> ShowS)
-> Show UntagColumnOperation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UntagColumnOperation] -> ShowS
$cshowList :: [UntagColumnOperation] -> ShowS
show :: UntagColumnOperation -> String
$cshow :: UntagColumnOperation -> String
showsPrec :: Int -> UntagColumnOperation -> ShowS
$cshowsPrec :: Int -> UntagColumnOperation -> ShowS
Prelude.Show, (forall x. UntagColumnOperation -> Rep UntagColumnOperation x)
-> (forall x. Rep UntagColumnOperation x -> UntagColumnOperation)
-> Generic UntagColumnOperation
forall x. Rep UntagColumnOperation x -> UntagColumnOperation
forall x. UntagColumnOperation -> Rep UntagColumnOperation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UntagColumnOperation x -> UntagColumnOperation
$cfrom :: forall x. UntagColumnOperation -> Rep UntagColumnOperation x
Prelude.Generic)

-- |
-- Create a value of 'UntagColumnOperation' 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', 'untagColumnOperation_columnName' - The column that this operation acts on.
--
-- 'tagNames', 'untagColumnOperation_tagNames' - The column tags to remove from this column.
newUntagColumnOperation ::
  -- | 'columnName'
  Prelude.Text ->
  UntagColumnOperation
newUntagColumnOperation :: Text -> UntagColumnOperation
newUntagColumnOperation Text
pColumnName_ =
  UntagColumnOperation' :: Text -> [ColumnTagName] -> UntagColumnOperation
UntagColumnOperation'
    { $sel:columnName:UntagColumnOperation' :: Text
columnName = Text
pColumnName_,
      $sel:tagNames:UntagColumnOperation' :: [ColumnTagName]
tagNames = [ColumnTagName]
forall a. Monoid a => a
Prelude.mempty
    }

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

-- | The column tags to remove from this column.
untagColumnOperation_tagNames :: Lens.Lens' UntagColumnOperation [ColumnTagName]
untagColumnOperation_tagNames :: ([ColumnTagName] -> f [ColumnTagName])
-> UntagColumnOperation -> f UntagColumnOperation
untagColumnOperation_tagNames = (UntagColumnOperation -> [ColumnTagName])
-> (UntagColumnOperation
    -> [ColumnTagName] -> UntagColumnOperation)
-> Lens
     UntagColumnOperation
     UntagColumnOperation
     [ColumnTagName]
     [ColumnTagName]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagColumnOperation' {[ColumnTagName]
tagNames :: [ColumnTagName]
$sel:tagNames:UntagColumnOperation' :: UntagColumnOperation -> [ColumnTagName]
tagNames} -> [ColumnTagName]
tagNames) (\s :: UntagColumnOperation
s@UntagColumnOperation' {} [ColumnTagName]
a -> UntagColumnOperation
s {$sel:tagNames:UntagColumnOperation' :: [ColumnTagName]
tagNames = [ColumnTagName]
a} :: UntagColumnOperation) (([ColumnTagName] -> f [ColumnTagName])
 -> UntagColumnOperation -> f UntagColumnOperation)
-> (([ColumnTagName] -> f [ColumnTagName])
    -> [ColumnTagName] -> f [ColumnTagName])
-> ([ColumnTagName] -> f [ColumnTagName])
-> UntagColumnOperation
-> f UntagColumnOperation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ColumnTagName] -> f [ColumnTagName])
-> [ColumnTagName] -> f [ColumnTagName]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON UntagColumnOperation where
  parseJSON :: Value -> Parser UntagColumnOperation
parseJSON =
    String
-> (Object -> Parser UntagColumnOperation)
-> Value
-> Parser UntagColumnOperation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UntagColumnOperation"
      ( \Object
x ->
          Text -> [ColumnTagName] -> UntagColumnOperation
UntagColumnOperation'
            (Text -> [ColumnTagName] -> UntagColumnOperation)
-> Parser Text -> Parser ([ColumnTagName] -> UntagColumnOperation)
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
"ColumnName")
            Parser ([ColumnTagName] -> UntagColumnOperation)
-> Parser [ColumnTagName] -> Parser UntagColumnOperation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [ColumnTagName])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TagNames" Parser (Maybe [ColumnTagName])
-> [ColumnTagName] -> Parser [ColumnTagName]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [ColumnTagName]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable UntagColumnOperation

instance Prelude.NFData UntagColumnOperation

instance Core.ToJSON UntagColumnOperation where
  toJSON :: UntagColumnOperation -> Value
toJSON UntagColumnOperation' {[ColumnTagName]
Text
tagNames :: [ColumnTagName]
columnName :: Text
$sel:tagNames:UntagColumnOperation' :: UntagColumnOperation -> [ColumnTagName]
$sel:columnName:UntagColumnOperation' :: UntagColumnOperation -> 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
"ColumnName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
columnName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TagNames" Text -> [ColumnTagName] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [ColumnTagName]
tagNames)
          ]
      )