{-# 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.APIGateway.GetVpcLinks
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the VpcLinks collection under the caller\'s account in a selected
-- region.
--
-- This operation returns paginated results.
module Amazonka.APIGateway.GetVpcLinks
  ( -- * Creating a Request
    GetVpcLinks (..),
    newGetVpcLinks,

    -- * Request Lenses
    getVpcLinks_limit,
    getVpcLinks_position,

    -- * Destructuring the Response
    GetVpcLinksResponse (..),
    newGetVpcLinksResponse,

    -- * Response Lenses
    getVpcLinksResponse_items,
    getVpcLinksResponse_position,
    getVpcLinksResponse_httpStatus,
  )
where

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

-- | Gets the VpcLinks collection under the caller\'s account in a selected
-- region.
--
-- /See:/ 'newGetVpcLinks' smart constructor.
data GetVpcLinks = GetVpcLinks'
  { -- | The maximum number of returned results per page. The default value is 25
    -- and the maximum value is 500.
    GetVpcLinks -> Maybe Int
limit :: Prelude.Maybe Prelude.Int,
    -- | The current pagination position in the paged result set.
    GetVpcLinks -> Maybe Text
position :: Prelude.Maybe Prelude.Text
  }
  deriving (GetVpcLinks -> GetVpcLinks -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetVpcLinks -> GetVpcLinks -> Bool
$c/= :: GetVpcLinks -> GetVpcLinks -> Bool
== :: GetVpcLinks -> GetVpcLinks -> Bool
$c== :: GetVpcLinks -> GetVpcLinks -> Bool
Prelude.Eq, ReadPrec [GetVpcLinks]
ReadPrec GetVpcLinks
Int -> ReadS GetVpcLinks
ReadS [GetVpcLinks]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetVpcLinks]
$creadListPrec :: ReadPrec [GetVpcLinks]
readPrec :: ReadPrec GetVpcLinks
$creadPrec :: ReadPrec GetVpcLinks
readList :: ReadS [GetVpcLinks]
$creadList :: ReadS [GetVpcLinks]
readsPrec :: Int -> ReadS GetVpcLinks
$creadsPrec :: Int -> ReadS GetVpcLinks
Prelude.Read, Int -> GetVpcLinks -> ShowS
[GetVpcLinks] -> ShowS
GetVpcLinks -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetVpcLinks] -> ShowS
$cshowList :: [GetVpcLinks] -> ShowS
show :: GetVpcLinks -> String
$cshow :: GetVpcLinks -> String
showsPrec :: Int -> GetVpcLinks -> ShowS
$cshowsPrec :: Int -> GetVpcLinks -> ShowS
Prelude.Show, forall x. Rep GetVpcLinks x -> GetVpcLinks
forall x. GetVpcLinks -> Rep GetVpcLinks x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetVpcLinks x -> GetVpcLinks
$cfrom :: forall x. GetVpcLinks -> Rep GetVpcLinks x
Prelude.Generic)

-- |
-- Create a value of 'GetVpcLinks' 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:
--
-- 'limit', 'getVpcLinks_limit' - The maximum number of returned results per page. The default value is 25
-- and the maximum value is 500.
--
-- 'position', 'getVpcLinks_position' - The current pagination position in the paged result set.
newGetVpcLinks ::
  GetVpcLinks
newGetVpcLinks :: GetVpcLinks
newGetVpcLinks =
  GetVpcLinks'
    { $sel:limit:GetVpcLinks' :: Maybe Int
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:position:GetVpcLinks' :: Maybe Text
position = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of returned results per page. The default value is 25
-- and the maximum value is 500.
getVpcLinks_limit :: Lens.Lens' GetVpcLinks (Prelude.Maybe Prelude.Int)
getVpcLinks_limit :: Lens' GetVpcLinks (Maybe Int)
getVpcLinks_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVpcLinks' {Maybe Int
limit :: Maybe Int
$sel:limit:GetVpcLinks' :: GetVpcLinks -> Maybe Int
limit} -> Maybe Int
limit) (\s :: GetVpcLinks
s@GetVpcLinks' {} Maybe Int
a -> GetVpcLinks
s {$sel:limit:GetVpcLinks' :: Maybe Int
limit = Maybe Int
a} :: GetVpcLinks)

-- | The current pagination position in the paged result set.
getVpcLinks_position :: Lens.Lens' GetVpcLinks (Prelude.Maybe Prelude.Text)
getVpcLinks_position :: Lens' GetVpcLinks (Maybe Text)
getVpcLinks_position = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVpcLinks' {Maybe Text
position :: Maybe Text
$sel:position:GetVpcLinks' :: GetVpcLinks -> Maybe Text
position} -> Maybe Text
position) (\s :: GetVpcLinks
s@GetVpcLinks' {} Maybe Text
a -> GetVpcLinks
s {$sel:position:GetVpcLinks' :: Maybe Text
position = Maybe Text
a} :: GetVpcLinks)

instance Core.AWSPager GetVpcLinks where
  page :: GetVpcLinks -> AWSResponse GetVpcLinks -> Maybe GetVpcLinks
page GetVpcLinks
rq AWSResponse GetVpcLinks
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetVpcLinks
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetVpcLinksResponse (Maybe Text)
getVpcLinksResponse_position
            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 GetVpcLinks
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetVpcLinksResponse (Maybe [VpcLink])
getVpcLinksResponse_items
            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.$ GetVpcLinks
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetVpcLinks (Maybe Text)
getVpcLinks_position
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetVpcLinks
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetVpcLinksResponse (Maybe Text)
getVpcLinksResponse_position
          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 GetVpcLinks where
  type AWSResponse GetVpcLinks = GetVpcLinksResponse
  request :: (Service -> Service) -> GetVpcLinks -> Request GetVpcLinks
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetVpcLinks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVpcLinks)))
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 [VpcLink] -> Maybe Text -> Int -> GetVpcLinksResponse
GetVpcLinksResponse'
            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
"item" 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
"position")
            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 GetVpcLinks where
  hashWithSalt :: Int -> GetVpcLinks -> Int
hashWithSalt Int
_salt GetVpcLinks' {Maybe Int
Maybe Text
position :: Maybe Text
limit :: Maybe Int
$sel:position:GetVpcLinks' :: GetVpcLinks -> Maybe Text
$sel:limit:GetVpcLinks' :: GetVpcLinks -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
limit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
position

instance Prelude.NFData GetVpcLinks where
  rnf :: GetVpcLinks -> ()
rnf GetVpcLinks' {Maybe Int
Maybe Text
position :: Maybe Text
limit :: Maybe Int
$sel:position:GetVpcLinks' :: GetVpcLinks -> Maybe Text
$sel:limit:GetVpcLinks' :: GetVpcLinks -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
limit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
position

instance Data.ToHeaders GetVpcLinks where
  toHeaders :: GetVpcLinks -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

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

instance Data.ToQuery GetVpcLinks where
  toQuery :: GetVpcLinks -> QueryString
toQuery GetVpcLinks' {Maybe Int
Maybe Text
position :: Maybe Text
limit :: Maybe Int
$sel:position:GetVpcLinks' :: GetVpcLinks -> Maybe Text
$sel:limit:GetVpcLinks' :: GetVpcLinks -> Maybe Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"limit" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
limit, ByteString
"position" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
position]

-- | The collection of VPC links under the caller\'s account in a region.
--
-- /See:/ 'newGetVpcLinksResponse' smart constructor.
data GetVpcLinksResponse = GetVpcLinksResponse'
  { -- | The current page of elements from this collection.
    GetVpcLinksResponse -> Maybe [VpcLink]
items :: Prelude.Maybe [VpcLink],
    GetVpcLinksResponse -> Maybe Text
position :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetVpcLinksResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetVpcLinksResponse -> GetVpcLinksResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetVpcLinksResponse -> GetVpcLinksResponse -> Bool
$c/= :: GetVpcLinksResponse -> GetVpcLinksResponse -> Bool
== :: GetVpcLinksResponse -> GetVpcLinksResponse -> Bool
$c== :: GetVpcLinksResponse -> GetVpcLinksResponse -> Bool
Prelude.Eq, ReadPrec [GetVpcLinksResponse]
ReadPrec GetVpcLinksResponse
Int -> ReadS GetVpcLinksResponse
ReadS [GetVpcLinksResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetVpcLinksResponse]
$creadListPrec :: ReadPrec [GetVpcLinksResponse]
readPrec :: ReadPrec GetVpcLinksResponse
$creadPrec :: ReadPrec GetVpcLinksResponse
readList :: ReadS [GetVpcLinksResponse]
$creadList :: ReadS [GetVpcLinksResponse]
readsPrec :: Int -> ReadS GetVpcLinksResponse
$creadsPrec :: Int -> ReadS GetVpcLinksResponse
Prelude.Read, Int -> GetVpcLinksResponse -> ShowS
[GetVpcLinksResponse] -> ShowS
GetVpcLinksResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetVpcLinksResponse] -> ShowS
$cshowList :: [GetVpcLinksResponse] -> ShowS
show :: GetVpcLinksResponse -> String
$cshow :: GetVpcLinksResponse -> String
showsPrec :: Int -> GetVpcLinksResponse -> ShowS
$cshowsPrec :: Int -> GetVpcLinksResponse -> ShowS
Prelude.Show, forall x. Rep GetVpcLinksResponse x -> GetVpcLinksResponse
forall x. GetVpcLinksResponse -> Rep GetVpcLinksResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetVpcLinksResponse x -> GetVpcLinksResponse
$cfrom :: forall x. GetVpcLinksResponse -> Rep GetVpcLinksResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetVpcLinksResponse' 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:
--
-- 'items', 'getVpcLinksResponse_items' - The current page of elements from this collection.
--
-- 'position', 'getVpcLinksResponse_position' - Undocumented member.
--
-- 'httpStatus', 'getVpcLinksResponse_httpStatus' - The response's http status code.
newGetVpcLinksResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetVpcLinksResponse
newGetVpcLinksResponse :: Int -> GetVpcLinksResponse
newGetVpcLinksResponse Int
pHttpStatus_ =
  GetVpcLinksResponse'
    { $sel:items:GetVpcLinksResponse' :: Maybe [VpcLink]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:position:GetVpcLinksResponse' :: Maybe Text
position = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetVpcLinksResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The current page of elements from this collection.
getVpcLinksResponse_items :: Lens.Lens' GetVpcLinksResponse (Prelude.Maybe [VpcLink])
getVpcLinksResponse_items :: Lens' GetVpcLinksResponse (Maybe [VpcLink])
getVpcLinksResponse_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVpcLinksResponse' {Maybe [VpcLink]
items :: Maybe [VpcLink]
$sel:items:GetVpcLinksResponse' :: GetVpcLinksResponse -> Maybe [VpcLink]
items} -> Maybe [VpcLink]
items) (\s :: GetVpcLinksResponse
s@GetVpcLinksResponse' {} Maybe [VpcLink]
a -> GetVpcLinksResponse
s {$sel:items:GetVpcLinksResponse' :: Maybe [VpcLink]
items = Maybe [VpcLink]
a} :: GetVpcLinksResponse) 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

-- | Undocumented member.
getVpcLinksResponse_position :: Lens.Lens' GetVpcLinksResponse (Prelude.Maybe Prelude.Text)
getVpcLinksResponse_position :: Lens' GetVpcLinksResponse (Maybe Text)
getVpcLinksResponse_position = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVpcLinksResponse' {Maybe Text
position :: Maybe Text
$sel:position:GetVpcLinksResponse' :: GetVpcLinksResponse -> Maybe Text
position} -> Maybe Text
position) (\s :: GetVpcLinksResponse
s@GetVpcLinksResponse' {} Maybe Text
a -> GetVpcLinksResponse
s {$sel:position:GetVpcLinksResponse' :: Maybe Text
position = Maybe Text
a} :: GetVpcLinksResponse)

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

instance Prelude.NFData GetVpcLinksResponse where
  rnf :: GetVpcLinksResponse -> ()
rnf GetVpcLinksResponse' {Int
Maybe [VpcLink]
Maybe Text
httpStatus :: Int
position :: Maybe Text
items :: Maybe [VpcLink]
$sel:httpStatus:GetVpcLinksResponse' :: GetVpcLinksResponse -> Int
$sel:position:GetVpcLinksResponse' :: GetVpcLinksResponse -> Maybe Text
$sel:items:GetVpcLinksResponse' :: GetVpcLinksResponse -> Maybe [VpcLink]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [VpcLink]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
position
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus