{-# 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.TargetGroupInfo
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeDeploy.Types.TargetGroupInfo where

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

-- | Information about a target group in Elastic Load Balancing to use in a
-- deployment. Instances are registered as targets in a target group, and
-- traffic is routed to the target group.
--
-- /See:/ 'newTargetGroupInfo' smart constructor.
data TargetGroupInfo = TargetGroupInfo'
  { -- | For blue\/green deployments, the name of the target group that instances
    -- in the original environment are deregistered from, and instances in the
    -- replacement environment are registered with. For in-place deployments,
    -- the name of the target group that instances are deregistered from, so
    -- they are not serving traffic during a deployment, and then re-registered
    -- with after the deployment is complete.
    TargetGroupInfo -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (TargetGroupInfo -> TargetGroupInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetGroupInfo -> TargetGroupInfo -> Bool
$c/= :: TargetGroupInfo -> TargetGroupInfo -> Bool
== :: TargetGroupInfo -> TargetGroupInfo -> Bool
$c== :: TargetGroupInfo -> TargetGroupInfo -> Bool
Prelude.Eq, ReadPrec [TargetGroupInfo]
ReadPrec TargetGroupInfo
Int -> ReadS TargetGroupInfo
ReadS [TargetGroupInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetGroupInfo]
$creadListPrec :: ReadPrec [TargetGroupInfo]
readPrec :: ReadPrec TargetGroupInfo
$creadPrec :: ReadPrec TargetGroupInfo
readList :: ReadS [TargetGroupInfo]
$creadList :: ReadS [TargetGroupInfo]
readsPrec :: Int -> ReadS TargetGroupInfo
$creadsPrec :: Int -> ReadS TargetGroupInfo
Prelude.Read, Int -> TargetGroupInfo -> ShowS
[TargetGroupInfo] -> ShowS
TargetGroupInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetGroupInfo] -> ShowS
$cshowList :: [TargetGroupInfo] -> ShowS
show :: TargetGroupInfo -> String
$cshow :: TargetGroupInfo -> String
showsPrec :: Int -> TargetGroupInfo -> ShowS
$cshowsPrec :: Int -> TargetGroupInfo -> ShowS
Prelude.Show, forall x. Rep TargetGroupInfo x -> TargetGroupInfo
forall x. TargetGroupInfo -> Rep TargetGroupInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetGroupInfo x -> TargetGroupInfo
$cfrom :: forall x. TargetGroupInfo -> Rep TargetGroupInfo x
Prelude.Generic)

-- |
-- Create a value of 'TargetGroupInfo' 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:
--
-- 'name', 'targetGroupInfo_name' - For blue\/green deployments, the name of the target group that instances
-- in the original environment are deregistered from, and instances in the
-- replacement environment are registered with. For in-place deployments,
-- the name of the target group that instances are deregistered from, so
-- they are not serving traffic during a deployment, and then re-registered
-- with after the deployment is complete.
newTargetGroupInfo ::
  TargetGroupInfo
newTargetGroupInfo :: TargetGroupInfo
newTargetGroupInfo =
  TargetGroupInfo' {$sel:name:TargetGroupInfo' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing}

-- | For blue\/green deployments, the name of the target group that instances
-- in the original environment are deregistered from, and instances in the
-- replacement environment are registered with. For in-place deployments,
-- the name of the target group that instances are deregistered from, so
-- they are not serving traffic during a deployment, and then re-registered
-- with after the deployment is complete.
targetGroupInfo_name :: Lens.Lens' TargetGroupInfo (Prelude.Maybe Prelude.Text)
targetGroupInfo_name :: Lens' TargetGroupInfo (Maybe Text)
targetGroupInfo_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetGroupInfo' {Maybe Text
name :: Maybe Text
$sel:name:TargetGroupInfo' :: TargetGroupInfo -> Maybe Text
name} -> Maybe Text
name) (\s :: TargetGroupInfo
s@TargetGroupInfo' {} Maybe Text
a -> TargetGroupInfo
s {$sel:name:TargetGroupInfo' :: Maybe Text
name = Maybe Text
a} :: TargetGroupInfo)

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

instance Prelude.Hashable TargetGroupInfo where
  hashWithSalt :: Int -> TargetGroupInfo -> Int
hashWithSalt Int
_salt TargetGroupInfo' {Maybe Text
name :: Maybe Text
$sel:name:TargetGroupInfo' :: TargetGroupInfo -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData TargetGroupInfo where
  rnf :: TargetGroupInfo -> ()
rnf TargetGroupInfo' {Maybe Text
name :: Maybe Text
$sel:name:TargetGroupInfo' :: TargetGroupInfo -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name

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