{-# 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.LayoutConfiguration
-- 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.LayoutConfiguration 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.FreeFormLayoutConfiguration
import Amazonka.QuickSight.Types.GridLayoutConfiguration
import Amazonka.QuickSight.Types.SectionBasedLayoutConfiguration

-- | The configuration that determines what the type of layout will be used
-- on a sheet.
--
-- This is a union type structure. For this structure to be valid, only one
-- of the attributes can be defined.
--
-- /See:/ 'newLayoutConfiguration' smart constructor.
data LayoutConfiguration = LayoutConfiguration'
  { -- | A free-form is optimized for a fixed width and has more control over the
    -- exact placement of layout elements.
    LayoutConfiguration -> Maybe FreeFormLayoutConfiguration
freeFormLayout :: Prelude.Maybe FreeFormLayoutConfiguration,
    -- | A type of layout that can be used on a sheet. In a grid layout, visuals
    -- snap to a grid with standard spacing and alignment. Dashboards are
    -- displayed as designed, with options to fit to screen or view at actual
    -- size. A grid layout can be configured to behave in one of two ways when
    -- the viewport is resized: @FIXED@ or @RESPONSIVE@.
    LayoutConfiguration -> Maybe GridLayoutConfiguration
gridLayout :: Prelude.Maybe GridLayoutConfiguration,
    -- | A section based layout organizes visuals into multiple sections and has
    -- customized header, footer and page break.
    LayoutConfiguration -> Maybe SectionBasedLayoutConfiguration
sectionBasedLayout :: Prelude.Maybe SectionBasedLayoutConfiguration
  }
  deriving (LayoutConfiguration -> LayoutConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LayoutConfiguration -> LayoutConfiguration -> Bool
$c/= :: LayoutConfiguration -> LayoutConfiguration -> Bool
== :: LayoutConfiguration -> LayoutConfiguration -> Bool
$c== :: LayoutConfiguration -> LayoutConfiguration -> Bool
Prelude.Eq, Int -> LayoutConfiguration -> ShowS
[LayoutConfiguration] -> ShowS
LayoutConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LayoutConfiguration] -> ShowS
$cshowList :: [LayoutConfiguration] -> ShowS
show :: LayoutConfiguration -> String
$cshow :: LayoutConfiguration -> String
showsPrec :: Int -> LayoutConfiguration -> ShowS
$cshowsPrec :: Int -> LayoutConfiguration -> ShowS
Prelude.Show, forall x. Rep LayoutConfiguration x -> LayoutConfiguration
forall x. LayoutConfiguration -> Rep LayoutConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LayoutConfiguration x -> LayoutConfiguration
$cfrom :: forall x. LayoutConfiguration -> Rep LayoutConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LayoutConfiguration' 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:
--
-- 'freeFormLayout', 'layoutConfiguration_freeFormLayout' - A free-form is optimized for a fixed width and has more control over the
-- exact placement of layout elements.
--
-- 'gridLayout', 'layoutConfiguration_gridLayout' - A type of layout that can be used on a sheet. In a grid layout, visuals
-- snap to a grid with standard spacing and alignment. Dashboards are
-- displayed as designed, with options to fit to screen or view at actual
-- size. A grid layout can be configured to behave in one of two ways when
-- the viewport is resized: @FIXED@ or @RESPONSIVE@.
--
-- 'sectionBasedLayout', 'layoutConfiguration_sectionBasedLayout' - A section based layout organizes visuals into multiple sections and has
-- customized header, footer and page break.
newLayoutConfiguration ::
  LayoutConfiguration
newLayoutConfiguration :: LayoutConfiguration
newLayoutConfiguration =
  LayoutConfiguration'
    { $sel:freeFormLayout:LayoutConfiguration' :: Maybe FreeFormLayoutConfiguration
freeFormLayout =
        forall a. Maybe a
Prelude.Nothing,
      $sel:gridLayout:LayoutConfiguration' :: Maybe GridLayoutConfiguration
gridLayout = forall a. Maybe a
Prelude.Nothing,
      $sel:sectionBasedLayout:LayoutConfiguration' :: Maybe SectionBasedLayoutConfiguration
sectionBasedLayout = forall a. Maybe a
Prelude.Nothing
    }

-- | A free-form is optimized for a fixed width and has more control over the
-- exact placement of layout elements.
layoutConfiguration_freeFormLayout :: Lens.Lens' LayoutConfiguration (Prelude.Maybe FreeFormLayoutConfiguration)
layoutConfiguration_freeFormLayout :: Lens' LayoutConfiguration (Maybe FreeFormLayoutConfiguration)
layoutConfiguration_freeFormLayout = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LayoutConfiguration' {Maybe FreeFormLayoutConfiguration
freeFormLayout :: Maybe FreeFormLayoutConfiguration
$sel:freeFormLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe FreeFormLayoutConfiguration
freeFormLayout} -> Maybe FreeFormLayoutConfiguration
freeFormLayout) (\s :: LayoutConfiguration
s@LayoutConfiguration' {} Maybe FreeFormLayoutConfiguration
a -> LayoutConfiguration
s {$sel:freeFormLayout:LayoutConfiguration' :: Maybe FreeFormLayoutConfiguration
freeFormLayout = Maybe FreeFormLayoutConfiguration
a} :: LayoutConfiguration)

-- | A type of layout that can be used on a sheet. In a grid layout, visuals
-- snap to a grid with standard spacing and alignment. Dashboards are
-- displayed as designed, with options to fit to screen or view at actual
-- size. A grid layout can be configured to behave in one of two ways when
-- the viewport is resized: @FIXED@ or @RESPONSIVE@.
layoutConfiguration_gridLayout :: Lens.Lens' LayoutConfiguration (Prelude.Maybe GridLayoutConfiguration)
layoutConfiguration_gridLayout :: Lens' LayoutConfiguration (Maybe GridLayoutConfiguration)
layoutConfiguration_gridLayout = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LayoutConfiguration' {Maybe GridLayoutConfiguration
gridLayout :: Maybe GridLayoutConfiguration
$sel:gridLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe GridLayoutConfiguration
gridLayout} -> Maybe GridLayoutConfiguration
gridLayout) (\s :: LayoutConfiguration
s@LayoutConfiguration' {} Maybe GridLayoutConfiguration
a -> LayoutConfiguration
s {$sel:gridLayout:LayoutConfiguration' :: Maybe GridLayoutConfiguration
gridLayout = Maybe GridLayoutConfiguration
a} :: LayoutConfiguration)

-- | A section based layout organizes visuals into multiple sections and has
-- customized header, footer and page break.
layoutConfiguration_sectionBasedLayout :: Lens.Lens' LayoutConfiguration (Prelude.Maybe SectionBasedLayoutConfiguration)
layoutConfiguration_sectionBasedLayout :: Lens' LayoutConfiguration (Maybe SectionBasedLayoutConfiguration)
layoutConfiguration_sectionBasedLayout = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LayoutConfiguration' {Maybe SectionBasedLayoutConfiguration
sectionBasedLayout :: Maybe SectionBasedLayoutConfiguration
$sel:sectionBasedLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe SectionBasedLayoutConfiguration
sectionBasedLayout} -> Maybe SectionBasedLayoutConfiguration
sectionBasedLayout) (\s :: LayoutConfiguration
s@LayoutConfiguration' {} Maybe SectionBasedLayoutConfiguration
a -> LayoutConfiguration
s {$sel:sectionBasedLayout:LayoutConfiguration' :: Maybe SectionBasedLayoutConfiguration
sectionBasedLayout = Maybe SectionBasedLayoutConfiguration
a} :: LayoutConfiguration)

instance Data.FromJSON LayoutConfiguration where
  parseJSON :: Value -> Parser LayoutConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LayoutConfiguration"
      ( \Object
x ->
          Maybe FreeFormLayoutConfiguration
-> Maybe GridLayoutConfiguration
-> Maybe SectionBasedLayoutConfiguration
-> LayoutConfiguration
LayoutConfiguration'
            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
"FreeFormLayout")
            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
"GridLayout")
            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
"SectionBasedLayout")
      )

instance Prelude.Hashable LayoutConfiguration where
  hashWithSalt :: Int -> LayoutConfiguration -> Int
hashWithSalt Int
_salt LayoutConfiguration' {Maybe GridLayoutConfiguration
Maybe SectionBasedLayoutConfiguration
Maybe FreeFormLayoutConfiguration
sectionBasedLayout :: Maybe SectionBasedLayoutConfiguration
gridLayout :: Maybe GridLayoutConfiguration
freeFormLayout :: Maybe FreeFormLayoutConfiguration
$sel:sectionBasedLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe SectionBasedLayoutConfiguration
$sel:gridLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe GridLayoutConfiguration
$sel:freeFormLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe FreeFormLayoutConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FreeFormLayoutConfiguration
freeFormLayout
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GridLayoutConfiguration
gridLayout
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SectionBasedLayoutConfiguration
sectionBasedLayout

instance Prelude.NFData LayoutConfiguration where
  rnf :: LayoutConfiguration -> ()
rnf LayoutConfiguration' {Maybe GridLayoutConfiguration
Maybe SectionBasedLayoutConfiguration
Maybe FreeFormLayoutConfiguration
sectionBasedLayout :: Maybe SectionBasedLayoutConfiguration
gridLayout :: Maybe GridLayoutConfiguration
freeFormLayout :: Maybe FreeFormLayoutConfiguration
$sel:sectionBasedLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe SectionBasedLayoutConfiguration
$sel:gridLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe GridLayoutConfiguration
$sel:freeFormLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe FreeFormLayoutConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FreeFormLayoutConfiguration
freeFormLayout
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe GridLayoutConfiguration
gridLayout
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SectionBasedLayoutConfiguration
sectionBasedLayout

instance Data.ToJSON LayoutConfiguration where
  toJSON :: LayoutConfiguration -> Value
toJSON LayoutConfiguration' {Maybe GridLayoutConfiguration
Maybe SectionBasedLayoutConfiguration
Maybe FreeFormLayoutConfiguration
sectionBasedLayout :: Maybe SectionBasedLayoutConfiguration
gridLayout :: Maybe GridLayoutConfiguration
freeFormLayout :: Maybe FreeFormLayoutConfiguration
$sel:sectionBasedLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe SectionBasedLayoutConfiguration
$sel:gridLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe GridLayoutConfiguration
$sel:freeFormLayout:LayoutConfiguration' :: LayoutConfiguration -> Maybe FreeFormLayoutConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FreeFormLayout" 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 FreeFormLayoutConfiguration
freeFormLayout,
            (Key
"GridLayout" 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 GridLayoutConfiguration
gridLayout,
            (Key
"SectionBasedLayout" 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 SectionBasedLayoutConfiguration
sectionBasedLayout
          ]
      )