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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A FieldFolder element is a folder that contains fields and nested
-- subfolders.
--
-- /See:/ 'newFieldFolder' smart constructor.
data FieldFolder = FieldFolder'
  { -- | A folder has a list of columns. A column can only be in one folder.
    FieldFolder -> Maybe [Text]
columns :: Prelude.Maybe [Prelude.Text],
    -- | The description for a field folder.
    FieldFolder -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (FieldFolder -> FieldFolder -> Bool
(FieldFolder -> FieldFolder -> Bool)
-> (FieldFolder -> FieldFolder -> Bool) -> Eq FieldFolder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldFolder -> FieldFolder -> Bool
$c/= :: FieldFolder -> FieldFolder -> Bool
== :: FieldFolder -> FieldFolder -> Bool
$c== :: FieldFolder -> FieldFolder -> Bool
Prelude.Eq, ReadPrec [FieldFolder]
ReadPrec FieldFolder
Int -> ReadS FieldFolder
ReadS [FieldFolder]
(Int -> ReadS FieldFolder)
-> ReadS [FieldFolder]
-> ReadPrec FieldFolder
-> ReadPrec [FieldFolder]
-> Read FieldFolder
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldFolder]
$creadListPrec :: ReadPrec [FieldFolder]
readPrec :: ReadPrec FieldFolder
$creadPrec :: ReadPrec FieldFolder
readList :: ReadS [FieldFolder]
$creadList :: ReadS [FieldFolder]
readsPrec :: Int -> ReadS FieldFolder
$creadsPrec :: Int -> ReadS FieldFolder
Prelude.Read, Int -> FieldFolder -> ShowS
[FieldFolder] -> ShowS
FieldFolder -> String
(Int -> FieldFolder -> ShowS)
-> (FieldFolder -> String)
-> ([FieldFolder] -> ShowS)
-> Show FieldFolder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldFolder] -> ShowS
$cshowList :: [FieldFolder] -> ShowS
show :: FieldFolder -> String
$cshow :: FieldFolder -> String
showsPrec :: Int -> FieldFolder -> ShowS
$cshowsPrec :: Int -> FieldFolder -> ShowS
Prelude.Show, (forall x. FieldFolder -> Rep FieldFolder x)
-> (forall x. Rep FieldFolder x -> FieldFolder)
-> Generic FieldFolder
forall x. Rep FieldFolder x -> FieldFolder
forall x. FieldFolder -> Rep FieldFolder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FieldFolder x -> FieldFolder
$cfrom :: forall x. FieldFolder -> Rep FieldFolder x
Prelude.Generic)

-- |
-- Create a value of 'FieldFolder' 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:
--
-- 'columns', 'fieldFolder_columns' - A folder has a list of columns. A column can only be in one folder.
--
-- 'description', 'fieldFolder_description' - The description for a field folder.
newFieldFolder ::
  FieldFolder
newFieldFolder :: FieldFolder
newFieldFolder =
  FieldFolder' :: Maybe [Text] -> Maybe Text -> FieldFolder
FieldFolder'
    { $sel:columns:FieldFolder' :: Maybe [Text]
columns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:description:FieldFolder' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A folder has a list of columns. A column can only be in one folder.
fieldFolder_columns :: Lens.Lens' FieldFolder (Prelude.Maybe [Prelude.Text])
fieldFolder_columns :: (Maybe [Text] -> f (Maybe [Text])) -> FieldFolder -> f FieldFolder
fieldFolder_columns = (FieldFolder -> Maybe [Text])
-> (FieldFolder -> Maybe [Text] -> FieldFolder)
-> Lens FieldFolder FieldFolder (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldFolder' {Maybe [Text]
columns :: Maybe [Text]
$sel:columns:FieldFolder' :: FieldFolder -> Maybe [Text]
columns} -> Maybe [Text]
columns) (\s :: FieldFolder
s@FieldFolder' {} Maybe [Text]
a -> FieldFolder
s {$sel:columns:FieldFolder' :: Maybe [Text]
columns = Maybe [Text]
a} :: FieldFolder) ((Maybe [Text] -> f (Maybe [Text]))
 -> FieldFolder -> f FieldFolder)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> FieldFolder
-> f FieldFolder
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The description for a field folder.
fieldFolder_description :: Lens.Lens' FieldFolder (Prelude.Maybe Prelude.Text)
fieldFolder_description :: (Maybe Text -> f (Maybe Text)) -> FieldFolder -> f FieldFolder
fieldFolder_description = (FieldFolder -> Maybe Text)
-> (FieldFolder -> Maybe Text -> FieldFolder)
-> Lens FieldFolder FieldFolder (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldFolder' {Maybe Text
description :: Maybe Text
$sel:description:FieldFolder' :: FieldFolder -> Maybe Text
description} -> Maybe Text
description) (\s :: FieldFolder
s@FieldFolder' {} Maybe Text
a -> FieldFolder
s {$sel:description:FieldFolder' :: Maybe Text
description = Maybe Text
a} :: FieldFolder)

instance Core.FromJSON FieldFolder where
  parseJSON :: Value -> Parser FieldFolder
parseJSON =
    String
-> (Object -> Parser FieldFolder) -> Value -> Parser FieldFolder
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FieldFolder"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> FieldFolder
FieldFolder'
            (Maybe [Text] -> Maybe Text -> FieldFolder)
-> Parser (Maybe [Text]) -> Parser (Maybe Text -> FieldFolder)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"columns" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> FieldFolder)
-> Parser (Maybe Text) -> Parser FieldFolder
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"description")
      )

instance Prelude.Hashable FieldFolder

instance Prelude.NFData FieldFolder

instance Core.ToJSON FieldFolder where
  toJSON :: FieldFolder -> Value
toJSON FieldFolder' {Maybe [Text]
Maybe Text
description :: Maybe Text
columns :: Maybe [Text]
$sel:description:FieldFolder' :: FieldFolder -> Maybe Text
$sel:columns:FieldFolder' :: FieldFolder -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"columns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
columns,
            (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description
          ]
      )