{-# 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.ApiGatewayV2.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 a collection of VPC links.
module Amazonka.ApiGatewayV2.GetVpcLinks
  ( -- * Creating a Request
    GetVpcLinks (..),
    newGetVpcLinks,

    -- * Request Lenses
    getVpcLinks_maxResults,
    getVpcLinks_nextToken,

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

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

import Amazonka.ApiGatewayV2.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

-- | /See:/ 'newGetVpcLinks' smart constructor.
data GetVpcLinks = GetVpcLinks'
  { -- | The maximum number of elements to be returned for this resource.
    GetVpcLinks -> Maybe Text
maxResults :: Prelude.Maybe Prelude.Text,
    -- | The next page of elements from this collection. Not valid for the last
    -- element of the collection.
    GetVpcLinks -> Maybe Text
nextToken :: 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:
--
-- 'maxResults', 'getVpcLinks_maxResults' - The maximum number of elements to be returned for this resource.
--
-- 'nextToken', 'getVpcLinks_nextToken' - The next page of elements from this collection. Not valid for the last
-- element of the collection.
newGetVpcLinks ::
  GetVpcLinks
newGetVpcLinks :: GetVpcLinks
newGetVpcLinks =
  GetVpcLinks'
    { $sel:maxResults:GetVpcLinks' :: Maybe Text
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetVpcLinks' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of elements to be returned for this resource.
getVpcLinks_maxResults :: Lens.Lens' GetVpcLinks (Prelude.Maybe Prelude.Text)
getVpcLinks_maxResults :: Lens' GetVpcLinks (Maybe Text)
getVpcLinks_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVpcLinks' {Maybe Text
maxResults :: Maybe Text
$sel:maxResults:GetVpcLinks' :: GetVpcLinks -> Maybe Text
maxResults} -> Maybe Text
maxResults) (\s :: GetVpcLinks
s@GetVpcLinks' {} Maybe Text
a -> GetVpcLinks
s {$sel:maxResults:GetVpcLinks' :: Maybe Text
maxResults = Maybe Text
a} :: GetVpcLinks)

-- | The next page of elements from this collection. Not valid for the last
-- element of the collection.
getVpcLinks_nextToken :: Lens.Lens' GetVpcLinks (Prelude.Maybe Prelude.Text)
getVpcLinks_nextToken :: Lens' GetVpcLinks (Maybe Text)
getVpcLinks_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVpcLinks' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetVpcLinks' :: GetVpcLinks -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetVpcLinks
s@GetVpcLinks' {} Maybe Text
a -> GetVpcLinks
s {$sel:nextToken:GetVpcLinks' :: Maybe Text
nextToken = Maybe Text
a} :: GetVpcLinks)

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
"items" 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 GetVpcLinks where
  hashWithSalt :: Int -> GetVpcLinks -> Int
hashWithSalt Int
_salt GetVpcLinks' {Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Text
$sel:nextToken:GetVpcLinks' :: GetVpcLinks -> Maybe Text
$sel:maxResults:GetVpcLinks' :: GetVpcLinks -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

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
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

-- | /See:/ 'newGetVpcLinksResponse' smart constructor.
data GetVpcLinksResponse = GetVpcLinksResponse'
  { -- | A collection of VPC links.
    GetVpcLinksResponse -> Maybe [VpcLink]
items :: Prelude.Maybe [VpcLink],
    -- | The next page of elements from this collection. Not valid for the last
    -- element of the collection.
    GetVpcLinksResponse -> Maybe Text
nextToken :: 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' - A collection of VPC links.
--
-- 'nextToken', 'getVpcLinksResponse_nextToken' - The next page of elements from this collection. Not valid for the last
-- element of the collection.
--
-- '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:nextToken:GetVpcLinksResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetVpcLinksResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A collection of VPC links.
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

-- | The next page of elements from this collection. Not valid for the last
-- element of the collection.
getVpcLinksResponse_nextToken :: Lens.Lens' GetVpcLinksResponse (Prelude.Maybe Prelude.Text)
getVpcLinksResponse_nextToken :: Lens' GetVpcLinksResponse (Maybe Text)
getVpcLinksResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVpcLinksResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetVpcLinksResponse' :: GetVpcLinksResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetVpcLinksResponse
s@GetVpcLinksResponse' {} Maybe Text
a -> GetVpcLinksResponse
s {$sel:nextToken:GetVpcLinksResponse' :: Maybe Text
nextToken = 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
nextToken :: Maybe Text
items :: Maybe [VpcLink]
$sel:httpStatus:GetVpcLinksResponse' :: GetVpcLinksResponse -> Int
$sel:nextToken: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
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus