{-# 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.ListByoipCidrs
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the IP address ranges that were specified in calls to
-- <https://docs.aws.amazon.com/global-accelerator/latest/api/ProvisionByoipCidr.html ProvisionByoipCidr>,
-- including the current state and a history of state changes.
--
-- This operation returns paginated results.
module Amazonka.GlobalAccelerator.ListByoipCidrs
  ( -- * Creating a Request
    ListByoipCidrs (..),
    newListByoipCidrs,

    -- * Request Lenses
    listByoipCidrs_maxResults,
    listByoipCidrs_nextToken,

    -- * Destructuring the Response
    ListByoipCidrsResponse (..),
    newListByoipCidrsResponse,

    -- * Response Lenses
    listByoipCidrsResponse_byoipCidrs,
    listByoipCidrsResponse_nextToken,
    listByoipCidrsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListByoipCidrs' smart constructor.
data ListByoipCidrs = ListByoipCidrs'
  { -- | The maximum number of results to return with a single call. To retrieve
    -- the remaining results, make another call with the returned @nextToken@
    -- value.
    ListByoipCidrs -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token for the next page of results.
    ListByoipCidrs -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListByoipCidrs -> ListByoipCidrs -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListByoipCidrs -> ListByoipCidrs -> Bool
$c/= :: ListByoipCidrs -> ListByoipCidrs -> Bool
== :: ListByoipCidrs -> ListByoipCidrs -> Bool
$c== :: ListByoipCidrs -> ListByoipCidrs -> Bool
Prelude.Eq, ReadPrec [ListByoipCidrs]
ReadPrec ListByoipCidrs
Int -> ReadS ListByoipCidrs
ReadS [ListByoipCidrs]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListByoipCidrs]
$creadListPrec :: ReadPrec [ListByoipCidrs]
readPrec :: ReadPrec ListByoipCidrs
$creadPrec :: ReadPrec ListByoipCidrs
readList :: ReadS [ListByoipCidrs]
$creadList :: ReadS [ListByoipCidrs]
readsPrec :: Int -> ReadS ListByoipCidrs
$creadsPrec :: Int -> ReadS ListByoipCidrs
Prelude.Read, Int -> ListByoipCidrs -> ShowS
[ListByoipCidrs] -> ShowS
ListByoipCidrs -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListByoipCidrs] -> ShowS
$cshowList :: [ListByoipCidrs] -> ShowS
show :: ListByoipCidrs -> String
$cshow :: ListByoipCidrs -> String
showsPrec :: Int -> ListByoipCidrs -> ShowS
$cshowsPrec :: Int -> ListByoipCidrs -> ShowS
Prelude.Show, forall x. Rep ListByoipCidrs x -> ListByoipCidrs
forall x. ListByoipCidrs -> Rep ListByoipCidrs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListByoipCidrs x -> ListByoipCidrs
$cfrom :: forall x. ListByoipCidrs -> Rep ListByoipCidrs x
Prelude.Generic)

-- |
-- Create a value of 'ListByoipCidrs' 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:
--
-- 'maxResults', 'listByoipCidrs_maxResults' - The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
--
-- 'nextToken', 'listByoipCidrs_nextToken' - The token for the next page of results.
newListByoipCidrs ::
  ListByoipCidrs
newListByoipCidrs :: ListByoipCidrs
newListByoipCidrs =
  ListByoipCidrs'
    { $sel:maxResults:ListByoipCidrs' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListByoipCidrs' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
listByoipCidrs_maxResults :: Lens.Lens' ListByoipCidrs (Prelude.Maybe Prelude.Natural)
listByoipCidrs_maxResults :: Lens' ListByoipCidrs (Maybe Natural)
listByoipCidrs_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListByoipCidrs' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListByoipCidrs' :: ListByoipCidrs -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListByoipCidrs
s@ListByoipCidrs' {} Maybe Natural
a -> ListByoipCidrs
s {$sel:maxResults:ListByoipCidrs' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListByoipCidrs)

-- | The token for the next page of results.
listByoipCidrs_nextToken :: Lens.Lens' ListByoipCidrs (Prelude.Maybe Prelude.Text)
listByoipCidrs_nextToken :: Lens' ListByoipCidrs (Maybe Text)
listByoipCidrs_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListByoipCidrs' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListByoipCidrs' :: ListByoipCidrs -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListByoipCidrs
s@ListByoipCidrs' {} Maybe Text
a -> ListByoipCidrs
s {$sel:nextToken:ListByoipCidrs' :: Maybe Text
nextToken = Maybe Text
a} :: ListByoipCidrs)

instance Core.AWSPager ListByoipCidrs where
  page :: ListByoipCidrs
-> AWSResponse ListByoipCidrs -> Maybe ListByoipCidrs
page ListByoipCidrs
rq AWSResponse ListByoipCidrs
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListByoipCidrs
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListByoipCidrsResponse (Maybe Text)
listByoipCidrsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListByoipCidrs
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListByoipCidrsResponse (Maybe [ByoipCidr])
listByoipCidrsResponse_byoipCidrs
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListByoipCidrs
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListByoipCidrs (Maybe Text)
listByoipCidrs_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListByoipCidrs
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListByoipCidrsResponse (Maybe Text)
listByoipCidrsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

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

instance Prelude.Hashable ListByoipCidrs where
  hashWithSalt :: Int -> ListByoipCidrs -> Int
hashWithSalt Int
_salt ListByoipCidrs' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListByoipCidrs' :: ListByoipCidrs -> Maybe Text
$sel:maxResults:ListByoipCidrs' :: ListByoipCidrs -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListByoipCidrs where
  rnf :: ListByoipCidrs -> ()
rnf ListByoipCidrs' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListByoipCidrs' :: ListByoipCidrs -> Maybe Text
$sel:maxResults:ListByoipCidrs' :: ListByoipCidrs -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

instance Data.ToJSON ListByoipCidrs where
  toJSON :: ListByoipCidrs -> Value
toJSON ListByoipCidrs' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListByoipCidrs' :: ListByoipCidrs -> Maybe Text
$sel:maxResults:ListByoipCidrs' :: ListByoipCidrs -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

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

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

-- | /See:/ 'newListByoipCidrsResponse' smart constructor.
data ListByoipCidrsResponse = ListByoipCidrsResponse'
  { -- | Information about your address ranges.
    ListByoipCidrsResponse -> Maybe [ByoipCidr]
byoipCidrs :: Prelude.Maybe [ByoipCidr],
    -- | The token for the next page of results.
    ListByoipCidrsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListByoipCidrsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListByoipCidrsResponse -> ListByoipCidrsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListByoipCidrsResponse -> ListByoipCidrsResponse -> Bool
$c/= :: ListByoipCidrsResponse -> ListByoipCidrsResponse -> Bool
== :: ListByoipCidrsResponse -> ListByoipCidrsResponse -> Bool
$c== :: ListByoipCidrsResponse -> ListByoipCidrsResponse -> Bool
Prelude.Eq, ReadPrec [ListByoipCidrsResponse]
ReadPrec ListByoipCidrsResponse
Int -> ReadS ListByoipCidrsResponse
ReadS [ListByoipCidrsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListByoipCidrsResponse]
$creadListPrec :: ReadPrec [ListByoipCidrsResponse]
readPrec :: ReadPrec ListByoipCidrsResponse
$creadPrec :: ReadPrec ListByoipCidrsResponse
readList :: ReadS [ListByoipCidrsResponse]
$creadList :: ReadS [ListByoipCidrsResponse]
readsPrec :: Int -> ReadS ListByoipCidrsResponse
$creadsPrec :: Int -> ReadS ListByoipCidrsResponse
Prelude.Read, Int -> ListByoipCidrsResponse -> ShowS
[ListByoipCidrsResponse] -> ShowS
ListByoipCidrsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListByoipCidrsResponse] -> ShowS
$cshowList :: [ListByoipCidrsResponse] -> ShowS
show :: ListByoipCidrsResponse -> String
$cshow :: ListByoipCidrsResponse -> String
showsPrec :: Int -> ListByoipCidrsResponse -> ShowS
$cshowsPrec :: Int -> ListByoipCidrsResponse -> ShowS
Prelude.Show, forall x. Rep ListByoipCidrsResponse x -> ListByoipCidrsResponse
forall x. ListByoipCidrsResponse -> Rep ListByoipCidrsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListByoipCidrsResponse x -> ListByoipCidrsResponse
$cfrom :: forall x. ListByoipCidrsResponse -> Rep ListByoipCidrsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListByoipCidrsResponse' 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:
--
-- 'byoipCidrs', 'listByoipCidrsResponse_byoipCidrs' - Information about your address ranges.
--
-- 'nextToken', 'listByoipCidrsResponse_nextToken' - The token for the next page of results.
--
-- 'httpStatus', 'listByoipCidrsResponse_httpStatus' - The response's http status code.
newListByoipCidrsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListByoipCidrsResponse
newListByoipCidrsResponse :: Int -> ListByoipCidrsResponse
newListByoipCidrsResponse Int
pHttpStatus_ =
  ListByoipCidrsResponse'
    { $sel:byoipCidrs:ListByoipCidrsResponse' :: Maybe [ByoipCidr]
byoipCidrs =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListByoipCidrsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListByoipCidrsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about your address ranges.
listByoipCidrsResponse_byoipCidrs :: Lens.Lens' ListByoipCidrsResponse (Prelude.Maybe [ByoipCidr])
listByoipCidrsResponse_byoipCidrs :: Lens' ListByoipCidrsResponse (Maybe [ByoipCidr])
listByoipCidrsResponse_byoipCidrs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListByoipCidrsResponse' {Maybe [ByoipCidr]
byoipCidrs :: Maybe [ByoipCidr]
$sel:byoipCidrs:ListByoipCidrsResponse' :: ListByoipCidrsResponse -> Maybe [ByoipCidr]
byoipCidrs} -> Maybe [ByoipCidr]
byoipCidrs) (\s :: ListByoipCidrsResponse
s@ListByoipCidrsResponse' {} Maybe [ByoipCidr]
a -> ListByoipCidrsResponse
s {$sel:byoipCidrs:ListByoipCidrsResponse' :: Maybe [ByoipCidr]
byoipCidrs = Maybe [ByoipCidr]
a} :: ListByoipCidrsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next page of results.
listByoipCidrsResponse_nextToken :: Lens.Lens' ListByoipCidrsResponse (Prelude.Maybe Prelude.Text)
listByoipCidrsResponse_nextToken :: Lens' ListByoipCidrsResponse (Maybe Text)
listByoipCidrsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListByoipCidrsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListByoipCidrsResponse' :: ListByoipCidrsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListByoipCidrsResponse
s@ListByoipCidrsResponse' {} Maybe Text
a -> ListByoipCidrsResponse
s {$sel:nextToken:ListByoipCidrsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListByoipCidrsResponse)

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

instance Prelude.NFData ListByoipCidrsResponse where
  rnf :: ListByoipCidrsResponse -> ()
rnf ListByoipCidrsResponse' {Int
Maybe [ByoipCidr]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
byoipCidrs :: Maybe [ByoipCidr]
$sel:httpStatus:ListByoipCidrsResponse' :: ListByoipCidrsResponse -> Int
$sel:nextToken:ListByoipCidrsResponse' :: ListByoipCidrsResponse -> Maybe Text
$sel:byoipCidrs:ListByoipCidrsResponse' :: ListByoipCidrsResponse -> Maybe [ByoipCidr]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ByoipCidr]
byoipCidrs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus