{-# 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.CustomContentVisual
-- 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.CustomContentVisual 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.CustomContentConfiguration
import Amazonka.QuickSight.Types.VisualCustomAction
import Amazonka.QuickSight.Types.VisualSubtitleLabelOptions
import Amazonka.QuickSight.Types.VisualTitleLabelOptions

-- | A visual that contains custom content.
--
-- For more information, see
-- <https://docs.aws.amazon.com/quicksight/latest/user/custom-visual-content.html Using custom visual content>
-- in the /Amazon QuickSight User Guide/.
--
-- /See:/ 'newCustomContentVisual' smart constructor.
data CustomContentVisual = CustomContentVisual'
  { -- | The list of custom actions that are configured for a visual.
    CustomContentVisual -> Maybe [VisualCustomAction]
actions :: Prelude.Maybe [VisualCustomAction],
    -- | The configuration of a @CustomContentVisual@.
    CustomContentVisual -> Maybe CustomContentConfiguration
chartConfiguration :: Prelude.Maybe CustomContentConfiguration,
    -- | The subtitle that is displayed on the visual.
    CustomContentVisual -> Maybe VisualSubtitleLabelOptions
subtitle :: Prelude.Maybe VisualSubtitleLabelOptions,
    -- | The title that is displayed on the visual.
    CustomContentVisual -> Maybe VisualTitleLabelOptions
title :: Prelude.Maybe VisualTitleLabelOptions,
    -- | 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.
    CustomContentVisual -> Text
visualId :: Prelude.Text,
    -- | The dataset that is used to create the custom content visual. You can\'t
    -- create a visual without a dataset.
    CustomContentVisual -> Text
dataSetIdentifier :: Prelude.Text
  }
  deriving (CustomContentVisual -> CustomContentVisual -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomContentVisual -> CustomContentVisual -> Bool
$c/= :: CustomContentVisual -> CustomContentVisual -> Bool
== :: CustomContentVisual -> CustomContentVisual -> Bool
$c== :: CustomContentVisual -> CustomContentVisual -> Bool
Prelude.Eq, Int -> CustomContentVisual -> ShowS
[CustomContentVisual] -> ShowS
CustomContentVisual -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomContentVisual] -> ShowS
$cshowList :: [CustomContentVisual] -> ShowS
show :: CustomContentVisual -> String
$cshow :: CustomContentVisual -> String
showsPrec :: Int -> CustomContentVisual -> ShowS
$cshowsPrec :: Int -> CustomContentVisual -> ShowS
Prelude.Show, forall x. Rep CustomContentVisual x -> CustomContentVisual
forall x. CustomContentVisual -> Rep CustomContentVisual x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomContentVisual x -> CustomContentVisual
$cfrom :: forall x. CustomContentVisual -> Rep CustomContentVisual x
Prelude.Generic)

-- |
-- Create a value of 'CustomContentVisual' 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', 'customContentVisual_actions' - The list of custom actions that are configured for a visual.
--
-- 'chartConfiguration', 'customContentVisual_chartConfiguration' - The configuration of a @CustomContentVisual@.
--
-- 'subtitle', 'customContentVisual_subtitle' - The subtitle that is displayed on the visual.
--
-- 'title', 'customContentVisual_title' - The title that is displayed on the visual.
--
-- 'visualId', 'customContentVisual_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', 'customContentVisual_dataSetIdentifier' - The dataset that is used to create the custom content visual. You can\'t
-- create a visual without a dataset.
newCustomContentVisual ::
  -- | 'visualId'
  Prelude.Text ->
  -- | 'dataSetIdentifier'
  Prelude.Text ->
  CustomContentVisual
newCustomContentVisual :: Text -> Text -> CustomContentVisual
newCustomContentVisual Text
pVisualId_ Text
pDataSetIdentifier_ =
  CustomContentVisual'
    { $sel:actions:CustomContentVisual' :: Maybe [VisualCustomAction]
actions = forall a. Maybe a
Prelude.Nothing,
      $sel:chartConfiguration:CustomContentVisual' :: Maybe CustomContentConfiguration
chartConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:subtitle:CustomContentVisual' :: Maybe VisualSubtitleLabelOptions
subtitle = forall a. Maybe a
Prelude.Nothing,
      $sel:title:CustomContentVisual' :: Maybe VisualTitleLabelOptions
title = forall a. Maybe a
Prelude.Nothing,
      $sel:visualId:CustomContentVisual' :: Text
visualId = Text
pVisualId_,
      $sel:dataSetIdentifier:CustomContentVisual' :: Text
dataSetIdentifier = Text
pDataSetIdentifier_
    }

-- | The list of custom actions that are configured for a visual.
customContentVisual_actions :: Lens.Lens' CustomContentVisual (Prelude.Maybe [VisualCustomAction])
customContentVisual_actions :: Lens' CustomContentVisual (Maybe [VisualCustomAction])
customContentVisual_actions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentVisual' {Maybe [VisualCustomAction]
actions :: Maybe [VisualCustomAction]
$sel:actions:CustomContentVisual' :: CustomContentVisual -> Maybe [VisualCustomAction]
actions} -> Maybe [VisualCustomAction]
actions) (\s :: CustomContentVisual
s@CustomContentVisual' {} Maybe [VisualCustomAction]
a -> CustomContentVisual
s {$sel:actions:CustomContentVisual' :: Maybe [VisualCustomAction]
actions = Maybe [VisualCustomAction]
a} :: CustomContentVisual) 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 configuration of a @CustomContentVisual@.
customContentVisual_chartConfiguration :: Lens.Lens' CustomContentVisual (Prelude.Maybe CustomContentConfiguration)
customContentVisual_chartConfiguration :: Lens' CustomContentVisual (Maybe CustomContentConfiguration)
customContentVisual_chartConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentVisual' {Maybe CustomContentConfiguration
chartConfiguration :: Maybe CustomContentConfiguration
$sel:chartConfiguration:CustomContentVisual' :: CustomContentVisual -> Maybe CustomContentConfiguration
chartConfiguration} -> Maybe CustomContentConfiguration
chartConfiguration) (\s :: CustomContentVisual
s@CustomContentVisual' {} Maybe CustomContentConfiguration
a -> CustomContentVisual
s {$sel:chartConfiguration:CustomContentVisual' :: Maybe CustomContentConfiguration
chartConfiguration = Maybe CustomContentConfiguration
a} :: CustomContentVisual)

-- | The subtitle that is displayed on the visual.
customContentVisual_subtitle :: Lens.Lens' CustomContentVisual (Prelude.Maybe VisualSubtitleLabelOptions)
customContentVisual_subtitle :: Lens' CustomContentVisual (Maybe VisualSubtitleLabelOptions)
customContentVisual_subtitle = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentVisual' {Maybe VisualSubtitleLabelOptions
subtitle :: Maybe VisualSubtitleLabelOptions
$sel:subtitle:CustomContentVisual' :: CustomContentVisual -> Maybe VisualSubtitleLabelOptions
subtitle} -> Maybe VisualSubtitleLabelOptions
subtitle) (\s :: CustomContentVisual
s@CustomContentVisual' {} Maybe VisualSubtitleLabelOptions
a -> CustomContentVisual
s {$sel:subtitle:CustomContentVisual' :: Maybe VisualSubtitleLabelOptions
subtitle = Maybe VisualSubtitleLabelOptions
a} :: CustomContentVisual)

-- | The title that is displayed on the visual.
customContentVisual_title :: Lens.Lens' CustomContentVisual (Prelude.Maybe VisualTitleLabelOptions)
customContentVisual_title :: Lens' CustomContentVisual (Maybe VisualTitleLabelOptions)
customContentVisual_title = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentVisual' {Maybe VisualTitleLabelOptions
title :: Maybe VisualTitleLabelOptions
$sel:title:CustomContentVisual' :: CustomContentVisual -> Maybe VisualTitleLabelOptions
title} -> Maybe VisualTitleLabelOptions
title) (\s :: CustomContentVisual
s@CustomContentVisual' {} Maybe VisualTitleLabelOptions
a -> CustomContentVisual
s {$sel:title:CustomContentVisual' :: Maybe VisualTitleLabelOptions
title = Maybe VisualTitleLabelOptions
a} :: CustomContentVisual)

-- | 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.
customContentVisual_visualId :: Lens.Lens' CustomContentVisual Prelude.Text
customContentVisual_visualId :: Lens' CustomContentVisual Text
customContentVisual_visualId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentVisual' {Text
visualId :: Text
$sel:visualId:CustomContentVisual' :: CustomContentVisual -> Text
visualId} -> Text
visualId) (\s :: CustomContentVisual
s@CustomContentVisual' {} Text
a -> CustomContentVisual
s {$sel:visualId:CustomContentVisual' :: Text
visualId = Text
a} :: CustomContentVisual)

-- | The dataset that is used to create the custom content visual. You can\'t
-- create a visual without a dataset.
customContentVisual_dataSetIdentifier :: Lens.Lens' CustomContentVisual Prelude.Text
customContentVisual_dataSetIdentifier :: Lens' CustomContentVisual Text
customContentVisual_dataSetIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentVisual' {Text
dataSetIdentifier :: Text
$sel:dataSetIdentifier:CustomContentVisual' :: CustomContentVisual -> Text
dataSetIdentifier} -> Text
dataSetIdentifier) (\s :: CustomContentVisual
s@CustomContentVisual' {} Text
a -> CustomContentVisual
s {$sel:dataSetIdentifier:CustomContentVisual' :: Text
dataSetIdentifier = Text
a} :: CustomContentVisual)

instance Data.FromJSON CustomContentVisual where
  parseJSON :: Value -> Parser CustomContentVisual
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomContentVisual"
      ( \Object
x ->
          Maybe [VisualCustomAction]
-> Maybe CustomContentConfiguration
-> Maybe VisualSubtitleLabelOptions
-> Maybe VisualTitleLabelOptions
-> Text
-> Text
-> CustomContentVisual
CustomContentVisual'
            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 (Maybe a)
Data..:? Key
"ChartConfiguration")
            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
"Subtitle")
            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
"Title")
            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 CustomContentVisual where
  hashWithSalt :: Int -> CustomContentVisual -> Int
hashWithSalt Int
_salt CustomContentVisual' {Maybe [VisualCustomAction]
Maybe CustomContentConfiguration
Maybe VisualSubtitleLabelOptions
Maybe VisualTitleLabelOptions
Text
dataSetIdentifier :: Text
visualId :: Text
title :: Maybe VisualTitleLabelOptions
subtitle :: Maybe VisualSubtitleLabelOptions
chartConfiguration :: Maybe CustomContentConfiguration
actions :: Maybe [VisualCustomAction]
$sel:dataSetIdentifier:CustomContentVisual' :: CustomContentVisual -> Text
$sel:visualId:CustomContentVisual' :: CustomContentVisual -> Text
$sel:title:CustomContentVisual' :: CustomContentVisual -> Maybe VisualTitleLabelOptions
$sel:subtitle:CustomContentVisual' :: CustomContentVisual -> Maybe VisualSubtitleLabelOptions
$sel:chartConfiguration:CustomContentVisual' :: CustomContentVisual -> Maybe CustomContentConfiguration
$sel:actions:CustomContentVisual' :: CustomContentVisual -> 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` Maybe CustomContentConfiguration
chartConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VisualSubtitleLabelOptions
subtitle
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VisualTitleLabelOptions
title
      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 CustomContentVisual where
  rnf :: CustomContentVisual -> ()
rnf CustomContentVisual' {Maybe [VisualCustomAction]
Maybe CustomContentConfiguration
Maybe VisualSubtitleLabelOptions
Maybe VisualTitleLabelOptions
Text
dataSetIdentifier :: Text
visualId :: Text
title :: Maybe VisualTitleLabelOptions
subtitle :: Maybe VisualSubtitleLabelOptions
chartConfiguration :: Maybe CustomContentConfiguration
actions :: Maybe [VisualCustomAction]
$sel:dataSetIdentifier:CustomContentVisual' :: CustomContentVisual -> Text
$sel:visualId:CustomContentVisual' :: CustomContentVisual -> Text
$sel:title:CustomContentVisual' :: CustomContentVisual -> Maybe VisualTitleLabelOptions
$sel:subtitle:CustomContentVisual' :: CustomContentVisual -> Maybe VisualSubtitleLabelOptions
$sel:chartConfiguration:CustomContentVisual' :: CustomContentVisual -> Maybe CustomContentConfiguration
$sel:actions:CustomContentVisual' :: CustomContentVisual -> 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 Maybe CustomContentConfiguration
chartConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VisualSubtitleLabelOptions
subtitle
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VisualTitleLabelOptions
title
      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 CustomContentVisual where
  toJSON :: CustomContentVisual -> Value
toJSON CustomContentVisual' {Maybe [VisualCustomAction]
Maybe CustomContentConfiguration
Maybe VisualSubtitleLabelOptions
Maybe VisualTitleLabelOptions
Text
dataSetIdentifier :: Text
visualId :: Text
title :: Maybe VisualTitleLabelOptions
subtitle :: Maybe VisualSubtitleLabelOptions
chartConfiguration :: Maybe CustomContentConfiguration
actions :: Maybe [VisualCustomAction]
$sel:dataSetIdentifier:CustomContentVisual' :: CustomContentVisual -> Text
$sel:visualId:CustomContentVisual' :: CustomContentVisual -> Text
$sel:title:CustomContentVisual' :: CustomContentVisual -> Maybe VisualTitleLabelOptions
$sel:subtitle:CustomContentVisual' :: CustomContentVisual -> Maybe VisualSubtitleLabelOptions
$sel:chartConfiguration:CustomContentVisual' :: CustomContentVisual -> Maybe CustomContentConfiguration
$sel:actions:CustomContentVisual' :: CustomContentVisual -> 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,
            (Key
"ChartConfiguration" 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 CustomContentConfiguration
chartConfiguration,
            (Key
"Subtitle" 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 VisualSubtitleLabelOptions
subtitle,
            (Key
"Title" 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 VisualTitleLabelOptions
title,
            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)
          ]
      )