{-# 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.Braket.Types.InstanceConfig
-- 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.Braket.Types.InstanceConfig where

import Amazonka.Braket.Types.InstanceType
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

-- | Configures the resource instances to use while running the Amazon Braket
-- hybrid job on Amazon Braket.
--
-- /See:/ 'newInstanceConfig' smart constructor.
data InstanceConfig = InstanceConfig'
  { -- | Configures the number of resource instances to use while running an
    -- Amazon Braket job on Amazon Braket. The default value is 1.
    InstanceConfig -> Maybe Natural
instanceCount :: Prelude.Maybe Prelude.Natural,
    -- | Configures the type resource instances to use while running an Amazon
    -- Braket hybrid job.
    InstanceConfig -> InstanceType
instanceType :: InstanceType,
    -- | The size of the storage volume, in GB, that user wants to provision.
    InstanceConfig -> Natural
volumeSizeInGb :: Prelude.Natural
  }
  deriving (InstanceConfig -> InstanceConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceConfig -> InstanceConfig -> Bool
$c/= :: InstanceConfig -> InstanceConfig -> Bool
== :: InstanceConfig -> InstanceConfig -> Bool
$c== :: InstanceConfig -> InstanceConfig -> Bool
Prelude.Eq, ReadPrec [InstanceConfig]
ReadPrec InstanceConfig
Int -> ReadS InstanceConfig
ReadS [InstanceConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceConfig]
$creadListPrec :: ReadPrec [InstanceConfig]
readPrec :: ReadPrec InstanceConfig
$creadPrec :: ReadPrec InstanceConfig
readList :: ReadS [InstanceConfig]
$creadList :: ReadS [InstanceConfig]
readsPrec :: Int -> ReadS InstanceConfig
$creadsPrec :: Int -> ReadS InstanceConfig
Prelude.Read, Int -> InstanceConfig -> ShowS
[InstanceConfig] -> ShowS
InstanceConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceConfig] -> ShowS
$cshowList :: [InstanceConfig] -> ShowS
show :: InstanceConfig -> String
$cshow :: InstanceConfig -> String
showsPrec :: Int -> InstanceConfig -> ShowS
$cshowsPrec :: Int -> InstanceConfig -> ShowS
Prelude.Show, forall x. Rep InstanceConfig x -> InstanceConfig
forall x. InstanceConfig -> Rep InstanceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceConfig x -> InstanceConfig
$cfrom :: forall x. InstanceConfig -> Rep InstanceConfig x
Prelude.Generic)

-- |
-- Create a value of 'InstanceConfig' 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:
--
-- 'instanceCount', 'instanceConfig_instanceCount' - Configures the number of resource instances to use while running an
-- Amazon Braket job on Amazon Braket. The default value is 1.
--
-- 'instanceType', 'instanceConfig_instanceType' - Configures the type resource instances to use while running an Amazon
-- Braket hybrid job.
--
-- 'volumeSizeInGb', 'instanceConfig_volumeSizeInGb' - The size of the storage volume, in GB, that user wants to provision.
newInstanceConfig ::
  -- | 'instanceType'
  InstanceType ->
  -- | 'volumeSizeInGb'
  Prelude.Natural ->
  InstanceConfig
newInstanceConfig :: InstanceType -> Natural -> InstanceConfig
newInstanceConfig InstanceType
pInstanceType_ Natural
pVolumeSizeInGb_ =
  InstanceConfig'
    { $sel:instanceCount:InstanceConfig' :: Maybe Natural
instanceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:InstanceConfig' :: InstanceType
instanceType = InstanceType
pInstanceType_,
      $sel:volumeSizeInGb:InstanceConfig' :: Natural
volumeSizeInGb = Natural
pVolumeSizeInGb_
    }

-- | Configures the number of resource instances to use while running an
-- Amazon Braket job on Amazon Braket. The default value is 1.
instanceConfig_instanceCount :: Lens.Lens' InstanceConfig (Prelude.Maybe Prelude.Natural)
instanceConfig_instanceCount :: Lens' InstanceConfig (Maybe Natural)
instanceConfig_instanceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceConfig' {Maybe Natural
instanceCount :: Maybe Natural
$sel:instanceCount:InstanceConfig' :: InstanceConfig -> Maybe Natural
instanceCount} -> Maybe Natural
instanceCount) (\s :: InstanceConfig
s@InstanceConfig' {} Maybe Natural
a -> InstanceConfig
s {$sel:instanceCount:InstanceConfig' :: Maybe Natural
instanceCount = Maybe Natural
a} :: InstanceConfig)

-- | Configures the type resource instances to use while running an Amazon
-- Braket hybrid job.
instanceConfig_instanceType :: Lens.Lens' InstanceConfig InstanceType
instanceConfig_instanceType :: Lens' InstanceConfig InstanceType
instanceConfig_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceConfig' {InstanceType
instanceType :: InstanceType
$sel:instanceType:InstanceConfig' :: InstanceConfig -> InstanceType
instanceType} -> InstanceType
instanceType) (\s :: InstanceConfig
s@InstanceConfig' {} InstanceType
a -> InstanceConfig
s {$sel:instanceType:InstanceConfig' :: InstanceType
instanceType = InstanceType
a} :: InstanceConfig)

-- | The size of the storage volume, in GB, that user wants to provision.
instanceConfig_volumeSizeInGb :: Lens.Lens' InstanceConfig Prelude.Natural
instanceConfig_volumeSizeInGb :: Lens' InstanceConfig Natural
instanceConfig_volumeSizeInGb = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceConfig' {Natural
volumeSizeInGb :: Natural
$sel:volumeSizeInGb:InstanceConfig' :: InstanceConfig -> Natural
volumeSizeInGb} -> Natural
volumeSizeInGb) (\s :: InstanceConfig
s@InstanceConfig' {} Natural
a -> InstanceConfig
s {$sel:volumeSizeInGb:InstanceConfig' :: Natural
volumeSizeInGb = Natural
a} :: InstanceConfig)

instance Data.FromJSON InstanceConfig where
  parseJSON :: Value -> Parser InstanceConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InstanceConfig"
      ( \Object
x ->
          Maybe Natural -> InstanceType -> Natural -> InstanceConfig
InstanceConfig'
            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
"instanceCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"volumeSizeInGb")
      )

instance Prelude.Hashable InstanceConfig where
  hashWithSalt :: Int -> InstanceConfig -> Int
hashWithSalt Int
_salt InstanceConfig' {Natural
Maybe Natural
InstanceType
volumeSizeInGb :: Natural
instanceType :: InstanceType
instanceCount :: Maybe Natural
$sel:volumeSizeInGb:InstanceConfig' :: InstanceConfig -> Natural
$sel:instanceType:InstanceConfig' :: InstanceConfig -> InstanceType
$sel:instanceCount:InstanceConfig' :: InstanceConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
instanceCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InstanceType
instanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
volumeSizeInGb

instance Prelude.NFData InstanceConfig where
  rnf :: InstanceConfig -> ()
rnf InstanceConfig' {Natural
Maybe Natural
InstanceType
volumeSizeInGb :: Natural
instanceType :: InstanceType
instanceCount :: Maybe Natural
$sel:volumeSizeInGb:InstanceConfig' :: InstanceConfig -> Natural
$sel:instanceType:InstanceConfig' :: InstanceConfig -> InstanceType
$sel:instanceCount:InstanceConfig' :: InstanceConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
instanceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf InstanceType
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
volumeSizeInGb

instance Data.ToJSON InstanceConfig where
  toJSON :: InstanceConfig -> Value
toJSON InstanceConfig' {Natural
Maybe Natural
InstanceType
volumeSizeInGb :: Natural
instanceType :: InstanceType
instanceCount :: Maybe Natural
$sel:volumeSizeInGb:InstanceConfig' :: InstanceConfig -> Natural
$sel:instanceType:InstanceConfig' :: InstanceConfig -> InstanceType
$sel:instanceCount:InstanceConfig' :: InstanceConfig -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"instanceCount" 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 Natural
instanceCount,
            forall a. a -> Maybe a
Prelude.Just (Key
"instanceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= InstanceType
instanceType),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"volumeSizeInGb" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
volumeSizeInGb)
          ]
      )