{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.ListCustomRoutingPortMappings
-- 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)
--
-- Provides a complete mapping from the public accelerator IP address and
-- port to destination EC2 instance IP addresses and ports in the virtual
-- public cloud (VPC) subnet endpoint for a custom routing accelerator. For
-- each subnet endpoint that you add, Global Accelerator creates a new
-- static port mapping for the accelerator. The port mappings don\'t change
-- after Global Accelerator generates them, so you can retrieve and cache
-- the full mapping on your servers.
--
-- If you remove a subnet from your accelerator, Global Accelerator removes
-- (reclaims) the port mappings. If you add a subnet to your accelerator,
-- Global Accelerator creates new port mappings (the existing ones don\'t
-- change). If you add or remove EC2 instances in your subnet, the port
-- mappings don\'t change, because the mappings are created when you add
-- the subnet to Global Accelerator.
--
-- The mappings also include a flag for each destination denoting which
-- destination IP addresses and ports are allowed or denied traffic.
--
-- This operation returns paginated results.
module Amazonka.GlobalAccelerator.ListCustomRoutingPortMappings
  ( -- * Creating a Request
    ListCustomRoutingPortMappings (..),
    newListCustomRoutingPortMappings,

    -- * Request Lenses
    listCustomRoutingPortMappings_endpointGroupArn,
    listCustomRoutingPortMappings_nextToken,
    listCustomRoutingPortMappings_maxResults,
    listCustomRoutingPortMappings_acceleratorArn,

    -- * Destructuring the Response
    ListCustomRoutingPortMappingsResponse (..),
    newListCustomRoutingPortMappingsResponse,

    -- * Response Lenses
    listCustomRoutingPortMappingsResponse_portMappings,
    listCustomRoutingPortMappingsResponse_nextToken,
    listCustomRoutingPortMappingsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListCustomRoutingPortMappings' smart constructor.
data ListCustomRoutingPortMappings = ListCustomRoutingPortMappings'
  { -- | The Amazon Resource Name (ARN) of the endpoint group to list the custom
    -- routing port mappings for.
    ListCustomRoutingPortMappings -> Maybe Text
endpointGroupArn :: Prelude.Maybe Prelude.Text,
    -- | The token for the next set of results. You receive this token from a
    -- previous call.
    ListCustomRoutingPortMappings -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The number of destination port mappings that you want to return with
    -- this call. The default value is 10.
    ListCustomRoutingPortMappings -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name (ARN) of the accelerator to list the custom
    -- routing port mappings for.
    ListCustomRoutingPortMappings -> Text
acceleratorArn :: Prelude.Text
  }
  deriving (ListCustomRoutingPortMappings
-> ListCustomRoutingPortMappings -> Bool
(ListCustomRoutingPortMappings
 -> ListCustomRoutingPortMappings -> Bool)
-> (ListCustomRoutingPortMappings
    -> ListCustomRoutingPortMappings -> Bool)
-> Eq ListCustomRoutingPortMappings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCustomRoutingPortMappings
-> ListCustomRoutingPortMappings -> Bool
$c/= :: ListCustomRoutingPortMappings
-> ListCustomRoutingPortMappings -> Bool
== :: ListCustomRoutingPortMappings
-> ListCustomRoutingPortMappings -> Bool
$c== :: ListCustomRoutingPortMappings
-> ListCustomRoutingPortMappings -> Bool
Prelude.Eq, ReadPrec [ListCustomRoutingPortMappings]
ReadPrec ListCustomRoutingPortMappings
Int -> ReadS ListCustomRoutingPortMappings
ReadS [ListCustomRoutingPortMappings]
(Int -> ReadS ListCustomRoutingPortMappings)
-> ReadS [ListCustomRoutingPortMappings]
-> ReadPrec ListCustomRoutingPortMappings
-> ReadPrec [ListCustomRoutingPortMappings]
-> Read ListCustomRoutingPortMappings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCustomRoutingPortMappings]
$creadListPrec :: ReadPrec [ListCustomRoutingPortMappings]
readPrec :: ReadPrec ListCustomRoutingPortMappings
$creadPrec :: ReadPrec ListCustomRoutingPortMappings
readList :: ReadS [ListCustomRoutingPortMappings]
$creadList :: ReadS [ListCustomRoutingPortMappings]
readsPrec :: Int -> ReadS ListCustomRoutingPortMappings
$creadsPrec :: Int -> ReadS ListCustomRoutingPortMappings
Prelude.Read, Int -> ListCustomRoutingPortMappings -> ShowS
[ListCustomRoutingPortMappings] -> ShowS
ListCustomRoutingPortMappings -> String
(Int -> ListCustomRoutingPortMappings -> ShowS)
-> (ListCustomRoutingPortMappings -> String)
-> ([ListCustomRoutingPortMappings] -> ShowS)
-> Show ListCustomRoutingPortMappings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCustomRoutingPortMappings] -> ShowS
$cshowList :: [ListCustomRoutingPortMappings] -> ShowS
show :: ListCustomRoutingPortMappings -> String
$cshow :: ListCustomRoutingPortMappings -> String
showsPrec :: Int -> ListCustomRoutingPortMappings -> ShowS
$cshowsPrec :: Int -> ListCustomRoutingPortMappings -> ShowS
Prelude.Show, (forall x.
 ListCustomRoutingPortMappings
 -> Rep ListCustomRoutingPortMappings x)
-> (forall x.
    Rep ListCustomRoutingPortMappings x
    -> ListCustomRoutingPortMappings)
-> Generic ListCustomRoutingPortMappings
forall x.
Rep ListCustomRoutingPortMappings x
-> ListCustomRoutingPortMappings
forall x.
ListCustomRoutingPortMappings
-> Rep ListCustomRoutingPortMappings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListCustomRoutingPortMappings x
-> ListCustomRoutingPortMappings
$cfrom :: forall x.
ListCustomRoutingPortMappings
-> Rep ListCustomRoutingPortMappings x
Prelude.Generic)

-- |
-- Create a value of 'ListCustomRoutingPortMappings' 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', 'listCustomRoutingPortMappings_endpointGroupArn' - The Amazon Resource Name (ARN) of the endpoint group to list the custom
-- routing port mappings for.
--
-- 'nextToken', 'listCustomRoutingPortMappings_nextToken' - The token for the next set of results. You receive this token from a
-- previous call.
--
-- 'maxResults', 'listCustomRoutingPortMappings_maxResults' - The number of destination port mappings that you want to return with
-- this call. The default value is 10.
--
-- 'acceleratorArn', 'listCustomRoutingPortMappings_acceleratorArn' - The Amazon Resource Name (ARN) of the accelerator to list the custom
-- routing port mappings for.
newListCustomRoutingPortMappings ::
  -- | 'acceleratorArn'
  Prelude.Text ->
  ListCustomRoutingPortMappings
newListCustomRoutingPortMappings :: Text -> ListCustomRoutingPortMappings
newListCustomRoutingPortMappings Text
pAcceleratorArn_ =
  ListCustomRoutingPortMappings' :: Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> ListCustomRoutingPortMappings
ListCustomRoutingPortMappings'
    { $sel:endpointGroupArn:ListCustomRoutingPortMappings' :: Maybe Text
endpointGroupArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCustomRoutingPortMappings' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListCustomRoutingPortMappings' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:acceleratorArn:ListCustomRoutingPortMappings' :: Text
acceleratorArn = Text
pAcceleratorArn_
    }

-- | The Amazon Resource Name (ARN) of the endpoint group to list the custom
-- routing port mappings for.
listCustomRoutingPortMappings_endpointGroupArn :: Lens.Lens' ListCustomRoutingPortMappings (Prelude.Maybe Prelude.Text)
listCustomRoutingPortMappings_endpointGroupArn :: (Maybe Text -> f (Maybe Text))
-> ListCustomRoutingPortMappings -> f ListCustomRoutingPortMappings
listCustomRoutingPortMappings_endpointGroupArn = (ListCustomRoutingPortMappings -> Maybe Text)
-> (ListCustomRoutingPortMappings
    -> Maybe Text -> ListCustomRoutingPortMappings)
-> Lens
     ListCustomRoutingPortMappings
     ListCustomRoutingPortMappings
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomRoutingPortMappings' {Maybe Text
endpointGroupArn :: Maybe Text
$sel:endpointGroupArn:ListCustomRoutingPortMappings' :: ListCustomRoutingPortMappings -> Maybe Text
endpointGroupArn} -> Maybe Text
endpointGroupArn) (\s :: ListCustomRoutingPortMappings
s@ListCustomRoutingPortMappings' {} Maybe Text
a -> ListCustomRoutingPortMappings
s {$sel:endpointGroupArn:ListCustomRoutingPortMappings' :: Maybe Text
endpointGroupArn = Maybe Text
a} :: ListCustomRoutingPortMappings)

-- | The token for the next set of results. You receive this token from a
-- previous call.
listCustomRoutingPortMappings_nextToken :: Lens.Lens' ListCustomRoutingPortMappings (Prelude.Maybe Prelude.Text)
listCustomRoutingPortMappings_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListCustomRoutingPortMappings -> f ListCustomRoutingPortMappings
listCustomRoutingPortMappings_nextToken = (ListCustomRoutingPortMappings -> Maybe Text)
-> (ListCustomRoutingPortMappings
    -> Maybe Text -> ListCustomRoutingPortMappings)
-> Lens
     ListCustomRoutingPortMappings
     ListCustomRoutingPortMappings
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomRoutingPortMappings' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCustomRoutingPortMappings' :: ListCustomRoutingPortMappings -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCustomRoutingPortMappings
s@ListCustomRoutingPortMappings' {} Maybe Text
a -> ListCustomRoutingPortMappings
s {$sel:nextToken:ListCustomRoutingPortMappings' :: Maybe Text
nextToken = Maybe Text
a} :: ListCustomRoutingPortMappings)

-- | The number of destination port mappings that you want to return with
-- this call. The default value is 10.
listCustomRoutingPortMappings_maxResults :: Lens.Lens' ListCustomRoutingPortMappings (Prelude.Maybe Prelude.Natural)
listCustomRoutingPortMappings_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListCustomRoutingPortMappings -> f ListCustomRoutingPortMappings
listCustomRoutingPortMappings_maxResults = (ListCustomRoutingPortMappings -> Maybe Natural)
-> (ListCustomRoutingPortMappings
    -> Maybe Natural -> ListCustomRoutingPortMappings)
-> Lens
     ListCustomRoutingPortMappings
     ListCustomRoutingPortMappings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomRoutingPortMappings' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListCustomRoutingPortMappings' :: ListCustomRoutingPortMappings -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListCustomRoutingPortMappings
s@ListCustomRoutingPortMappings' {} Maybe Natural
a -> ListCustomRoutingPortMappings
s {$sel:maxResults:ListCustomRoutingPortMappings' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListCustomRoutingPortMappings)

-- | The Amazon Resource Name (ARN) of the accelerator to list the custom
-- routing port mappings for.
listCustomRoutingPortMappings_acceleratorArn :: Lens.Lens' ListCustomRoutingPortMappings Prelude.Text
listCustomRoutingPortMappings_acceleratorArn :: (Text -> f Text)
-> ListCustomRoutingPortMappings -> f ListCustomRoutingPortMappings
listCustomRoutingPortMappings_acceleratorArn = (ListCustomRoutingPortMappings -> Text)
-> (ListCustomRoutingPortMappings
    -> Text -> ListCustomRoutingPortMappings)
-> Lens
     ListCustomRoutingPortMappings
     ListCustomRoutingPortMappings
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomRoutingPortMappings' {Text
acceleratorArn :: Text
$sel:acceleratorArn:ListCustomRoutingPortMappings' :: ListCustomRoutingPortMappings -> Text
acceleratorArn} -> Text
acceleratorArn) (\s :: ListCustomRoutingPortMappings
s@ListCustomRoutingPortMappings' {} Text
a -> ListCustomRoutingPortMappings
s {$sel:acceleratorArn:ListCustomRoutingPortMappings' :: Text
acceleratorArn = Text
a} :: ListCustomRoutingPortMappings)

instance Core.AWSPager ListCustomRoutingPortMappings where
  page :: ListCustomRoutingPortMappings
-> AWSResponse ListCustomRoutingPortMappings
-> Maybe ListCustomRoutingPortMappings
page ListCustomRoutingPortMappings
rq AWSResponse ListCustomRoutingPortMappings
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListCustomRoutingPortMappings
ListCustomRoutingPortMappingsResponse
rs
            ListCustomRoutingPortMappingsResponse
-> Getting (First Text) ListCustomRoutingPortMappingsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListCustomRoutingPortMappingsResponse
-> Const (First Text) ListCustomRoutingPortMappingsResponse
Lens' ListCustomRoutingPortMappingsResponse (Maybe Text)
listCustomRoutingPortMappingsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListCustomRoutingPortMappingsResponse
 -> Const (First Text) ListCustomRoutingPortMappingsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListCustomRoutingPortMappingsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListCustomRoutingPortMappings
forall a. Maybe a
Prelude.Nothing
    | Maybe [PortMapping] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListCustomRoutingPortMappings
ListCustomRoutingPortMappingsResponse
rs
            ListCustomRoutingPortMappingsResponse
-> Getting
     (First [PortMapping])
     ListCustomRoutingPortMappingsResponse
     [PortMapping]
-> Maybe [PortMapping]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [PortMapping]
 -> Const (First [PortMapping]) (Maybe [PortMapping]))
-> ListCustomRoutingPortMappingsResponse
-> Const
     (First [PortMapping]) ListCustomRoutingPortMappingsResponse
Lens' ListCustomRoutingPortMappingsResponse (Maybe [PortMapping])
listCustomRoutingPortMappingsResponse_portMappings
              ((Maybe [PortMapping]
  -> Const (First [PortMapping]) (Maybe [PortMapping]))
 -> ListCustomRoutingPortMappingsResponse
 -> Const
      (First [PortMapping]) ListCustomRoutingPortMappingsResponse)
-> (([PortMapping] -> Const (First [PortMapping]) [PortMapping])
    -> Maybe [PortMapping]
    -> Const (First [PortMapping]) (Maybe [PortMapping]))
-> Getting
     (First [PortMapping])
     ListCustomRoutingPortMappingsResponse
     [PortMapping]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PortMapping] -> Const (First [PortMapping]) [PortMapping])
-> Maybe [PortMapping]
-> Const (First [PortMapping]) (Maybe [PortMapping])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListCustomRoutingPortMappings
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListCustomRoutingPortMappings
-> Maybe ListCustomRoutingPortMappings
forall a. a -> Maybe a
Prelude.Just (ListCustomRoutingPortMappings
 -> Maybe ListCustomRoutingPortMappings)
-> ListCustomRoutingPortMappings
-> Maybe ListCustomRoutingPortMappings
forall a b. (a -> b) -> a -> b
Prelude.$
        ListCustomRoutingPortMappings
rq
          ListCustomRoutingPortMappings
-> (ListCustomRoutingPortMappings -> ListCustomRoutingPortMappings)
-> ListCustomRoutingPortMappings
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListCustomRoutingPortMappings
-> Identity ListCustomRoutingPortMappings
Lens
  ListCustomRoutingPortMappings
  ListCustomRoutingPortMappings
  (Maybe Text)
  (Maybe Text)
listCustomRoutingPortMappings_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListCustomRoutingPortMappings
 -> Identity ListCustomRoutingPortMappings)
-> Maybe Text
-> ListCustomRoutingPortMappings
-> ListCustomRoutingPortMappings
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListCustomRoutingPortMappings
ListCustomRoutingPortMappingsResponse
rs
          ListCustomRoutingPortMappingsResponse
-> Getting (First Text) ListCustomRoutingPortMappingsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListCustomRoutingPortMappingsResponse
-> Const (First Text) ListCustomRoutingPortMappingsResponse
Lens' ListCustomRoutingPortMappingsResponse (Maybe Text)
listCustomRoutingPortMappingsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListCustomRoutingPortMappingsResponse
 -> Const (First Text) ListCustomRoutingPortMappingsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListCustomRoutingPortMappingsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance
  Core.AWSRequest
    ListCustomRoutingPortMappings
  where
  type
    AWSResponse ListCustomRoutingPortMappings =
      ListCustomRoutingPortMappingsResponse
  request :: ListCustomRoutingPortMappings
-> Request ListCustomRoutingPortMappings
request = Service
-> ListCustomRoutingPortMappings
-> Request ListCustomRoutingPortMappings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListCustomRoutingPortMappings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListCustomRoutingPortMappings)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListCustomRoutingPortMappings))
-> Logger
-> Service
-> Proxy ListCustomRoutingPortMappings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListCustomRoutingPortMappings)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [PortMapping]
-> Maybe Text -> Int -> ListCustomRoutingPortMappingsResponse
ListCustomRoutingPortMappingsResponse'
            (Maybe [PortMapping]
 -> Maybe Text -> Int -> ListCustomRoutingPortMappingsResponse)
-> Either String (Maybe [PortMapping])
-> Either
     String (Maybe Text -> Int -> ListCustomRoutingPortMappingsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [PortMapping]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PortMappings" Either String (Maybe (Maybe [PortMapping]))
-> Maybe [PortMapping] -> Either String (Maybe [PortMapping])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PortMapping]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String (Maybe Text -> Int -> ListCustomRoutingPortMappingsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListCustomRoutingPortMappingsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> ListCustomRoutingPortMappingsResponse)
-> Either String Int
-> Either String ListCustomRoutingPortMappingsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    ListCustomRoutingPortMappings

instance Prelude.NFData ListCustomRoutingPortMappings

instance Core.ToHeaders ListCustomRoutingPortMappings where
  toHeaders :: ListCustomRoutingPortMappings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListCustomRoutingPortMappings -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"GlobalAccelerator_V20180706.ListCustomRoutingPortMappings" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListCustomRoutingPortMappings where
  toJSON :: ListCustomRoutingPortMappings -> Value
toJSON ListCustomRoutingPortMappings' {Maybe Natural
Maybe Text
Text
acceleratorArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
endpointGroupArn :: Maybe Text
$sel:acceleratorArn:ListCustomRoutingPortMappings' :: ListCustomRoutingPortMappings -> Text
$sel:maxResults:ListCustomRoutingPortMappings' :: ListCustomRoutingPortMappings -> Maybe Natural
$sel:nextToken:ListCustomRoutingPortMappings' :: ListCustomRoutingPortMappings -> Maybe Text
$sel:endpointGroupArn:ListCustomRoutingPortMappings' :: ListCustomRoutingPortMappings -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EndpointGroupArn" 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
endpointGroupArn,
            (Text
"NextToken" 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
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AcceleratorArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
acceleratorArn)
          ]
      )

instance Core.ToPath ListCustomRoutingPortMappings where
  toPath :: ListCustomRoutingPortMappings -> ByteString
toPath = ByteString -> ListCustomRoutingPortMappings -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ListCustomRoutingPortMappings where
  toQuery :: ListCustomRoutingPortMappings -> QueryString
toQuery = QueryString -> ListCustomRoutingPortMappings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListCustomRoutingPortMappingsResponse' smart constructor.
data ListCustomRoutingPortMappingsResponse = ListCustomRoutingPortMappingsResponse'
  { -- | The port mappings for a custom routing accelerator.
    ListCustomRoutingPortMappingsResponse -> Maybe [PortMapping]
portMappings :: Prelude.Maybe [PortMapping],
    -- | The token for the next set of results. You receive this token from a
    -- previous call.
    ListCustomRoutingPortMappingsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListCustomRoutingPortMappingsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListCustomRoutingPortMappingsResponse
-> ListCustomRoutingPortMappingsResponse -> Bool
(ListCustomRoutingPortMappingsResponse
 -> ListCustomRoutingPortMappingsResponse -> Bool)
-> (ListCustomRoutingPortMappingsResponse
    -> ListCustomRoutingPortMappingsResponse -> Bool)
-> Eq ListCustomRoutingPortMappingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCustomRoutingPortMappingsResponse
-> ListCustomRoutingPortMappingsResponse -> Bool
$c/= :: ListCustomRoutingPortMappingsResponse
-> ListCustomRoutingPortMappingsResponse -> Bool
== :: ListCustomRoutingPortMappingsResponse
-> ListCustomRoutingPortMappingsResponse -> Bool
$c== :: ListCustomRoutingPortMappingsResponse
-> ListCustomRoutingPortMappingsResponse -> Bool
Prelude.Eq, ReadPrec [ListCustomRoutingPortMappingsResponse]
ReadPrec ListCustomRoutingPortMappingsResponse
Int -> ReadS ListCustomRoutingPortMappingsResponse
ReadS [ListCustomRoutingPortMappingsResponse]
(Int -> ReadS ListCustomRoutingPortMappingsResponse)
-> ReadS [ListCustomRoutingPortMappingsResponse]
-> ReadPrec ListCustomRoutingPortMappingsResponse
-> ReadPrec [ListCustomRoutingPortMappingsResponse]
-> Read ListCustomRoutingPortMappingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCustomRoutingPortMappingsResponse]
$creadListPrec :: ReadPrec [ListCustomRoutingPortMappingsResponse]
readPrec :: ReadPrec ListCustomRoutingPortMappingsResponse
$creadPrec :: ReadPrec ListCustomRoutingPortMappingsResponse
readList :: ReadS [ListCustomRoutingPortMappingsResponse]
$creadList :: ReadS [ListCustomRoutingPortMappingsResponse]
readsPrec :: Int -> ReadS ListCustomRoutingPortMappingsResponse
$creadsPrec :: Int -> ReadS ListCustomRoutingPortMappingsResponse
Prelude.Read, Int -> ListCustomRoutingPortMappingsResponse -> ShowS
[ListCustomRoutingPortMappingsResponse] -> ShowS
ListCustomRoutingPortMappingsResponse -> String
(Int -> ListCustomRoutingPortMappingsResponse -> ShowS)
-> (ListCustomRoutingPortMappingsResponse -> String)
-> ([ListCustomRoutingPortMappingsResponse] -> ShowS)
-> Show ListCustomRoutingPortMappingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCustomRoutingPortMappingsResponse] -> ShowS
$cshowList :: [ListCustomRoutingPortMappingsResponse] -> ShowS
show :: ListCustomRoutingPortMappingsResponse -> String
$cshow :: ListCustomRoutingPortMappingsResponse -> String
showsPrec :: Int -> ListCustomRoutingPortMappingsResponse -> ShowS
$cshowsPrec :: Int -> ListCustomRoutingPortMappingsResponse -> ShowS
Prelude.Show, (forall x.
 ListCustomRoutingPortMappingsResponse
 -> Rep ListCustomRoutingPortMappingsResponse x)
-> (forall x.
    Rep ListCustomRoutingPortMappingsResponse x
    -> ListCustomRoutingPortMappingsResponse)
-> Generic ListCustomRoutingPortMappingsResponse
forall x.
Rep ListCustomRoutingPortMappingsResponse x
-> ListCustomRoutingPortMappingsResponse
forall x.
ListCustomRoutingPortMappingsResponse
-> Rep ListCustomRoutingPortMappingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListCustomRoutingPortMappingsResponse x
-> ListCustomRoutingPortMappingsResponse
$cfrom :: forall x.
ListCustomRoutingPortMappingsResponse
-> Rep ListCustomRoutingPortMappingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListCustomRoutingPortMappingsResponse' 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:
--
-- 'portMappings', 'listCustomRoutingPortMappingsResponse_portMappings' - The port mappings for a custom routing accelerator.
--
-- 'nextToken', 'listCustomRoutingPortMappingsResponse_nextToken' - The token for the next set of results. You receive this token from a
-- previous call.
--
-- 'httpStatus', 'listCustomRoutingPortMappingsResponse_httpStatus' - The response's http status code.
newListCustomRoutingPortMappingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCustomRoutingPortMappingsResponse
newListCustomRoutingPortMappingsResponse :: Int -> ListCustomRoutingPortMappingsResponse
newListCustomRoutingPortMappingsResponse Int
pHttpStatus_ =
  ListCustomRoutingPortMappingsResponse' :: Maybe [PortMapping]
-> Maybe Text -> Int -> ListCustomRoutingPortMappingsResponse
ListCustomRoutingPortMappingsResponse'
    { $sel:portMappings:ListCustomRoutingPortMappingsResponse' :: Maybe [PortMapping]
portMappings =
        Maybe [PortMapping]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCustomRoutingPortMappingsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCustomRoutingPortMappingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The port mappings for a custom routing accelerator.
listCustomRoutingPortMappingsResponse_portMappings :: Lens.Lens' ListCustomRoutingPortMappingsResponse (Prelude.Maybe [PortMapping])
listCustomRoutingPortMappingsResponse_portMappings :: (Maybe [PortMapping] -> f (Maybe [PortMapping]))
-> ListCustomRoutingPortMappingsResponse
-> f ListCustomRoutingPortMappingsResponse
listCustomRoutingPortMappingsResponse_portMappings = (ListCustomRoutingPortMappingsResponse -> Maybe [PortMapping])
-> (ListCustomRoutingPortMappingsResponse
    -> Maybe [PortMapping] -> ListCustomRoutingPortMappingsResponse)
-> Lens'
     ListCustomRoutingPortMappingsResponse (Maybe [PortMapping])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomRoutingPortMappingsResponse' {Maybe [PortMapping]
portMappings :: Maybe [PortMapping]
$sel:portMappings:ListCustomRoutingPortMappingsResponse' :: ListCustomRoutingPortMappingsResponse -> Maybe [PortMapping]
portMappings} -> Maybe [PortMapping]
portMappings) (\s :: ListCustomRoutingPortMappingsResponse
s@ListCustomRoutingPortMappingsResponse' {} Maybe [PortMapping]
a -> ListCustomRoutingPortMappingsResponse
s {$sel:portMappings:ListCustomRoutingPortMappingsResponse' :: Maybe [PortMapping]
portMappings = Maybe [PortMapping]
a} :: ListCustomRoutingPortMappingsResponse) ((Maybe [PortMapping] -> f (Maybe [PortMapping]))
 -> ListCustomRoutingPortMappingsResponse
 -> f ListCustomRoutingPortMappingsResponse)
-> ((Maybe [PortMapping] -> f (Maybe [PortMapping]))
    -> Maybe [PortMapping] -> f (Maybe [PortMapping]))
-> (Maybe [PortMapping] -> f (Maybe [PortMapping]))
-> ListCustomRoutingPortMappingsResponse
-> f ListCustomRoutingPortMappingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [PortMapping] [PortMapping] [PortMapping] [PortMapping]
-> Iso
     (Maybe [PortMapping])
     (Maybe [PortMapping])
     (Maybe [PortMapping])
     (Maybe [PortMapping])
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 [PortMapping] [PortMapping] [PortMapping] [PortMapping]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next set of results. You receive this token from a
-- previous call.
listCustomRoutingPortMappingsResponse_nextToken :: Lens.Lens' ListCustomRoutingPortMappingsResponse (Prelude.Maybe Prelude.Text)
listCustomRoutingPortMappingsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListCustomRoutingPortMappingsResponse
-> f ListCustomRoutingPortMappingsResponse
listCustomRoutingPortMappingsResponse_nextToken = (ListCustomRoutingPortMappingsResponse -> Maybe Text)
-> (ListCustomRoutingPortMappingsResponse
    -> Maybe Text -> ListCustomRoutingPortMappingsResponse)
-> Lens' ListCustomRoutingPortMappingsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomRoutingPortMappingsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCustomRoutingPortMappingsResponse' :: ListCustomRoutingPortMappingsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCustomRoutingPortMappingsResponse
s@ListCustomRoutingPortMappingsResponse' {} Maybe Text
a -> ListCustomRoutingPortMappingsResponse
s {$sel:nextToken:ListCustomRoutingPortMappingsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListCustomRoutingPortMappingsResponse)

-- | The response's http status code.
listCustomRoutingPortMappingsResponse_httpStatus :: Lens.Lens' ListCustomRoutingPortMappingsResponse Prelude.Int
listCustomRoutingPortMappingsResponse_httpStatus :: (Int -> f Int)
-> ListCustomRoutingPortMappingsResponse
-> f ListCustomRoutingPortMappingsResponse
listCustomRoutingPortMappingsResponse_httpStatus = (ListCustomRoutingPortMappingsResponse -> Int)
-> (ListCustomRoutingPortMappingsResponse
    -> Int -> ListCustomRoutingPortMappingsResponse)
-> Lens
     ListCustomRoutingPortMappingsResponse
     ListCustomRoutingPortMappingsResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomRoutingPortMappingsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListCustomRoutingPortMappingsResponse' :: ListCustomRoutingPortMappingsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListCustomRoutingPortMappingsResponse
s@ListCustomRoutingPortMappingsResponse' {} Int
a -> ListCustomRoutingPortMappingsResponse
s {$sel:httpStatus:ListCustomRoutingPortMappingsResponse' :: Int
httpStatus = Int
a} :: ListCustomRoutingPortMappingsResponse)

instance
  Prelude.NFData
    ListCustomRoutingPortMappingsResponse