{-# 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.JobCheckpointConfig
-- 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.JobCheckpointConfig 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

-- | Contains information about the output locations for job checkpoint data.
--
-- /See:/ 'newJobCheckpointConfig' smart constructor.
data JobCheckpointConfig = JobCheckpointConfig'
  { -- | (Optional) The local directory where checkpoints are written. The
    -- default directory is @\/opt\/braket\/checkpoints\/@.
    JobCheckpointConfig -> Maybe Text
localPath :: Prelude.Maybe Prelude.Text,
    -- | Identifies the S3 path where you want Amazon Braket to store
    -- checkpoints. For example, @s3:\/\/bucket-name\/key-name-prefix@.
    JobCheckpointConfig -> Text
s3Uri :: Prelude.Text
  }
  deriving (JobCheckpointConfig -> JobCheckpointConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobCheckpointConfig -> JobCheckpointConfig -> Bool
$c/= :: JobCheckpointConfig -> JobCheckpointConfig -> Bool
== :: JobCheckpointConfig -> JobCheckpointConfig -> Bool
$c== :: JobCheckpointConfig -> JobCheckpointConfig -> Bool
Prelude.Eq, ReadPrec [JobCheckpointConfig]
ReadPrec JobCheckpointConfig
Int -> ReadS JobCheckpointConfig
ReadS [JobCheckpointConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobCheckpointConfig]
$creadListPrec :: ReadPrec [JobCheckpointConfig]
readPrec :: ReadPrec JobCheckpointConfig
$creadPrec :: ReadPrec JobCheckpointConfig
readList :: ReadS [JobCheckpointConfig]
$creadList :: ReadS [JobCheckpointConfig]
readsPrec :: Int -> ReadS JobCheckpointConfig
$creadsPrec :: Int -> ReadS JobCheckpointConfig
Prelude.Read, Int -> JobCheckpointConfig -> ShowS
[JobCheckpointConfig] -> ShowS
JobCheckpointConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobCheckpointConfig] -> ShowS
$cshowList :: [JobCheckpointConfig] -> ShowS
show :: JobCheckpointConfig -> String
$cshow :: JobCheckpointConfig -> String
showsPrec :: Int -> JobCheckpointConfig -> ShowS
$cshowsPrec :: Int -> JobCheckpointConfig -> ShowS
Prelude.Show, forall x. Rep JobCheckpointConfig x -> JobCheckpointConfig
forall x. JobCheckpointConfig -> Rep JobCheckpointConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobCheckpointConfig x -> JobCheckpointConfig
$cfrom :: forall x. JobCheckpointConfig -> Rep JobCheckpointConfig x
Prelude.Generic)

-- |
-- Create a value of 'JobCheckpointConfig' 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:
--
-- 'localPath', 'jobCheckpointConfig_localPath' - (Optional) The local directory where checkpoints are written. The
-- default directory is @\/opt\/braket\/checkpoints\/@.
--
-- 's3Uri', 'jobCheckpointConfig_s3Uri' - Identifies the S3 path where you want Amazon Braket to store
-- checkpoints. For example, @s3:\/\/bucket-name\/key-name-prefix@.
newJobCheckpointConfig ::
  -- | 's3Uri'
  Prelude.Text ->
  JobCheckpointConfig
newJobCheckpointConfig :: Text -> JobCheckpointConfig
newJobCheckpointConfig Text
pS3Uri_ =
  JobCheckpointConfig'
    { $sel:localPath:JobCheckpointConfig' :: Maybe Text
localPath = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Uri:JobCheckpointConfig' :: Text
s3Uri = Text
pS3Uri_
    }

-- | (Optional) The local directory where checkpoints are written. The
-- default directory is @\/opt\/braket\/checkpoints\/@.
jobCheckpointConfig_localPath :: Lens.Lens' JobCheckpointConfig (Prelude.Maybe Prelude.Text)
jobCheckpointConfig_localPath :: Lens' JobCheckpointConfig (Maybe Text)
jobCheckpointConfig_localPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobCheckpointConfig' {Maybe Text
localPath :: Maybe Text
$sel:localPath:JobCheckpointConfig' :: JobCheckpointConfig -> Maybe Text
localPath} -> Maybe Text
localPath) (\s :: JobCheckpointConfig
s@JobCheckpointConfig' {} Maybe Text
a -> JobCheckpointConfig
s {$sel:localPath:JobCheckpointConfig' :: Maybe Text
localPath = Maybe Text
a} :: JobCheckpointConfig)

-- | Identifies the S3 path where you want Amazon Braket to store
-- checkpoints. For example, @s3:\/\/bucket-name\/key-name-prefix@.
jobCheckpointConfig_s3Uri :: Lens.Lens' JobCheckpointConfig Prelude.Text
jobCheckpointConfig_s3Uri :: Lens' JobCheckpointConfig Text
jobCheckpointConfig_s3Uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobCheckpointConfig' {Text
s3Uri :: Text
$sel:s3Uri:JobCheckpointConfig' :: JobCheckpointConfig -> Text
s3Uri} -> Text
s3Uri) (\s :: JobCheckpointConfig
s@JobCheckpointConfig' {} Text
a -> JobCheckpointConfig
s {$sel:s3Uri:JobCheckpointConfig' :: Text
s3Uri = Text
a} :: JobCheckpointConfig)

instance Data.FromJSON JobCheckpointConfig where
  parseJSON :: Value -> Parser JobCheckpointConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JobCheckpointConfig"
      ( \Object
x ->
          Maybe Text -> Text -> JobCheckpointConfig
JobCheckpointConfig'
            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
"localPath")
            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
"s3Uri")
      )

instance Prelude.Hashable JobCheckpointConfig where
  hashWithSalt :: Int -> JobCheckpointConfig -> Int
hashWithSalt Int
_salt JobCheckpointConfig' {Maybe Text
Text
s3Uri :: Text
localPath :: Maybe Text
$sel:s3Uri:JobCheckpointConfig' :: JobCheckpointConfig -> Text
$sel:localPath:JobCheckpointConfig' :: JobCheckpointConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
localPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3Uri

instance Prelude.NFData JobCheckpointConfig where
  rnf :: JobCheckpointConfig -> ()
rnf JobCheckpointConfig' {Maybe Text
Text
s3Uri :: Text
localPath :: Maybe Text
$sel:s3Uri:JobCheckpointConfig' :: JobCheckpointConfig -> Text
$sel:localPath:JobCheckpointConfig' :: JobCheckpointConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
localPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3Uri

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