{-# 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.GlobalAccelerator.Types.CustomRoutingEndpointGroup
-- 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.GlobalAccelerator.Types.CustomRoutingEndpointGroup where

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.Types.CustomRoutingDestinationDescription
import Amazonka.GlobalAccelerator.Types.CustomRoutingEndpointDescription
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A complex type for the endpoint group for a custom routing accelerator.
-- An AWS Region can have only one endpoint group for a specific listener.
--
-- /See:/ 'newCustomRoutingEndpointGroup' smart constructor.
data CustomRoutingEndpointGroup = CustomRoutingEndpointGroup'
  { -- | The Amazon Resource Name (ARN) of the endpoint group.
    CustomRoutingEndpointGroup -> Maybe Text
endpointGroupArn :: Prelude.Maybe Prelude.Text,
    -- | The AWS Region where the endpoint group is located.
    CustomRoutingEndpointGroup -> Maybe Text
endpointGroupRegion :: Prelude.Maybe Prelude.Text,
    -- | For a custom routing accelerator, describes the endpoints (virtual
    -- private cloud subnets) in an endpoint group to accept client traffic on.
    CustomRoutingEndpointGroup
-> Maybe [CustomRoutingEndpointDescription]
endpointDescriptions :: Prelude.Maybe [CustomRoutingEndpointDescription],
    -- | For a custom routing accelerator, describes the port range and protocol
    -- for all endpoints (virtual private cloud subnets) in an endpoint group
    -- to accept client traffic on.
    CustomRoutingEndpointGroup
-> Maybe [CustomRoutingDestinationDescription]
destinationDescriptions :: Prelude.Maybe [CustomRoutingDestinationDescription]
  }
  deriving (CustomRoutingEndpointGroup -> CustomRoutingEndpointGroup -> Bool
(CustomRoutingEndpointGroup -> CustomRoutingEndpointGroup -> Bool)
-> (CustomRoutingEndpointGroup
    -> CustomRoutingEndpointGroup -> Bool)
-> Eq CustomRoutingEndpointGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomRoutingEndpointGroup -> CustomRoutingEndpointGroup -> Bool
$c/= :: CustomRoutingEndpointGroup -> CustomRoutingEndpointGroup -> Bool
== :: CustomRoutingEndpointGroup -> CustomRoutingEndpointGroup -> Bool
$c== :: CustomRoutingEndpointGroup -> CustomRoutingEndpointGroup -> Bool
Prelude.Eq, ReadPrec [CustomRoutingEndpointGroup]
ReadPrec CustomRoutingEndpointGroup
Int -> ReadS CustomRoutingEndpointGroup
ReadS [CustomRoutingEndpointGroup]
(Int -> ReadS CustomRoutingEndpointGroup)
-> ReadS [CustomRoutingEndpointGroup]
-> ReadPrec CustomRoutingEndpointGroup
-> ReadPrec [CustomRoutingEndpointGroup]
-> Read CustomRoutingEndpointGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomRoutingEndpointGroup]
$creadListPrec :: ReadPrec [CustomRoutingEndpointGroup]
readPrec :: ReadPrec CustomRoutingEndpointGroup
$creadPrec :: ReadPrec CustomRoutingEndpointGroup
readList :: ReadS [CustomRoutingEndpointGroup]
$creadList :: ReadS [CustomRoutingEndpointGroup]
readsPrec :: Int -> ReadS CustomRoutingEndpointGroup
$creadsPrec :: Int -> ReadS CustomRoutingEndpointGroup
Prelude.Read, Int -> CustomRoutingEndpointGroup -> ShowS
[CustomRoutingEndpointGroup] -> ShowS
CustomRoutingEndpointGroup -> String
(Int -> CustomRoutingEndpointGroup -> ShowS)
-> (CustomRoutingEndpointGroup -> String)
-> ([CustomRoutingEndpointGroup] -> ShowS)
-> Show CustomRoutingEndpointGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomRoutingEndpointGroup] -> ShowS
$cshowList :: [CustomRoutingEndpointGroup] -> ShowS
show :: CustomRoutingEndpointGroup -> String
$cshow :: CustomRoutingEndpointGroup -> String
showsPrec :: Int -> CustomRoutingEndpointGroup -> ShowS
$cshowsPrec :: Int -> CustomRoutingEndpointGroup -> ShowS
Prelude.Show, (forall x.
 CustomRoutingEndpointGroup -> Rep CustomRoutingEndpointGroup x)
-> (forall x.
    Rep CustomRoutingEndpointGroup x -> CustomRoutingEndpointGroup)
-> Generic CustomRoutingEndpointGroup
forall x.
Rep CustomRoutingEndpointGroup x -> CustomRoutingEndpointGroup
forall x.
CustomRoutingEndpointGroup -> Rep CustomRoutingEndpointGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomRoutingEndpointGroup x -> CustomRoutingEndpointGroup
$cfrom :: forall x.
CustomRoutingEndpointGroup -> Rep CustomRoutingEndpointGroup x
Prelude.Generic)

-- |
-- Create a value of 'CustomRoutingEndpointGroup' 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:
--
-- 'endpointGroupArn', 'customRoutingEndpointGroup_endpointGroupArn' - The Amazon Resource Name (ARN) of the endpoint group.
--
-- 'endpointGroupRegion', 'customRoutingEndpointGroup_endpointGroupRegion' - The AWS Region where the endpoint group is located.
--
-- 'endpointDescriptions', 'customRoutingEndpointGroup_endpointDescriptions' - For a custom routing accelerator, describes the endpoints (virtual
-- private cloud subnets) in an endpoint group to accept client traffic on.
--
-- 'destinationDescriptions', 'customRoutingEndpointGroup_destinationDescriptions' - For a custom routing accelerator, describes the port range and protocol
-- for all endpoints (virtual private cloud subnets) in an endpoint group
-- to accept client traffic on.
newCustomRoutingEndpointGroup ::
  CustomRoutingEndpointGroup
newCustomRoutingEndpointGroup :: CustomRoutingEndpointGroup
newCustomRoutingEndpointGroup =
  CustomRoutingEndpointGroup' :: Maybe Text
-> Maybe Text
-> Maybe [CustomRoutingEndpointDescription]
-> Maybe [CustomRoutingDestinationDescription]
-> CustomRoutingEndpointGroup
CustomRoutingEndpointGroup'
    { $sel:endpointGroupArn:CustomRoutingEndpointGroup' :: Maybe Text
endpointGroupArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointGroupRegion:CustomRoutingEndpointGroup' :: Maybe Text
endpointGroupRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointDescriptions:CustomRoutingEndpointGroup' :: Maybe [CustomRoutingEndpointDescription]
endpointDescriptions = Maybe [CustomRoutingEndpointDescription]
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationDescriptions:CustomRoutingEndpointGroup' :: Maybe [CustomRoutingDestinationDescription]
destinationDescriptions = Maybe [CustomRoutingDestinationDescription]
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the endpoint group.
customRoutingEndpointGroup_endpointGroupArn :: Lens.Lens' CustomRoutingEndpointGroup (Prelude.Maybe Prelude.Text)
customRoutingEndpointGroup_endpointGroupArn :: (Maybe Text -> f (Maybe Text))
-> CustomRoutingEndpointGroup -> f CustomRoutingEndpointGroup
customRoutingEndpointGroup_endpointGroupArn = (CustomRoutingEndpointGroup -> Maybe Text)
-> (CustomRoutingEndpointGroup
    -> Maybe Text -> CustomRoutingEndpointGroup)
-> Lens
     CustomRoutingEndpointGroup
     CustomRoutingEndpointGroup
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRoutingEndpointGroup' {Maybe Text
endpointGroupArn :: Maybe Text
$sel:endpointGroupArn:CustomRoutingEndpointGroup' :: CustomRoutingEndpointGroup -> Maybe Text
endpointGroupArn} -> Maybe Text
endpointGroupArn) (\s :: CustomRoutingEndpointGroup
s@CustomRoutingEndpointGroup' {} Maybe Text
a -> CustomRoutingEndpointGroup
s {$sel:endpointGroupArn:CustomRoutingEndpointGroup' :: Maybe Text
endpointGroupArn = Maybe Text
a} :: CustomRoutingEndpointGroup)

-- | The AWS Region where the endpoint group is located.
customRoutingEndpointGroup_endpointGroupRegion :: Lens.Lens' CustomRoutingEndpointGroup (Prelude.Maybe Prelude.Text)
customRoutingEndpointGroup_endpointGroupRegion :: (Maybe Text -> f (Maybe Text))
-> CustomRoutingEndpointGroup -> f CustomRoutingEndpointGroup
customRoutingEndpointGroup_endpointGroupRegion = (CustomRoutingEndpointGroup -> Maybe Text)
-> (CustomRoutingEndpointGroup
    -> Maybe Text -> CustomRoutingEndpointGroup)
-> Lens
     CustomRoutingEndpointGroup
     CustomRoutingEndpointGroup
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRoutingEndpointGroup' {Maybe Text
endpointGroupRegion :: Maybe Text
$sel:endpointGroupRegion:CustomRoutingEndpointGroup' :: CustomRoutingEndpointGroup -> Maybe Text
endpointGroupRegion} -> Maybe Text
endpointGroupRegion) (\s :: CustomRoutingEndpointGroup
s@CustomRoutingEndpointGroup' {} Maybe Text
a -> CustomRoutingEndpointGroup
s {$sel:endpointGroupRegion:CustomRoutingEndpointGroup' :: Maybe Text
endpointGroupRegion = Maybe Text
a} :: CustomRoutingEndpointGroup)

-- | For a custom routing accelerator, describes the endpoints (virtual
-- private cloud subnets) in an endpoint group to accept client traffic on.
customRoutingEndpointGroup_endpointDescriptions :: Lens.Lens' CustomRoutingEndpointGroup (Prelude.Maybe [CustomRoutingEndpointDescription])
customRoutingEndpointGroup_endpointDescriptions :: (Maybe [CustomRoutingEndpointDescription]
 -> f (Maybe [CustomRoutingEndpointDescription]))
-> CustomRoutingEndpointGroup -> f CustomRoutingEndpointGroup
customRoutingEndpointGroup_endpointDescriptions = (CustomRoutingEndpointGroup
 -> Maybe [CustomRoutingEndpointDescription])
-> (CustomRoutingEndpointGroup
    -> Maybe [CustomRoutingEndpointDescription]
    -> CustomRoutingEndpointGroup)
-> Lens
     CustomRoutingEndpointGroup
     CustomRoutingEndpointGroup
     (Maybe [CustomRoutingEndpointDescription])
     (Maybe [CustomRoutingEndpointDescription])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRoutingEndpointGroup' {Maybe [CustomRoutingEndpointDescription]
endpointDescriptions :: Maybe [CustomRoutingEndpointDescription]
$sel:endpointDescriptions:CustomRoutingEndpointGroup' :: CustomRoutingEndpointGroup
-> Maybe [CustomRoutingEndpointDescription]
endpointDescriptions} -> Maybe [CustomRoutingEndpointDescription]
endpointDescriptions) (\s :: CustomRoutingEndpointGroup
s@CustomRoutingEndpointGroup' {} Maybe [CustomRoutingEndpointDescription]
a -> CustomRoutingEndpointGroup
s {$sel:endpointDescriptions:CustomRoutingEndpointGroup' :: Maybe [CustomRoutingEndpointDescription]
endpointDescriptions = Maybe [CustomRoutingEndpointDescription]
a} :: CustomRoutingEndpointGroup) ((Maybe [CustomRoutingEndpointDescription]
  -> f (Maybe [CustomRoutingEndpointDescription]))
 -> CustomRoutingEndpointGroup -> f CustomRoutingEndpointGroup)
-> ((Maybe [CustomRoutingEndpointDescription]
     -> f (Maybe [CustomRoutingEndpointDescription]))
    -> Maybe [CustomRoutingEndpointDescription]
    -> f (Maybe [CustomRoutingEndpointDescription]))
-> (Maybe [CustomRoutingEndpointDescription]
    -> f (Maybe [CustomRoutingEndpointDescription]))
-> CustomRoutingEndpointGroup
-> f CustomRoutingEndpointGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CustomRoutingEndpointDescription]
  [CustomRoutingEndpointDescription]
  [CustomRoutingEndpointDescription]
  [CustomRoutingEndpointDescription]
-> Iso
     (Maybe [CustomRoutingEndpointDescription])
     (Maybe [CustomRoutingEndpointDescription])
     (Maybe [CustomRoutingEndpointDescription])
     (Maybe [CustomRoutingEndpointDescription])
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
  [CustomRoutingEndpointDescription]
  [CustomRoutingEndpointDescription]
  [CustomRoutingEndpointDescription]
  [CustomRoutingEndpointDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | For a custom routing accelerator, describes the port range and protocol
-- for all endpoints (virtual private cloud subnets) in an endpoint group
-- to accept client traffic on.
customRoutingEndpointGroup_destinationDescriptions :: Lens.Lens' CustomRoutingEndpointGroup (Prelude.Maybe [CustomRoutingDestinationDescription])
customRoutingEndpointGroup_destinationDescriptions :: (Maybe [CustomRoutingDestinationDescription]
 -> f (Maybe [CustomRoutingDestinationDescription]))
-> CustomRoutingEndpointGroup -> f CustomRoutingEndpointGroup
customRoutingEndpointGroup_destinationDescriptions = (CustomRoutingEndpointGroup
 -> Maybe [CustomRoutingDestinationDescription])
-> (CustomRoutingEndpointGroup
    -> Maybe [CustomRoutingDestinationDescription]
    -> CustomRoutingEndpointGroup)
-> Lens
     CustomRoutingEndpointGroup
     CustomRoutingEndpointGroup
     (Maybe [CustomRoutingDestinationDescription])
     (Maybe [CustomRoutingDestinationDescription])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRoutingEndpointGroup' {Maybe [CustomRoutingDestinationDescription]
destinationDescriptions :: Maybe [CustomRoutingDestinationDescription]
$sel:destinationDescriptions:CustomRoutingEndpointGroup' :: CustomRoutingEndpointGroup
-> Maybe [CustomRoutingDestinationDescription]
destinationDescriptions} -> Maybe [CustomRoutingDestinationDescription]
destinationDescriptions) (\s :: CustomRoutingEndpointGroup
s@CustomRoutingEndpointGroup' {} Maybe [CustomRoutingDestinationDescription]
a -> CustomRoutingEndpointGroup
s {$sel:destinationDescriptions:CustomRoutingEndpointGroup' :: Maybe [CustomRoutingDestinationDescription]
destinationDescriptions = Maybe [CustomRoutingDestinationDescription]
a} :: CustomRoutingEndpointGroup) ((Maybe [CustomRoutingDestinationDescription]
  -> f (Maybe [CustomRoutingDestinationDescription]))
 -> CustomRoutingEndpointGroup -> f CustomRoutingEndpointGroup)
-> ((Maybe [CustomRoutingDestinationDescription]
     -> f (Maybe [CustomRoutingDestinationDescription]))
    -> Maybe [CustomRoutingDestinationDescription]
    -> f (Maybe [CustomRoutingDestinationDescription]))
-> (Maybe [CustomRoutingDestinationDescription]
    -> f (Maybe [CustomRoutingDestinationDescription]))
-> CustomRoutingEndpointGroup
-> f CustomRoutingEndpointGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CustomRoutingDestinationDescription]
  [CustomRoutingDestinationDescription]
  [CustomRoutingDestinationDescription]
  [CustomRoutingDestinationDescription]
-> Iso
     (Maybe [CustomRoutingDestinationDescription])
     (Maybe [CustomRoutingDestinationDescription])
     (Maybe [CustomRoutingDestinationDescription])
     (Maybe [CustomRoutingDestinationDescription])
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
  [CustomRoutingDestinationDescription]
  [CustomRoutingDestinationDescription]
  [CustomRoutingDestinationDescription]
  [CustomRoutingDestinationDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON CustomRoutingEndpointGroup where
  parseJSON :: Value -> Parser CustomRoutingEndpointGroup
parseJSON =
    String
-> (Object -> Parser CustomRoutingEndpointGroup)
-> Value
-> Parser CustomRoutingEndpointGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomRoutingEndpointGroup"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [CustomRoutingEndpointDescription]
-> Maybe [CustomRoutingDestinationDescription]
-> CustomRoutingEndpointGroup
CustomRoutingEndpointGroup'
            (Maybe Text
 -> Maybe Text
 -> Maybe [CustomRoutingEndpointDescription]
 -> Maybe [CustomRoutingDestinationDescription]
 -> CustomRoutingEndpointGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [CustomRoutingEndpointDescription]
      -> Maybe [CustomRoutingDestinationDescription]
      -> CustomRoutingEndpointGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndpointGroupArn")
            Parser
  (Maybe Text
   -> Maybe [CustomRoutingEndpointDescription]
   -> Maybe [CustomRoutingDestinationDescription]
   -> CustomRoutingEndpointGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe [CustomRoutingEndpointDescription]
      -> Maybe [CustomRoutingDestinationDescription]
      -> CustomRoutingEndpointGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndpointGroupRegion")
            Parser
  (Maybe [CustomRoutingEndpointDescription]
   -> Maybe [CustomRoutingDestinationDescription]
   -> CustomRoutingEndpointGroup)
-> Parser (Maybe [CustomRoutingEndpointDescription])
-> Parser
     (Maybe [CustomRoutingDestinationDescription]
      -> CustomRoutingEndpointGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text
-> Parser (Maybe (Maybe [CustomRoutingEndpointDescription]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndpointDescriptions"
                            Parser (Maybe (Maybe [CustomRoutingEndpointDescription]))
-> Maybe [CustomRoutingEndpointDescription]
-> Parser (Maybe [CustomRoutingEndpointDescription])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CustomRoutingEndpointDescription]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [CustomRoutingDestinationDescription]
   -> CustomRoutingEndpointGroup)
-> Parser (Maybe [CustomRoutingDestinationDescription])
-> Parser CustomRoutingEndpointGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text
-> Parser (Maybe (Maybe [CustomRoutingDestinationDescription]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DestinationDescriptions"
                            Parser (Maybe (Maybe [CustomRoutingDestinationDescription]))
-> Maybe [CustomRoutingDestinationDescription]
-> Parser (Maybe [CustomRoutingDestinationDescription])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CustomRoutingDestinationDescription]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable CustomRoutingEndpointGroup

instance Prelude.NFData CustomRoutingEndpointGroup