{-# 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.CustomActionURLOperation
-- 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.CustomActionURLOperation 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.URLTargetConfiguration

-- | The URL operation that opens a link to another webpage.
--
-- /See:/ 'newCustomActionURLOperation' smart constructor.
data CustomActionURLOperation = CustomActionURLOperation'
  { -- | THe URL link of the @CustomActionURLOperation@.
    CustomActionURLOperation -> Text
uRLTemplate :: Prelude.Text,
    -- | The target of the @CustomActionURLOperation@.
    --
    -- Valid values are defined as follows:
    --
    -- -   @NEW_TAB@: Opens the target URL in a new browser tab.
    --
    -- -   @NEW_WINDOW@: Opens the target URL in a new browser window.
    --
    -- -   @SAME_TAB@: Opens the target URL in the same browser tab.
    CustomActionURLOperation -> URLTargetConfiguration
uRLTarget :: URLTargetConfiguration
  }
  deriving (CustomActionURLOperation -> CustomActionURLOperation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomActionURLOperation -> CustomActionURLOperation -> Bool
$c/= :: CustomActionURLOperation -> CustomActionURLOperation -> Bool
== :: CustomActionURLOperation -> CustomActionURLOperation -> Bool
$c== :: CustomActionURLOperation -> CustomActionURLOperation -> Bool
Prelude.Eq, ReadPrec [CustomActionURLOperation]
ReadPrec CustomActionURLOperation
Int -> ReadS CustomActionURLOperation
ReadS [CustomActionURLOperation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomActionURLOperation]
$creadListPrec :: ReadPrec [CustomActionURLOperation]
readPrec :: ReadPrec CustomActionURLOperation
$creadPrec :: ReadPrec CustomActionURLOperation
readList :: ReadS [CustomActionURLOperation]
$creadList :: ReadS [CustomActionURLOperation]
readsPrec :: Int -> ReadS CustomActionURLOperation
$creadsPrec :: Int -> ReadS CustomActionURLOperation
Prelude.Read, Int -> CustomActionURLOperation -> ShowS
[CustomActionURLOperation] -> ShowS
CustomActionURLOperation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomActionURLOperation] -> ShowS
$cshowList :: [CustomActionURLOperation] -> ShowS
show :: CustomActionURLOperation -> String
$cshow :: CustomActionURLOperation -> String
showsPrec :: Int -> CustomActionURLOperation -> ShowS
$cshowsPrec :: Int -> CustomActionURLOperation -> ShowS
Prelude.Show, forall x.
Rep CustomActionURLOperation x -> CustomActionURLOperation
forall x.
CustomActionURLOperation -> Rep CustomActionURLOperation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomActionURLOperation x -> CustomActionURLOperation
$cfrom :: forall x.
CustomActionURLOperation -> Rep CustomActionURLOperation x
Prelude.Generic)

-- |
-- Create a value of 'CustomActionURLOperation' 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:
--
-- 'uRLTemplate', 'customActionURLOperation_uRLTemplate' - THe URL link of the @CustomActionURLOperation@.
--
-- 'uRLTarget', 'customActionURLOperation_uRLTarget' - The target of the @CustomActionURLOperation@.
--
-- Valid values are defined as follows:
--
-- -   @NEW_TAB@: Opens the target URL in a new browser tab.
--
-- -   @NEW_WINDOW@: Opens the target URL in a new browser window.
--
-- -   @SAME_TAB@: Opens the target URL in the same browser tab.
newCustomActionURLOperation ::
  -- | 'uRLTemplate'
  Prelude.Text ->
  -- | 'uRLTarget'
  URLTargetConfiguration ->
  CustomActionURLOperation
newCustomActionURLOperation :: Text -> URLTargetConfiguration -> CustomActionURLOperation
newCustomActionURLOperation Text
pURLTemplate_ URLTargetConfiguration
pURLTarget_ =
  CustomActionURLOperation'
    { $sel:uRLTemplate:CustomActionURLOperation' :: Text
uRLTemplate =
        Text
pURLTemplate_,
      $sel:uRLTarget:CustomActionURLOperation' :: URLTargetConfiguration
uRLTarget = URLTargetConfiguration
pURLTarget_
    }

-- | THe URL link of the @CustomActionURLOperation@.
customActionURLOperation_uRLTemplate :: Lens.Lens' CustomActionURLOperation Prelude.Text
customActionURLOperation_uRLTemplate :: Lens' CustomActionURLOperation Text
customActionURLOperation_uRLTemplate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomActionURLOperation' {Text
uRLTemplate :: Text
$sel:uRLTemplate:CustomActionURLOperation' :: CustomActionURLOperation -> Text
uRLTemplate} -> Text
uRLTemplate) (\s :: CustomActionURLOperation
s@CustomActionURLOperation' {} Text
a -> CustomActionURLOperation
s {$sel:uRLTemplate:CustomActionURLOperation' :: Text
uRLTemplate = Text
a} :: CustomActionURLOperation)

-- | The target of the @CustomActionURLOperation@.
--
-- Valid values are defined as follows:
--
-- -   @NEW_TAB@: Opens the target URL in a new browser tab.
--
-- -   @NEW_WINDOW@: Opens the target URL in a new browser window.
--
-- -   @SAME_TAB@: Opens the target URL in the same browser tab.
customActionURLOperation_uRLTarget :: Lens.Lens' CustomActionURLOperation URLTargetConfiguration
customActionURLOperation_uRLTarget :: Lens' CustomActionURLOperation URLTargetConfiguration
customActionURLOperation_uRLTarget = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomActionURLOperation' {URLTargetConfiguration
uRLTarget :: URLTargetConfiguration
$sel:uRLTarget:CustomActionURLOperation' :: CustomActionURLOperation -> URLTargetConfiguration
uRLTarget} -> URLTargetConfiguration
uRLTarget) (\s :: CustomActionURLOperation
s@CustomActionURLOperation' {} URLTargetConfiguration
a -> CustomActionURLOperation
s {$sel:uRLTarget:CustomActionURLOperation' :: URLTargetConfiguration
uRLTarget = URLTargetConfiguration
a} :: CustomActionURLOperation)

instance Data.FromJSON CustomActionURLOperation where
  parseJSON :: Value -> Parser CustomActionURLOperation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomActionURLOperation"
      ( \Object
x ->
          Text -> URLTargetConfiguration -> CustomActionURLOperation
CustomActionURLOperation'
            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
"URLTemplate")
            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
"URLTarget")
      )

instance Prelude.Hashable CustomActionURLOperation where
  hashWithSalt :: Int -> CustomActionURLOperation -> Int
hashWithSalt Int
_salt CustomActionURLOperation' {Text
URLTargetConfiguration
uRLTarget :: URLTargetConfiguration
uRLTemplate :: Text
$sel:uRLTarget:CustomActionURLOperation' :: CustomActionURLOperation -> URLTargetConfiguration
$sel:uRLTemplate:CustomActionURLOperation' :: CustomActionURLOperation -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
uRLTemplate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` URLTargetConfiguration
uRLTarget

instance Prelude.NFData CustomActionURLOperation where
  rnf :: CustomActionURLOperation -> ()
rnf CustomActionURLOperation' {Text
URLTargetConfiguration
uRLTarget :: URLTargetConfiguration
uRLTemplate :: Text
$sel:uRLTarget:CustomActionURLOperation' :: CustomActionURLOperation -> URLTargetConfiguration
$sel:uRLTemplate:CustomActionURLOperation' :: CustomActionURLOperation -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
uRLTemplate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf URLTargetConfiguration
uRLTarget

instance Data.ToJSON CustomActionURLOperation where
  toJSON :: CustomActionURLOperation -> Value
toJSON CustomActionURLOperation' {Text
URLTargetConfiguration
uRLTarget :: URLTargetConfiguration
uRLTemplate :: Text
$sel:uRLTarget:CustomActionURLOperation' :: CustomActionURLOperation -> URLTargetConfiguration
$sel:uRLTemplate:CustomActionURLOperation' :: CustomActionURLOperation -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"URLTemplate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
uRLTemplate),
            forall a. a -> Maybe a
Prelude.Just (Key
"URLTarget" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= URLTargetConfiguration
uRLTarget)
          ]
      )