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

import Amazonka.CodeDeploy.Types.TargetGroupInfo
import Amazonka.CodeDeploy.Types.TrafficRoute
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about two target groups and how traffic is routed during an
-- Amazon ECS deployment. An optional test traffic route can be specified.
--
-- /See:/ 'newTargetGroupPairInfo' smart constructor.
data TargetGroupPairInfo = TargetGroupPairInfo'
  { -- | The path used by a load balancer to route production traffic when an
    -- Amazon ECS deployment is complete.
    TargetGroupPairInfo -> Maybe TrafficRoute
prodTrafficRoute :: Prelude.Maybe TrafficRoute,
    -- | An optional path used by a load balancer to route test traffic after an
    -- Amazon ECS deployment. Validation can occur while test traffic is served
    -- during a deployment.
    TargetGroupPairInfo -> Maybe TrafficRoute
testTrafficRoute :: Prelude.Maybe TrafficRoute,
    -- | One pair of target groups. One is associated with the original task set.
    -- The second is associated with the task set that serves traffic after the
    -- deployment is complete.
    TargetGroupPairInfo -> Maybe [TargetGroupInfo]
targetGroups :: Prelude.Maybe [TargetGroupInfo]
  }
  deriving (TargetGroupPairInfo -> TargetGroupPairInfo -> Bool
(TargetGroupPairInfo -> TargetGroupPairInfo -> Bool)
-> (TargetGroupPairInfo -> TargetGroupPairInfo -> Bool)
-> Eq TargetGroupPairInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetGroupPairInfo -> TargetGroupPairInfo -> Bool
$c/= :: TargetGroupPairInfo -> TargetGroupPairInfo -> Bool
== :: TargetGroupPairInfo -> TargetGroupPairInfo -> Bool
$c== :: TargetGroupPairInfo -> TargetGroupPairInfo -> Bool
Prelude.Eq, ReadPrec [TargetGroupPairInfo]
ReadPrec TargetGroupPairInfo
Int -> ReadS TargetGroupPairInfo
ReadS [TargetGroupPairInfo]
(Int -> ReadS TargetGroupPairInfo)
-> ReadS [TargetGroupPairInfo]
-> ReadPrec TargetGroupPairInfo
-> ReadPrec [TargetGroupPairInfo]
-> Read TargetGroupPairInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetGroupPairInfo]
$creadListPrec :: ReadPrec [TargetGroupPairInfo]
readPrec :: ReadPrec TargetGroupPairInfo
$creadPrec :: ReadPrec TargetGroupPairInfo
readList :: ReadS [TargetGroupPairInfo]
$creadList :: ReadS [TargetGroupPairInfo]
readsPrec :: Int -> ReadS TargetGroupPairInfo
$creadsPrec :: Int -> ReadS TargetGroupPairInfo
Prelude.Read, Int -> TargetGroupPairInfo -> ShowS
[TargetGroupPairInfo] -> ShowS
TargetGroupPairInfo -> String
(Int -> TargetGroupPairInfo -> ShowS)
-> (TargetGroupPairInfo -> String)
-> ([TargetGroupPairInfo] -> ShowS)
-> Show TargetGroupPairInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetGroupPairInfo] -> ShowS
$cshowList :: [TargetGroupPairInfo] -> ShowS
show :: TargetGroupPairInfo -> String
$cshow :: TargetGroupPairInfo -> String
showsPrec :: Int -> TargetGroupPairInfo -> ShowS
$cshowsPrec :: Int -> TargetGroupPairInfo -> ShowS
Prelude.Show, (forall x. TargetGroupPairInfo -> Rep TargetGroupPairInfo x)
-> (forall x. Rep TargetGroupPairInfo x -> TargetGroupPairInfo)
-> Generic TargetGroupPairInfo
forall x. Rep TargetGroupPairInfo x -> TargetGroupPairInfo
forall x. TargetGroupPairInfo -> Rep TargetGroupPairInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetGroupPairInfo x -> TargetGroupPairInfo
$cfrom :: forall x. TargetGroupPairInfo -> Rep TargetGroupPairInfo x
Prelude.Generic)

-- |
-- Create a value of 'TargetGroupPairInfo' 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:
--
-- 'prodTrafficRoute', 'targetGroupPairInfo_prodTrafficRoute' - The path used by a load balancer to route production traffic when an
-- Amazon ECS deployment is complete.
--
-- 'testTrafficRoute', 'targetGroupPairInfo_testTrafficRoute' - An optional path used by a load balancer to route test traffic after an
-- Amazon ECS deployment. Validation can occur while test traffic is served
-- during a deployment.
--
-- 'targetGroups', 'targetGroupPairInfo_targetGroups' - One pair of target groups. One is associated with the original task set.
-- The second is associated with the task set that serves traffic after the
-- deployment is complete.
newTargetGroupPairInfo ::
  TargetGroupPairInfo
newTargetGroupPairInfo :: TargetGroupPairInfo
newTargetGroupPairInfo =
  TargetGroupPairInfo' :: Maybe TrafficRoute
-> Maybe TrafficRoute
-> Maybe [TargetGroupInfo]
-> TargetGroupPairInfo
TargetGroupPairInfo'
    { $sel:prodTrafficRoute:TargetGroupPairInfo' :: Maybe TrafficRoute
prodTrafficRoute =
        Maybe TrafficRoute
forall a. Maybe a
Prelude.Nothing,
      $sel:testTrafficRoute:TargetGroupPairInfo' :: Maybe TrafficRoute
testTrafficRoute = Maybe TrafficRoute
forall a. Maybe a
Prelude.Nothing,
      $sel:targetGroups:TargetGroupPairInfo' :: Maybe [TargetGroupInfo]
targetGroups = Maybe [TargetGroupInfo]
forall a. Maybe a
Prelude.Nothing
    }

-- | The path used by a load balancer to route production traffic when an
-- Amazon ECS deployment is complete.
targetGroupPairInfo_prodTrafficRoute :: Lens.Lens' TargetGroupPairInfo (Prelude.Maybe TrafficRoute)
targetGroupPairInfo_prodTrafficRoute :: (Maybe TrafficRoute -> f (Maybe TrafficRoute))
-> TargetGroupPairInfo -> f TargetGroupPairInfo
targetGroupPairInfo_prodTrafficRoute = (TargetGroupPairInfo -> Maybe TrafficRoute)
-> (TargetGroupPairInfo
    -> Maybe TrafficRoute -> TargetGroupPairInfo)
-> Lens
     TargetGroupPairInfo
     TargetGroupPairInfo
     (Maybe TrafficRoute)
     (Maybe TrafficRoute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetGroupPairInfo' {Maybe TrafficRoute
prodTrafficRoute :: Maybe TrafficRoute
$sel:prodTrafficRoute:TargetGroupPairInfo' :: TargetGroupPairInfo -> Maybe TrafficRoute
prodTrafficRoute} -> Maybe TrafficRoute
prodTrafficRoute) (\s :: TargetGroupPairInfo
s@TargetGroupPairInfo' {} Maybe TrafficRoute
a -> TargetGroupPairInfo
s {$sel:prodTrafficRoute:TargetGroupPairInfo' :: Maybe TrafficRoute
prodTrafficRoute = Maybe TrafficRoute
a} :: TargetGroupPairInfo)

-- | An optional path used by a load balancer to route test traffic after an
-- Amazon ECS deployment. Validation can occur while test traffic is served
-- during a deployment.
targetGroupPairInfo_testTrafficRoute :: Lens.Lens' TargetGroupPairInfo (Prelude.Maybe TrafficRoute)
targetGroupPairInfo_testTrafficRoute :: (Maybe TrafficRoute -> f (Maybe TrafficRoute))
-> TargetGroupPairInfo -> f TargetGroupPairInfo
targetGroupPairInfo_testTrafficRoute = (TargetGroupPairInfo -> Maybe TrafficRoute)
-> (TargetGroupPairInfo
    -> Maybe TrafficRoute -> TargetGroupPairInfo)
-> Lens
     TargetGroupPairInfo
     TargetGroupPairInfo
     (Maybe TrafficRoute)
     (Maybe TrafficRoute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetGroupPairInfo' {Maybe TrafficRoute
testTrafficRoute :: Maybe TrafficRoute
$sel:testTrafficRoute:TargetGroupPairInfo' :: TargetGroupPairInfo -> Maybe TrafficRoute
testTrafficRoute} -> Maybe TrafficRoute
testTrafficRoute) (\s :: TargetGroupPairInfo
s@TargetGroupPairInfo' {} Maybe TrafficRoute
a -> TargetGroupPairInfo
s {$sel:testTrafficRoute:TargetGroupPairInfo' :: Maybe TrafficRoute
testTrafficRoute = Maybe TrafficRoute
a} :: TargetGroupPairInfo)

-- | One pair of target groups. One is associated with the original task set.
-- The second is associated with the task set that serves traffic after the
-- deployment is complete.
targetGroupPairInfo_targetGroups :: Lens.Lens' TargetGroupPairInfo (Prelude.Maybe [TargetGroupInfo])
targetGroupPairInfo_targetGroups :: (Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
-> TargetGroupPairInfo -> f TargetGroupPairInfo
targetGroupPairInfo_targetGroups = (TargetGroupPairInfo -> Maybe [TargetGroupInfo])
-> (TargetGroupPairInfo
    -> Maybe [TargetGroupInfo] -> TargetGroupPairInfo)
-> Lens
     TargetGroupPairInfo
     TargetGroupPairInfo
     (Maybe [TargetGroupInfo])
     (Maybe [TargetGroupInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetGroupPairInfo' {Maybe [TargetGroupInfo]
targetGroups :: Maybe [TargetGroupInfo]
$sel:targetGroups:TargetGroupPairInfo' :: TargetGroupPairInfo -> Maybe [TargetGroupInfo]
targetGroups} -> Maybe [TargetGroupInfo]
targetGroups) (\s :: TargetGroupPairInfo
s@TargetGroupPairInfo' {} Maybe [TargetGroupInfo]
a -> TargetGroupPairInfo
s {$sel:targetGroups:TargetGroupPairInfo' :: Maybe [TargetGroupInfo]
targetGroups = Maybe [TargetGroupInfo]
a} :: TargetGroupPairInfo) ((Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
 -> TargetGroupPairInfo -> f TargetGroupPairInfo)
-> ((Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
    -> Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
-> (Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
-> TargetGroupPairInfo
-> f TargetGroupPairInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [TargetGroupInfo]
  [TargetGroupInfo]
  [TargetGroupInfo]
  [TargetGroupInfo]
-> Iso
     (Maybe [TargetGroupInfo])
     (Maybe [TargetGroupInfo])
     (Maybe [TargetGroupInfo])
     (Maybe [TargetGroupInfo])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [TargetGroupInfo]
  [TargetGroupInfo]
  [TargetGroupInfo]
  [TargetGroupInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON TargetGroupPairInfo where
  parseJSON :: Value -> Parser TargetGroupPairInfo
parseJSON =
    String
-> (Object -> Parser TargetGroupPairInfo)
-> Value
-> Parser TargetGroupPairInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TargetGroupPairInfo"
      ( \Object
x ->
          Maybe TrafficRoute
-> Maybe TrafficRoute
-> Maybe [TargetGroupInfo]
-> TargetGroupPairInfo
TargetGroupPairInfo'
            (Maybe TrafficRoute
 -> Maybe TrafficRoute
 -> Maybe [TargetGroupInfo]
 -> TargetGroupPairInfo)
-> Parser (Maybe TrafficRoute)
-> Parser
     (Maybe TrafficRoute
      -> Maybe [TargetGroupInfo] -> TargetGroupPairInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TrafficRoute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"prodTrafficRoute")
            Parser
  (Maybe TrafficRoute
   -> Maybe [TargetGroupInfo] -> TargetGroupPairInfo)
-> Parser (Maybe TrafficRoute)
-> Parser (Maybe [TargetGroupInfo] -> TargetGroupPairInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TrafficRoute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"testTrafficRoute")
            Parser (Maybe [TargetGroupInfo] -> TargetGroupPairInfo)
-> Parser (Maybe [TargetGroupInfo]) -> Parser TargetGroupPairInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [TargetGroupInfo]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targetGroups" Parser (Maybe (Maybe [TargetGroupInfo]))
-> Maybe [TargetGroupInfo] -> Parser (Maybe [TargetGroupInfo])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [TargetGroupInfo]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TargetGroupPairInfo

instance Prelude.NFData TargetGroupPairInfo

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