{-# 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.Layout
-- 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.Layout 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.LayoutConfiguration

-- | A @Layout@ defines the placement of elements within a sheet.
--
-- For more information, see
-- <https://docs.aws.amazon.com/quicksight/latest/user/types-of-layout.html Types of layout>
-- in the /Amazon QuickSight User Guide/.
--
-- This is a union type structure. For this structure to be valid, only one
-- of the attributes can be defined.
--
-- /See:/ 'newLayout' smart constructor.
data Layout = Layout'
  { -- | The configuration that determines what the type of layout for a sheet.
    Layout -> LayoutConfiguration
configuration :: LayoutConfiguration
  }
  deriving (Layout -> Layout -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Layout -> Layout -> Bool
$c/= :: Layout -> Layout -> Bool
== :: Layout -> Layout -> Bool
$c== :: Layout -> Layout -> Bool
Prelude.Eq, Int -> Layout -> ShowS
[Layout] -> ShowS
Layout -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Layout] -> ShowS
$cshowList :: [Layout] -> ShowS
show :: Layout -> String
$cshow :: Layout -> String
showsPrec :: Int -> Layout -> ShowS
$cshowsPrec :: Int -> Layout -> ShowS
Prelude.Show, forall x. Rep Layout x -> Layout
forall x. Layout -> Rep Layout x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Layout x -> Layout
$cfrom :: forall x. Layout -> Rep Layout x
Prelude.Generic)

-- |
-- Create a value of 'Layout' 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:
--
-- 'configuration', 'layout_configuration' - The configuration that determines what the type of layout for a sheet.
newLayout ::
  -- | 'configuration'
  LayoutConfiguration ->
  Layout
newLayout :: LayoutConfiguration -> Layout
newLayout LayoutConfiguration
pConfiguration_ =
  Layout' {$sel:configuration:Layout' :: LayoutConfiguration
configuration = LayoutConfiguration
pConfiguration_}

-- | The configuration that determines what the type of layout for a sheet.
layout_configuration :: Lens.Lens' Layout LayoutConfiguration
layout_configuration :: Lens' Layout LayoutConfiguration
layout_configuration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Layout' {LayoutConfiguration
configuration :: LayoutConfiguration
$sel:configuration:Layout' :: Layout -> LayoutConfiguration
configuration} -> LayoutConfiguration
configuration) (\s :: Layout
s@Layout' {} LayoutConfiguration
a -> Layout
s {$sel:configuration:Layout' :: LayoutConfiguration
configuration = LayoutConfiguration
a} :: Layout)

instance Data.FromJSON Layout where
  parseJSON :: Value -> Parser Layout
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Layout"
      ( \Object
x ->
          LayoutConfiguration -> Layout
Layout' 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
"Configuration")
      )

instance Prelude.Hashable Layout where
  hashWithSalt :: Int -> Layout -> Int
hashWithSalt Int
_salt Layout' {LayoutConfiguration
configuration :: LayoutConfiguration
$sel:configuration:Layout' :: Layout -> LayoutConfiguration
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LayoutConfiguration
configuration

instance Prelude.NFData Layout where
  rnf :: Layout -> ()
rnf Layout' {LayoutConfiguration
configuration :: LayoutConfiguration
$sel:configuration:Layout' :: Layout -> LayoutConfiguration
..} = forall a. NFData a => a -> ()
Prelude.rnf LayoutConfiguration
configuration

instance Data.ToJSON Layout where
  toJSON :: Layout -> Value
toJSON Layout' {LayoutConfiguration
configuration :: LayoutConfiguration
$sel:configuration:Layout' :: Layout -> LayoutConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"Configuration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LayoutConfiguration
configuration)
          ]
      )