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

    -- * Request Lenses
    getVpcLinks_nextToken,
    getVpcLinks_maxResults,

    -- * 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.Lens as Lens
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 next page of elements from this collection. Not valid for the last
    -- element of the collection.
    GetVpcLinks -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of elements to be returned for this resource.
    GetVpcLinks -> Maybe Text
maxResults :: Prelude.Maybe Prelude.Text
  }
  deriving (GetVpcLinks -> GetVpcLinks -> Bool
(GetVpcLinks -> GetVpcLinks -> Bool)
-> (GetVpcLinks -> GetVpcLinks -> Bool) -> Eq GetVpcLinks
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]
(Int -> ReadS GetVpcLinks)
-> ReadS [GetVpcLinks]
-> ReadPrec GetVpcLinks
-> ReadPrec [GetVpcLinks]
-> Read 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
(Int -> GetVpcLinks -> ShowS)
-> (GetVpcLinks -> String)
-> ([GetVpcLinks] -> ShowS)
-> Show GetVpcLinks
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. GetVpcLinks -> Rep GetVpcLinks x)
-> (forall x. Rep GetVpcLinks x -> GetVpcLinks)
-> Generic GetVpcLinks
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:
--
-- 'nextToken', 'getVpcLinks_nextToken' - The next page of elements from this collection. Not valid for the last
-- element of the collection.
--
-- 'maxResults', 'getVpcLinks_maxResults' - The maximum number of elements to be returned for this resource.
newGetVpcLinks ::
  GetVpcLinks
newGetVpcLinks :: GetVpcLinks
newGetVpcLinks =
  GetVpcLinks' :: Maybe Text -> Maybe Text -> GetVpcLinks
GetVpcLinks'
    { $sel:nextToken:GetVpcLinks' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetVpcLinks' :: Maybe Text
maxResults = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> GetVpcLinks -> f GetVpcLinks
getVpcLinks_nextToken = (GetVpcLinks -> Maybe Text)
-> (GetVpcLinks -> Maybe Text -> GetVpcLinks)
-> Lens GetVpcLinks GetVpcLinks (Maybe Text) (Maybe Text)
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)

-- | The maximum number of elements to be returned for this resource.
getVpcLinks_maxResults :: Lens.Lens' GetVpcLinks (Prelude.Maybe Prelude.Text)
getVpcLinks_maxResults :: (Maybe Text -> f (Maybe Text)) -> GetVpcLinks -> f GetVpcLinks
getVpcLinks_maxResults = (GetVpcLinks -> Maybe Text)
-> (GetVpcLinks -> Maybe Text -> GetVpcLinks)
-> Lens GetVpcLinks GetVpcLinks (Maybe Text) (Maybe Text)
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)

instance Core.AWSRequest GetVpcLinks where
  type AWSResponse GetVpcLinks = GetVpcLinksResponse
  request :: GetVpcLinks -> Request GetVpcLinks
request = Service -> GetVpcLinks -> Request GetVpcLinks
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetVpcLinks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVpcLinks)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetVpcLinks))
-> Logger
-> Service
-> Proxy GetVpcLinks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVpcLinks)))
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 [VpcLink] -> Maybe Text -> Int -> GetVpcLinksResponse
GetVpcLinksResponse'
            (Maybe [VpcLink] -> Maybe Text -> Int -> GetVpcLinksResponse)
-> Either String (Maybe [VpcLink])
-> Either String (Maybe Text -> Int -> GetVpcLinksResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [VpcLink]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"items" Either String (Maybe (Maybe [VpcLink]))
-> Maybe [VpcLink] -> Either String (Maybe [VpcLink])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [VpcLink]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> GetVpcLinksResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetVpcLinksResponse)
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 -> GetVpcLinksResponse)
-> Either String Int -> Either String GetVpcLinksResponse
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 GetVpcLinks

instance Prelude.NFData GetVpcLinks

instance Core.ToHeaders GetVpcLinks where
  toHeaders :: GetVpcLinks -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetVpcLinks -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetVpcLinks where
  toPath :: GetVpcLinks -> ByteString
toPath = ByteString -> GetVpcLinks -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v2/vpclinks"

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

-- | /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
(GetVpcLinksResponse -> GetVpcLinksResponse -> Bool)
-> (GetVpcLinksResponse -> GetVpcLinksResponse -> Bool)
-> Eq GetVpcLinksResponse
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]
(Int -> ReadS GetVpcLinksResponse)
-> ReadS [GetVpcLinksResponse]
-> ReadPrec GetVpcLinksResponse
-> ReadPrec [GetVpcLinksResponse]
-> Read 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
(Int -> GetVpcLinksResponse -> ShowS)
-> (GetVpcLinksResponse -> String)
-> ([GetVpcLinksResponse] -> ShowS)
-> Show GetVpcLinksResponse
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. GetVpcLinksResponse -> Rep GetVpcLinksResponse x)
-> (forall x. Rep GetVpcLinksResponse x -> GetVpcLinksResponse)
-> Generic GetVpcLinksResponse
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' :: Maybe [VpcLink] -> Maybe Text -> Int -> GetVpcLinksResponse
GetVpcLinksResponse'
    { $sel:items:GetVpcLinksResponse' :: Maybe [VpcLink]
items = Maybe [VpcLink]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetVpcLinksResponse' :: Maybe Text
nextToken = Maybe Text
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 :: (Maybe [VpcLink] -> f (Maybe [VpcLink]))
-> GetVpcLinksResponse -> f GetVpcLinksResponse
getVpcLinksResponse_items = (GetVpcLinksResponse -> Maybe [VpcLink])
-> (GetVpcLinksResponse -> Maybe [VpcLink] -> GetVpcLinksResponse)
-> Lens
     GetVpcLinksResponse
     GetVpcLinksResponse
     (Maybe [VpcLink])
     (Maybe [VpcLink])
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) ((Maybe [VpcLink] -> f (Maybe [VpcLink]))
 -> GetVpcLinksResponse -> f GetVpcLinksResponse)
-> ((Maybe [VpcLink] -> f (Maybe [VpcLink]))
    -> Maybe [VpcLink] -> f (Maybe [VpcLink]))
-> (Maybe [VpcLink] -> f (Maybe [VpcLink]))
-> GetVpcLinksResponse
-> f GetVpcLinksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [VpcLink] [VpcLink] [VpcLink] [VpcLink]
-> Iso
     (Maybe [VpcLink])
     (Maybe [VpcLink])
     (Maybe [VpcLink])
     (Maybe [VpcLink])
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 [VpcLink] [VpcLink] [VpcLink] [VpcLink]
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 :: (Maybe Text -> f (Maybe Text))
-> GetVpcLinksResponse -> f GetVpcLinksResponse
getVpcLinksResponse_nextToken = (GetVpcLinksResponse -> Maybe Text)
-> (GetVpcLinksResponse -> Maybe Text -> GetVpcLinksResponse)
-> Lens
     GetVpcLinksResponse GetVpcLinksResponse (Maybe Text) (Maybe Text)
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 :: (Int -> f Int) -> GetVpcLinksResponse -> f GetVpcLinksResponse
getVpcLinksResponse_httpStatus = (GetVpcLinksResponse -> Int)
-> (GetVpcLinksResponse -> Int -> GetVpcLinksResponse)
-> Lens GetVpcLinksResponse GetVpcLinksResponse Int Int
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