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

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

-- | Contains information about an IoT job configuration.
--
-- /See:/ 'newDeploymentIoTJobConfiguration' smart constructor.
data DeploymentIoTJobConfiguration = 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
-> Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig :: Prelude.Maybe IoTJobExecutionsRolloutConfig,
    -- | 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 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
(DeploymentIoTJobConfiguration
 -> DeploymentIoTJobConfiguration -> Bool)
-> (DeploymentIoTJobConfiguration
    -> DeploymentIoTJobConfiguration -> Bool)
-> Eq DeploymentIoTJobConfiguration
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]
(Int -> ReadS DeploymentIoTJobConfiguration)
-> ReadS [DeploymentIoTJobConfiguration]
-> ReadPrec DeploymentIoTJobConfiguration
-> ReadPrec [DeploymentIoTJobConfiguration]
-> Read 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
(Int -> DeploymentIoTJobConfiguration -> ShowS)
-> (DeploymentIoTJobConfiguration -> String)
-> ([DeploymentIoTJobConfiguration] -> ShowS)
-> Show DeploymentIoTJobConfiguration
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.
 DeploymentIoTJobConfiguration
 -> Rep DeploymentIoTJobConfiguration x)
-> (forall x.
    Rep DeploymentIoTJobConfiguration x
    -> DeploymentIoTJobConfiguration)
-> Generic DeploymentIoTJobConfiguration
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:
--
-- '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.
--
-- 'abortConfig', 'deploymentIoTJobConfiguration_abortConfig' - The stop configuration for the job. This configuration defines when and
-- how to stop a job rollout.
--
-- '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' :: Maybe IoTJobExecutionsRolloutConfig
-> Maybe IoTJobAbortConfig
-> Maybe IoTJobTimeoutConfig
-> DeploymentIoTJobConfiguration
DeploymentIoTJobConfiguration'
    { $sel:jobExecutionsRolloutConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig =
        Maybe IoTJobExecutionsRolloutConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:abortConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobAbortConfig
abortConfig = Maybe IoTJobAbortConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutConfig:DeploymentIoTJobConfiguration' :: Maybe IoTJobTimeoutConfig
timeoutConfig = Maybe IoTJobTimeoutConfig
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe IoTJobExecutionsRolloutConfig
 -> f (Maybe IoTJobExecutionsRolloutConfig))
-> DeploymentIoTJobConfiguration -> f DeploymentIoTJobConfiguration
deploymentIoTJobConfiguration_jobExecutionsRolloutConfig = (DeploymentIoTJobConfiguration
 -> Maybe IoTJobExecutionsRolloutConfig)
-> (DeploymentIoTJobConfiguration
    -> Maybe IoTJobExecutionsRolloutConfig
    -> DeploymentIoTJobConfiguration)
-> Lens
     DeploymentIoTJobConfiguration
     DeploymentIoTJobConfiguration
     (Maybe IoTJobExecutionsRolloutConfig)
     (Maybe IoTJobExecutionsRolloutConfig)
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 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 :: (Maybe IoTJobAbortConfig -> f (Maybe IoTJobAbortConfig))
-> DeploymentIoTJobConfiguration -> f DeploymentIoTJobConfiguration
deploymentIoTJobConfiguration_abortConfig = (DeploymentIoTJobConfiguration -> Maybe IoTJobAbortConfig)
-> (DeploymentIoTJobConfiguration
    -> Maybe IoTJobAbortConfig -> DeploymentIoTJobConfiguration)
-> Lens
     DeploymentIoTJobConfiguration
     DeploymentIoTJobConfiguration
     (Maybe IoTJobAbortConfig)
     (Maybe IoTJobAbortConfig)
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 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 :: (Maybe IoTJobTimeoutConfig -> f (Maybe IoTJobTimeoutConfig))
-> DeploymentIoTJobConfiguration -> f DeploymentIoTJobConfiguration
deploymentIoTJobConfiguration_timeoutConfig = (DeploymentIoTJobConfiguration -> Maybe IoTJobTimeoutConfig)
-> (DeploymentIoTJobConfiguration
    -> Maybe IoTJobTimeoutConfig -> DeploymentIoTJobConfiguration)
-> Lens
     DeploymentIoTJobConfiguration
     DeploymentIoTJobConfiguration
     (Maybe IoTJobTimeoutConfig)
     (Maybe IoTJobTimeoutConfig)
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 Core.FromJSON DeploymentIoTJobConfiguration where
  parseJSON :: Value -> Parser DeploymentIoTJobConfiguration
parseJSON =
    String
-> (Object -> Parser DeploymentIoTJobConfiguration)
-> Value
-> Parser DeploymentIoTJobConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeploymentIoTJobConfiguration"
      ( \Object
x ->
          Maybe IoTJobExecutionsRolloutConfig
-> Maybe IoTJobAbortConfig
-> Maybe IoTJobTimeoutConfig
-> DeploymentIoTJobConfiguration
DeploymentIoTJobConfiguration'
            (Maybe IoTJobExecutionsRolloutConfig
 -> Maybe IoTJobAbortConfig
 -> Maybe IoTJobTimeoutConfig
 -> DeploymentIoTJobConfiguration)
-> Parser (Maybe IoTJobExecutionsRolloutConfig)
-> Parser
     (Maybe IoTJobAbortConfig
      -> Maybe IoTJobTimeoutConfig -> DeploymentIoTJobConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe IoTJobExecutionsRolloutConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"jobExecutionsRolloutConfig")
            Parser
  (Maybe IoTJobAbortConfig
   -> Maybe IoTJobTimeoutConfig -> DeploymentIoTJobConfiguration)
-> Parser (Maybe IoTJobAbortConfig)
-> Parser
     (Maybe IoTJobTimeoutConfig -> DeploymentIoTJobConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IoTJobAbortConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"abortConfig")
            Parser (Maybe IoTJobTimeoutConfig -> DeploymentIoTJobConfiguration)
-> Parser (Maybe IoTJobTimeoutConfig)
-> Parser DeploymentIoTJobConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IoTJobTimeoutConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timeoutConfig")
      )

instance
  Prelude.Hashable
    DeploymentIoTJobConfiguration

instance Prelude.NFData DeploymentIoTJobConfiguration

instance Core.ToJSON DeploymentIoTJobConfiguration where
  toJSON :: DeploymentIoTJobConfiguration -> Value
toJSON DeploymentIoTJobConfiguration' {Maybe IoTJobAbortConfig
Maybe IoTJobExecutionsRolloutConfig
Maybe IoTJobTimeoutConfig
timeoutConfig :: Maybe IoTJobTimeoutConfig
abortConfig :: Maybe IoTJobAbortConfig
jobExecutionsRolloutConfig :: Maybe IoTJobExecutionsRolloutConfig
$sel:timeoutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobTimeoutConfig
$sel:abortConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration -> Maybe IoTJobAbortConfig
$sel:jobExecutionsRolloutConfig:DeploymentIoTJobConfiguration' :: DeploymentIoTJobConfiguration
-> Maybe IoTJobExecutionsRolloutConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"jobExecutionsRolloutConfig" Text -> IoTJobExecutionsRolloutConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (IoTJobExecutionsRolloutConfig -> Pair)
-> Maybe IoTJobExecutionsRolloutConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IoTJobExecutionsRolloutConfig
jobExecutionsRolloutConfig,
            (Text
"abortConfig" Text -> IoTJobAbortConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (IoTJobAbortConfig -> Pair)
-> Maybe IoTJobAbortConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IoTJobAbortConfig
abortConfig,
            (Text
"timeoutConfig" Text -> IoTJobTimeoutConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (IoTJobTimeoutConfig -> Pair)
-> Maybe IoTJobTimeoutConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IoTJobTimeoutConfig
timeoutConfig
          ]
      )