{-# 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.SparkParameters
-- 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.SparkParameters 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

-- | The parameters for Spark.
--
-- /See:/ 'newSparkParameters' smart constructor.
data SparkParameters = SparkParameters'
  { -- | Host.
    SparkParameters -> Text
host :: Prelude.Text,
    -- | Port.
    SparkParameters -> Natural
port :: Prelude.Natural
  }
  deriving (SparkParameters -> SparkParameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SparkParameters -> SparkParameters -> Bool
$c/= :: SparkParameters -> SparkParameters -> Bool
== :: SparkParameters -> SparkParameters -> Bool
$c== :: SparkParameters -> SparkParameters -> Bool
Prelude.Eq, ReadPrec [SparkParameters]
ReadPrec SparkParameters
Int -> ReadS SparkParameters
ReadS [SparkParameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SparkParameters]
$creadListPrec :: ReadPrec [SparkParameters]
readPrec :: ReadPrec SparkParameters
$creadPrec :: ReadPrec SparkParameters
readList :: ReadS [SparkParameters]
$creadList :: ReadS [SparkParameters]
readsPrec :: Int -> ReadS SparkParameters
$creadsPrec :: Int -> ReadS SparkParameters
Prelude.Read, Int -> SparkParameters -> ShowS
[SparkParameters] -> ShowS
SparkParameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SparkParameters] -> ShowS
$cshowList :: [SparkParameters] -> ShowS
show :: SparkParameters -> String
$cshow :: SparkParameters -> String
showsPrec :: Int -> SparkParameters -> ShowS
$cshowsPrec :: Int -> SparkParameters -> ShowS
Prelude.Show, forall x. Rep SparkParameters x -> SparkParameters
forall x. SparkParameters -> Rep SparkParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SparkParameters x -> SparkParameters
$cfrom :: forall x. SparkParameters -> Rep SparkParameters x
Prelude.Generic)

-- |
-- Create a value of 'SparkParameters' 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:
--
-- 'host', 'sparkParameters_host' - Host.
--
-- 'port', 'sparkParameters_port' - Port.
newSparkParameters ::
  -- | 'host'
  Prelude.Text ->
  -- | 'port'
  Prelude.Natural ->
  SparkParameters
newSparkParameters :: Text -> Natural -> SparkParameters
newSparkParameters Text
pHost_ Natural
pPort_ =
  SparkParameters' {$sel:host:SparkParameters' :: Text
host = Text
pHost_, $sel:port:SparkParameters' :: Natural
port = Natural
pPort_}

-- | Host.
sparkParameters_host :: Lens.Lens' SparkParameters Prelude.Text
sparkParameters_host :: Lens' SparkParameters Text
sparkParameters_host = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkParameters' {Text
host :: Text
$sel:host:SparkParameters' :: SparkParameters -> Text
host} -> Text
host) (\s :: SparkParameters
s@SparkParameters' {} Text
a -> SparkParameters
s {$sel:host:SparkParameters' :: Text
host = Text
a} :: SparkParameters)

-- | Port.
sparkParameters_port :: Lens.Lens' SparkParameters Prelude.Natural
sparkParameters_port :: Lens' SparkParameters Natural
sparkParameters_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkParameters' {Natural
port :: Natural
$sel:port:SparkParameters' :: SparkParameters -> Natural
port} -> Natural
port) (\s :: SparkParameters
s@SparkParameters' {} Natural
a -> SparkParameters
s {$sel:port:SparkParameters' :: Natural
port = Natural
a} :: SparkParameters)

instance Data.FromJSON SparkParameters where
  parseJSON :: Value -> Parser SparkParameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SparkParameters"
      ( \Object
x ->
          Text -> Natural -> SparkParameters
SparkParameters'
            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
"Host")
            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
"Port")
      )

instance Prelude.Hashable SparkParameters where
  hashWithSalt :: Int -> SparkParameters -> Int
hashWithSalt Int
_salt SparkParameters' {Natural
Text
port :: Natural
host :: Text
$sel:port:SparkParameters' :: SparkParameters -> Natural
$sel:host:SparkParameters' :: SparkParameters -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
host
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
port

instance Prelude.NFData SparkParameters where
  rnf :: SparkParameters -> ()
rnf SparkParameters' {Natural
Text
port :: Natural
host :: Text
$sel:port:SparkParameters' :: SparkParameters -> Natural
$sel:host:SparkParameters' :: SparkParameters -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
host seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
port

instance Data.ToJSON SparkParameters where
  toJSON :: SparkParameters -> Value
toJSON SparkParameters' {Natural
Text
port :: Natural
host :: Text
$sel:port:SparkParameters' :: SparkParameters -> Natural
$sel:host:SparkParameters' :: SparkParameters -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Host" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
host),
            forall a. a -> Maybe a
Prelude.Just (Key
"Port" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
port)
          ]
      )