{-# 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.RSessionAppSettings
-- 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.SageMaker.Types.RSessionAppSettings 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.SageMaker.Types.CustomImage
import Amazonka.SageMaker.Types.ResourceSpec

-- | A collection of settings that apply to an @RSessionGateway@ app.
--
-- /See:/ 'newRSessionAppSettings' smart constructor.
data RSessionAppSettings = RSessionAppSettings'
  { -- | A list of custom SageMaker images that are configured to run as a
    -- RSession app.
    RSessionAppSettings -> Maybe [CustomImage]
customImages :: Prelude.Maybe [CustomImage],
    RSessionAppSettings -> Maybe ResourceSpec
defaultResourceSpec :: Prelude.Maybe ResourceSpec
  }
  deriving (RSessionAppSettings -> RSessionAppSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RSessionAppSettings -> RSessionAppSettings -> Bool
$c/= :: RSessionAppSettings -> RSessionAppSettings -> Bool
== :: RSessionAppSettings -> RSessionAppSettings -> Bool
$c== :: RSessionAppSettings -> RSessionAppSettings -> Bool
Prelude.Eq, ReadPrec [RSessionAppSettings]
ReadPrec RSessionAppSettings
Int -> ReadS RSessionAppSettings
ReadS [RSessionAppSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RSessionAppSettings]
$creadListPrec :: ReadPrec [RSessionAppSettings]
readPrec :: ReadPrec RSessionAppSettings
$creadPrec :: ReadPrec RSessionAppSettings
readList :: ReadS [RSessionAppSettings]
$creadList :: ReadS [RSessionAppSettings]
readsPrec :: Int -> ReadS RSessionAppSettings
$creadsPrec :: Int -> ReadS RSessionAppSettings
Prelude.Read, Int -> RSessionAppSettings -> ShowS
[RSessionAppSettings] -> ShowS
RSessionAppSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RSessionAppSettings] -> ShowS
$cshowList :: [RSessionAppSettings] -> ShowS
show :: RSessionAppSettings -> String
$cshow :: RSessionAppSettings -> String
showsPrec :: Int -> RSessionAppSettings -> ShowS
$cshowsPrec :: Int -> RSessionAppSettings -> ShowS
Prelude.Show, forall x. Rep RSessionAppSettings x -> RSessionAppSettings
forall x. RSessionAppSettings -> Rep RSessionAppSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RSessionAppSettings x -> RSessionAppSettings
$cfrom :: forall x. RSessionAppSettings -> Rep RSessionAppSettings x
Prelude.Generic)

-- |
-- Create a value of 'RSessionAppSettings' 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:
--
-- 'customImages', 'rSessionAppSettings_customImages' - A list of custom SageMaker images that are configured to run as a
-- RSession app.
--
-- 'defaultResourceSpec', 'rSessionAppSettings_defaultResourceSpec' - Undocumented member.
newRSessionAppSettings ::
  RSessionAppSettings
newRSessionAppSettings :: RSessionAppSettings
newRSessionAppSettings =
  RSessionAppSettings'
    { $sel:customImages:RSessionAppSettings' :: Maybe [CustomImage]
customImages =
        forall a. Maybe a
Prelude.Nothing,
      $sel:defaultResourceSpec:RSessionAppSettings' :: Maybe ResourceSpec
defaultResourceSpec = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of custom SageMaker images that are configured to run as a
-- RSession app.
rSessionAppSettings_customImages :: Lens.Lens' RSessionAppSettings (Prelude.Maybe [CustomImage])
rSessionAppSettings_customImages :: Lens' RSessionAppSettings (Maybe [CustomImage])
rSessionAppSettings_customImages = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RSessionAppSettings' {Maybe [CustomImage]
customImages :: Maybe [CustomImage]
$sel:customImages:RSessionAppSettings' :: RSessionAppSettings -> Maybe [CustomImage]
customImages} -> Maybe [CustomImage]
customImages) (\s :: RSessionAppSettings
s@RSessionAppSettings' {} Maybe [CustomImage]
a -> RSessionAppSettings
s {$sel:customImages:RSessionAppSettings' :: Maybe [CustomImage]
customImages = Maybe [CustomImage]
a} :: RSessionAppSettings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
rSessionAppSettings_defaultResourceSpec :: Lens.Lens' RSessionAppSettings (Prelude.Maybe ResourceSpec)
rSessionAppSettings_defaultResourceSpec :: Lens' RSessionAppSettings (Maybe ResourceSpec)
rSessionAppSettings_defaultResourceSpec = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RSessionAppSettings' {Maybe ResourceSpec
defaultResourceSpec :: Maybe ResourceSpec
$sel:defaultResourceSpec:RSessionAppSettings' :: RSessionAppSettings -> Maybe ResourceSpec
defaultResourceSpec} -> Maybe ResourceSpec
defaultResourceSpec) (\s :: RSessionAppSettings
s@RSessionAppSettings' {} Maybe ResourceSpec
a -> RSessionAppSettings
s {$sel:defaultResourceSpec:RSessionAppSettings' :: Maybe ResourceSpec
defaultResourceSpec = Maybe ResourceSpec
a} :: RSessionAppSettings)

instance Data.FromJSON RSessionAppSettings where
  parseJSON :: Value -> Parser RSessionAppSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RSessionAppSettings"
      ( \Object
x ->
          Maybe [CustomImage] -> Maybe ResourceSpec -> RSessionAppSettings
RSessionAppSettings'
            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
"CustomImages" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"DefaultResourceSpec")
      )

instance Prelude.Hashable RSessionAppSettings where
  hashWithSalt :: Int -> RSessionAppSettings -> Int
hashWithSalt Int
_salt RSessionAppSettings' {Maybe [CustomImage]
Maybe ResourceSpec
defaultResourceSpec :: Maybe ResourceSpec
customImages :: Maybe [CustomImage]
$sel:defaultResourceSpec:RSessionAppSettings' :: RSessionAppSettings -> Maybe ResourceSpec
$sel:customImages:RSessionAppSettings' :: RSessionAppSettings -> Maybe [CustomImage]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [CustomImage]
customImages
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceSpec
defaultResourceSpec

instance Prelude.NFData RSessionAppSettings where
  rnf :: RSessionAppSettings -> ()
rnf RSessionAppSettings' {Maybe [CustomImage]
Maybe ResourceSpec
defaultResourceSpec :: Maybe ResourceSpec
customImages :: Maybe [CustomImage]
$sel:defaultResourceSpec:RSessionAppSettings' :: RSessionAppSettings -> Maybe ResourceSpec
$sel:customImages:RSessionAppSettings' :: RSessionAppSettings -> Maybe [CustomImage]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CustomImage]
customImages
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceSpec
defaultResourceSpec

instance Data.ToJSON RSessionAppSettings where
  toJSON :: RSessionAppSettings -> Value
toJSON RSessionAppSettings' {Maybe [CustomImage]
Maybe ResourceSpec
defaultResourceSpec :: Maybe ResourceSpec
customImages :: Maybe [CustomImage]
$sel:defaultResourceSpec:RSessionAppSettings' :: RSessionAppSettings -> Maybe ResourceSpec
$sel:customImages:RSessionAppSettings' :: RSessionAppSettings -> Maybe [CustomImage]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CustomImages" 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 [CustomImage]
customImages,
            (Key
"DefaultResourceSpec" 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 ResourceSpec
defaultResourceSpec
          ]
      )