{-# 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.CodeDeploy.Types.DeploymentStyle
-- 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.CodeDeploy.Types.DeploymentStyle where

import Amazonka.CodeDeploy.Types.DeploymentOption
import Amazonka.CodeDeploy.Types.DeploymentType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the type of deployment, either in-place or
-- blue\/green, you want to run and whether to route deployment traffic
-- behind a load balancer.
--
-- /See:/ 'newDeploymentStyle' smart constructor.
data DeploymentStyle = DeploymentStyle'
  { -- | Indicates whether to route deployment traffic behind a load balancer.
    DeploymentStyle -> Maybe DeploymentOption
deploymentOption :: Prelude.Maybe DeploymentOption,
    -- | Indicates whether to run an in-place deployment or a blue\/green
    -- deployment.
    DeploymentStyle -> Maybe DeploymentType
deploymentType :: Prelude.Maybe DeploymentType
  }
  deriving (DeploymentStyle -> DeploymentStyle -> Bool
(DeploymentStyle -> DeploymentStyle -> Bool)
-> (DeploymentStyle -> DeploymentStyle -> Bool)
-> Eq DeploymentStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentStyle -> DeploymentStyle -> Bool
$c/= :: DeploymentStyle -> DeploymentStyle -> Bool
== :: DeploymentStyle -> DeploymentStyle -> Bool
$c== :: DeploymentStyle -> DeploymentStyle -> Bool
Prelude.Eq, ReadPrec [DeploymentStyle]
ReadPrec DeploymentStyle
Int -> ReadS DeploymentStyle
ReadS [DeploymentStyle]
(Int -> ReadS DeploymentStyle)
-> ReadS [DeploymentStyle]
-> ReadPrec DeploymentStyle
-> ReadPrec [DeploymentStyle]
-> Read DeploymentStyle
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentStyle]
$creadListPrec :: ReadPrec [DeploymentStyle]
readPrec :: ReadPrec DeploymentStyle
$creadPrec :: ReadPrec DeploymentStyle
readList :: ReadS [DeploymentStyle]
$creadList :: ReadS [DeploymentStyle]
readsPrec :: Int -> ReadS DeploymentStyle
$creadsPrec :: Int -> ReadS DeploymentStyle
Prelude.Read, Int -> DeploymentStyle -> ShowS
[DeploymentStyle] -> ShowS
DeploymentStyle -> String
(Int -> DeploymentStyle -> ShowS)
-> (DeploymentStyle -> String)
-> ([DeploymentStyle] -> ShowS)
-> Show DeploymentStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentStyle] -> ShowS
$cshowList :: [DeploymentStyle] -> ShowS
show :: DeploymentStyle -> String
$cshow :: DeploymentStyle -> String
showsPrec :: Int -> DeploymentStyle -> ShowS
$cshowsPrec :: Int -> DeploymentStyle -> ShowS
Prelude.Show, (forall x. DeploymentStyle -> Rep DeploymentStyle x)
-> (forall x. Rep DeploymentStyle x -> DeploymentStyle)
-> Generic DeploymentStyle
forall x. Rep DeploymentStyle x -> DeploymentStyle
forall x. DeploymentStyle -> Rep DeploymentStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeploymentStyle x -> DeploymentStyle
$cfrom :: forall x. DeploymentStyle -> Rep DeploymentStyle x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentStyle' 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:
--
-- 'deploymentOption', 'deploymentStyle_deploymentOption' - Indicates whether to route deployment traffic behind a load balancer.
--
-- 'deploymentType', 'deploymentStyle_deploymentType' - Indicates whether to run an in-place deployment or a blue\/green
-- deployment.
newDeploymentStyle ::
  DeploymentStyle
newDeploymentStyle :: DeploymentStyle
newDeploymentStyle =
  DeploymentStyle' :: Maybe DeploymentOption -> Maybe DeploymentType -> DeploymentStyle
DeploymentStyle'
    { $sel:deploymentOption:DeploymentStyle' :: Maybe DeploymentOption
deploymentOption =
        Maybe DeploymentOption
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentType:DeploymentStyle' :: Maybe DeploymentType
deploymentType = Maybe DeploymentType
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether to route deployment traffic behind a load balancer.
deploymentStyle_deploymentOption :: Lens.Lens' DeploymentStyle (Prelude.Maybe DeploymentOption)
deploymentStyle_deploymentOption :: (Maybe DeploymentOption -> f (Maybe DeploymentOption))
-> DeploymentStyle -> f DeploymentStyle
deploymentStyle_deploymentOption = (DeploymentStyle -> Maybe DeploymentOption)
-> (DeploymentStyle -> Maybe DeploymentOption -> DeploymentStyle)
-> Lens
     DeploymentStyle
     DeploymentStyle
     (Maybe DeploymentOption)
     (Maybe DeploymentOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStyle' {Maybe DeploymentOption
deploymentOption :: Maybe DeploymentOption
$sel:deploymentOption:DeploymentStyle' :: DeploymentStyle -> Maybe DeploymentOption
deploymentOption} -> Maybe DeploymentOption
deploymentOption) (\s :: DeploymentStyle
s@DeploymentStyle' {} Maybe DeploymentOption
a -> DeploymentStyle
s {$sel:deploymentOption:DeploymentStyle' :: Maybe DeploymentOption
deploymentOption = Maybe DeploymentOption
a} :: DeploymentStyle)

-- | Indicates whether to run an in-place deployment or a blue\/green
-- deployment.
deploymentStyle_deploymentType :: Lens.Lens' DeploymentStyle (Prelude.Maybe DeploymentType)
deploymentStyle_deploymentType :: (Maybe DeploymentType -> f (Maybe DeploymentType))
-> DeploymentStyle -> f DeploymentStyle
deploymentStyle_deploymentType = (DeploymentStyle -> Maybe DeploymentType)
-> (DeploymentStyle -> Maybe DeploymentType -> DeploymentStyle)
-> Lens
     DeploymentStyle
     DeploymentStyle
     (Maybe DeploymentType)
     (Maybe DeploymentType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStyle' {Maybe DeploymentType
deploymentType :: Maybe DeploymentType
$sel:deploymentType:DeploymentStyle' :: DeploymentStyle -> Maybe DeploymentType
deploymentType} -> Maybe DeploymentType
deploymentType) (\s :: DeploymentStyle
s@DeploymentStyle' {} Maybe DeploymentType
a -> DeploymentStyle
s {$sel:deploymentType:DeploymentStyle' :: Maybe DeploymentType
deploymentType = Maybe DeploymentType
a} :: DeploymentStyle)

instance Core.FromJSON DeploymentStyle where
  parseJSON :: Value -> Parser DeploymentStyle
parseJSON =
    String
-> (Object -> Parser DeploymentStyle)
-> Value
-> Parser DeploymentStyle
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeploymentStyle"
      ( \Object
x ->
          Maybe DeploymentOption -> Maybe DeploymentType -> DeploymentStyle
DeploymentStyle'
            (Maybe DeploymentOption -> Maybe DeploymentType -> DeploymentStyle)
-> Parser (Maybe DeploymentOption)
-> Parser (Maybe DeploymentType -> DeploymentStyle)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DeploymentOption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deploymentOption")
            Parser (Maybe DeploymentType -> DeploymentStyle)
-> Parser (Maybe DeploymentType) -> Parser DeploymentStyle
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeploymentType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deploymentType")
      )

instance Prelude.Hashable DeploymentStyle

instance Prelude.NFData DeploymentStyle

instance Core.ToJSON DeploymentStyle where
  toJSON :: DeploymentStyle -> Value
toJSON DeploymentStyle' {Maybe DeploymentOption
Maybe DeploymentType
deploymentType :: Maybe DeploymentType
deploymentOption :: Maybe DeploymentOption
$sel:deploymentType:DeploymentStyle' :: DeploymentStyle -> Maybe DeploymentType
$sel:deploymentOption:DeploymentStyle' :: DeploymentStyle -> Maybe DeploymentOption
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"deploymentOption" Text -> DeploymentOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DeploymentOption -> Pair) -> Maybe DeploymentOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeploymentOption
deploymentOption,
            (Text
"deploymentType" Text -> DeploymentType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DeploymentType -> Pair) -> Maybe DeploymentType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeploymentType
deploymentType
          ]
      )