{-# 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.CustomContentConfiguration
-- 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.CustomContentConfiguration 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.CustomContentImageScalingConfiguration
import Amazonka.QuickSight.Types.CustomContentType

-- | The configuration of a @CustomContentVisual@.
--
-- /See:/ 'newCustomContentConfiguration' smart constructor.
data CustomContentConfiguration = CustomContentConfiguration'
  { -- | The content type of the custom content visual. You can use this to have
    -- the visual render as an image.
    CustomContentConfiguration -> Maybe CustomContentType
contentType :: Prelude.Maybe CustomContentType,
    -- | The input URL that links to the custom content that you want in the
    -- custom visual.
    CustomContentConfiguration -> Maybe Text
contentUrl :: Prelude.Maybe Prelude.Text,
    -- | The sizing options for the size of the custom content visual. This
    -- structure is required when the @ContentType@ of the visual is
    -- @\'IMAGE\'@.
    CustomContentConfiguration
-> Maybe CustomContentImageScalingConfiguration
imageScaling :: Prelude.Maybe CustomContentImageScalingConfiguration
  }
  deriving (CustomContentConfiguration -> CustomContentConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomContentConfiguration -> CustomContentConfiguration -> Bool
$c/= :: CustomContentConfiguration -> CustomContentConfiguration -> Bool
== :: CustomContentConfiguration -> CustomContentConfiguration -> Bool
$c== :: CustomContentConfiguration -> CustomContentConfiguration -> Bool
Prelude.Eq, ReadPrec [CustomContentConfiguration]
ReadPrec CustomContentConfiguration
Int -> ReadS CustomContentConfiguration
ReadS [CustomContentConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomContentConfiguration]
$creadListPrec :: ReadPrec [CustomContentConfiguration]
readPrec :: ReadPrec CustomContentConfiguration
$creadPrec :: ReadPrec CustomContentConfiguration
readList :: ReadS [CustomContentConfiguration]
$creadList :: ReadS [CustomContentConfiguration]
readsPrec :: Int -> ReadS CustomContentConfiguration
$creadsPrec :: Int -> ReadS CustomContentConfiguration
Prelude.Read, Int -> CustomContentConfiguration -> ShowS
[CustomContentConfiguration] -> ShowS
CustomContentConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomContentConfiguration] -> ShowS
$cshowList :: [CustomContentConfiguration] -> ShowS
show :: CustomContentConfiguration -> String
$cshow :: CustomContentConfiguration -> String
showsPrec :: Int -> CustomContentConfiguration -> ShowS
$cshowsPrec :: Int -> CustomContentConfiguration -> ShowS
Prelude.Show, forall x.
Rep CustomContentConfiguration x -> CustomContentConfiguration
forall x.
CustomContentConfiguration -> Rep CustomContentConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomContentConfiguration x -> CustomContentConfiguration
$cfrom :: forall x.
CustomContentConfiguration -> Rep CustomContentConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CustomContentConfiguration' 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:
--
-- 'contentType', 'customContentConfiguration_contentType' - The content type of the custom content visual. You can use this to have
-- the visual render as an image.
--
-- 'contentUrl', 'customContentConfiguration_contentUrl' - The input URL that links to the custom content that you want in the
-- custom visual.
--
-- 'imageScaling', 'customContentConfiguration_imageScaling' - The sizing options for the size of the custom content visual. This
-- structure is required when the @ContentType@ of the visual is
-- @\'IMAGE\'@.
newCustomContentConfiguration ::
  CustomContentConfiguration
newCustomContentConfiguration :: CustomContentConfiguration
newCustomContentConfiguration =
  CustomContentConfiguration'
    { $sel:contentType:CustomContentConfiguration' :: Maybe CustomContentType
contentType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:contentUrl:CustomContentConfiguration' :: Maybe Text
contentUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:imageScaling:CustomContentConfiguration' :: Maybe CustomContentImageScalingConfiguration
imageScaling = forall a. Maybe a
Prelude.Nothing
    }

-- | The content type of the custom content visual. You can use this to have
-- the visual render as an image.
customContentConfiguration_contentType :: Lens.Lens' CustomContentConfiguration (Prelude.Maybe CustomContentType)
customContentConfiguration_contentType :: Lens' CustomContentConfiguration (Maybe CustomContentType)
customContentConfiguration_contentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentConfiguration' {Maybe CustomContentType
contentType :: Maybe CustomContentType
$sel:contentType:CustomContentConfiguration' :: CustomContentConfiguration -> Maybe CustomContentType
contentType} -> Maybe CustomContentType
contentType) (\s :: CustomContentConfiguration
s@CustomContentConfiguration' {} Maybe CustomContentType
a -> CustomContentConfiguration
s {$sel:contentType:CustomContentConfiguration' :: Maybe CustomContentType
contentType = Maybe CustomContentType
a} :: CustomContentConfiguration)

-- | The input URL that links to the custom content that you want in the
-- custom visual.
customContentConfiguration_contentUrl :: Lens.Lens' CustomContentConfiguration (Prelude.Maybe Prelude.Text)
customContentConfiguration_contentUrl :: Lens' CustomContentConfiguration (Maybe Text)
customContentConfiguration_contentUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentConfiguration' {Maybe Text
contentUrl :: Maybe Text
$sel:contentUrl:CustomContentConfiguration' :: CustomContentConfiguration -> Maybe Text
contentUrl} -> Maybe Text
contentUrl) (\s :: CustomContentConfiguration
s@CustomContentConfiguration' {} Maybe Text
a -> CustomContentConfiguration
s {$sel:contentUrl:CustomContentConfiguration' :: Maybe Text
contentUrl = Maybe Text
a} :: CustomContentConfiguration)

-- | The sizing options for the size of the custom content visual. This
-- structure is required when the @ContentType@ of the visual is
-- @\'IMAGE\'@.
customContentConfiguration_imageScaling :: Lens.Lens' CustomContentConfiguration (Prelude.Maybe CustomContentImageScalingConfiguration)
customContentConfiguration_imageScaling :: Lens'
  CustomContentConfiguration
  (Maybe CustomContentImageScalingConfiguration)
customContentConfiguration_imageScaling = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomContentConfiguration' {Maybe CustomContentImageScalingConfiguration
imageScaling :: Maybe CustomContentImageScalingConfiguration
$sel:imageScaling:CustomContentConfiguration' :: CustomContentConfiguration
-> Maybe CustomContentImageScalingConfiguration
imageScaling} -> Maybe CustomContentImageScalingConfiguration
imageScaling) (\s :: CustomContentConfiguration
s@CustomContentConfiguration' {} Maybe CustomContentImageScalingConfiguration
a -> CustomContentConfiguration
s {$sel:imageScaling:CustomContentConfiguration' :: Maybe CustomContentImageScalingConfiguration
imageScaling = Maybe CustomContentImageScalingConfiguration
a} :: CustomContentConfiguration)

instance Data.FromJSON CustomContentConfiguration where
  parseJSON :: Value -> Parser CustomContentConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomContentConfiguration"
      ( \Object
x ->
          Maybe CustomContentType
-> Maybe Text
-> Maybe CustomContentImageScalingConfiguration
-> CustomContentConfiguration
CustomContentConfiguration'
            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
"ContentType")
            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
"ContentUrl")
            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
"ImageScaling")
      )

instance Prelude.Hashable CustomContentConfiguration where
  hashWithSalt :: Int -> CustomContentConfiguration -> Int
hashWithSalt Int
_salt CustomContentConfiguration' {Maybe Text
Maybe CustomContentImageScalingConfiguration
Maybe CustomContentType
imageScaling :: Maybe CustomContentImageScalingConfiguration
contentUrl :: Maybe Text
contentType :: Maybe CustomContentType
$sel:imageScaling:CustomContentConfiguration' :: CustomContentConfiguration
-> Maybe CustomContentImageScalingConfiguration
$sel:contentUrl:CustomContentConfiguration' :: CustomContentConfiguration -> Maybe Text
$sel:contentType:CustomContentConfiguration' :: CustomContentConfiguration -> Maybe CustomContentType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CustomContentType
contentType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contentUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CustomContentImageScalingConfiguration
imageScaling

instance Prelude.NFData CustomContentConfiguration where
  rnf :: CustomContentConfiguration -> ()
rnf CustomContentConfiguration' {Maybe Text
Maybe CustomContentImageScalingConfiguration
Maybe CustomContentType
imageScaling :: Maybe CustomContentImageScalingConfiguration
contentUrl :: Maybe Text
contentType :: Maybe CustomContentType
$sel:imageScaling:CustomContentConfiguration' :: CustomContentConfiguration
-> Maybe CustomContentImageScalingConfiguration
$sel:contentUrl:CustomContentConfiguration' :: CustomContentConfiguration -> Maybe Text
$sel:contentType:CustomContentConfiguration' :: CustomContentConfiguration -> Maybe CustomContentType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CustomContentType
contentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contentUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CustomContentImageScalingConfiguration
imageScaling

instance Data.ToJSON CustomContentConfiguration where
  toJSON :: CustomContentConfiguration -> Value
toJSON CustomContentConfiguration' {Maybe Text
Maybe CustomContentImageScalingConfiguration
Maybe CustomContentType
imageScaling :: Maybe CustomContentImageScalingConfiguration
contentUrl :: Maybe Text
contentType :: Maybe CustomContentType
$sel:imageScaling:CustomContentConfiguration' :: CustomContentConfiguration
-> Maybe CustomContentImageScalingConfiguration
$sel:contentUrl:CustomContentConfiguration' :: CustomContentConfiguration -> Maybe Text
$sel:contentType:CustomContentConfiguration' :: CustomContentConfiguration -> Maybe CustomContentType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ContentType" 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 CustomContentType
contentType,
            (Key
"ContentUrl" 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 Text
contentUrl,
            (Key
"ImageScaling" 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 CustomContentImageScalingConfiguration
imageScaling
          ]
      )