{-# 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.RobOMaker.Types.Tool
-- 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.RobOMaker.Types.Tool 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
import Amazonka.RobOMaker.Types.ExitBehavior

-- | Information about a tool. Tools are used in a simulation job.
--
-- /See:/ 'newTool' smart constructor.
data Tool = Tool'
  { -- | Exit behavior determines what happens when your tool quits running.
    -- @RESTART@ will cause your tool to be restarted. @FAIL@ will cause your
    -- job to exit. The default is @RESTART@.
    Tool -> Maybe ExitBehavior
exitBehavior :: Prelude.Maybe ExitBehavior,
    -- | Boolean indicating whether logs will be recorded in CloudWatch for the
    -- tool. The default is @False@.
    Tool -> Maybe Bool
streamOutputToCloudWatch :: Prelude.Maybe Prelude.Bool,
    -- | Boolean indicating whether a streaming session will be configured for
    -- the tool. If @True@, AWS RoboMaker will configure a connection so you
    -- can interact with the tool as it is running in the simulation. It must
    -- have a graphical user interface. The default is @False@.
    Tool -> Maybe Bool
streamUI :: Prelude.Maybe Prelude.Bool,
    -- | The name of the tool.
    Tool -> Text
name :: Prelude.Text,
    -- | Command-line arguments for the tool. It must include the tool executable
    -- name.
    Tool -> Text
command :: Prelude.Text
  }
  deriving (Tool -> Tool -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tool -> Tool -> Bool
$c/= :: Tool -> Tool -> Bool
== :: Tool -> Tool -> Bool
$c== :: Tool -> Tool -> Bool
Prelude.Eq, ReadPrec [Tool]
ReadPrec Tool
Int -> ReadS Tool
ReadS [Tool]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Tool]
$creadListPrec :: ReadPrec [Tool]
readPrec :: ReadPrec Tool
$creadPrec :: ReadPrec Tool
readList :: ReadS [Tool]
$creadList :: ReadS [Tool]
readsPrec :: Int -> ReadS Tool
$creadsPrec :: Int -> ReadS Tool
Prelude.Read, Int -> Tool -> ShowS
[Tool] -> ShowS
Tool -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tool] -> ShowS
$cshowList :: [Tool] -> ShowS
show :: Tool -> String
$cshow :: Tool -> String
showsPrec :: Int -> Tool -> ShowS
$cshowsPrec :: Int -> Tool -> ShowS
Prelude.Show, forall x. Rep Tool x -> Tool
forall x. Tool -> Rep Tool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Tool x -> Tool
$cfrom :: forall x. Tool -> Rep Tool x
Prelude.Generic)

-- |
-- Create a value of 'Tool' 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:
--
-- 'exitBehavior', 'tool_exitBehavior' - Exit behavior determines what happens when your tool quits running.
-- @RESTART@ will cause your tool to be restarted. @FAIL@ will cause your
-- job to exit. The default is @RESTART@.
--
-- 'streamOutputToCloudWatch', 'tool_streamOutputToCloudWatch' - Boolean indicating whether logs will be recorded in CloudWatch for the
-- tool. The default is @False@.
--
-- 'streamUI', 'tool_streamUI' - Boolean indicating whether a streaming session will be configured for
-- the tool. If @True@, AWS RoboMaker will configure a connection so you
-- can interact with the tool as it is running in the simulation. It must
-- have a graphical user interface. The default is @False@.
--
-- 'name', 'tool_name' - The name of the tool.
--
-- 'command', 'tool_command' - Command-line arguments for the tool. It must include the tool executable
-- name.
newTool ::
  -- | 'name'
  Prelude.Text ->
  -- | 'command'
  Prelude.Text ->
  Tool
newTool :: Text -> Text -> Tool
newTool Text
pName_ Text
pCommand_ =
  Tool'
    { $sel:exitBehavior:Tool' :: Maybe ExitBehavior
exitBehavior = forall a. Maybe a
Prelude.Nothing,
      $sel:streamOutputToCloudWatch:Tool' :: Maybe Bool
streamOutputToCloudWatch = forall a. Maybe a
Prelude.Nothing,
      $sel:streamUI:Tool' :: Maybe Bool
streamUI = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Tool' :: Text
name = Text
pName_,
      $sel:command:Tool' :: Text
command = Text
pCommand_
    }

-- | Exit behavior determines what happens when your tool quits running.
-- @RESTART@ will cause your tool to be restarted. @FAIL@ will cause your
-- job to exit. The default is @RESTART@.
tool_exitBehavior :: Lens.Lens' Tool (Prelude.Maybe ExitBehavior)
tool_exitBehavior :: Lens' Tool (Maybe ExitBehavior)
tool_exitBehavior = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tool' {Maybe ExitBehavior
exitBehavior :: Maybe ExitBehavior
$sel:exitBehavior:Tool' :: Tool -> Maybe ExitBehavior
exitBehavior} -> Maybe ExitBehavior
exitBehavior) (\s :: Tool
s@Tool' {} Maybe ExitBehavior
a -> Tool
s {$sel:exitBehavior:Tool' :: Maybe ExitBehavior
exitBehavior = Maybe ExitBehavior
a} :: Tool)

-- | Boolean indicating whether logs will be recorded in CloudWatch for the
-- tool. The default is @False@.
tool_streamOutputToCloudWatch :: Lens.Lens' Tool (Prelude.Maybe Prelude.Bool)
tool_streamOutputToCloudWatch :: Lens' Tool (Maybe Bool)
tool_streamOutputToCloudWatch = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tool' {Maybe Bool
streamOutputToCloudWatch :: Maybe Bool
$sel:streamOutputToCloudWatch:Tool' :: Tool -> Maybe Bool
streamOutputToCloudWatch} -> Maybe Bool
streamOutputToCloudWatch) (\s :: Tool
s@Tool' {} Maybe Bool
a -> Tool
s {$sel:streamOutputToCloudWatch:Tool' :: Maybe Bool
streamOutputToCloudWatch = Maybe Bool
a} :: Tool)

-- | Boolean indicating whether a streaming session will be configured for
-- the tool. If @True@, AWS RoboMaker will configure a connection so you
-- can interact with the tool as it is running in the simulation. It must
-- have a graphical user interface. The default is @False@.
tool_streamUI :: Lens.Lens' Tool (Prelude.Maybe Prelude.Bool)
tool_streamUI :: Lens' Tool (Maybe Bool)
tool_streamUI = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tool' {Maybe Bool
streamUI :: Maybe Bool
$sel:streamUI:Tool' :: Tool -> Maybe Bool
streamUI} -> Maybe Bool
streamUI) (\s :: Tool
s@Tool' {} Maybe Bool
a -> Tool
s {$sel:streamUI:Tool' :: Maybe Bool
streamUI = Maybe Bool
a} :: Tool)

-- | The name of the tool.
tool_name :: Lens.Lens' Tool Prelude.Text
tool_name :: Lens' Tool Text
tool_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tool' {Text
name :: Text
$sel:name:Tool' :: Tool -> Text
name} -> Text
name) (\s :: Tool
s@Tool' {} Text
a -> Tool
s {$sel:name:Tool' :: Text
name = Text
a} :: Tool)

-- | Command-line arguments for the tool. It must include the tool executable
-- name.
tool_command :: Lens.Lens' Tool Prelude.Text
tool_command :: Lens' Tool Text
tool_command = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tool' {Text
command :: Text
$sel:command:Tool' :: Tool -> Text
command} -> Text
command) (\s :: Tool
s@Tool' {} Text
a -> Tool
s {$sel:command:Tool' :: Text
command = Text
a} :: Tool)

instance Data.FromJSON Tool where
  parseJSON :: Value -> Parser Tool
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Tool"
      ( \Object
x ->
          Maybe ExitBehavior
-> Maybe Bool -> Maybe Bool -> Text -> Text -> Tool
Tool'
            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
"exitBehavior")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"streamOutputToCloudWatch")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"streamUI")
            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
"name")
            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
"command")
      )

instance Prelude.Hashable Tool where
  hashWithSalt :: Int -> Tool -> Int
hashWithSalt Int
_salt Tool' {Maybe Bool
Maybe ExitBehavior
Text
command :: Text
name :: Text
streamUI :: Maybe Bool
streamOutputToCloudWatch :: Maybe Bool
exitBehavior :: Maybe ExitBehavior
$sel:command:Tool' :: Tool -> Text
$sel:name:Tool' :: Tool -> Text
$sel:streamUI:Tool' :: Tool -> Maybe Bool
$sel:streamOutputToCloudWatch:Tool' :: Tool -> Maybe Bool
$sel:exitBehavior:Tool' :: Tool -> Maybe ExitBehavior
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExitBehavior
exitBehavior
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
streamOutputToCloudWatch
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
streamUI
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
command

instance Prelude.NFData Tool where
  rnf :: Tool -> ()
rnf Tool' {Maybe Bool
Maybe ExitBehavior
Text
command :: Text
name :: Text
streamUI :: Maybe Bool
streamOutputToCloudWatch :: Maybe Bool
exitBehavior :: Maybe ExitBehavior
$sel:command:Tool' :: Tool -> Text
$sel:name:Tool' :: Tool -> Text
$sel:streamUI:Tool' :: Tool -> Maybe Bool
$sel:streamOutputToCloudWatch:Tool' :: Tool -> Maybe Bool
$sel:exitBehavior:Tool' :: Tool -> Maybe ExitBehavior
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ExitBehavior
exitBehavior
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
streamOutputToCloudWatch
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
streamUI
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
command

instance Data.ToJSON Tool where
  toJSON :: Tool -> Value
toJSON Tool' {Maybe Bool
Maybe ExitBehavior
Text
command :: Text
name :: Text
streamUI :: Maybe Bool
streamOutputToCloudWatch :: Maybe Bool
exitBehavior :: Maybe ExitBehavior
$sel:command:Tool' :: Tool -> Text
$sel:name:Tool' :: Tool -> Text
$sel:streamUI:Tool' :: Tool -> Maybe Bool
$sel:streamOutputToCloudWatch:Tool' :: Tool -> Maybe Bool
$sel:exitBehavior:Tool' :: Tool -> Maybe ExitBehavior
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"exitBehavior" 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 ExitBehavior
exitBehavior,
            (Key
"streamOutputToCloudWatch" 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 Bool
streamOutputToCloudWatch,
            (Key
"streamUI" 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 Bool
streamUI,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"command" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
command)
          ]
      )