{-# 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.GreenFleetProvisioningOption
-- 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.GreenFleetProvisioningOption where

import Amazonka.CodeDeploy.Types.GreenFleetProvisioningAction
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the instances that belong to the replacement
-- environment in a blue\/green deployment.
--
-- /See:/ 'newGreenFleetProvisioningOption' smart constructor.
data GreenFleetProvisioningOption = GreenFleetProvisioningOption'
  { -- | The method used to add instances to a replacement environment.
    --
    -- -   @DISCOVER_EXISTING@: Use instances that already exist or will be
    --     created manually.
    --
    -- -   @COPY_AUTO_SCALING_GROUP@: Use settings from a specified Auto
    --     Scaling group to define and create instances in a new Auto Scaling
    --     group.
    GreenFleetProvisioningOption -> Maybe GreenFleetProvisioningAction
action :: Prelude.Maybe GreenFleetProvisioningAction
  }
  deriving (GreenFleetProvisioningOption
-> GreenFleetProvisioningOption -> Bool
(GreenFleetProvisioningOption
 -> GreenFleetProvisioningOption -> Bool)
-> (GreenFleetProvisioningOption
    -> GreenFleetProvisioningOption -> Bool)
-> Eq GreenFleetProvisioningOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GreenFleetProvisioningOption
-> GreenFleetProvisioningOption -> Bool
$c/= :: GreenFleetProvisioningOption
-> GreenFleetProvisioningOption -> Bool
== :: GreenFleetProvisioningOption
-> GreenFleetProvisioningOption -> Bool
$c== :: GreenFleetProvisioningOption
-> GreenFleetProvisioningOption -> Bool
Prelude.Eq, ReadPrec [GreenFleetProvisioningOption]
ReadPrec GreenFleetProvisioningOption
Int -> ReadS GreenFleetProvisioningOption
ReadS [GreenFleetProvisioningOption]
(Int -> ReadS GreenFleetProvisioningOption)
-> ReadS [GreenFleetProvisioningOption]
-> ReadPrec GreenFleetProvisioningOption
-> ReadPrec [GreenFleetProvisioningOption]
-> Read GreenFleetProvisioningOption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GreenFleetProvisioningOption]
$creadListPrec :: ReadPrec [GreenFleetProvisioningOption]
readPrec :: ReadPrec GreenFleetProvisioningOption
$creadPrec :: ReadPrec GreenFleetProvisioningOption
readList :: ReadS [GreenFleetProvisioningOption]
$creadList :: ReadS [GreenFleetProvisioningOption]
readsPrec :: Int -> ReadS GreenFleetProvisioningOption
$creadsPrec :: Int -> ReadS GreenFleetProvisioningOption
Prelude.Read, Int -> GreenFleetProvisioningOption -> ShowS
[GreenFleetProvisioningOption] -> ShowS
GreenFleetProvisioningOption -> String
(Int -> GreenFleetProvisioningOption -> ShowS)
-> (GreenFleetProvisioningOption -> String)
-> ([GreenFleetProvisioningOption] -> ShowS)
-> Show GreenFleetProvisioningOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GreenFleetProvisioningOption] -> ShowS
$cshowList :: [GreenFleetProvisioningOption] -> ShowS
show :: GreenFleetProvisioningOption -> String
$cshow :: GreenFleetProvisioningOption -> String
showsPrec :: Int -> GreenFleetProvisioningOption -> ShowS
$cshowsPrec :: Int -> GreenFleetProvisioningOption -> ShowS
Prelude.Show, (forall x.
 GreenFleetProvisioningOption -> Rep GreenFleetProvisioningOption x)
-> (forall x.
    Rep GreenFleetProvisioningOption x -> GreenFleetProvisioningOption)
-> Generic GreenFleetProvisioningOption
forall x.
Rep GreenFleetProvisioningOption x -> GreenFleetProvisioningOption
forall x.
GreenFleetProvisioningOption -> Rep GreenFleetProvisioningOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GreenFleetProvisioningOption x -> GreenFleetProvisioningOption
$cfrom :: forall x.
GreenFleetProvisioningOption -> Rep GreenFleetProvisioningOption x
Prelude.Generic)

-- |
-- Create a value of 'GreenFleetProvisioningOption' 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:
--
-- 'action', 'greenFleetProvisioningOption_action' - The method used to add instances to a replacement environment.
--
-- -   @DISCOVER_EXISTING@: Use instances that already exist or will be
--     created manually.
--
-- -   @COPY_AUTO_SCALING_GROUP@: Use settings from a specified Auto
--     Scaling group to define and create instances in a new Auto Scaling
--     group.
newGreenFleetProvisioningOption ::
  GreenFleetProvisioningOption
newGreenFleetProvisioningOption :: GreenFleetProvisioningOption
newGreenFleetProvisioningOption =
  GreenFleetProvisioningOption' :: Maybe GreenFleetProvisioningAction -> GreenFleetProvisioningOption
GreenFleetProvisioningOption'
    { $sel:action:GreenFleetProvisioningOption' :: Maybe GreenFleetProvisioningAction
action =
        Maybe GreenFleetProvisioningAction
forall a. Maybe a
Prelude.Nothing
    }

-- | The method used to add instances to a replacement environment.
--
-- -   @DISCOVER_EXISTING@: Use instances that already exist or will be
--     created manually.
--
-- -   @COPY_AUTO_SCALING_GROUP@: Use settings from a specified Auto
--     Scaling group to define and create instances in a new Auto Scaling
--     group.
greenFleetProvisioningOption_action :: Lens.Lens' GreenFleetProvisioningOption (Prelude.Maybe GreenFleetProvisioningAction)
greenFleetProvisioningOption_action :: (Maybe GreenFleetProvisioningAction
 -> f (Maybe GreenFleetProvisioningAction))
-> GreenFleetProvisioningOption -> f GreenFleetProvisioningOption
greenFleetProvisioningOption_action = (GreenFleetProvisioningOption
 -> Maybe GreenFleetProvisioningAction)
-> (GreenFleetProvisioningOption
    -> Maybe GreenFleetProvisioningAction
    -> GreenFleetProvisioningOption)
-> Lens
     GreenFleetProvisioningOption
     GreenFleetProvisioningOption
     (Maybe GreenFleetProvisioningAction)
     (Maybe GreenFleetProvisioningAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GreenFleetProvisioningOption' {Maybe GreenFleetProvisioningAction
action :: Maybe GreenFleetProvisioningAction
$sel:action:GreenFleetProvisioningOption' :: GreenFleetProvisioningOption -> Maybe GreenFleetProvisioningAction
action} -> Maybe GreenFleetProvisioningAction
action) (\s :: GreenFleetProvisioningOption
s@GreenFleetProvisioningOption' {} Maybe GreenFleetProvisioningAction
a -> GreenFleetProvisioningOption
s {$sel:action:GreenFleetProvisioningOption' :: Maybe GreenFleetProvisioningAction
action = Maybe GreenFleetProvisioningAction
a} :: GreenFleetProvisioningOption)

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

instance
  Prelude.Hashable
    GreenFleetProvisioningOption

instance Prelude.NFData GreenFleetProvisioningOption

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