{-# 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-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.RobOMaker.Types.Tool where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | Boolean indicating whether logs will be recorded in CloudWatch for the
    -- tool. The default is @False@.
    Tool -> Maybe Bool
streamOutputToCloudWatch :: Prelude.Maybe Prelude.Bool,
    -- | 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 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
(Tool -> Tool -> Bool) -> (Tool -> Tool -> Bool) -> Eq Tool
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]
(Int -> ReadS Tool)
-> ReadS [Tool] -> ReadPrec Tool -> ReadPrec [Tool] -> Read 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
(Int -> Tool -> ShowS)
-> (Tool -> String) -> ([Tool] -> ShowS) -> Show Tool
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. Tool -> Rep Tool x)
-> (forall x. Rep Tool x -> Tool) -> Generic Tool
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:
--
-- 'streamOutputToCloudWatch', 'tool_streamOutputToCloudWatch' - Boolean indicating whether logs will be recorded in CloudWatch for the
-- tool. The default is @False@.
--
-- '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@.
--
-- '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' :: Maybe Bool
-> Maybe ExitBehavior -> Maybe Bool -> Text -> Text -> Tool
Tool'
    { $sel:streamOutputToCloudWatch:Tool' :: Maybe Bool
streamOutputToCloudWatch = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:exitBehavior:Tool' :: Maybe ExitBehavior
exitBehavior = Maybe ExitBehavior
forall a. Maybe a
Prelude.Nothing,
      $sel:streamUI:Tool' :: Maybe Bool
streamUI = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Tool' :: Text
name = Text
pName_,
      $sel:command:Tool' :: Text
command = Text
pCommand_
    }

-- | 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 :: (Maybe Bool -> f (Maybe Bool)) -> Tool -> f Tool
tool_streamOutputToCloudWatch = (Tool -> Maybe Bool)
-> (Tool -> Maybe Bool -> Tool)
-> Lens Tool Tool (Maybe Bool) (Maybe Bool)
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)

-- | 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 :: (Maybe ExitBehavior -> f (Maybe ExitBehavior)) -> Tool -> f Tool
tool_exitBehavior = (Tool -> Maybe ExitBehavior)
-> (Tool -> Maybe ExitBehavior -> Tool)
-> Lens Tool Tool (Maybe ExitBehavior) (Maybe 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 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 :: (Maybe Bool -> f (Maybe Bool)) -> Tool -> f Tool
tool_streamUI = (Tool -> Maybe Bool)
-> (Tool -> Maybe Bool -> Tool)
-> Lens Tool Tool (Maybe Bool) (Maybe Bool)
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 :: (Text -> f Text) -> Tool -> f Tool
tool_name = (Tool -> Text)
-> (Tool -> Text -> Tool) -> Lens Tool Tool Text Text
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 :: (Text -> f Text) -> Tool -> f Tool
tool_command = (Tool -> Text)
-> (Tool -> Text -> Tool) -> Lens Tool Tool Text Text
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 Core.FromJSON Tool where
  parseJSON :: Value -> Parser Tool
parseJSON =
    String -> (Object -> Parser Tool) -> Value -> Parser Tool
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Tool"
      ( \Object
x ->
          Maybe Bool
-> Maybe ExitBehavior -> Maybe Bool -> Text -> Text -> Tool
Tool'
            (Maybe Bool
 -> Maybe ExitBehavior -> Maybe Bool -> Text -> Text -> Tool)
-> Parser (Maybe Bool)
-> Parser
     (Maybe ExitBehavior -> Maybe Bool -> Text -> Text -> Tool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"streamOutputToCloudWatch")
            Parser (Maybe ExitBehavior -> Maybe Bool -> Text -> Text -> Tool)
-> Parser (Maybe ExitBehavior)
-> Parser (Maybe Bool -> Text -> Text -> Tool)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExitBehavior)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"exitBehavior")
            Parser (Maybe Bool -> Text -> Text -> Tool)
-> Parser (Maybe Bool) -> Parser (Text -> Text -> Tool)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"streamUI")
            Parser (Text -> Text -> Tool)
-> Parser Text -> Parser (Text -> Tool)
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
"name")
            Parser (Text -> Tool) -> Parser Text -> Parser Tool
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
"command")
      )

instance Prelude.Hashable Tool

instance Prelude.NFData Tool

instance Core.ToJSON Tool where
  toJSON :: Tool -> Value
toJSON Tool' {Maybe Bool
Maybe ExitBehavior
Text
command :: Text
name :: Text
streamUI :: Maybe Bool
exitBehavior :: Maybe ExitBehavior
streamOutputToCloudWatch :: Maybe Bool
$sel:command:Tool' :: Tool -> Text
$sel:name:Tool' :: Tool -> Text
$sel:streamUI:Tool' :: Tool -> Maybe Bool
$sel:exitBehavior:Tool' :: Tool -> Maybe ExitBehavior
$sel:streamOutputToCloudWatch:Tool' :: Tool -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"streamOutputToCloudWatch" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
streamOutputToCloudWatch,
            (Text
"exitBehavior" Text -> ExitBehavior -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ExitBehavior -> Pair) -> Maybe ExitBehavior -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ExitBehavior
exitBehavior,
            (Text
"streamUI" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
streamUI,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"command" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
command)
          ]
      )