{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.OpsWorks.Types.Command 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

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

-- | Date and time when the command was acknowledged.
command_acknowledgedAt :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_acknowledgedAt :: Lens' Command (Maybe Text)
command_acknowledgedAt = 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)

-- | The command ID.
command_commandId :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_commandId :: Lens' Command (Maybe Text)
command_commandId = 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)

-- | Date when the command completed.
command_completedAt :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_completedAt :: Lens' Command (Maybe Text)
command_completedAt = 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 run.
command_createdAt :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_createdAt :: Lens' Command (Maybe Text)
command_createdAt = 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 deployment ID.
command_deploymentId :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_deploymentId :: Lens' Command (Maybe Text)
command_deploymentId = 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 command exit code.
command_exitCode :: Lens.Lens' Command (Prelude.Maybe Prelude.Int)
command_exitCode :: Lens' Command (Maybe Int)
command_exitCode = 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 ID of the instance where the command was executed.
command_instanceId :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_instanceId :: Lens' Command (Maybe Text)
command_instanceId = 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 URL of the command log.
command_logUrl :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_logUrl :: Lens' Command (Maybe Text)
command_logUrl = 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)

-- | The command status:
--
-- -   failed
--
-- -   successful
--
-- -   skipped
--
-- -   pending
command_status :: Lens.Lens' Command (Prelude.Maybe Prelude.Text)
command_status :: Lens' Command (Maybe Text)
command_status = 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 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 :: Lens' Command (Maybe Text)
command_type = 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)

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

instance Prelude.Hashable Command where
  hashWithSalt :: Int -> Command -> Int
hashWithSalt Int
_salt Command' {Maybe Int
Maybe Text
type' :: Maybe Text
status :: Maybe Text
logUrl :: Maybe Text
instanceId :: Maybe Text
exitCode :: Maybe Int
deploymentId :: Maybe Text
createdAt :: Maybe Text
completedAt :: Maybe Text
commandId :: Maybe Text
acknowledgedAt :: Maybe Text
$sel:type':Command' :: Command -> Maybe Text
$sel:status:Command' :: Command -> Maybe Text
$sel:logUrl:Command' :: Command -> Maybe Text
$sel:instanceId:Command' :: Command -> Maybe Text
$sel:exitCode:Command' :: Command -> Maybe Int
$sel:deploymentId:Command' :: Command -> Maybe Text
$sel:createdAt:Command' :: Command -> Maybe Text
$sel:completedAt:Command' :: Command -> Maybe Text
$sel:commandId:Command' :: Command -> Maybe Text
$sel:acknowledgedAt:Command' :: Command -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
acknowledgedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
commandId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
completedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deploymentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
exitCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData Command where
  rnf :: Command -> ()
rnf Command' {Maybe Int
Maybe Text
type' :: Maybe Text
status :: Maybe Text
logUrl :: Maybe Text
instanceId :: Maybe Text
exitCode :: Maybe Int
deploymentId :: Maybe Text
createdAt :: Maybe Text
completedAt :: Maybe Text
commandId :: Maybe Text
acknowledgedAt :: Maybe Text
$sel:type':Command' :: Command -> Maybe Text
$sel:status:Command' :: Command -> Maybe Text
$sel:logUrl:Command' :: Command -> Maybe Text
$sel:instanceId:Command' :: Command -> Maybe Text
$sel:exitCode:Command' :: Command -> Maybe Int
$sel:deploymentId:Command' :: Command -> Maybe Text
$sel:createdAt:Command' :: Command -> Maybe Text
$sel:completedAt:Command' :: Command -> Maybe Text
$sel:commandId:Command' :: Command -> Maybe Text
$sel:acknowledgedAt:Command' :: Command -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
acknowledgedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
commandId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
completedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deploymentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
exitCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'