{-# 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.SageMaker.Types.KernelSpec
-- 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.SageMaker.Types.KernelSpec where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The specification of a Jupyter kernel.
--
-- /See:/ 'newKernelSpec' smart constructor.
data KernelSpec = KernelSpec'
  { -- | The display name of the kernel.
    KernelSpec -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The name of the Jupyter kernel in the image. This value is case
    -- sensitive.
    KernelSpec -> Text
name :: Prelude.Text
  }
  deriving (KernelSpec -> KernelSpec -> Bool
(KernelSpec -> KernelSpec -> Bool)
-> (KernelSpec -> KernelSpec -> Bool) -> Eq KernelSpec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KernelSpec -> KernelSpec -> Bool
$c/= :: KernelSpec -> KernelSpec -> Bool
== :: KernelSpec -> KernelSpec -> Bool
$c== :: KernelSpec -> KernelSpec -> Bool
Prelude.Eq, ReadPrec [KernelSpec]
ReadPrec KernelSpec
Int -> ReadS KernelSpec
ReadS [KernelSpec]
(Int -> ReadS KernelSpec)
-> ReadS [KernelSpec]
-> ReadPrec KernelSpec
-> ReadPrec [KernelSpec]
-> Read KernelSpec
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KernelSpec]
$creadListPrec :: ReadPrec [KernelSpec]
readPrec :: ReadPrec KernelSpec
$creadPrec :: ReadPrec KernelSpec
readList :: ReadS [KernelSpec]
$creadList :: ReadS [KernelSpec]
readsPrec :: Int -> ReadS KernelSpec
$creadsPrec :: Int -> ReadS KernelSpec
Prelude.Read, Int -> KernelSpec -> ShowS
[KernelSpec] -> ShowS
KernelSpec -> String
(Int -> KernelSpec -> ShowS)
-> (KernelSpec -> String)
-> ([KernelSpec] -> ShowS)
-> Show KernelSpec
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KernelSpec] -> ShowS
$cshowList :: [KernelSpec] -> ShowS
show :: KernelSpec -> String
$cshow :: KernelSpec -> String
showsPrec :: Int -> KernelSpec -> ShowS
$cshowsPrec :: Int -> KernelSpec -> ShowS
Prelude.Show, (forall x. KernelSpec -> Rep KernelSpec x)
-> (forall x. Rep KernelSpec x -> KernelSpec) -> Generic KernelSpec
forall x. Rep KernelSpec x -> KernelSpec
forall x. KernelSpec -> Rep KernelSpec x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KernelSpec x -> KernelSpec
$cfrom :: forall x. KernelSpec -> Rep KernelSpec x
Prelude.Generic)

-- |
-- Create a value of 'KernelSpec' 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:
--
-- 'displayName', 'kernelSpec_displayName' - The display name of the kernel.
--
-- 'name', 'kernelSpec_name' - The name of the Jupyter kernel in the image. This value is case
-- sensitive.
newKernelSpec ::
  -- | 'name'
  Prelude.Text ->
  KernelSpec
newKernelSpec :: Text -> KernelSpec
newKernelSpec Text
pName_ =
  KernelSpec' :: Maybe Text -> Text -> KernelSpec
KernelSpec'
    { $sel:displayName:KernelSpec' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:KernelSpec' :: Text
name = Text
pName_
    }

-- | The display name of the kernel.
kernelSpec_displayName :: Lens.Lens' KernelSpec (Prelude.Maybe Prelude.Text)
kernelSpec_displayName :: (Maybe Text -> f (Maybe Text)) -> KernelSpec -> f KernelSpec
kernelSpec_displayName = (KernelSpec -> Maybe Text)
-> (KernelSpec -> Maybe Text -> KernelSpec)
-> Lens KernelSpec KernelSpec (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KernelSpec' {Maybe Text
displayName :: Maybe Text
$sel:displayName:KernelSpec' :: KernelSpec -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: KernelSpec
s@KernelSpec' {} Maybe Text
a -> KernelSpec
s {$sel:displayName:KernelSpec' :: Maybe Text
displayName = Maybe Text
a} :: KernelSpec)

-- | The name of the Jupyter kernel in the image. This value is case
-- sensitive.
kernelSpec_name :: Lens.Lens' KernelSpec Prelude.Text
kernelSpec_name :: (Text -> f Text) -> KernelSpec -> f KernelSpec
kernelSpec_name = (KernelSpec -> Text)
-> (KernelSpec -> Text -> KernelSpec)
-> Lens KernelSpec KernelSpec Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KernelSpec' {Text
name :: Text
$sel:name:KernelSpec' :: KernelSpec -> Text
name} -> Text
name) (\s :: KernelSpec
s@KernelSpec' {} Text
a -> KernelSpec
s {$sel:name:KernelSpec' :: Text
name = Text
a} :: KernelSpec)

instance Core.FromJSON KernelSpec where
  parseJSON :: Value -> Parser KernelSpec
parseJSON =
    String
-> (Object -> Parser KernelSpec) -> Value -> Parser KernelSpec
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"KernelSpec"
      ( \Object
x ->
          Maybe Text -> Text -> KernelSpec
KernelSpec'
            (Maybe Text -> Text -> KernelSpec)
-> Parser (Maybe Text) -> Parser (Text -> KernelSpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DisplayName")
            Parser (Text -> KernelSpec) -> Parser Text -> Parser KernelSpec
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
      )

instance Prelude.Hashable KernelSpec

instance Prelude.NFData KernelSpec

instance Core.ToJSON KernelSpec where
  toJSON :: KernelSpec -> Value
toJSON KernelSpec' {Maybe Text
Text
name :: Text
displayName :: Maybe Text
$sel:name:KernelSpec' :: KernelSpec -> Text
$sel:displayName:KernelSpec' :: KernelSpec -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DisplayName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
displayName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )