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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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.
    ResourceSpec -> Maybe AppInstanceType
instanceType :: Prelude.Maybe AppInstanceType,
    -- | 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,
    -- | The Amazon Resource Name (ARN) of the Lifecycle Configuration attached
    -- to the Resource.
    ResourceSpec -> Maybe Text
lifecycleConfigArn :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceSpec -> ResourceSpec -> Bool
(ResourceSpec -> ResourceSpec -> Bool)
-> (ResourceSpec -> ResourceSpec -> Bool) -> Eq ResourceSpec
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]
(Int -> ReadS ResourceSpec)
-> ReadS [ResourceSpec]
-> ReadPrec ResourceSpec
-> ReadPrec [ResourceSpec]
-> Read 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
(Int -> ResourceSpec -> ShowS)
-> (ResourceSpec -> String)
-> ([ResourceSpec] -> ShowS)
-> Show ResourceSpec
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. ResourceSpec -> Rep ResourceSpec x)
-> (forall x. Rep ResourceSpec x -> ResourceSpec)
-> Generic ResourceSpec
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.
--
-- '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.
--
-- 'lifecycleConfigArn', 'resourceSpec_lifecycleConfigArn' - The Amazon Resource Name (ARN) of the Lifecycle Configuration attached
-- to the Resource.
newResourceSpec ::
  ResourceSpec
newResourceSpec :: ResourceSpec
newResourceSpec =
  ResourceSpec' :: Maybe AppInstanceType
-> Maybe Text -> Maybe Text -> Maybe Text -> ResourceSpec
ResourceSpec'
    { $sel:instanceType:ResourceSpec' :: Maybe AppInstanceType
instanceType = Maybe AppInstanceType
forall a. Maybe a
Prelude.Nothing,
      $sel:sageMakerImageArn:ResourceSpec' :: Maybe Text
sageMakerImageArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sageMakerImageVersionArn:ResourceSpec' :: Maybe Text
sageMakerImageVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lifecycleConfigArn:ResourceSpec' :: Maybe Text
lifecycleConfigArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The instance type that the image version runs on.
resourceSpec_instanceType :: Lens.Lens' ResourceSpec (Prelude.Maybe AppInstanceType)
resourceSpec_instanceType :: (Maybe AppInstanceType -> f (Maybe AppInstanceType))
-> ResourceSpec -> f ResourceSpec
resourceSpec_instanceType = (ResourceSpec -> Maybe AppInstanceType)
-> (ResourceSpec -> Maybe AppInstanceType -> ResourceSpec)
-> Lens
     ResourceSpec
     ResourceSpec
     (Maybe AppInstanceType)
     (Maybe AppInstanceType)
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 ARN of the SageMaker image that the image version belongs to.
resourceSpec_sageMakerImageArn :: Lens.Lens' ResourceSpec (Prelude.Maybe Prelude.Text)
resourceSpec_sageMakerImageArn :: (Maybe Text -> f (Maybe Text)) -> ResourceSpec -> f ResourceSpec
resourceSpec_sageMakerImageArn = (ResourceSpec -> Maybe Text)
-> (ResourceSpec -> Maybe Text -> ResourceSpec)
-> Lens ResourceSpec ResourceSpec (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> ResourceSpec -> f ResourceSpec
resourceSpec_sageMakerImageVersionArn = (ResourceSpec -> Maybe Text)
-> (ResourceSpec -> Maybe Text -> ResourceSpec)
-> Lens ResourceSpec ResourceSpec (Maybe Text) (Maybe Text)
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)

-- | The Amazon Resource Name (ARN) of the Lifecycle Configuration attached
-- to the Resource.
resourceSpec_lifecycleConfigArn :: Lens.Lens' ResourceSpec (Prelude.Maybe Prelude.Text)
resourceSpec_lifecycleConfigArn :: (Maybe Text -> f (Maybe Text)) -> ResourceSpec -> f ResourceSpec
resourceSpec_lifecycleConfigArn = (ResourceSpec -> Maybe Text)
-> (ResourceSpec -> Maybe Text -> ResourceSpec)
-> Lens ResourceSpec ResourceSpec (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON ResourceSpec where
  parseJSON :: Value -> Parser ResourceSpec
parseJSON =
    String
-> (Object -> Parser ResourceSpec) -> Value -> Parser ResourceSpec
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceSpec"
      ( \Object
x ->
          Maybe AppInstanceType
-> Maybe Text -> Maybe Text -> Maybe Text -> ResourceSpec
ResourceSpec'
            (Maybe AppInstanceType
 -> Maybe Text -> Maybe Text -> Maybe Text -> ResourceSpec)
-> Parser (Maybe AppInstanceType)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> ResourceSpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AppInstanceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InstanceType")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> ResourceSpec)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> ResourceSpec)
forall (f :: * -> *) a b. Applicative f => 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
"SageMakerImageArn")
            Parser (Maybe Text -> Maybe Text -> ResourceSpec)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ResourceSpec)
forall (f :: * -> *) a b. Applicative f => 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
"SageMakerImageVersionArn")
            Parser (Maybe Text -> ResourceSpec)
-> Parser (Maybe Text) -> Parser ResourceSpec
forall (f :: * -> *) a b. Applicative f => 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
"LifecycleConfigArn")
      )

instance Prelude.Hashable ResourceSpec

instance Prelude.NFData ResourceSpec

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