{-# 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.OpenSearchServerless.BatchGetVpcEndpoint
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns attributes for one or more VPC endpoints associated with the
-- current account. For more information, see
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-vpc.html Access Amazon OpenSearch Serverless using an interface endpoint>.
module Amazonka.OpenSearchServerless.BatchGetVpcEndpoint
  ( -- * Creating a Request
    BatchGetVpcEndpoint (..),
    newBatchGetVpcEndpoint,

    -- * Request Lenses
    batchGetVpcEndpoint_ids,

    -- * Destructuring the Response
    BatchGetVpcEndpointResponse (..),
    newBatchGetVpcEndpointResponse,

    -- * Response Lenses
    batchGetVpcEndpointResponse_vpcEndpointDetails,
    batchGetVpcEndpointResponse_vpcEndpointErrorDetails,
    batchGetVpcEndpointResponse_httpStatus,
  )
where

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

-- | /See:/ 'newBatchGetVpcEndpoint' smart constructor.
data BatchGetVpcEndpoint = BatchGetVpcEndpoint'
  { -- | A list of VPC endpoint identifiers.
    BatchGetVpcEndpoint -> NonEmpty Text
ids :: Prelude.NonEmpty Prelude.Text
  }
  deriving (BatchGetVpcEndpoint -> BatchGetVpcEndpoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetVpcEndpoint -> BatchGetVpcEndpoint -> Bool
$c/= :: BatchGetVpcEndpoint -> BatchGetVpcEndpoint -> Bool
== :: BatchGetVpcEndpoint -> BatchGetVpcEndpoint -> Bool
$c== :: BatchGetVpcEndpoint -> BatchGetVpcEndpoint -> Bool
Prelude.Eq, ReadPrec [BatchGetVpcEndpoint]
ReadPrec BatchGetVpcEndpoint
Int -> ReadS BatchGetVpcEndpoint
ReadS [BatchGetVpcEndpoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetVpcEndpoint]
$creadListPrec :: ReadPrec [BatchGetVpcEndpoint]
readPrec :: ReadPrec BatchGetVpcEndpoint
$creadPrec :: ReadPrec BatchGetVpcEndpoint
readList :: ReadS [BatchGetVpcEndpoint]
$creadList :: ReadS [BatchGetVpcEndpoint]
readsPrec :: Int -> ReadS BatchGetVpcEndpoint
$creadsPrec :: Int -> ReadS BatchGetVpcEndpoint
Prelude.Read, Int -> BatchGetVpcEndpoint -> ShowS
[BatchGetVpcEndpoint] -> ShowS
BatchGetVpcEndpoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetVpcEndpoint] -> ShowS
$cshowList :: [BatchGetVpcEndpoint] -> ShowS
show :: BatchGetVpcEndpoint -> String
$cshow :: BatchGetVpcEndpoint -> String
showsPrec :: Int -> BatchGetVpcEndpoint -> ShowS
$cshowsPrec :: Int -> BatchGetVpcEndpoint -> ShowS
Prelude.Show, forall x. Rep BatchGetVpcEndpoint x -> BatchGetVpcEndpoint
forall x. BatchGetVpcEndpoint -> Rep BatchGetVpcEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetVpcEndpoint x -> BatchGetVpcEndpoint
$cfrom :: forall x. BatchGetVpcEndpoint -> Rep BatchGetVpcEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetVpcEndpoint' 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:
--
-- 'ids', 'batchGetVpcEndpoint_ids' - A list of VPC endpoint identifiers.
newBatchGetVpcEndpoint ::
  -- | 'ids'
  Prelude.NonEmpty Prelude.Text ->
  BatchGetVpcEndpoint
newBatchGetVpcEndpoint :: NonEmpty Text -> BatchGetVpcEndpoint
newBatchGetVpcEndpoint NonEmpty Text
pIds_ =
  BatchGetVpcEndpoint'
    { $sel:ids:BatchGetVpcEndpoint' :: NonEmpty Text
ids =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pIds_
    }

-- | A list of VPC endpoint identifiers.
batchGetVpcEndpoint_ids :: Lens.Lens' BatchGetVpcEndpoint (Prelude.NonEmpty Prelude.Text)
batchGetVpcEndpoint_ids :: Lens' BatchGetVpcEndpoint (NonEmpty Text)
batchGetVpcEndpoint_ids = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetVpcEndpoint' {NonEmpty Text
ids :: NonEmpty Text
$sel:ids:BatchGetVpcEndpoint' :: BatchGetVpcEndpoint -> NonEmpty Text
ids} -> NonEmpty Text
ids) (\s :: BatchGetVpcEndpoint
s@BatchGetVpcEndpoint' {} NonEmpty Text
a -> BatchGetVpcEndpoint
s {$sel:ids:BatchGetVpcEndpoint' :: NonEmpty Text
ids = NonEmpty Text
a} :: BatchGetVpcEndpoint) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchGetVpcEndpoint where
  type
    AWSResponse BatchGetVpcEndpoint =
      BatchGetVpcEndpointResponse
  request :: (Service -> Service)
-> BatchGetVpcEndpoint -> Request BatchGetVpcEndpoint
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 BatchGetVpcEndpoint
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetVpcEndpoint)))
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 [VpcEndpointDetail]
-> Maybe [VpcEndpointErrorDetail]
-> Int
-> BatchGetVpcEndpointResponse
BatchGetVpcEndpointResponse'
            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
"vpcEndpointDetails"
                            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
"vpcEndpointErrorDetails"
                            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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable BatchGetVpcEndpoint where
  hashWithSalt :: Int -> BatchGetVpcEndpoint -> Int
hashWithSalt Int
_salt BatchGetVpcEndpoint' {NonEmpty Text
ids :: NonEmpty Text
$sel:ids:BatchGetVpcEndpoint' :: BatchGetVpcEndpoint -> NonEmpty Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
ids

instance Prelude.NFData BatchGetVpcEndpoint where
  rnf :: BatchGetVpcEndpoint -> ()
rnf BatchGetVpcEndpoint' {NonEmpty Text
ids :: NonEmpty Text
$sel:ids:BatchGetVpcEndpoint' :: BatchGetVpcEndpoint -> NonEmpty Text
..} = forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
ids

instance Data.ToHeaders BatchGetVpcEndpoint where
  toHeaders :: BatchGetVpcEndpoint -> 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
"OpenSearchServerless.BatchGetVpcEndpoint" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON BatchGetVpcEndpoint where
  toJSON :: BatchGetVpcEndpoint -> Value
toJSON BatchGetVpcEndpoint' {NonEmpty Text
ids :: NonEmpty Text
$sel:ids:BatchGetVpcEndpoint' :: BatchGetVpcEndpoint -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ids" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
ids)]
      )

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

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

-- | /See:/ 'newBatchGetVpcEndpointResponse' smart constructor.
data BatchGetVpcEndpointResponse = BatchGetVpcEndpointResponse'
  { -- | Details about the specified VPC endpoint.
    BatchGetVpcEndpointResponse -> Maybe [VpcEndpointDetail]
vpcEndpointDetails :: Prelude.Maybe [VpcEndpointDetail],
    -- | Error information for a failed request.
    BatchGetVpcEndpointResponse -> Maybe [VpcEndpointErrorDetail]
vpcEndpointErrorDetails :: Prelude.Maybe [VpcEndpointErrorDetail],
    -- | The response's http status code.
    BatchGetVpcEndpointResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchGetVpcEndpointResponse -> BatchGetVpcEndpointResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetVpcEndpointResponse -> BatchGetVpcEndpointResponse -> Bool
$c/= :: BatchGetVpcEndpointResponse -> BatchGetVpcEndpointResponse -> Bool
== :: BatchGetVpcEndpointResponse -> BatchGetVpcEndpointResponse -> Bool
$c== :: BatchGetVpcEndpointResponse -> BatchGetVpcEndpointResponse -> Bool
Prelude.Eq, ReadPrec [BatchGetVpcEndpointResponse]
ReadPrec BatchGetVpcEndpointResponse
Int -> ReadS BatchGetVpcEndpointResponse
ReadS [BatchGetVpcEndpointResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetVpcEndpointResponse]
$creadListPrec :: ReadPrec [BatchGetVpcEndpointResponse]
readPrec :: ReadPrec BatchGetVpcEndpointResponse
$creadPrec :: ReadPrec BatchGetVpcEndpointResponse
readList :: ReadS [BatchGetVpcEndpointResponse]
$creadList :: ReadS [BatchGetVpcEndpointResponse]
readsPrec :: Int -> ReadS BatchGetVpcEndpointResponse
$creadsPrec :: Int -> ReadS BatchGetVpcEndpointResponse
Prelude.Read, Int -> BatchGetVpcEndpointResponse -> ShowS
[BatchGetVpcEndpointResponse] -> ShowS
BatchGetVpcEndpointResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetVpcEndpointResponse] -> ShowS
$cshowList :: [BatchGetVpcEndpointResponse] -> ShowS
show :: BatchGetVpcEndpointResponse -> String
$cshow :: BatchGetVpcEndpointResponse -> String
showsPrec :: Int -> BatchGetVpcEndpointResponse -> ShowS
$cshowsPrec :: Int -> BatchGetVpcEndpointResponse -> ShowS
Prelude.Show, forall x.
Rep BatchGetVpcEndpointResponse x -> BatchGetVpcEndpointResponse
forall x.
BatchGetVpcEndpointResponse -> Rep BatchGetVpcEndpointResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchGetVpcEndpointResponse x -> BatchGetVpcEndpointResponse
$cfrom :: forall x.
BatchGetVpcEndpointResponse -> Rep BatchGetVpcEndpointResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetVpcEndpointResponse' 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:
--
-- 'vpcEndpointDetails', 'batchGetVpcEndpointResponse_vpcEndpointDetails' - Details about the specified VPC endpoint.
--
-- 'vpcEndpointErrorDetails', 'batchGetVpcEndpointResponse_vpcEndpointErrorDetails' - Error information for a failed request.
--
-- 'httpStatus', 'batchGetVpcEndpointResponse_httpStatus' - The response's http status code.
newBatchGetVpcEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetVpcEndpointResponse
newBatchGetVpcEndpointResponse :: Int -> BatchGetVpcEndpointResponse
newBatchGetVpcEndpointResponse Int
pHttpStatus_ =
  BatchGetVpcEndpointResponse'
    { $sel:vpcEndpointDetails:BatchGetVpcEndpointResponse' :: Maybe [VpcEndpointDetail]
vpcEndpointDetails =
        forall a. Maybe a
Prelude.Nothing,
      $sel:vpcEndpointErrorDetails:BatchGetVpcEndpointResponse' :: Maybe [VpcEndpointErrorDetail]
vpcEndpointErrorDetails = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetVpcEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details about the specified VPC endpoint.
batchGetVpcEndpointResponse_vpcEndpointDetails :: Lens.Lens' BatchGetVpcEndpointResponse (Prelude.Maybe [VpcEndpointDetail])
batchGetVpcEndpointResponse_vpcEndpointDetails :: Lens' BatchGetVpcEndpointResponse (Maybe [VpcEndpointDetail])
batchGetVpcEndpointResponse_vpcEndpointDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetVpcEndpointResponse' {Maybe [VpcEndpointDetail]
vpcEndpointDetails :: Maybe [VpcEndpointDetail]
$sel:vpcEndpointDetails:BatchGetVpcEndpointResponse' :: BatchGetVpcEndpointResponse -> Maybe [VpcEndpointDetail]
vpcEndpointDetails} -> Maybe [VpcEndpointDetail]
vpcEndpointDetails) (\s :: BatchGetVpcEndpointResponse
s@BatchGetVpcEndpointResponse' {} Maybe [VpcEndpointDetail]
a -> BatchGetVpcEndpointResponse
s {$sel:vpcEndpointDetails:BatchGetVpcEndpointResponse' :: Maybe [VpcEndpointDetail]
vpcEndpointDetails = Maybe [VpcEndpointDetail]
a} :: BatchGetVpcEndpointResponse) 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

-- | Error information for a failed request.
batchGetVpcEndpointResponse_vpcEndpointErrorDetails :: Lens.Lens' BatchGetVpcEndpointResponse (Prelude.Maybe [VpcEndpointErrorDetail])
batchGetVpcEndpointResponse_vpcEndpointErrorDetails :: Lens' BatchGetVpcEndpointResponse (Maybe [VpcEndpointErrorDetail])
batchGetVpcEndpointResponse_vpcEndpointErrorDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetVpcEndpointResponse' {Maybe [VpcEndpointErrorDetail]
vpcEndpointErrorDetails :: Maybe [VpcEndpointErrorDetail]
$sel:vpcEndpointErrorDetails:BatchGetVpcEndpointResponse' :: BatchGetVpcEndpointResponse -> Maybe [VpcEndpointErrorDetail]
vpcEndpointErrorDetails} -> Maybe [VpcEndpointErrorDetail]
vpcEndpointErrorDetails) (\s :: BatchGetVpcEndpointResponse
s@BatchGetVpcEndpointResponse' {} Maybe [VpcEndpointErrorDetail]
a -> BatchGetVpcEndpointResponse
s {$sel:vpcEndpointErrorDetails:BatchGetVpcEndpointResponse' :: Maybe [VpcEndpointErrorDetail]
vpcEndpointErrorDetails = Maybe [VpcEndpointErrorDetail]
a} :: BatchGetVpcEndpointResponse) 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 response's http status code.
batchGetVpcEndpointResponse_httpStatus :: Lens.Lens' BatchGetVpcEndpointResponse Prelude.Int
batchGetVpcEndpointResponse_httpStatus :: Lens' BatchGetVpcEndpointResponse Int
batchGetVpcEndpointResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetVpcEndpointResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchGetVpcEndpointResponse' :: BatchGetVpcEndpointResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchGetVpcEndpointResponse
s@BatchGetVpcEndpointResponse' {} Int
a -> BatchGetVpcEndpointResponse
s {$sel:httpStatus:BatchGetVpcEndpointResponse' :: Int
httpStatus = Int
a} :: BatchGetVpcEndpointResponse)

instance Prelude.NFData BatchGetVpcEndpointResponse where
  rnf :: BatchGetVpcEndpointResponse -> ()
rnf BatchGetVpcEndpointResponse' {Int
Maybe [VpcEndpointErrorDetail]
Maybe [VpcEndpointDetail]
httpStatus :: Int
vpcEndpointErrorDetails :: Maybe [VpcEndpointErrorDetail]
vpcEndpointDetails :: Maybe [VpcEndpointDetail]
$sel:httpStatus:BatchGetVpcEndpointResponse' :: BatchGetVpcEndpointResponse -> Int
$sel:vpcEndpointErrorDetails:BatchGetVpcEndpointResponse' :: BatchGetVpcEndpointResponse -> Maybe [VpcEndpointErrorDetail]
$sel:vpcEndpointDetails:BatchGetVpcEndpointResponse' :: BatchGetVpcEndpointResponse -> Maybe [VpcEndpointDetail]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [VpcEndpointDetail]
vpcEndpointDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [VpcEndpointErrorDetail]
vpcEndpointErrorDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus