{-# 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.Glue.GetDevEndpoints
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves all the development endpoints in this Amazon Web Services
-- account.
--
-- When you create a development endpoint in a virtual private cloud (VPC),
-- Glue returns only a private IP address and the public IP address field
-- is not populated. When you create a non-VPC development endpoint, Glue
-- returns only a public IP address.
--
-- This operation returns paginated results.
module Amazonka.Glue.GetDevEndpoints
  ( -- * Creating a Request
    GetDevEndpoints (..),
    newGetDevEndpoints,

    -- * Request Lenses
    getDevEndpoints_maxResults,
    getDevEndpoints_nextToken,

    -- * Destructuring the Response
    GetDevEndpointsResponse (..),
    newGetDevEndpointsResponse,

    -- * Response Lenses
    getDevEndpointsResponse_devEndpoints,
    getDevEndpointsResponse_nextToken,
    getDevEndpointsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetDevEndpoints' smart constructor.
data GetDevEndpoints = GetDevEndpoints'
  { -- | The maximum size of information to return.
    GetDevEndpoints -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A continuation token, if this is a continuation call.
    GetDevEndpoints -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (GetDevEndpoints -> GetDevEndpoints -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevEndpoints -> GetDevEndpoints -> Bool
$c/= :: GetDevEndpoints -> GetDevEndpoints -> Bool
== :: GetDevEndpoints -> GetDevEndpoints -> Bool
$c== :: GetDevEndpoints -> GetDevEndpoints -> Bool
Prelude.Eq, ReadPrec [GetDevEndpoints]
ReadPrec GetDevEndpoints
Int -> ReadS GetDevEndpoints
ReadS [GetDevEndpoints]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDevEndpoints]
$creadListPrec :: ReadPrec [GetDevEndpoints]
readPrec :: ReadPrec GetDevEndpoints
$creadPrec :: ReadPrec GetDevEndpoints
readList :: ReadS [GetDevEndpoints]
$creadList :: ReadS [GetDevEndpoints]
readsPrec :: Int -> ReadS GetDevEndpoints
$creadsPrec :: Int -> ReadS GetDevEndpoints
Prelude.Read, Int -> GetDevEndpoints -> ShowS
[GetDevEndpoints] -> ShowS
GetDevEndpoints -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevEndpoints] -> ShowS
$cshowList :: [GetDevEndpoints] -> ShowS
show :: GetDevEndpoints -> String
$cshow :: GetDevEndpoints -> String
showsPrec :: Int -> GetDevEndpoints -> ShowS
$cshowsPrec :: Int -> GetDevEndpoints -> ShowS
Prelude.Show, forall x. Rep GetDevEndpoints x -> GetDevEndpoints
forall x. GetDevEndpoints -> Rep GetDevEndpoints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDevEndpoints x -> GetDevEndpoints
$cfrom :: forall x. GetDevEndpoints -> Rep GetDevEndpoints x
Prelude.Generic)

-- |
-- Create a value of 'GetDevEndpoints' 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', 'getDevEndpoints_maxResults' - The maximum size of information to return.
--
-- 'nextToken', 'getDevEndpoints_nextToken' - A continuation token, if this is a continuation call.
newGetDevEndpoints ::
  GetDevEndpoints
newGetDevEndpoints :: GetDevEndpoints
newGetDevEndpoints =
  GetDevEndpoints'
    { $sel:maxResults:GetDevEndpoints' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetDevEndpoints' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum size of information to return.
getDevEndpoints_maxResults :: Lens.Lens' GetDevEndpoints (Prelude.Maybe Prelude.Natural)
getDevEndpoints_maxResults :: Lens' GetDevEndpoints (Maybe Natural)
getDevEndpoints_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevEndpoints' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetDevEndpoints' :: GetDevEndpoints -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetDevEndpoints
s@GetDevEndpoints' {} Maybe Natural
a -> GetDevEndpoints
s {$sel:maxResults:GetDevEndpoints' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetDevEndpoints)

-- | A continuation token, if this is a continuation call.
getDevEndpoints_nextToken :: Lens.Lens' GetDevEndpoints (Prelude.Maybe Prelude.Text)
getDevEndpoints_nextToken :: Lens' GetDevEndpoints (Maybe Text)
getDevEndpoints_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevEndpoints' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDevEndpoints' :: GetDevEndpoints -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDevEndpoints
s@GetDevEndpoints' {} Maybe Text
a -> GetDevEndpoints
s {$sel:nextToken:GetDevEndpoints' :: Maybe Text
nextToken = Maybe Text
a} :: GetDevEndpoints)

instance Core.AWSPager GetDevEndpoints where
  page :: GetDevEndpoints
-> AWSResponse GetDevEndpoints -> Maybe GetDevEndpoints
page GetDevEndpoints
rq AWSResponse GetDevEndpoints
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetDevEndpoints
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetDevEndpointsResponse (Maybe Text)
getDevEndpointsResponse_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 GetDevEndpoints
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetDevEndpointsResponse (Maybe [DevEndpoint])
getDevEndpointsResponse_devEndpoints
            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.$ GetDevEndpoints
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetDevEndpoints (Maybe Text)
getDevEndpoints_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetDevEndpoints
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetDevEndpointsResponse (Maybe Text)
getDevEndpointsResponse_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 GetDevEndpoints where
  type
    AWSResponse GetDevEndpoints =
      GetDevEndpointsResponse
  request :: (Service -> Service) -> GetDevEndpoints -> Request GetDevEndpoints
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 GetDevEndpoints
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDevEndpoints)))
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 [DevEndpoint] -> Maybe Text -> Int -> GetDevEndpointsResponse
GetDevEndpointsResponse'
            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
"DevEndpoints" 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 GetDevEndpoints where
  hashWithSalt :: Int -> GetDevEndpoints -> Int
hashWithSalt Int
_salt GetDevEndpoints' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetDevEndpoints' :: GetDevEndpoints -> Maybe Text
$sel:maxResults:GetDevEndpoints' :: GetDevEndpoints -> 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 GetDevEndpoints where
  rnf :: GetDevEndpoints -> ()
rnf GetDevEndpoints' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetDevEndpoints' :: GetDevEndpoints -> Maybe Text
$sel:maxResults:GetDevEndpoints' :: GetDevEndpoints -> 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 GetDevEndpoints where
  toHeaders :: GetDevEndpoints -> 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
"AWSGlue.GetDevEndpoints" :: 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 GetDevEndpoints where
  toJSON :: GetDevEndpoints -> Value
toJSON GetDevEndpoints' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetDevEndpoints' :: GetDevEndpoints -> Maybe Text
$sel:maxResults:GetDevEndpoints' :: GetDevEndpoints -> 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 GetDevEndpoints where
  toPath :: GetDevEndpoints -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newGetDevEndpointsResponse' smart constructor.
data GetDevEndpointsResponse = GetDevEndpointsResponse'
  { -- | A list of @DevEndpoint@ definitions.
    GetDevEndpointsResponse -> Maybe [DevEndpoint]
devEndpoints :: Prelude.Maybe [DevEndpoint],
    -- | A continuation token, if not all @DevEndpoint@ definitions have yet been
    -- returned.
    GetDevEndpointsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetDevEndpointsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDevEndpointsResponse -> GetDevEndpointsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevEndpointsResponse -> GetDevEndpointsResponse -> Bool
$c/= :: GetDevEndpointsResponse -> GetDevEndpointsResponse -> Bool
== :: GetDevEndpointsResponse -> GetDevEndpointsResponse -> Bool
$c== :: GetDevEndpointsResponse -> GetDevEndpointsResponse -> Bool
Prelude.Eq, ReadPrec [GetDevEndpointsResponse]
ReadPrec GetDevEndpointsResponse
Int -> ReadS GetDevEndpointsResponse
ReadS [GetDevEndpointsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDevEndpointsResponse]
$creadListPrec :: ReadPrec [GetDevEndpointsResponse]
readPrec :: ReadPrec GetDevEndpointsResponse
$creadPrec :: ReadPrec GetDevEndpointsResponse
readList :: ReadS [GetDevEndpointsResponse]
$creadList :: ReadS [GetDevEndpointsResponse]
readsPrec :: Int -> ReadS GetDevEndpointsResponse
$creadsPrec :: Int -> ReadS GetDevEndpointsResponse
Prelude.Read, Int -> GetDevEndpointsResponse -> ShowS
[GetDevEndpointsResponse] -> ShowS
GetDevEndpointsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevEndpointsResponse] -> ShowS
$cshowList :: [GetDevEndpointsResponse] -> ShowS
show :: GetDevEndpointsResponse -> String
$cshow :: GetDevEndpointsResponse -> String
showsPrec :: Int -> GetDevEndpointsResponse -> ShowS
$cshowsPrec :: Int -> GetDevEndpointsResponse -> ShowS
Prelude.Show, forall x. Rep GetDevEndpointsResponse x -> GetDevEndpointsResponse
forall x. GetDevEndpointsResponse -> Rep GetDevEndpointsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDevEndpointsResponse x -> GetDevEndpointsResponse
$cfrom :: forall x. GetDevEndpointsResponse -> Rep GetDevEndpointsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDevEndpointsResponse' 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:
--
-- 'devEndpoints', 'getDevEndpointsResponse_devEndpoints' - A list of @DevEndpoint@ definitions.
--
-- 'nextToken', 'getDevEndpointsResponse_nextToken' - A continuation token, if not all @DevEndpoint@ definitions have yet been
-- returned.
--
-- 'httpStatus', 'getDevEndpointsResponse_httpStatus' - The response's http status code.
newGetDevEndpointsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDevEndpointsResponse
newGetDevEndpointsResponse :: Int -> GetDevEndpointsResponse
newGetDevEndpointsResponse Int
pHttpStatus_ =
  GetDevEndpointsResponse'
    { $sel:devEndpoints:GetDevEndpointsResponse' :: Maybe [DevEndpoint]
devEndpoints =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetDevEndpointsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDevEndpointsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of @DevEndpoint@ definitions.
getDevEndpointsResponse_devEndpoints :: Lens.Lens' GetDevEndpointsResponse (Prelude.Maybe [DevEndpoint])
getDevEndpointsResponse_devEndpoints :: Lens' GetDevEndpointsResponse (Maybe [DevEndpoint])
getDevEndpointsResponse_devEndpoints = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevEndpointsResponse' {Maybe [DevEndpoint]
devEndpoints :: Maybe [DevEndpoint]
$sel:devEndpoints:GetDevEndpointsResponse' :: GetDevEndpointsResponse -> Maybe [DevEndpoint]
devEndpoints} -> Maybe [DevEndpoint]
devEndpoints) (\s :: GetDevEndpointsResponse
s@GetDevEndpointsResponse' {} Maybe [DevEndpoint]
a -> GetDevEndpointsResponse
s {$sel:devEndpoints:GetDevEndpointsResponse' :: Maybe [DevEndpoint]
devEndpoints = Maybe [DevEndpoint]
a} :: GetDevEndpointsResponse) 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

-- | A continuation token, if not all @DevEndpoint@ definitions have yet been
-- returned.
getDevEndpointsResponse_nextToken :: Lens.Lens' GetDevEndpointsResponse (Prelude.Maybe Prelude.Text)
getDevEndpointsResponse_nextToken :: Lens' GetDevEndpointsResponse (Maybe Text)
getDevEndpointsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevEndpointsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDevEndpointsResponse' :: GetDevEndpointsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDevEndpointsResponse
s@GetDevEndpointsResponse' {} Maybe Text
a -> GetDevEndpointsResponse
s {$sel:nextToken:GetDevEndpointsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetDevEndpointsResponse)

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

instance Prelude.NFData GetDevEndpointsResponse where
  rnf :: GetDevEndpointsResponse -> ()
rnf GetDevEndpointsResponse' {Int
Maybe [DevEndpoint]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
devEndpoints :: Maybe [DevEndpoint]
$sel:httpStatus:GetDevEndpointsResponse' :: GetDevEndpointsResponse -> Int
$sel:nextToken:GetDevEndpointsResponse' :: GetDevEndpointsResponse -> Maybe Text
$sel:devEndpoints:GetDevEndpointsResponse' :: GetDevEndpointsResponse -> Maybe [DevEndpoint]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DevEndpoint]
devEndpoints
      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