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

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

-- | Information about a listener. The listener contains the path used to
-- route traffic that is received from the load balancer to a target group.
--
-- /See:/ 'newTrafficRoute' smart constructor.
data TrafficRoute = TrafficRoute'
  { -- | The Amazon Resource Name (ARN) of one listener. The listener identifies
    -- the route between a target group and a load balancer. This is an array
    -- of strings with a maximum size of one.
    TrafficRoute -> Maybe [Text]
listenerArns :: Prelude.Maybe [Prelude.Text]
  }
  deriving (TrafficRoute -> TrafficRoute -> Bool
(TrafficRoute -> TrafficRoute -> Bool)
-> (TrafficRoute -> TrafficRoute -> Bool) -> Eq TrafficRoute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrafficRoute -> TrafficRoute -> Bool
$c/= :: TrafficRoute -> TrafficRoute -> Bool
== :: TrafficRoute -> TrafficRoute -> Bool
$c== :: TrafficRoute -> TrafficRoute -> Bool
Prelude.Eq, ReadPrec [TrafficRoute]
ReadPrec TrafficRoute
Int -> ReadS TrafficRoute
ReadS [TrafficRoute]
(Int -> ReadS TrafficRoute)
-> ReadS [TrafficRoute]
-> ReadPrec TrafficRoute
-> ReadPrec [TrafficRoute]
-> Read TrafficRoute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrafficRoute]
$creadListPrec :: ReadPrec [TrafficRoute]
readPrec :: ReadPrec TrafficRoute
$creadPrec :: ReadPrec TrafficRoute
readList :: ReadS [TrafficRoute]
$creadList :: ReadS [TrafficRoute]
readsPrec :: Int -> ReadS TrafficRoute
$creadsPrec :: Int -> ReadS TrafficRoute
Prelude.Read, Int -> TrafficRoute -> ShowS
[TrafficRoute] -> ShowS
TrafficRoute -> String
(Int -> TrafficRoute -> ShowS)
-> (TrafficRoute -> String)
-> ([TrafficRoute] -> ShowS)
-> Show TrafficRoute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrafficRoute] -> ShowS
$cshowList :: [TrafficRoute] -> ShowS
show :: TrafficRoute -> String
$cshow :: TrafficRoute -> String
showsPrec :: Int -> TrafficRoute -> ShowS
$cshowsPrec :: Int -> TrafficRoute -> ShowS
Prelude.Show, (forall x. TrafficRoute -> Rep TrafficRoute x)
-> (forall x. Rep TrafficRoute x -> TrafficRoute)
-> Generic TrafficRoute
forall x. Rep TrafficRoute x -> TrafficRoute
forall x. TrafficRoute -> Rep TrafficRoute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrafficRoute x -> TrafficRoute
$cfrom :: forall x. TrafficRoute -> Rep TrafficRoute x
Prelude.Generic)

-- |
-- Create a value of 'TrafficRoute' 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:
--
-- 'listenerArns', 'trafficRoute_listenerArns' - The Amazon Resource Name (ARN) of one listener. The listener identifies
-- the route between a target group and a load balancer. This is an array
-- of strings with a maximum size of one.
newTrafficRoute ::
  TrafficRoute
newTrafficRoute :: TrafficRoute
newTrafficRoute =
  TrafficRoute' :: Maybe [Text] -> TrafficRoute
TrafficRoute' {$sel:listenerArns:TrafficRoute' :: Maybe [Text]
listenerArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing}

-- | The Amazon Resource Name (ARN) of one listener. The listener identifies
-- the route between a target group and a load balancer. This is an array
-- of strings with a maximum size of one.
trafficRoute_listenerArns :: Lens.Lens' TrafficRoute (Prelude.Maybe [Prelude.Text])
trafficRoute_listenerArns :: (Maybe [Text] -> f (Maybe [Text]))
-> TrafficRoute -> f TrafficRoute
trafficRoute_listenerArns = (TrafficRoute -> Maybe [Text])
-> (TrafficRoute -> Maybe [Text] -> TrafficRoute)
-> Lens TrafficRoute TrafficRoute (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficRoute' {Maybe [Text]
listenerArns :: Maybe [Text]
$sel:listenerArns:TrafficRoute' :: TrafficRoute -> Maybe [Text]
listenerArns} -> Maybe [Text]
listenerArns) (\s :: TrafficRoute
s@TrafficRoute' {} Maybe [Text]
a -> TrafficRoute
s {$sel:listenerArns:TrafficRoute' :: Maybe [Text]
listenerArns = Maybe [Text]
a} :: TrafficRoute) ((Maybe [Text] -> f (Maybe [Text]))
 -> TrafficRoute -> f TrafficRoute)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> TrafficRoute
-> f TrafficRoute
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable TrafficRoute

instance Prelude.NFData TrafficRoute

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