{-# 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.GreengrassV2.Types.DeploymentIoTJobConfiguration
-- 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.GreengrassV2.Types.DeploymentIoTJobConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GreengrassV2.Types.IoTJobAbortConfig
import Amazonka.GreengrassV2.Types.IoTJobExecutionsRolloutConfig
import Amazonka.GreengrassV2.Types.IoTJobTimeoutConfig
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an IoT job configuration.
--
-- /See:/ 'newDeploymentIoTJobConfiguration' smart constructor.
data DeploymentIoTJobConfiguration = DeploymentIoTJobConfiguration'
  { -- | The stop configuration for the job. This configuration defines when and
    -- how to stop a job rollout.
    DeploymentIoTJobConfiguration -> Maybe IoTJobAbortConfig
abortConfig :: Prelude.Maybe IoTJobAbortConfig,
    -- | The rollout configuration for the job. This configuration defines the
    -- rate at which the job rolls out to the fleet of target devices.
    DeploymentIoTJobConfiguration
-> Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig :: Prelude.Maybe IoTJobExecutionsRolloutConfig,
    -- | The timeout configuration for the job. This configuration defines the
    -- amount of time each device has to complete the job.
    DeploymentIoTJobConfiguration -> Maybe IoTJobTimeoutConfig
timeoutConfig :: Prelude.Maybe IoTJobTimeoutConfig
  }
  deriving (DeploymentIoTJobConfiguration
-> DeploymentIoTJobConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentIoTJobConfiguration
-> DeploymentIoTJobConfiguration -> Bool
$c/= :: DeploymentIoTJobConfiguration
-> DeploymentIoTJobConfiguration -> Bool
== :: DeploymentIoTJobConfiguration
-> DeploymentIoTJobConfiguration -> Bool
$c== :: DeploymentIoTJobConfiguration
-> DeploymentIoTJobConfiguration -> Bool
Prelude.Eq, ReadPrec [DeploymentIoTJobConfiguration]
ReadPrec DeploymentIoTJobConfiguration
Int -> ReadS DeploymentIoTJobConfiguration
ReadS [DeploymentIoTJobConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentIoTJobConfiguration]
$creadListPrec :: ReadPrec [DeploymentIoTJobConfiguration]
readPrec :: ReadPrec DeploymentIoTJobConfiguration
$creadPrec :: ReadPrec DeploymentIoTJobConfiguration
readList :: ReadS [DeploymentIoTJobConfiguration]
$creadList :: ReadS [DeploymentIoTJobConfiguration]
readsPrec :: Int -> ReadS DeploymentIoTJobConfiguration
$creadsPrec :: Int -> ReadS DeploymentIoTJobConfiguration
Prelude.Read, Int -> DeploymentIoTJobConfiguration -> ShowS
[DeploymentIoTJobConfiguration] -> ShowS
DeploymentIoTJobConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentIoTJobConfiguration] -> ShowS
$cshowList :: [DeploymentIoTJobConfiguration] -> ShowS
show :: DeploymentIoTJobConfiguration -> String
$cshow :: DeploymentIoTJobConfiguration -> String
showsPrec :: Int -> DeploymentIoTJobConfiguration -> ShowS
$cshowsPrec :: Int -> DeploymentIoTJobConfiguration -> ShowS
Prelude.Show, forall x.
Rep DeploymentIoTJobConfiguration x
-> DeploymentIoTJobConfiguration
forall x.
DeploymentIoTJobConfiguration
-> Rep DeploymentIoTJobConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeploymentIoTJobConfiguration x
-> DeploymentIoTJobConfiguration
$cfrom :: forall x.
DeploymentIoTJobConfiguration
-> Rep DeploymentIoTJobConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentIoTJobConfiguration' 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:
--
-- 'abortConfig', 'deploymentIoTJobConfiguration_abortConfig' - The stop configuration for the job. This configuration defines when and
-- how to stop a job rollout.
--
-- 'jobExecutionsRolloutConfig', 'deploymentIoTJobConfiguration_jobExecutionsRolloutConfig' - The rollout configuration for the job. This configuration defines the
-- rate at which the job rolls out to the fleet of target devices.
--
-- 'timeoutConfig', 'deploymentIoTJobConfiguration_timeoutConfig' - The timeout configuration for the job. This configuration defines the
-- amount of time each device has to complete the job.
newDeploymentIoTJobConfiguration ::
  DeploymentIoTJobConfiguration
newDeploymentIoTJobConfiguration :: DeploymentIoTJobConfiguration
newDeploymentIoTJobConfiguration =
  DeploymentIoTJobConfiguration'
    { $sel:abortConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobAbortConfig
abortConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:jobExecutionsRolloutConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobTimeoutConfig
timeoutConfig = forall a. Maybe a
Prelude.Nothing
    }

-- | The stop configuration for the job. This configuration defines when and
-- how to stop a job rollout.
deploymentIoTJobConfiguration_abortConfig :: Lens.Lens' DeploymentIoTJobConfiguration (Prelude.Maybe IoTJobAbortConfig)
deploymentIoTJobConfiguration_abortConfig :: Lens' DeploymentIoTJobConfiguration (Maybe IoTJobAbortConfig)
deploymentIoTJobConfiguration_abortConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentIoTJobConfiguration' {Maybe IoTJobAbortConfig
abortConfig :: Maybe IoTJobAbortConfig
$sel:abortConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobAbortConfig
abortConfig} -> Maybe IoTJobAbortConfig
abortConfig) (\s :: DeploymentIoTJobConfiguration
s@DeploymentIoTJobConfiguration' {} Maybe IoTJobAbortConfig
a -> DeploymentIoTJobConfiguration
s {$sel:abortConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobAbortConfig
abortConfig = Maybe IoTJobAbortConfig
a} :: DeploymentIoTJobConfiguration)

-- | The rollout configuration for the job. This configuration defines the
-- rate at which the job rolls out to the fleet of target devices.
deploymentIoTJobConfiguration_jobExecutionsRolloutConfig :: Lens.Lens' DeploymentIoTJobConfiguration (Prelude.Maybe IoTJobExecutionsRolloutConfig)
deploymentIoTJobConfiguration_jobExecutionsRolloutConfig :: Lens'
  DeploymentIoTJobConfiguration (Maybe IoTJobExecutionsRolloutConfig)
deploymentIoTJobConfiguration_jobExecutionsRolloutConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentIoTJobConfiguration' {Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig :: Maybe IoTJobExecutionsRolloutConfig
$sel:jobExecutionsRolloutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration
-> Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig} -> Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig) (\s :: DeploymentIoTJobConfiguration
s@DeploymentIoTJobConfiguration' {} Maybe IoTJobExecutionsRolloutConfig
a -> DeploymentIoTJobConfiguration
s {$sel:jobExecutionsRolloutConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig = Maybe IoTJobExecutionsRolloutConfig
a} :: DeploymentIoTJobConfiguration)

-- | The timeout configuration for the job. This configuration defines the
-- amount of time each device has to complete the job.
deploymentIoTJobConfiguration_timeoutConfig :: Lens.Lens' DeploymentIoTJobConfiguration (Prelude.Maybe IoTJobTimeoutConfig)
deploymentIoTJobConfiguration_timeoutConfig :: Lens' DeploymentIoTJobConfiguration (Maybe IoTJobTimeoutConfig)
deploymentIoTJobConfiguration_timeoutConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentIoTJobConfiguration' {Maybe IoTJobTimeoutConfig
timeoutConfig :: Maybe IoTJobTimeoutConfig
$sel:timeoutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobTimeoutConfig
timeoutConfig} -> Maybe IoTJobTimeoutConfig
timeoutConfig) (\s :: DeploymentIoTJobConfiguration
s@DeploymentIoTJobConfiguration' {} Maybe IoTJobTimeoutConfig
a -> DeploymentIoTJobConfiguration
s {$sel:timeoutConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobTimeoutConfig
timeoutConfig = Maybe IoTJobTimeoutConfig
a} :: DeploymentIoTJobConfiguration)

instance Data.FromJSON DeploymentIoTJobConfiguration where
  parseJSON :: Value -> Parser DeploymentIoTJobConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DeploymentIoTJobConfiguration"
      ( \Object
x ->
          Maybe IoTJobAbortConfig
-> Maybe IoTJobExecutionsRolloutConfig
-> Maybe IoTJobTimeoutConfig
-> DeploymentIoTJobConfiguration
DeploymentIoTJobConfiguration'
            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
"abortConfig")
            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
"jobExecutionsRolloutConfig")
            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
"timeoutConfig")
      )

instance
  Prelude.Hashable
    DeploymentIoTJobConfiguration
  where
  hashWithSalt :: Int -> DeploymentIoTJobConfiguration -> Int
hashWithSalt Int
_salt DeploymentIoTJobConfiguration' {Maybe IoTJobAbortConfig
Maybe IoTJobExecutionsRolloutConfig
Maybe IoTJobTimeoutConfig
timeoutConfig :: Maybe IoTJobTimeoutConfig
jobExecutionsRolloutConfig :: Maybe IoTJobExecutionsRolloutConfig
abortConfig :: Maybe IoTJobAbortConfig
$sel:timeoutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobTimeoutConfig
$sel:jobExecutionsRolloutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration
-> Maybe IoTJobExecutionsRolloutConfig
$sel:abortConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobAbortConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IoTJobAbortConfig
abortConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IoTJobTimeoutConfig
timeoutConfig

instance Prelude.NFData DeploymentIoTJobConfiguration where
  rnf :: DeploymentIoTJobConfiguration -> ()
rnf DeploymentIoTJobConfiguration' {Maybe IoTJobAbortConfig
Maybe IoTJobExecutionsRolloutConfig
Maybe IoTJobTimeoutConfig
timeoutConfig :: Maybe IoTJobTimeoutConfig
jobExecutionsRolloutConfig :: Maybe IoTJobExecutionsRolloutConfig
abortConfig :: Maybe IoTJobAbortConfig
$sel:timeoutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobTimeoutConfig
$sel:jobExecutionsRolloutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration
-> Maybe IoTJobExecutionsRolloutConfig
$sel:abortConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobAbortConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe IoTJobAbortConfig
abortConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IoTJobTimeoutConfig
timeoutConfig

instance Data.ToJSON DeploymentIoTJobConfiguration where
  toJSON :: DeploymentIoTJobConfiguration -> Value
toJSON DeploymentIoTJobConfiguration' {Maybe IoTJobAbortConfig
Maybe IoTJobExecutionsRolloutConfig
Maybe IoTJobTimeoutConfig
timeoutConfig :: Maybe IoTJobTimeoutConfig
jobExecutionsRolloutConfig :: Maybe IoTJobExecutionsRolloutConfig
abortConfig :: Maybe IoTJobAbortConfig
$sel:timeoutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobTimeoutConfig
$sel:jobExecutionsRolloutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration
-> Maybe IoTJobExecutionsRolloutConfig
$sel:abortConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobAbortConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"abortConfig" 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 IoTJobAbortConfig
abortConfig,
            (Key
"jobExecutionsRolloutConfig" 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 IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig,
            (Key
"timeoutConfig" 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 IoTJobTimeoutConfig
timeoutConfig
          ]
      )