{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.SparkParameters where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SparkParameters -> SparkParameters -> Bool)
-> (SparkParameters -> SparkParameters -> Bool)
-> Eq SparkParameters
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]
(Int -> ReadS SparkParameters)
-> ReadS [SparkParameters]
-> ReadPrec SparkParameters
-> ReadPrec [SparkParameters]
-> Read 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
(Int -> SparkParameters -> ShowS)
-> (SparkParameters -> String)
-> ([SparkParameters] -> ShowS)
-> Show SparkParameters
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. SparkParameters -> Rep SparkParameters x)
-> (forall x. Rep SparkParameters x -> SparkParameters)
-> Generic SparkParameters
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' :: Text -> Natural -> SparkParameters
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 :: (Text -> f Text) -> SparkParameters -> f SparkParameters
sparkParameters_host = (SparkParameters -> Text)
-> (SparkParameters -> Text -> SparkParameters)
-> Lens SparkParameters SparkParameters Text Text
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 :: (Natural -> f Natural) -> SparkParameters -> f SparkParameters
sparkParameters_port = (SparkParameters -> Natural)
-> (SparkParameters -> Natural -> SparkParameters)
-> Lens SparkParameters SparkParameters Natural Natural
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 Core.FromJSON SparkParameters where
  parseJSON :: Value -> Parser SparkParameters
parseJSON =
    String
-> (Object -> Parser SparkParameters)
-> Value
-> Parser SparkParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SparkParameters"
      ( \Object
x ->
          Text -> Natural -> SparkParameters
SparkParameters'
            (Text -> Natural -> SparkParameters)
-> Parser Text -> Parser (Natural -> SparkParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Host") Parser (Natural -> SparkParameters)
-> Parser Natural -> Parser SparkParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Port")
      )

instance Prelude.Hashable SparkParameters

instance Prelude.NFData SparkParameters

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Host" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
host),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Port" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
port)
          ]
      )