{-# 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.SecurityHub.Types.AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-- 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.SecurityHub.Types.AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Determines whether a service deployment fails if a service cannot reach
-- a steady state.
--
-- /See:/ 'newAwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' smart constructor.
data AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails = AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails'
  { -- | Whether to roll back the service if a service deployment fails. If
    -- rollback is enabled, when a service deployment fails, the service is
    -- rolled back to the last deployment that completed successfully.
    AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Maybe Bool
rollback :: Prelude.Maybe Prelude.Bool,
    -- | Whether to enable the deployment circuit breaker logic for the service.
    AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Maybe Bool
enable :: Prelude.Maybe Prelude.Bool
  }
  deriving (AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Bool
(AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
 -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
 -> Bool)
-> (AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
    -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
    -> Bool)
-> Eq
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Bool
$c/= :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Bool
== :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Bool
$c== :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Bool
Prelude.Eq, ReadPrec
  [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
ReadPrec
  AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
Int
-> ReadS
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
ReadS
  [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
(Int
 -> ReadS
      AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)
-> ReadS
     [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
-> ReadPrec
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> ReadPrec
     [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
-> Read
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec
  [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
$creadListPrec :: ReadPrec
  [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
readPrec :: ReadPrec
  AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
$creadPrec :: ReadPrec
  AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
readList :: ReadS
  [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
$creadList :: ReadS
  [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
readsPrec :: Int
-> ReadS
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
$creadsPrec :: Int
-> ReadS
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
Prelude.Read, Int
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> ShowS
[AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
-> ShowS
AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> String
(Int
 -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
 -> ShowS)
-> (AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
    -> String)
-> ([AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
    -> ShowS)
-> Show
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
-> ShowS
$cshowList :: [AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails]
-> ShowS
show :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> String
$cshow :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> String
showsPrec :: Int
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> ShowS
$cshowsPrec :: Int
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> ShowS
Prelude.Show, (forall x.
 AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
 -> Rep
      AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
      x)
-> (forall x.
    Rep
      AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
      x
    -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)
-> Generic
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
forall x.
Rep
  AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
  x
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
forall x.
AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Rep
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
     x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep
  AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
  x
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
$cfrom :: forall x.
AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Rep
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
     x
Prelude.Generic)

-- |
-- Create a value of 'AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' 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:
--
-- 'rollback', 'awsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails_rollback' - Whether to roll back the service if a service deployment fails. If
-- rollback is enabled, when a service deployment fails, the service is
-- rolled back to the last deployment that completed successfully.
--
-- 'enable', 'awsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails_enable' - Whether to enable the deployment circuit breaker logic for the service.
newAwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails ::
  AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
newAwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
newAwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails =
  AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: Maybe Bool
-> Maybe Bool
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails'
    { $sel:rollback:AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: Maybe Bool
rollback =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:enable:AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: Maybe Bool
enable =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether to roll back the service if a service deployment fails. If
-- rollback is enabled, when a service deployment fails, the service is
-- rolled back to the last deployment that completed successfully.
awsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails_rollback :: Lens.Lens' AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails (Prelude.Maybe Prelude.Bool)
awsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails_rollback :: (Maybe Bool -> f (Maybe Bool))
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> f AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
awsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails_rollback = (AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
 -> Maybe Bool)
-> (AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
    -> Maybe Bool
    -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)
-> Lens
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' {Maybe Bool
rollback :: Maybe Bool
$sel:rollback:AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Maybe Bool
rollback} -> Maybe Bool
rollback) (\s :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
s@AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' {} Maybe Bool
a -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
s {$sel:rollback:AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: Maybe Bool
rollback = Maybe Bool
a} :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)

-- | Whether to enable the deployment circuit breaker logic for the service.
awsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails_enable :: Lens.Lens' AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails (Prelude.Maybe Prelude.Bool)
awsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails_enable :: (Maybe Bool -> f (Maybe Bool))
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> f AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
awsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails_enable = (AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
 -> Maybe Bool)
-> (AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
    -> Maybe Bool
    -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)
-> Lens
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' {Maybe Bool
enable :: Maybe Bool
$sel:enable:AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Maybe Bool
enable} -> Maybe Bool
enable) (\s :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
s@AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' {} Maybe Bool
a -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
s {$sel:enable:AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: Maybe Bool
enable = Maybe Bool
a} :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)

instance
  Core.FromJSON
    AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
  where
  parseJSON :: Value
-> Parser
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
parseJSON =
    String
-> (Object
    -> Parser
         AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)
-> Value
-> Parser
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails"
      ( \Object
x ->
          Maybe Bool
-> Maybe Bool
-> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails'
            (Maybe Bool
 -> Maybe Bool
 -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Rollback")
              Parser
  (Maybe Bool
   -> AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails)
-> Parser (Maybe Bool)
-> Parser
     AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enable")
      )

instance
  Prelude.Hashable
    AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails

instance
  Prelude.NFData
    AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails

instance
  Core.ToJSON
    AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
  where
  toJSON :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Value
toJSON
    AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' {Maybe Bool
enable :: Maybe Bool
rollback :: Maybe Bool
$sel:enable:AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Maybe Bool
$sel:rollback:AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails' :: AwsEcsServiceDeploymentConfigurationDeploymentCircuitBreakerDetails
-> Maybe Bool
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Text
"Rollback" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
rollback,
              (Text
"Enable" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enable
            ]
        )