{-# 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.MigrationHubOrchestrator.Types.PlatformCommand
-- 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.MigrationHubOrchestrator.Types.PlatformCommand 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

-- | Command to be run on a particular operating system.
--
-- /See:/ 'newPlatformCommand' smart constructor.
data PlatformCommand = PlatformCommand'
  { -- | Command for Linux.
    PlatformCommand -> Maybe Text
linux :: Prelude.Maybe Prelude.Text,
    -- | Command for Windows.
    PlatformCommand -> Maybe Text
windows :: Prelude.Maybe Prelude.Text
  }
  deriving (PlatformCommand -> PlatformCommand -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlatformCommand -> PlatformCommand -> Bool
$c/= :: PlatformCommand -> PlatformCommand -> Bool
== :: PlatformCommand -> PlatformCommand -> Bool
$c== :: PlatformCommand -> PlatformCommand -> Bool
Prelude.Eq, ReadPrec [PlatformCommand]
ReadPrec PlatformCommand
Int -> ReadS PlatformCommand
ReadS [PlatformCommand]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PlatformCommand]
$creadListPrec :: ReadPrec [PlatformCommand]
readPrec :: ReadPrec PlatformCommand
$creadPrec :: ReadPrec PlatformCommand
readList :: ReadS [PlatformCommand]
$creadList :: ReadS [PlatformCommand]
readsPrec :: Int -> ReadS PlatformCommand
$creadsPrec :: Int -> ReadS PlatformCommand
Prelude.Read, Int -> PlatformCommand -> ShowS
[PlatformCommand] -> ShowS
PlatformCommand -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlatformCommand] -> ShowS
$cshowList :: [PlatformCommand] -> ShowS
show :: PlatformCommand -> String
$cshow :: PlatformCommand -> String
showsPrec :: Int -> PlatformCommand -> ShowS
$cshowsPrec :: Int -> PlatformCommand -> ShowS
Prelude.Show, forall x. Rep PlatformCommand x -> PlatformCommand
forall x. PlatformCommand -> Rep PlatformCommand x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlatformCommand x -> PlatformCommand
$cfrom :: forall x. PlatformCommand -> Rep PlatformCommand x
Prelude.Generic)

-- |
-- Create a value of 'PlatformCommand' 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:
--
-- 'linux', 'platformCommand_linux' - Command for Linux.
--
-- 'windows', 'platformCommand_windows' - Command for Windows.
newPlatformCommand ::
  PlatformCommand
newPlatformCommand :: PlatformCommand
newPlatformCommand =
  PlatformCommand'
    { $sel:linux:PlatformCommand' :: Maybe Text
linux = forall a. Maybe a
Prelude.Nothing,
      $sel:windows:PlatformCommand' :: Maybe Text
windows = forall a. Maybe a
Prelude.Nothing
    }

-- | Command for Linux.
platformCommand_linux :: Lens.Lens' PlatformCommand (Prelude.Maybe Prelude.Text)
platformCommand_linux :: Lens' PlatformCommand (Maybe Text)
platformCommand_linux = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlatformCommand' {Maybe Text
linux :: Maybe Text
$sel:linux:PlatformCommand' :: PlatformCommand -> Maybe Text
linux} -> Maybe Text
linux) (\s :: PlatformCommand
s@PlatformCommand' {} Maybe Text
a -> PlatformCommand
s {$sel:linux:PlatformCommand' :: Maybe Text
linux = Maybe Text
a} :: PlatformCommand)

-- | Command for Windows.
platformCommand_windows :: Lens.Lens' PlatformCommand (Prelude.Maybe Prelude.Text)
platformCommand_windows :: Lens' PlatformCommand (Maybe Text)
platformCommand_windows = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlatformCommand' {Maybe Text
windows :: Maybe Text
$sel:windows:PlatformCommand' :: PlatformCommand -> Maybe Text
windows} -> Maybe Text
windows) (\s :: PlatformCommand
s@PlatformCommand' {} Maybe Text
a -> PlatformCommand
s {$sel:windows:PlatformCommand' :: Maybe Text
windows = Maybe Text
a} :: PlatformCommand)

instance Data.FromJSON PlatformCommand where
  parseJSON :: Value -> Parser PlatformCommand
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PlatformCommand"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> PlatformCommand
PlatformCommand'
            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
"linux")
            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
"windows")
      )

instance Prelude.Hashable PlatformCommand where
  hashWithSalt :: Int -> PlatformCommand -> Int
hashWithSalt Int
_salt PlatformCommand' {Maybe Text
windows :: Maybe Text
linux :: Maybe Text
$sel:windows:PlatformCommand' :: PlatformCommand -> Maybe Text
$sel:linux:PlatformCommand' :: PlatformCommand -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
linux
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
windows

instance Prelude.NFData PlatformCommand where
  rnf :: PlatformCommand -> ()
rnf PlatformCommand' {Maybe Text
windows :: Maybe Text
linux :: Maybe Text
$sel:windows:PlatformCommand' :: PlatformCommand -> Maybe Text
$sel:linux:PlatformCommand' :: PlatformCommand -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
linux seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
windows

instance Data.ToJSON PlatformCommand where
  toJSON :: PlatformCommand -> Value
toJSON PlatformCommand' {Maybe Text
windows :: Maybe Text
linux :: Maybe Text
$sel:windows:PlatformCommand' :: PlatformCommand -> Maybe Text
$sel:linux:PlatformCommand' :: PlatformCommand -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"linux" 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 Text
linux,
            (Key
"windows" 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 Text
windows
          ]
      )