{-# 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.RobOMaker.Types.DeploymentConfig
-- 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.RobOMaker.Types.DeploymentConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RobOMaker.Types.S3Object

-- | Information about a deployment configuration.
--
-- /See:/ 'newDeploymentConfig' smart constructor.
data DeploymentConfig = DeploymentConfig'
  { -- | The percentage of robots receiving the deployment at the same time.
    DeploymentConfig -> Maybe Natural
concurrentDeploymentPercentage :: Prelude.Maybe Prelude.Natural,
    -- | The download condition file.
    DeploymentConfig -> Maybe S3Object
downloadConditionFile :: Prelude.Maybe S3Object,
    -- | The percentage of deployments that need to fail before stopping
    -- deployment.
    DeploymentConfig -> Maybe Natural
failureThresholdPercentage :: Prelude.Maybe Prelude.Natural,
    -- | The amount of time, in seconds, to wait for deployment to a single robot
    -- to complete. Choose a time between 1 minute and 7 days. The default is 5
    -- hours.
    DeploymentConfig -> Maybe Integer
robotDeploymentTimeoutInSeconds :: Prelude.Maybe Prelude.Integer
  }
  deriving (DeploymentConfig -> DeploymentConfig -> Bool
(DeploymentConfig -> DeploymentConfig -> Bool)
-> (DeploymentConfig -> DeploymentConfig -> Bool)
-> Eq DeploymentConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentConfig -> DeploymentConfig -> Bool
$c/= :: DeploymentConfig -> DeploymentConfig -> Bool
== :: DeploymentConfig -> DeploymentConfig -> Bool
$c== :: DeploymentConfig -> DeploymentConfig -> Bool
Prelude.Eq, ReadPrec [DeploymentConfig]
ReadPrec DeploymentConfig
Int -> ReadS DeploymentConfig
ReadS [DeploymentConfig]
(Int -> ReadS DeploymentConfig)
-> ReadS [DeploymentConfig]
-> ReadPrec DeploymentConfig
-> ReadPrec [DeploymentConfig]
-> Read DeploymentConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentConfig]
$creadListPrec :: ReadPrec [DeploymentConfig]
readPrec :: ReadPrec DeploymentConfig
$creadPrec :: ReadPrec DeploymentConfig
readList :: ReadS [DeploymentConfig]
$creadList :: ReadS [DeploymentConfig]
readsPrec :: Int -> ReadS DeploymentConfig
$creadsPrec :: Int -> ReadS DeploymentConfig
Prelude.Read, Int -> DeploymentConfig -> ShowS
[DeploymentConfig] -> ShowS
DeploymentConfig -> String
(Int -> DeploymentConfig -> ShowS)
-> (DeploymentConfig -> String)
-> ([DeploymentConfig] -> ShowS)
-> Show DeploymentConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentConfig] -> ShowS
$cshowList :: [DeploymentConfig] -> ShowS
show :: DeploymentConfig -> String
$cshow :: DeploymentConfig -> String
showsPrec :: Int -> DeploymentConfig -> ShowS
$cshowsPrec :: Int -> DeploymentConfig -> ShowS
Prelude.Show, (forall x. DeploymentConfig -> Rep DeploymentConfig x)
-> (forall x. Rep DeploymentConfig x -> DeploymentConfig)
-> Generic DeploymentConfig
forall x. Rep DeploymentConfig x -> DeploymentConfig
forall x. DeploymentConfig -> Rep DeploymentConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeploymentConfig x -> DeploymentConfig
$cfrom :: forall x. DeploymentConfig -> Rep DeploymentConfig x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentConfig' 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:
--
-- 'concurrentDeploymentPercentage', 'deploymentConfig_concurrentDeploymentPercentage' - The percentage of robots receiving the deployment at the same time.
--
-- 'downloadConditionFile', 'deploymentConfig_downloadConditionFile' - The download condition file.
--
-- 'failureThresholdPercentage', 'deploymentConfig_failureThresholdPercentage' - The percentage of deployments that need to fail before stopping
-- deployment.
--
-- 'robotDeploymentTimeoutInSeconds', 'deploymentConfig_robotDeploymentTimeoutInSeconds' - The amount of time, in seconds, to wait for deployment to a single robot
-- to complete. Choose a time between 1 minute and 7 days. The default is 5
-- hours.
newDeploymentConfig ::
  DeploymentConfig
newDeploymentConfig :: DeploymentConfig
newDeploymentConfig =
  DeploymentConfig' :: Maybe Natural
-> Maybe S3Object
-> Maybe Natural
-> Maybe Integer
-> DeploymentConfig
DeploymentConfig'
    { $sel:concurrentDeploymentPercentage:DeploymentConfig' :: Maybe Natural
concurrentDeploymentPercentage =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:downloadConditionFile:DeploymentConfig' :: Maybe S3Object
downloadConditionFile = Maybe S3Object
forall a. Maybe a
Prelude.Nothing,
      $sel:failureThresholdPercentage:DeploymentConfig' :: Maybe Natural
failureThresholdPercentage = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:robotDeploymentTimeoutInSeconds:DeploymentConfig' :: Maybe Integer
robotDeploymentTimeoutInSeconds = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The percentage of robots receiving the deployment at the same time.
deploymentConfig_concurrentDeploymentPercentage :: Lens.Lens' DeploymentConfig (Prelude.Maybe Prelude.Natural)
deploymentConfig_concurrentDeploymentPercentage :: (Maybe Natural -> f (Maybe Natural))
-> DeploymentConfig -> f DeploymentConfig
deploymentConfig_concurrentDeploymentPercentage = (DeploymentConfig -> Maybe Natural)
-> (DeploymentConfig -> Maybe Natural -> DeploymentConfig)
-> Lens
     DeploymentConfig DeploymentConfig (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentConfig' {Maybe Natural
concurrentDeploymentPercentage :: Maybe Natural
$sel:concurrentDeploymentPercentage:DeploymentConfig' :: DeploymentConfig -> Maybe Natural
concurrentDeploymentPercentage} -> Maybe Natural
concurrentDeploymentPercentage) (\s :: DeploymentConfig
s@DeploymentConfig' {} Maybe Natural
a -> DeploymentConfig
s {$sel:concurrentDeploymentPercentage:DeploymentConfig' :: Maybe Natural
concurrentDeploymentPercentage = Maybe Natural
a} :: DeploymentConfig)

-- | The download condition file.
deploymentConfig_downloadConditionFile :: Lens.Lens' DeploymentConfig (Prelude.Maybe S3Object)
deploymentConfig_downloadConditionFile :: (Maybe S3Object -> f (Maybe S3Object))
-> DeploymentConfig -> f DeploymentConfig
deploymentConfig_downloadConditionFile = (DeploymentConfig -> Maybe S3Object)
-> (DeploymentConfig -> Maybe S3Object -> DeploymentConfig)
-> Lens
     DeploymentConfig DeploymentConfig (Maybe S3Object) (Maybe S3Object)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentConfig' {Maybe S3Object
downloadConditionFile :: Maybe S3Object
$sel:downloadConditionFile:DeploymentConfig' :: DeploymentConfig -> Maybe S3Object
downloadConditionFile} -> Maybe S3Object
downloadConditionFile) (\s :: DeploymentConfig
s@DeploymentConfig' {} Maybe S3Object
a -> DeploymentConfig
s {$sel:downloadConditionFile:DeploymentConfig' :: Maybe S3Object
downloadConditionFile = Maybe S3Object
a} :: DeploymentConfig)

-- | The percentage of deployments that need to fail before stopping
-- deployment.
deploymentConfig_failureThresholdPercentage :: Lens.Lens' DeploymentConfig (Prelude.Maybe Prelude.Natural)
deploymentConfig_failureThresholdPercentage :: (Maybe Natural -> f (Maybe Natural))
-> DeploymentConfig -> f DeploymentConfig
deploymentConfig_failureThresholdPercentage = (DeploymentConfig -> Maybe Natural)
-> (DeploymentConfig -> Maybe Natural -> DeploymentConfig)
-> Lens
     DeploymentConfig DeploymentConfig (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentConfig' {Maybe Natural
failureThresholdPercentage :: Maybe Natural
$sel:failureThresholdPercentage:DeploymentConfig' :: DeploymentConfig -> Maybe Natural
failureThresholdPercentage} -> Maybe Natural
failureThresholdPercentage) (\s :: DeploymentConfig
s@DeploymentConfig' {} Maybe Natural
a -> DeploymentConfig
s {$sel:failureThresholdPercentage:DeploymentConfig' :: Maybe Natural
failureThresholdPercentage = Maybe Natural
a} :: DeploymentConfig)

-- | The amount of time, in seconds, to wait for deployment to a single robot
-- to complete. Choose a time between 1 minute and 7 days. The default is 5
-- hours.
deploymentConfig_robotDeploymentTimeoutInSeconds :: Lens.Lens' DeploymentConfig (Prelude.Maybe Prelude.Integer)
deploymentConfig_robotDeploymentTimeoutInSeconds :: (Maybe Integer -> f (Maybe Integer))
-> DeploymentConfig -> f DeploymentConfig
deploymentConfig_robotDeploymentTimeoutInSeconds = (DeploymentConfig -> Maybe Integer)
-> (DeploymentConfig -> Maybe Integer -> DeploymentConfig)
-> Lens
     DeploymentConfig DeploymentConfig (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentConfig' {Maybe Integer
robotDeploymentTimeoutInSeconds :: Maybe Integer
$sel:robotDeploymentTimeoutInSeconds:DeploymentConfig' :: DeploymentConfig -> Maybe Integer
robotDeploymentTimeoutInSeconds} -> Maybe Integer
robotDeploymentTimeoutInSeconds) (\s :: DeploymentConfig
s@DeploymentConfig' {} Maybe Integer
a -> DeploymentConfig
s {$sel:robotDeploymentTimeoutInSeconds:DeploymentConfig' :: Maybe Integer
robotDeploymentTimeoutInSeconds = Maybe Integer
a} :: DeploymentConfig)

instance Core.FromJSON DeploymentConfig where
  parseJSON :: Value -> Parser DeploymentConfig
parseJSON =
    String
-> (Object -> Parser DeploymentConfig)
-> Value
-> Parser DeploymentConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeploymentConfig"
      ( \Object
x ->
          Maybe Natural
-> Maybe S3Object
-> Maybe Natural
-> Maybe Integer
-> DeploymentConfig
DeploymentConfig'
            (Maybe Natural
 -> Maybe S3Object
 -> Maybe Natural
 -> Maybe Integer
 -> DeploymentConfig)
-> Parser (Maybe Natural)
-> Parser
     (Maybe S3Object
      -> Maybe Natural -> Maybe Integer -> DeploymentConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"concurrentDeploymentPercentage")
            Parser
  (Maybe S3Object
   -> Maybe Natural -> Maybe Integer -> DeploymentConfig)
-> Parser (Maybe S3Object)
-> Parser (Maybe Natural -> Maybe Integer -> DeploymentConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3Object)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"downloadConditionFile")
            Parser (Maybe Natural -> Maybe Integer -> DeploymentConfig)
-> Parser (Maybe Natural)
-> Parser (Maybe Integer -> DeploymentConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"failureThresholdPercentage")
            Parser (Maybe Integer -> DeploymentConfig)
-> Parser (Maybe Integer) -> Parser DeploymentConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"robotDeploymentTimeoutInSeconds")
      )

instance Prelude.Hashable DeploymentConfig

instance Prelude.NFData DeploymentConfig

instance Core.ToJSON DeploymentConfig where
  toJSON :: DeploymentConfig -> Value
toJSON DeploymentConfig' {Maybe Integer
Maybe Natural
Maybe S3Object
robotDeploymentTimeoutInSeconds :: Maybe Integer
failureThresholdPercentage :: Maybe Natural
downloadConditionFile :: Maybe S3Object
concurrentDeploymentPercentage :: Maybe Natural
$sel:robotDeploymentTimeoutInSeconds:DeploymentConfig' :: DeploymentConfig -> Maybe Integer
$sel:failureThresholdPercentage:DeploymentConfig' :: DeploymentConfig -> Maybe Natural
$sel:downloadConditionFile:DeploymentConfig' :: DeploymentConfig -> Maybe S3Object
$sel:concurrentDeploymentPercentage:DeploymentConfig' :: DeploymentConfig -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"concurrentDeploymentPercentage" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
concurrentDeploymentPercentage,
            (Text
"downloadConditionFile" Text -> S3Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (S3Object -> Pair) -> Maybe S3Object -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Object
downloadConditionFile,
            (Text
"failureThresholdPercentage" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
failureThresholdPercentage,
            (Text
"robotDeploymentTimeoutInSeconds" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
robotDeploymentTimeoutInSeconds
          ]
      )