{-# 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.OpsWorks.Types.Command
-- 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.OpsWorks.Types.Command where

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

-- | Describes a command.
--
-- /See:/ 'newCommand' smart constructor.
data Command = Command'
  { -- | The command deployment ID.
    Command -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the instance where the command was executed.
    Command -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The command status:
    --
    -- -   failed
    --
    -- -   successful
    --
    -- -   skipped
    --
    -- -   pending
    Command -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The URL of the command log.
    Command -> Maybe Text
logUrl :: Prelude.Maybe Prelude.Text,
    -- | Date and time when the command was run.
    Command -> Maybe Text
createdAt :: Prelude.Maybe Prelude.Text,
    -- | The command ID.
    Command -> Maybe Text
commandId :: Prelude.Maybe Prelude.Text,
    -- | The command exit code.
    Command -> Maybe Int
exitCode :: Prelude.Maybe Prelude.Int,
    -- | The command type:
    --
    -- -   @configure@
    --
    -- -   @deploy@
    --
    -- -   @execute_recipes@
    --
    -- -   @install_dependencies@
    --
    -- -   @restart@
    --
    -- -   @rollback@
    --
    -- -   @setup@
    --
    -- -   @start@
    --
    -- -   @stop@
    --
    -- -   @undeploy@
    --
    -- -   @update_custom_cookbooks@
    --
    -- -   @update_dependencies@
    Command -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | Date when the command completed.
    Command -> Maybe Text
completedAt :: Prelude.Maybe Prelude.Text,
    -- | Date and time when the command was acknowledged.
    Command -> Maybe Text
acknowledgedAt :: Prelude.Maybe Prelude.Text
  }
  deriving (Command -> Command -> Bool
(Command -> Command -> Bool)
-> (Command -> Command -> Bool) -> Eq Command
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Command -> Command -> Bool
$c/= :: Command -> Command -> Bool
== :: Command -> Command -> Bool
$c== :: Command -> Command -> Bool
Prelude.Eq, ReadPrec [Command]
ReadPrec Command
Int -> ReadS Command
ReadS [Command]
(Int -> ReadS Command)
-> ReadS [Command]
-> ReadPrec Command
-> ReadPrec [Command]
-> Read Command
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Command]
$creadListPrec :: ReadPrec [Command]
readPrec :: ReadPrec Command
$creadPrec :: ReadPrec Command
readList :: ReadS [Command]
$creadList :: ReadS [Command]
readsPrec :: Int -> ReadS Command
$creadsPrec :: Int -> ReadS Command
Prelude.Read, Int -> Command -> ShowS
[Command] -> ShowS
Command -> String
(Int -> Command -> ShowS)
-> (Command -> String) -> ([Command] -> ShowS) -> Show Command
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Command] -> ShowS
$cshowList :: [Command] -> ShowS
show :: Command -> String
$cshow :: Command -> String
showsPrec :: Int -> Command -> ShowS
$cshowsPrec :: Int -> Command -> ShowS
Prelude.Show, (forall x. Command -> Rep Command x)
-> (forall x. Rep Command x -> Command) -> Generic Command
forall x. Rep Command x -> Command
forall x. Command -> Rep Command x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Command x -> Command
$cfrom :: forall x. Command -> Rep Command x
Prelude.Generic)

-- |
-- Create a value of 'Command' 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:
--
-- 'deploymentId', 'command_deploymentId' - The command deployment ID.
--
-- 'instanceId', 'command_instanceId' - The ID of the instance where the command was executed.
--
-- 'status', 'command_status' - The command status:
--
-- -   failed
--
-- -   successful
--
-- -   skipped
--
-- -   pending
--
-- 'logUrl', 'command_logUrl' - The URL of the command log.
--
-- 'createdAt', 'command_createdAt' - Date and time when the command was run.
--
-- 'commandId', 'command_commandId' - The command ID.
--
-- 'exitCode', 'command_exitCode' - The command exit code.
--
-- 'type'', 'command_type' - The command type:
--
-- -   @configure@
--
-- -   @deploy@
--
-- -   @execute_recipes@
--
-- -   @install_dependencies@
--
-- -   @restart@
--
-- -   @rollback@
--
-- -   @setup@
--
-- -   @start@
--
-- -   @stop@
--
-- -   @undeploy@
--
-- -   @update_custom_cookbooks@
--
-- -   @update_dependencies@
--
-- 'completedAt', 'command_completedAt' - Date when the command completed.
--
-- 'acknowledgedAt', 'command_acknowledgedAt' - Date and time when the command was acknowledged.
newCommand ::
  Command
newCommand :: Command
newCommand =
  Command' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Command
Command'
    { $sel:deploymentId:Command' :: Maybe Text
deploymentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:Command' :: Maybe Text
instanceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:Command' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logUrl:Command' :: Maybe Text
logUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:Command' :: Maybe Text
createdAt = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:commandId:Command' :: Maybe Text
commandId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:exitCode:Command' :: Maybe Int
exitCode = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Command' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:completedAt:Command' :: Maybe Text
completedAt = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:acknowledgedAt:Command' :: Maybe Text
acknowledgedAt = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The command deployment ID.
command_deploymentId :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_deploymentId :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_deploymentId = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
deploymentId :: Maybe Text
$sel:deploymentId:Command' :: Command -> Maybe Text
deploymentId} -> Maybe Text
deploymentId) (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:deploymentId:Command' :: Maybe Text
deploymentId = Maybe Text
a} :: Command)

-- | The ID of the instance where the command was executed.
command_instanceId :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_instanceId :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_instanceId = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:Command' :: Command -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:instanceId:Command' :: Maybe Text
instanceId = Maybe Text
a} :: Command)

-- | The command status:
--
-- -   failed
--
-- -   successful
--
-- -   skipped
--
-- -   pending
command_status :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_status :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_status = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
status :: Maybe Text
$sel:status:Command' :: Command -> Maybe Text
status} -> Maybe Text
status) (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:status:Command' :: Maybe Text
status = Maybe Text
a} :: Command)

-- | The URL of the command log.
command_logUrl :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_logUrl :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_logUrl = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
logUrl :: Maybe Text
$sel:logUrl:Command' :: Command -> Maybe Text
logUrl} -> Maybe Text
logUrl) (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:logUrl:Command' :: Maybe Text
logUrl = Maybe Text
a} :: Command)

-- | Date and time when the command was run.
command_createdAt :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_createdAt :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_createdAt = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
createdAt :: Maybe Text
$sel:createdAt:Command' :: Command -> Maybe Text
createdAt} -> Maybe Text
createdAt) (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:createdAt:Command' :: Maybe Text
createdAt = Maybe Text
a} :: Command)

-- | The command ID.
command_commandId :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_commandId :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_commandId = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
commandId :: Maybe Text
$sel:commandId:Command' :: Command -> Maybe Text
commandId} -> Maybe Text
commandId) (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:commandId:Command' :: Maybe Text
commandId = Maybe Text
a} :: Command)

-- | The command exit code.
command_exitCode :: Lens.Lens' Command (Prelude.Maybe Prelude.Int)
command_exitCode :: (Maybe Int -> f (Maybe Int)) -> Command -> f Command
command_exitCode = (Command -> Maybe Int)
-> (Command -> Maybe Int -> Command)
-> Lens Command Command (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Int
exitCode :: Maybe Int
$sel:exitCode:Command' :: Command -> Maybe Int
exitCode} -> Maybe Int
exitCode) (\s :: Command
s@Command' {} Maybe Int
a -> Command
s {$sel:exitCode:Command' :: Maybe Int
exitCode = Maybe Int
a} :: Command)

-- | The command type:
--
-- -   @configure@
--
-- -   @deploy@
--
-- -   @execute_recipes@
--
-- -   @install_dependencies@
--
-- -   @restart@
--
-- -   @rollback@
--
-- -   @setup@
--
-- -   @start@
--
-- -   @stop@
--
-- -   @undeploy@
--
-- -   @update_custom_cookbooks@
--
-- -   @update_dependencies@
command_type :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_type :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_type = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
type' :: Maybe Text
$sel:type':Command' :: Command -> Maybe Text
type'} -> Maybe Text
type') (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:type':Command' :: Maybe Text
type' = Maybe Text
a} :: Command)

-- | Date when the command completed.
command_completedAt :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_completedAt :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_completedAt = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
completedAt :: Maybe Text
$sel:completedAt:Command' :: Command -> Maybe Text
completedAt} -> Maybe Text
completedAt) (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:completedAt:Command' :: Maybe Text
completedAt = Maybe Text
a} :: Command)

-- | Date and time when the command was acknowledged.
command_acknowledgedAt :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_acknowledgedAt :: (Maybe Text -> f (Maybe Text)) -> Command -> f Command
command_acknowledgedAt = (Command -> Maybe Text)
-> (Command -> Maybe Text -> Command)
-> Lens Command Command (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Command' {Maybe Text
acknowledgedAt :: Maybe Text
$sel:acknowledgedAt:Command' :: Command -> Maybe Text
acknowledgedAt} -> Maybe Text
acknowledgedAt) (\s :: Command
s@Command' {} Maybe Text
a -> Command
s {$sel:acknowledgedAt:Command' :: Maybe Text
acknowledgedAt = Maybe Text
a} :: Command)

instance Core.FromJSON Command where
  parseJSON :: Value -> Parser Command
parseJSON =
    String -> (Object -> Parser Command) -> Value -> Parser Command
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Command"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Command
Command'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Int
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Command)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Command)
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
"DeploymentId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Command)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Command)
forall (f :: * -> *) a b. Applicative f => 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
"InstanceId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Command)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Command)
forall (f :: * -> *) a b. Applicative f => 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
"Status")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Command)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Command)
forall (f :: * -> *) a b. Applicative f => 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
"LogUrl")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Command)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Int -> Maybe Text -> Maybe Text -> Maybe Text -> Command)
forall (f :: * -> *) a b. Applicative f => 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
"CreatedAt")
            Parser
  (Maybe Text
   -> Maybe Int -> Maybe Text -> Maybe Text -> Maybe Text -> Command)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int -> Maybe Text -> Maybe Text -> Maybe Text -> Command)
forall (f :: * -> *) a b. Applicative f => 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
"CommandId")
            Parser
  (Maybe Int -> Maybe Text -> Maybe Text -> Maybe Text -> Command)
-> Parser (Maybe Int)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExitCode")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Command)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Command)
forall (f :: * -> *) a b. Applicative f => 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
"Type")
            Parser (Maybe Text -> Maybe Text -> Command)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Command)
forall (f :: * -> *) a b. Applicative f => 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
"CompletedAt")
            Parser (Maybe Text -> Command)
-> Parser (Maybe Text) -> Parser Command
forall (f :: * -> *) a b. Applicative f => 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
"AcknowledgedAt")
      )

instance Prelude.Hashable Command

instance Prelude.NFData Command