{-# 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.ResourceSpec
-- 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.ResourceSpec 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.AppInstanceType

-- | Specifies the ARN\'s of a SageMaker image and SageMaker image version,
-- and the instance type that the version runs on.
--
-- /See:/ 'newResourceSpec' smart constructor.
data ResourceSpec = ResourceSpec'
  { -- | The instance type that the image version runs on.
    --
    -- __JupyterServer apps__ only support the @system@ value.
    --
    -- For __KernelGateway apps__, the @system@ value is translated to
    -- @ml.t3.medium@. KernelGateway apps also support all other values for
    -- available instance types.
    ResourceSpec -> Maybe AppInstanceType
instanceType :: Prelude.Maybe AppInstanceType,
    -- | The Amazon Resource Name (ARN) of the Lifecycle Configuration attached
    -- to the Resource.
    ResourceSpec -> Maybe Text
lifecycleConfigArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the SageMaker image that the image version belongs to.
    ResourceSpec -> Maybe Text
sageMakerImageArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the image version created on the instance.
    ResourceSpec -> Maybe Text
sageMakerImageVersionArn :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceSpec -> ResourceSpec -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceSpec -> ResourceSpec -> Bool
$c/= :: ResourceSpec -> ResourceSpec -> Bool
== :: ResourceSpec -> ResourceSpec -> Bool
$c== :: ResourceSpec -> ResourceSpec -> Bool
Prelude.Eq, ReadPrec [ResourceSpec]
ReadPrec ResourceSpec
Int -> ReadS ResourceSpec
ReadS [ResourceSpec]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceSpec]
$creadListPrec :: ReadPrec [ResourceSpec]
readPrec :: ReadPrec ResourceSpec
$creadPrec :: ReadPrec ResourceSpec
readList :: ReadS [ResourceSpec]
$creadList :: ReadS [ResourceSpec]
readsPrec :: Int -> ReadS ResourceSpec
$creadsPrec :: Int -> ReadS ResourceSpec
Prelude.Read, Int -> ResourceSpec -> ShowS
[ResourceSpec] -> ShowS
ResourceSpec -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceSpec] -> ShowS
$cshowList :: [ResourceSpec] -> ShowS
show :: ResourceSpec -> String
$cshow :: ResourceSpec -> String
showsPrec :: Int -> ResourceSpec -> ShowS
$cshowsPrec :: Int -> ResourceSpec -> ShowS
Prelude.Show, forall x. Rep ResourceSpec x -> ResourceSpec
forall x. ResourceSpec -> Rep ResourceSpec x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceSpec x -> ResourceSpec
$cfrom :: forall x. ResourceSpec -> Rep ResourceSpec x
Prelude.Generic)

-- |
-- Create a value of 'ResourceSpec' 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:
--
-- 'instanceType', 'resourceSpec_instanceType' - The instance type that the image version runs on.
--
-- __JupyterServer apps__ only support the @system@ value.
--
-- For __KernelGateway apps__, the @system@ value is translated to
-- @ml.t3.medium@. KernelGateway apps also support all other values for
-- available instance types.
--
-- 'lifecycleConfigArn', 'resourceSpec_lifecycleConfigArn' - The Amazon Resource Name (ARN) of the Lifecycle Configuration attached
-- to the Resource.
--
-- 'sageMakerImageArn', 'resourceSpec_sageMakerImageArn' - The ARN of the SageMaker image that the image version belongs to.
--
-- 'sageMakerImageVersionArn', 'resourceSpec_sageMakerImageVersionArn' - The ARN of the image version created on the instance.
newResourceSpec ::
  ResourceSpec
newResourceSpec :: ResourceSpec
newResourceSpec =
  ResourceSpec'
    { $sel:instanceType:ResourceSpec' :: Maybe AppInstanceType
instanceType = forall a. Maybe a
Prelude.Nothing,
      $sel:lifecycleConfigArn:ResourceSpec' :: Maybe Text
lifecycleConfigArn = forall a. Maybe a
Prelude.Nothing,
      $sel:sageMakerImageArn:ResourceSpec' :: Maybe Text
sageMakerImageArn = forall a. Maybe a
Prelude.Nothing,
      $sel:sageMakerImageVersionArn:ResourceSpec' :: Maybe Text
sageMakerImageVersionArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The instance type that the image version runs on.
--
-- __JupyterServer apps__ only support the @system@ value.
--
-- For __KernelGateway apps__, the @system@ value is translated to
-- @ml.t3.medium@. KernelGateway apps also support all other values for
-- available instance types.
resourceSpec_instanceType :: Lens.Lens' ResourceSpec (Prelude.Maybe AppInstanceType)
resourceSpec_instanceType :: Lens' ResourceSpec (Maybe AppInstanceType)
resourceSpec_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceSpec' {Maybe AppInstanceType
instanceType :: Maybe AppInstanceType
$sel:instanceType:ResourceSpec' :: ResourceSpec -> Maybe AppInstanceType
instanceType} -> Maybe AppInstanceType
instanceType) (\s :: ResourceSpec
s@ResourceSpec' {} Maybe AppInstanceType
a -> ResourceSpec
s {$sel:instanceType:ResourceSpec' :: Maybe AppInstanceType
instanceType = Maybe AppInstanceType
a} :: ResourceSpec)

-- | The Amazon Resource Name (ARN) of the Lifecycle Configuration attached
-- to the Resource.
resourceSpec_lifecycleConfigArn :: Lens.Lens' ResourceSpec (Prelude.Maybe Prelude.Text)
resourceSpec_lifecycleConfigArn :: Lens' ResourceSpec (Maybe Text)
resourceSpec_lifecycleConfigArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceSpec' {Maybe Text
lifecycleConfigArn :: Maybe Text
$sel:lifecycleConfigArn:ResourceSpec' :: ResourceSpec -> Maybe Text
lifecycleConfigArn} -> Maybe Text
lifecycleConfigArn) (\s :: ResourceSpec
s@ResourceSpec' {} Maybe Text
a -> ResourceSpec
s {$sel:lifecycleConfigArn:ResourceSpec' :: Maybe Text
lifecycleConfigArn = Maybe Text
a} :: ResourceSpec)

-- | The ARN of the SageMaker image that the image version belongs to.
resourceSpec_sageMakerImageArn :: Lens.Lens' ResourceSpec (Prelude.Maybe Prelude.Text)
resourceSpec_sageMakerImageArn :: Lens' ResourceSpec (Maybe Text)
resourceSpec_sageMakerImageArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceSpec' {Maybe Text
sageMakerImageArn :: Maybe Text
$sel:sageMakerImageArn:ResourceSpec' :: ResourceSpec -> Maybe Text
sageMakerImageArn} -> Maybe Text
sageMakerImageArn) (\s :: ResourceSpec
s@ResourceSpec' {} Maybe Text
a -> ResourceSpec
s {$sel:sageMakerImageArn:ResourceSpec' :: Maybe Text
sageMakerImageArn = Maybe Text
a} :: ResourceSpec)

-- | The ARN of the image version created on the instance.
resourceSpec_sageMakerImageVersionArn :: Lens.Lens' ResourceSpec (Prelude.Maybe Prelude.Text)
resourceSpec_sageMakerImageVersionArn :: Lens' ResourceSpec (Maybe Text)
resourceSpec_sageMakerImageVersionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceSpec' {Maybe Text
sageMakerImageVersionArn :: Maybe Text
$sel:sageMakerImageVersionArn:ResourceSpec' :: ResourceSpec -> Maybe Text
sageMakerImageVersionArn} -> Maybe Text
sageMakerImageVersionArn) (\s :: ResourceSpec
s@ResourceSpec' {} Maybe Text
a -> ResourceSpec
s {$sel:sageMakerImageVersionArn:ResourceSpec' :: Maybe Text
sageMakerImageVersionArn = Maybe Text
a} :: ResourceSpec)

instance Data.FromJSON ResourceSpec where
  parseJSON :: Value -> Parser ResourceSpec
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceSpec"
      ( \Object
x ->
          Maybe AppInstanceType
-> Maybe Text -> Maybe Text -> Maybe Text -> ResourceSpec
ResourceSpec'
            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
"InstanceType")
            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
"LifecycleConfigArn")
            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
"SageMakerImageArn")
            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
"SageMakerImageVersionArn")
      )

instance Prelude.Hashable ResourceSpec where
  hashWithSalt :: Int -> ResourceSpec -> Int
hashWithSalt Int
_salt ResourceSpec' {Maybe Text
Maybe AppInstanceType
sageMakerImageVersionArn :: Maybe Text
sageMakerImageArn :: Maybe Text
lifecycleConfigArn :: Maybe Text
instanceType :: Maybe AppInstanceType
$sel:sageMakerImageVersionArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:sageMakerImageArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:lifecycleConfigArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:instanceType:ResourceSpec' :: ResourceSpec -> Maybe AppInstanceType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AppInstanceType
instanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
lifecycleConfigArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sageMakerImageArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sageMakerImageVersionArn

instance Prelude.NFData ResourceSpec where
  rnf :: ResourceSpec -> ()
rnf ResourceSpec' {Maybe Text
Maybe AppInstanceType
sageMakerImageVersionArn :: Maybe Text
sageMakerImageArn :: Maybe Text
lifecycleConfigArn :: Maybe Text
instanceType :: Maybe AppInstanceType
$sel:sageMakerImageVersionArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:sageMakerImageArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:lifecycleConfigArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:instanceType:ResourceSpec' :: ResourceSpec -> Maybe AppInstanceType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AppInstanceType
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
lifecycleConfigArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sageMakerImageArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sageMakerImageVersionArn

instance Data.ToJSON ResourceSpec where
  toJSON :: ResourceSpec -> Value
toJSON ResourceSpec' {Maybe Text
Maybe AppInstanceType
sageMakerImageVersionArn :: Maybe Text
sageMakerImageArn :: Maybe Text
lifecycleConfigArn :: Maybe Text
instanceType :: Maybe AppInstanceType
$sel:sageMakerImageVersionArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:sageMakerImageArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:lifecycleConfigArn:ResourceSpec' :: ResourceSpec -> Maybe Text
$sel:instanceType:ResourceSpec' :: ResourceSpec -> Maybe AppInstanceType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"InstanceType" 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 AppInstanceType
instanceType,
            (Key
"LifecycleConfigArn" 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 Text
lifecycleConfigArn,
            (Key
"SageMakerImageArn" 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 Text
sageMakerImageArn,
            (Key
"SageMakerImageVersionArn" 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 Text
sageMakerImageVersionArn
          ]
      )