{-# 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.FreeFormLayoutConfiguration
-- 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.FreeFormLayoutConfiguration 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.FreeFormLayoutCanvasSizeOptions
import Amazonka.QuickSight.Types.FreeFormLayoutElement

-- | The configuration of a free-form layout.
--
-- /See:/ 'newFreeFormLayoutConfiguration' smart constructor.
data FreeFormLayoutConfiguration = FreeFormLayoutConfiguration'
  { FreeFormLayoutConfiguration
-> Maybe FreeFormLayoutCanvasSizeOptions
canvasSizeOptions :: Prelude.Maybe FreeFormLayoutCanvasSizeOptions,
    -- | The elements that are included in a free-form layout.
    FreeFormLayoutConfiguration -> [FreeFormLayoutElement]
elements :: [FreeFormLayoutElement]
  }
  deriving (FreeFormLayoutConfiguration -> FreeFormLayoutConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FreeFormLayoutConfiguration -> FreeFormLayoutConfiguration -> Bool
$c/= :: FreeFormLayoutConfiguration -> FreeFormLayoutConfiguration -> Bool
== :: FreeFormLayoutConfiguration -> FreeFormLayoutConfiguration -> Bool
$c== :: FreeFormLayoutConfiguration -> FreeFormLayoutConfiguration -> Bool
Prelude.Eq, Int -> FreeFormLayoutConfiguration -> ShowS
[FreeFormLayoutConfiguration] -> ShowS
FreeFormLayoutConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FreeFormLayoutConfiguration] -> ShowS
$cshowList :: [FreeFormLayoutConfiguration] -> ShowS
show :: FreeFormLayoutConfiguration -> String
$cshow :: FreeFormLayoutConfiguration -> String
showsPrec :: Int -> FreeFormLayoutConfiguration -> ShowS
$cshowsPrec :: Int -> FreeFormLayoutConfiguration -> ShowS
Prelude.Show, forall x.
Rep FreeFormLayoutConfiguration x -> FreeFormLayoutConfiguration
forall x.
FreeFormLayoutConfiguration -> Rep FreeFormLayoutConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FreeFormLayoutConfiguration x -> FreeFormLayoutConfiguration
$cfrom :: forall x.
FreeFormLayoutConfiguration -> Rep FreeFormLayoutConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'FreeFormLayoutConfiguration' 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:
--
-- 'canvasSizeOptions', 'freeFormLayoutConfiguration_canvasSizeOptions' - Undocumented member.
--
-- 'elements', 'freeFormLayoutConfiguration_elements' - The elements that are included in a free-form layout.
newFreeFormLayoutConfiguration ::
  FreeFormLayoutConfiguration
newFreeFormLayoutConfiguration :: FreeFormLayoutConfiguration
newFreeFormLayoutConfiguration =
  FreeFormLayoutConfiguration'
    { $sel:canvasSizeOptions:FreeFormLayoutConfiguration' :: Maybe FreeFormLayoutCanvasSizeOptions
canvasSizeOptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:elements:FreeFormLayoutConfiguration' :: [FreeFormLayoutElement]
elements = forall a. Monoid a => a
Prelude.mempty
    }

-- | Undocumented member.
freeFormLayoutConfiguration_canvasSizeOptions :: Lens.Lens' FreeFormLayoutConfiguration (Prelude.Maybe FreeFormLayoutCanvasSizeOptions)
freeFormLayoutConfiguration_canvasSizeOptions :: Lens'
  FreeFormLayoutConfiguration (Maybe FreeFormLayoutCanvasSizeOptions)
freeFormLayoutConfiguration_canvasSizeOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FreeFormLayoutConfiguration' {Maybe FreeFormLayoutCanvasSizeOptions
canvasSizeOptions :: Maybe FreeFormLayoutCanvasSizeOptions
$sel:canvasSizeOptions:FreeFormLayoutConfiguration' :: FreeFormLayoutConfiguration
-> Maybe FreeFormLayoutCanvasSizeOptions
canvasSizeOptions} -> Maybe FreeFormLayoutCanvasSizeOptions
canvasSizeOptions) (\s :: FreeFormLayoutConfiguration
s@FreeFormLayoutConfiguration' {} Maybe FreeFormLayoutCanvasSizeOptions
a -> FreeFormLayoutConfiguration
s {$sel:canvasSizeOptions:FreeFormLayoutConfiguration' :: Maybe FreeFormLayoutCanvasSizeOptions
canvasSizeOptions = Maybe FreeFormLayoutCanvasSizeOptions
a} :: FreeFormLayoutConfiguration)

-- | The elements that are included in a free-form layout.
freeFormLayoutConfiguration_elements :: Lens.Lens' FreeFormLayoutConfiguration [FreeFormLayoutElement]
freeFormLayoutConfiguration_elements :: Lens' FreeFormLayoutConfiguration [FreeFormLayoutElement]
freeFormLayoutConfiguration_elements = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FreeFormLayoutConfiguration' {[FreeFormLayoutElement]
elements :: [FreeFormLayoutElement]
$sel:elements:FreeFormLayoutConfiguration' :: FreeFormLayoutConfiguration -> [FreeFormLayoutElement]
elements} -> [FreeFormLayoutElement]
elements) (\s :: FreeFormLayoutConfiguration
s@FreeFormLayoutConfiguration' {} [FreeFormLayoutElement]
a -> FreeFormLayoutConfiguration
s {$sel:elements:FreeFormLayoutConfiguration' :: [FreeFormLayoutElement]
elements = [FreeFormLayoutElement]
a} :: FreeFormLayoutConfiguration) 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 FreeFormLayoutConfiguration where
  parseJSON :: Value -> Parser FreeFormLayoutConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FreeFormLayoutConfiguration"
      ( \Object
x ->
          Maybe FreeFormLayoutCanvasSizeOptions
-> [FreeFormLayoutElement] -> FreeFormLayoutConfiguration
FreeFormLayoutConfiguration'
            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
"CanvasSizeOptions")
            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
"Elements" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable FreeFormLayoutConfiguration where
  hashWithSalt :: Int -> FreeFormLayoutConfiguration -> Int
hashWithSalt Int
_salt FreeFormLayoutConfiguration' {[FreeFormLayoutElement]
Maybe FreeFormLayoutCanvasSizeOptions
elements :: [FreeFormLayoutElement]
canvasSizeOptions :: Maybe FreeFormLayoutCanvasSizeOptions
$sel:elements:FreeFormLayoutConfiguration' :: FreeFormLayoutConfiguration -> [FreeFormLayoutElement]
$sel:canvasSizeOptions:FreeFormLayoutConfiguration' :: FreeFormLayoutConfiguration
-> Maybe FreeFormLayoutCanvasSizeOptions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FreeFormLayoutCanvasSizeOptions
canvasSizeOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [FreeFormLayoutElement]
elements

instance Prelude.NFData FreeFormLayoutConfiguration where
  rnf :: FreeFormLayoutConfiguration -> ()
rnf FreeFormLayoutConfiguration' {[FreeFormLayoutElement]
Maybe FreeFormLayoutCanvasSizeOptions
elements :: [FreeFormLayoutElement]
canvasSizeOptions :: Maybe FreeFormLayoutCanvasSizeOptions
$sel:elements:FreeFormLayoutConfiguration' :: FreeFormLayoutConfiguration -> [FreeFormLayoutElement]
$sel:canvasSizeOptions:FreeFormLayoutConfiguration' :: FreeFormLayoutConfiguration
-> Maybe FreeFormLayoutCanvasSizeOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FreeFormLayoutCanvasSizeOptions
canvasSizeOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [FreeFormLayoutElement]
elements

instance Data.ToJSON FreeFormLayoutConfiguration where
  toJSON :: FreeFormLayoutConfiguration -> Value
toJSON FreeFormLayoutConfiguration' {[FreeFormLayoutElement]
Maybe FreeFormLayoutCanvasSizeOptions
elements :: [FreeFormLayoutElement]
canvasSizeOptions :: Maybe FreeFormLayoutCanvasSizeOptions
$sel:elements:FreeFormLayoutConfiguration' :: FreeFormLayoutConfiguration -> [FreeFormLayoutElement]
$sel:canvasSizeOptions:FreeFormLayoutConfiguration' :: FreeFormLayoutConfiguration
-> Maybe FreeFormLayoutCanvasSizeOptions
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CanvasSizeOptions" 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 FreeFormLayoutCanvasSizeOptions
canvasSizeOptions,
            forall a. a -> Maybe a
Prelude.Just (Key
"Elements" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [FreeFormLayoutElement]
elements)
          ]
      )