{-# 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.ELBV2.Types.TargetGroupTuple
-- 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.ELBV2.Types.TargetGroupTuple 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 how traffic will be distributed between multiple
-- target groups in a forward rule.
--
-- /See:/ 'newTargetGroupTuple' smart constructor.
data TargetGroupTuple = TargetGroupTuple'
  { -- | The Amazon Resource Name (ARN) of the target group.
    TargetGroupTuple -> Maybe Text
targetGroupArn :: Prelude.Maybe Prelude.Text,
    -- | The weight. The range is 0 to 999.
    TargetGroupTuple -> Maybe Int
weight :: Prelude.Maybe Prelude.Int
  }
  deriving (TargetGroupTuple -> TargetGroupTuple -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetGroupTuple -> TargetGroupTuple -> Bool
$c/= :: TargetGroupTuple -> TargetGroupTuple -> Bool
== :: TargetGroupTuple -> TargetGroupTuple -> Bool
$c== :: TargetGroupTuple -> TargetGroupTuple -> Bool
Prelude.Eq, ReadPrec [TargetGroupTuple]
ReadPrec TargetGroupTuple
Int -> ReadS TargetGroupTuple
ReadS [TargetGroupTuple]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetGroupTuple]
$creadListPrec :: ReadPrec [TargetGroupTuple]
readPrec :: ReadPrec TargetGroupTuple
$creadPrec :: ReadPrec TargetGroupTuple
readList :: ReadS [TargetGroupTuple]
$creadList :: ReadS [TargetGroupTuple]
readsPrec :: Int -> ReadS TargetGroupTuple
$creadsPrec :: Int -> ReadS TargetGroupTuple
Prelude.Read, Int -> TargetGroupTuple -> ShowS
[TargetGroupTuple] -> ShowS
TargetGroupTuple -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetGroupTuple] -> ShowS
$cshowList :: [TargetGroupTuple] -> ShowS
show :: TargetGroupTuple -> String
$cshow :: TargetGroupTuple -> String
showsPrec :: Int -> TargetGroupTuple -> ShowS
$cshowsPrec :: Int -> TargetGroupTuple -> ShowS
Prelude.Show, forall x. Rep TargetGroupTuple x -> TargetGroupTuple
forall x. TargetGroupTuple -> Rep TargetGroupTuple x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetGroupTuple x -> TargetGroupTuple
$cfrom :: forall x. TargetGroupTuple -> Rep TargetGroupTuple x
Prelude.Generic)

-- |
-- Create a value of 'TargetGroupTuple' 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:
--
-- 'targetGroupArn', 'targetGroupTuple_targetGroupArn' - The Amazon Resource Name (ARN) of the target group.
--
-- 'weight', 'targetGroupTuple_weight' - The weight. The range is 0 to 999.
newTargetGroupTuple ::
  TargetGroupTuple
newTargetGroupTuple :: TargetGroupTuple
newTargetGroupTuple =
  TargetGroupTuple'
    { $sel:targetGroupArn:TargetGroupTuple' :: Maybe Text
targetGroupArn = forall a. Maybe a
Prelude.Nothing,
      $sel:weight:TargetGroupTuple' :: Maybe Int
weight = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the target group.
targetGroupTuple_targetGroupArn :: Lens.Lens' TargetGroupTuple (Prelude.Maybe Prelude.Text)
targetGroupTuple_targetGroupArn :: Lens' TargetGroupTuple (Maybe Text)
targetGroupTuple_targetGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetGroupTuple' {Maybe Text
targetGroupArn :: Maybe Text
$sel:targetGroupArn:TargetGroupTuple' :: TargetGroupTuple -> Maybe Text
targetGroupArn} -> Maybe Text
targetGroupArn) (\s :: TargetGroupTuple
s@TargetGroupTuple' {} Maybe Text
a -> TargetGroupTuple
s {$sel:targetGroupArn:TargetGroupTuple' :: Maybe Text
targetGroupArn = Maybe Text
a} :: TargetGroupTuple)

-- | The weight. The range is 0 to 999.
targetGroupTuple_weight :: Lens.Lens' TargetGroupTuple (Prelude.Maybe Prelude.Int)
targetGroupTuple_weight :: Lens' TargetGroupTuple (Maybe Int)
targetGroupTuple_weight = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetGroupTuple' {Maybe Int
weight :: Maybe Int
$sel:weight:TargetGroupTuple' :: TargetGroupTuple -> Maybe Int
weight} -> Maybe Int
weight) (\s :: TargetGroupTuple
s@TargetGroupTuple' {} Maybe Int
a -> TargetGroupTuple
s {$sel:weight:TargetGroupTuple' :: Maybe Int
weight = Maybe Int
a} :: TargetGroupTuple)

instance Data.FromXML TargetGroupTuple where
  parseXML :: [Node] -> Either String TargetGroupTuple
parseXML [Node]
x =
    Maybe Text -> Maybe Int -> TargetGroupTuple
TargetGroupTuple'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"TargetGroupArn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Weight")

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

instance Prelude.NFData TargetGroupTuple where
  rnf :: TargetGroupTuple -> ()
rnf TargetGroupTuple' {Maybe Int
Maybe Text
weight :: Maybe Int
targetGroupArn :: Maybe Text
$sel:weight:TargetGroupTuple' :: TargetGroupTuple -> Maybe Int
$sel:targetGroupArn:TargetGroupTuple' :: TargetGroupTuple -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetGroupArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
weight

instance Data.ToQuery TargetGroupTuple where
  toQuery :: TargetGroupTuple -> QueryString
toQuery TargetGroupTuple' {Maybe Int
Maybe Text
weight :: Maybe Int
targetGroupArn :: Maybe Text
$sel:weight:TargetGroupTuple' :: TargetGroupTuple -> Maybe Int
$sel:targetGroupArn:TargetGroupTuple' :: TargetGroupTuple -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"TargetGroupArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
targetGroupArn,
        ByteString
"Weight" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
weight
      ]