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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration of storage locations for the 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
(TensorBoardOutputConfig -> TensorBoardOutputConfig -> Bool)
-> (TensorBoardOutputConfig -> TensorBoardOutputConfig -> Bool)
-> Eq TensorBoardOutputConfig
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]
(Int -> ReadS TensorBoardOutputConfig)
-> ReadS [TensorBoardOutputConfig]
-> ReadPrec TensorBoardOutputConfig
-> ReadPrec [TensorBoardOutputConfig]
-> Read 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
(Int -> TensorBoardOutputConfig -> ShowS)
-> (TensorBoardOutputConfig -> String)
-> ([TensorBoardOutputConfig] -> ShowS)
-> Show TensorBoardOutputConfig
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.
 TensorBoardOutputConfig -> Rep TensorBoardOutputConfig x)
-> (forall x.
    Rep TensorBoardOutputConfig x -> TensorBoardOutputConfig)
-> Generic TensorBoardOutputConfig
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' :: Maybe Text -> Text -> TensorBoardOutputConfig
TensorBoardOutputConfig'
    { $sel:localPath:TensorBoardOutputConfig' :: Maybe Text
localPath =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> TensorBoardOutputConfig -> f TensorBoardOutputConfig
tensorBoardOutputConfig_localPath = (TensorBoardOutputConfig -> Maybe Text)
-> (TensorBoardOutputConfig
    -> Maybe Text -> TensorBoardOutputConfig)
-> Lens
     TensorBoardOutputConfig
     TensorBoardOutputConfig
     (Maybe Text)
     (Maybe Text)
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 :: (Text -> f Text)
-> TensorBoardOutputConfig -> f TensorBoardOutputConfig
tensorBoardOutputConfig_s3OutputPath = (TensorBoardOutputConfig -> Text)
-> (TensorBoardOutputConfig -> Text -> TensorBoardOutputConfig)
-> Lens TensorBoardOutputConfig TensorBoardOutputConfig Text Text
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 Core.FromJSON TensorBoardOutputConfig where
  parseJSON :: Value -> Parser TensorBoardOutputConfig
parseJSON =
    String
-> (Object -> Parser TensorBoardOutputConfig)
-> Value
-> Parser TensorBoardOutputConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TensorBoardOutputConfig"
      ( \Object
x ->
          Maybe Text -> Text -> TensorBoardOutputConfig
TensorBoardOutputConfig'
            (Maybe Text -> Text -> TensorBoardOutputConfig)
-> Parser (Maybe Text) -> Parser (Text -> TensorBoardOutputConfig)
forall (f :: * -> *) a b. Functor 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
"LocalPath")
            Parser (Text -> TensorBoardOutputConfig)
-> Parser Text -> Parser TensorBoardOutputConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3OutputPath")
      )

instance Prelude.Hashable TensorBoardOutputConfig

instance Prelude.NFData TensorBoardOutputConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LocalPath" 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
localPath,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"S3OutputPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3OutputPath)
          ]
      )