{-# 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.EmptyVisual
-- 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.EmptyVisual 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.VisualCustomAction

-- | An empty visual.
--
-- Empty visuals are used in layouts but have not been configured to show
-- any data. A new visual created in the Amazon QuickSight console is
-- considered an @EmptyVisual@ until a visual type is selected.
--
-- /See:/ 'newEmptyVisual' smart constructor.
data EmptyVisual = EmptyVisual'
  { -- | The list of custom actions that are configured for a visual.
    EmptyVisual -> Maybe [VisualCustomAction]
actions :: Prelude.Maybe [VisualCustomAction],
    -- | The unique identifier of a visual. This identifier must be unique within
    -- the context of a dashboard, template, or analysis. Two dashboards,
    -- analyses, or templates can have visuals with the same identifiers.
    EmptyVisual -> Text
visualId :: Prelude.Text,
    -- | The data set that is used in the empty visual. Every visual requires a
    -- dataset to render.
    EmptyVisual -> Text
dataSetIdentifier :: Prelude.Text
  }
  deriving (EmptyVisual -> EmptyVisual -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmptyVisual -> EmptyVisual -> Bool
$c/= :: EmptyVisual -> EmptyVisual -> Bool
== :: EmptyVisual -> EmptyVisual -> Bool
$c== :: EmptyVisual -> EmptyVisual -> Bool
Prelude.Eq, Int -> EmptyVisual -> ShowS
[EmptyVisual] -> ShowS
EmptyVisual -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmptyVisual] -> ShowS
$cshowList :: [EmptyVisual] -> ShowS
show :: EmptyVisual -> String
$cshow :: EmptyVisual -> String
showsPrec :: Int -> EmptyVisual -> ShowS
$cshowsPrec :: Int -> EmptyVisual -> ShowS
Prelude.Show, forall x. Rep EmptyVisual x -> EmptyVisual
forall x. EmptyVisual -> Rep EmptyVisual x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EmptyVisual x -> EmptyVisual
$cfrom :: forall x. EmptyVisual -> Rep EmptyVisual x
Prelude.Generic)

-- |
-- Create a value of 'EmptyVisual' 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:
--
-- 'actions', 'emptyVisual_actions' - The list of custom actions that are configured for a visual.
--
-- 'visualId', 'emptyVisual_visualId' - The unique identifier of a visual. This identifier must be unique within
-- the context of a dashboard, template, or analysis. Two dashboards,
-- analyses, or templates can have visuals with the same identifiers.
--
-- 'dataSetIdentifier', 'emptyVisual_dataSetIdentifier' - The data set that is used in the empty visual. Every visual requires a
-- dataset to render.
newEmptyVisual ::
  -- | 'visualId'
  Prelude.Text ->
  -- | 'dataSetIdentifier'
  Prelude.Text ->
  EmptyVisual
newEmptyVisual :: Text -> Text -> EmptyVisual
newEmptyVisual Text
pVisualId_ Text
pDataSetIdentifier_ =
  EmptyVisual'
    { $sel:actions:EmptyVisual' :: Maybe [VisualCustomAction]
actions = forall a. Maybe a
Prelude.Nothing,
      $sel:visualId:EmptyVisual' :: Text
visualId = Text
pVisualId_,
      $sel:dataSetIdentifier:EmptyVisual' :: Text
dataSetIdentifier = Text
pDataSetIdentifier_
    }

-- | The list of custom actions that are configured for a visual.
emptyVisual_actions :: Lens.Lens' EmptyVisual (Prelude.Maybe [VisualCustomAction])
emptyVisual_actions :: Lens' EmptyVisual (Maybe [VisualCustomAction])
emptyVisual_actions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmptyVisual' {Maybe [VisualCustomAction]
actions :: Maybe [VisualCustomAction]
$sel:actions:EmptyVisual' :: EmptyVisual -> Maybe [VisualCustomAction]
actions} -> Maybe [VisualCustomAction]
actions) (\s :: EmptyVisual
s@EmptyVisual' {} Maybe [VisualCustomAction]
a -> EmptyVisual
s {$sel:actions:EmptyVisual' :: Maybe [VisualCustomAction]
actions = Maybe [VisualCustomAction]
a} :: EmptyVisual) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique identifier of a visual. This identifier must be unique within
-- the context of a dashboard, template, or analysis. Two dashboards,
-- analyses, or templates can have visuals with the same identifiers.
emptyVisual_visualId :: Lens.Lens' EmptyVisual Prelude.Text
emptyVisual_visualId :: Lens' EmptyVisual Text
emptyVisual_visualId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmptyVisual' {Text
visualId :: Text
$sel:visualId:EmptyVisual' :: EmptyVisual -> Text
visualId} -> Text
visualId) (\s :: EmptyVisual
s@EmptyVisual' {} Text
a -> EmptyVisual
s {$sel:visualId:EmptyVisual' :: Text
visualId = Text
a} :: EmptyVisual)

-- | The data set that is used in the empty visual. Every visual requires a
-- dataset to render.
emptyVisual_dataSetIdentifier :: Lens.Lens' EmptyVisual Prelude.Text
emptyVisual_dataSetIdentifier :: Lens' EmptyVisual Text
emptyVisual_dataSetIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmptyVisual' {Text
dataSetIdentifier :: Text
$sel:dataSetIdentifier:EmptyVisual' :: EmptyVisual -> Text
dataSetIdentifier} -> Text
dataSetIdentifier) (\s :: EmptyVisual
s@EmptyVisual' {} Text
a -> EmptyVisual
s {$sel:dataSetIdentifier:EmptyVisual' :: Text
dataSetIdentifier = Text
a} :: EmptyVisual)

instance Data.FromJSON EmptyVisual where
  parseJSON :: Value -> Parser EmptyVisual
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EmptyVisual"
      ( \Object
x ->
          Maybe [VisualCustomAction] -> Text -> Text -> EmptyVisual
EmptyVisual'
            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
"Actions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"VisualId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DataSetIdentifier")
      )

instance Prelude.Hashable EmptyVisual where
  hashWithSalt :: Int -> EmptyVisual -> Int
hashWithSalt Int
_salt EmptyVisual' {Maybe [VisualCustomAction]
Text
dataSetIdentifier :: Text
visualId :: Text
actions :: Maybe [VisualCustomAction]
$sel:dataSetIdentifier:EmptyVisual' :: EmptyVisual -> Text
$sel:visualId:EmptyVisual' :: EmptyVisual -> Text
$sel:actions:EmptyVisual' :: EmptyVisual -> Maybe [VisualCustomAction]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [VisualCustomAction]
actions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
visualId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dataSetIdentifier

instance Prelude.NFData EmptyVisual where
  rnf :: EmptyVisual -> ()
rnf EmptyVisual' {Maybe [VisualCustomAction]
Text
dataSetIdentifier :: Text
visualId :: Text
actions :: Maybe [VisualCustomAction]
$sel:dataSetIdentifier:EmptyVisual' :: EmptyVisual -> Text
$sel:visualId:EmptyVisual' :: EmptyVisual -> Text
$sel:actions:EmptyVisual' :: EmptyVisual -> Maybe [VisualCustomAction]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [VisualCustomAction]
actions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
visualId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
dataSetIdentifier

instance Data.ToJSON EmptyVisual where
  toJSON :: EmptyVisual -> Value
toJSON EmptyVisual' {Maybe [VisualCustomAction]
Text
dataSetIdentifier :: Text
visualId :: Text
actions :: Maybe [VisualCustomAction]
$sel:dataSetIdentifier:EmptyVisual' :: EmptyVisual -> Text
$sel:visualId:EmptyVisual' :: EmptyVisual -> Text
$sel:actions:EmptyVisual' :: EmptyVisual -> Maybe [VisualCustomAction]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Actions" 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 [VisualCustomAction]
actions,
            forall a. a -> Maybe a
Prelude.Just (Key
"VisualId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
visualId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"DataSetIdentifier" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
dataSetIdentifier)
          ]
      )