{-# 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-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.ELBV2.Types.TargetGroupTuple where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 weight. The range is 0 to 999.
    TargetGroupTuple -> Maybe Int
weight :: Prelude.Maybe Prelude.Int,
    -- | The Amazon Resource Name (ARN) of the target group.
    TargetGroupTuple -> Maybe Text
targetGroupArn :: Prelude.Maybe Prelude.Text
  }
  deriving (TargetGroupTuple -> TargetGroupTuple -> Bool
(TargetGroupTuple -> TargetGroupTuple -> Bool)
-> (TargetGroupTuple -> TargetGroupTuple -> Bool)
-> Eq TargetGroupTuple
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]
(Int -> ReadS TargetGroupTuple)
-> ReadS [TargetGroupTuple]
-> ReadPrec TargetGroupTuple
-> ReadPrec [TargetGroupTuple]
-> Read 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
(Int -> TargetGroupTuple -> ShowS)
-> (TargetGroupTuple -> String)
-> ([TargetGroupTuple] -> ShowS)
-> Show TargetGroupTuple
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. TargetGroupTuple -> Rep TargetGroupTuple x)
-> (forall x. Rep TargetGroupTuple x -> TargetGroupTuple)
-> Generic TargetGroupTuple
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:
--
-- 'weight', 'targetGroupTuple_weight' - The weight. The range is 0 to 999.
--
-- 'targetGroupArn', 'targetGroupTuple_targetGroupArn' - The Amazon Resource Name (ARN) of the target group.
newTargetGroupTuple ::
  TargetGroupTuple
newTargetGroupTuple :: TargetGroupTuple
newTargetGroupTuple =
  TargetGroupTuple' :: Maybe Int -> Maybe Text -> TargetGroupTuple
TargetGroupTuple'
    { $sel:weight:TargetGroupTuple' :: Maybe Int
weight = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:targetGroupArn:TargetGroupTuple' :: Maybe Text
targetGroupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The weight. The range is 0 to 999.
targetGroupTuple_weight :: Lens.Lens' TargetGroupTuple (Prelude.Maybe Prelude.Int)
targetGroupTuple_weight :: (Maybe Int -> f (Maybe Int))
-> TargetGroupTuple -> f TargetGroupTuple
targetGroupTuple_weight = (TargetGroupTuple -> Maybe Int)
-> (TargetGroupTuple -> Maybe Int -> TargetGroupTuple)
-> Lens TargetGroupTuple TargetGroupTuple (Maybe Int) (Maybe Int)
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)

-- | The Amazon Resource Name (ARN) of the target group.
targetGroupTuple_targetGroupArn :: Lens.Lens' TargetGroupTuple (Prelude.Maybe Prelude.Text)
targetGroupTuple_targetGroupArn :: (Maybe Text -> f (Maybe Text))
-> TargetGroupTuple -> f TargetGroupTuple
targetGroupTuple_targetGroupArn = (TargetGroupTuple -> Maybe Text)
-> (TargetGroupTuple -> Maybe Text -> TargetGroupTuple)
-> Lens TargetGroupTuple TargetGroupTuple (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable TargetGroupTuple

instance Prelude.NFData TargetGroupTuple

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