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

-- | Configuration of storage locations for the Amazon SageMaker Debugger
-- TensorBoard output data.
--
-- /See:/ 'newTensorBoardOutputConfig' smart constructor.
data TensorBoardOutputConfig = TensorBoardOutputConfig'
  { -- | Path to local storage location for tensorBoard output. Defaults to
    -- @\/opt\/ml\/output\/tensorboard@.
    TensorBoardOutputConfig -> Maybe Text
localPath :: Prelude.Maybe Prelude.Text,
    -- | Path to Amazon S3 storage location for TensorBoard output.
    TensorBoardOutputConfig -> Text
s3OutputPath :: Prelude.Text
  }
  deriving (TensorBoardOutputConfig -> TensorBoardOutputConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TensorBoardOutputConfig -> TensorBoardOutputConfig -> Bool
$c/= :: TensorBoardOutputConfig -> TensorBoardOutputConfig -> Bool
== :: TensorBoardOutputConfig -> TensorBoardOutputConfig -> Bool
$c== :: TensorBoardOutputConfig -> TensorBoardOutputConfig -> Bool
Prelude.Eq, ReadPrec [TensorBoardOutputConfig]
ReadPrec TensorBoardOutputConfig
Int -> ReadS TensorBoardOutputConfig
ReadS [TensorBoardOutputConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TensorBoardOutputConfig]
$creadListPrec :: ReadPrec [TensorBoardOutputConfig]
readPrec :: ReadPrec TensorBoardOutputConfig
$creadPrec :: ReadPrec TensorBoardOutputConfig
readList :: ReadS [TensorBoardOutputConfig]
$creadList :: ReadS [TensorBoardOutputConfig]
readsPrec :: Int -> ReadS TensorBoardOutputConfig
$creadsPrec :: Int -> ReadS TensorBoardOutputConfig
Prelude.Read, Int -> TensorBoardOutputConfig -> ShowS
[TensorBoardOutputConfig] -> ShowS
TensorBoardOutputConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TensorBoardOutputConfig] -> ShowS
$cshowList :: [TensorBoardOutputConfig] -> ShowS
show :: TensorBoardOutputConfig -> String
$cshow :: TensorBoardOutputConfig -> String
showsPrec :: Int -> TensorBoardOutputConfig -> ShowS
$cshowsPrec :: Int -> TensorBoardOutputConfig -> ShowS
Prelude.Show, forall x. Rep TensorBoardOutputConfig x -> TensorBoardOutputConfig
forall x. TensorBoardOutputConfig -> Rep TensorBoardOutputConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TensorBoardOutputConfig x -> TensorBoardOutputConfig
$cfrom :: forall x. TensorBoardOutputConfig -> Rep TensorBoardOutputConfig x
Prelude.Generic)

-- |
-- Create a value of 'TensorBoardOutputConfig' 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', 'tensorBoardOutputConfig_localPath' - Path to local storage location for tensorBoard output. Defaults to
-- @\/opt\/ml\/output\/tensorboard@.
--
-- 's3OutputPath', 'tensorBoardOutputConfig_s3OutputPath' - Path to Amazon S3 storage location for TensorBoard output.
newTensorBoardOutputConfig ::
  -- | 's3OutputPath'
  Prelude.Text ->
  TensorBoardOutputConfig
newTensorBoardOutputConfig :: Text -> TensorBoardOutputConfig
newTensorBoardOutputConfig Text
pS3OutputPath_ =
  TensorBoardOutputConfig'
    { $sel:localPath:TensorBoardOutputConfig' :: Maybe Text
localPath =
        forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:TensorBoardOutputConfig' :: Text
s3OutputPath = Text
pS3OutputPath_
    }

-- | Path to local storage location for tensorBoard output. Defaults to
-- @\/opt\/ml\/output\/tensorboard@.
tensorBoardOutputConfig_localPath :: Lens.Lens' TensorBoardOutputConfig (Prelude.Maybe Prelude.Text)
tensorBoardOutputConfig_localPath :: Lens' TensorBoardOutputConfig (Maybe Text)
tensorBoardOutputConfig_localPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TensorBoardOutputConfig' {Maybe Text
localPath :: Maybe Text
$sel:localPath:TensorBoardOutputConfig' :: TensorBoardOutputConfig -> Maybe Text
localPath} -> Maybe Text
localPath) (\s :: TensorBoardOutputConfig
s@TensorBoardOutputConfig' {} Maybe Text
a -> TensorBoardOutputConfig
s {$sel:localPath:TensorBoardOutputConfig' :: Maybe Text
localPath = Maybe Text
a} :: TensorBoardOutputConfig)

-- | Path to Amazon S3 storage location for TensorBoard output.
tensorBoardOutputConfig_s3OutputPath :: Lens.Lens' TensorBoardOutputConfig Prelude.Text
tensorBoardOutputConfig_s3OutputPath :: Lens' TensorBoardOutputConfig Text
tensorBoardOutputConfig_s3OutputPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TensorBoardOutputConfig' {Text
s3OutputPath :: Text
$sel:s3OutputPath:TensorBoardOutputConfig' :: TensorBoardOutputConfig -> Text
s3OutputPath} -> Text
s3OutputPath) (\s :: TensorBoardOutputConfig
s@TensorBoardOutputConfig' {} Text
a -> TensorBoardOutputConfig
s {$sel:s3OutputPath:TensorBoardOutputConfig' :: Text
s3OutputPath = Text
a} :: TensorBoardOutputConfig)

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

instance Prelude.Hashable TensorBoardOutputConfig where
  hashWithSalt :: Int -> TensorBoardOutputConfig -> Int
hashWithSalt Int
_salt TensorBoardOutputConfig' {Maybe Text
Text
s3OutputPath :: Text
localPath :: Maybe Text
$sel:s3OutputPath:TensorBoardOutputConfig' :: TensorBoardOutputConfig -> Text
$sel:localPath:TensorBoardOutputConfig' :: TensorBoardOutputConfig -> 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
s3OutputPath

instance Prelude.NFData TensorBoardOutputConfig where
  rnf :: TensorBoardOutputConfig -> ()
rnf TensorBoardOutputConfig' {Maybe Text
Text
s3OutputPath :: Text
localPath :: Maybe Text
$sel:s3OutputPath:TensorBoardOutputConfig' :: TensorBoardOutputConfig -> Text
$sel:localPath:TensorBoardOutputConfig' :: TensorBoardOutputConfig -> 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
s3OutputPath

instance Data.ToJSON TensorBoardOutputConfig where
  toJSON :: TensorBoardOutputConfig -> Value
toJSON TensorBoardOutputConfig' {Maybe Text
Text
s3OutputPath :: Text
localPath :: Maybe Text
$sel:s3OutputPath:TensorBoardOutputConfig' :: TensorBoardOutputConfig -> Text
$sel:localPath:TensorBoardOutputConfig' :: TensorBoardOutputConfig -> 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
"S3OutputPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3OutputPath)
          ]
      )