{-# 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.OpenSearch.ListVpcEndpointAccess
-- 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 information about each Amazon Web Services principal that is
-- allowed to access a given Amazon OpenSearch Service domain through the
-- use of an interface VPC endpoint.
module Amazonka.OpenSearch.ListVpcEndpointAccess
  ( -- * Creating a Request
    ListVpcEndpointAccess (..),
    newListVpcEndpointAccess,

    -- * Request Lenses
    listVpcEndpointAccess_nextToken,
    listVpcEndpointAccess_domainName,

    -- * Destructuring the Response
    ListVpcEndpointAccessResponse (..),
    newListVpcEndpointAccessResponse,

    -- * Response Lenses
    listVpcEndpointAccessResponse_httpStatus,
    listVpcEndpointAccessResponse_authorizedPrincipalList,
    listVpcEndpointAccessResponse_nextToken,
  )
where

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

-- | /See:/ 'newListVpcEndpointAccess' smart constructor.
data ListVpcEndpointAccess = ListVpcEndpointAccess'
  { -- | If your initial @ListVpcEndpointAccess@ operation returns a @nextToken@,
    -- you can include the returned @nextToken@ in subsequent
    -- @ListVpcEndpointAccess@ operations, which returns results in the next
    -- page.
    ListVpcEndpointAccess -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the OpenSearch Service domain to retrieve access information
    -- for.
    ListVpcEndpointAccess -> Text
domainName :: Prelude.Text
  }
  deriving (ListVpcEndpointAccess -> ListVpcEndpointAccess -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListVpcEndpointAccess -> ListVpcEndpointAccess -> Bool
$c/= :: ListVpcEndpointAccess -> ListVpcEndpointAccess -> Bool
== :: ListVpcEndpointAccess -> ListVpcEndpointAccess -> Bool
$c== :: ListVpcEndpointAccess -> ListVpcEndpointAccess -> Bool
Prelude.Eq, ReadPrec [ListVpcEndpointAccess]
ReadPrec ListVpcEndpointAccess
Int -> ReadS ListVpcEndpointAccess
ReadS [ListVpcEndpointAccess]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListVpcEndpointAccess]
$creadListPrec :: ReadPrec [ListVpcEndpointAccess]
readPrec :: ReadPrec ListVpcEndpointAccess
$creadPrec :: ReadPrec ListVpcEndpointAccess
readList :: ReadS [ListVpcEndpointAccess]
$creadList :: ReadS [ListVpcEndpointAccess]
readsPrec :: Int -> ReadS ListVpcEndpointAccess
$creadsPrec :: Int -> ReadS ListVpcEndpointAccess
Prelude.Read, Int -> ListVpcEndpointAccess -> ShowS
[ListVpcEndpointAccess] -> ShowS
ListVpcEndpointAccess -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListVpcEndpointAccess] -> ShowS
$cshowList :: [ListVpcEndpointAccess] -> ShowS
show :: ListVpcEndpointAccess -> String
$cshow :: ListVpcEndpointAccess -> String
showsPrec :: Int -> ListVpcEndpointAccess -> ShowS
$cshowsPrec :: Int -> ListVpcEndpointAccess -> ShowS
Prelude.Show, forall x. Rep ListVpcEndpointAccess x -> ListVpcEndpointAccess
forall x. ListVpcEndpointAccess -> Rep ListVpcEndpointAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListVpcEndpointAccess x -> ListVpcEndpointAccess
$cfrom :: forall x. ListVpcEndpointAccess -> Rep ListVpcEndpointAccess x
Prelude.Generic)

-- |
-- Create a value of 'ListVpcEndpointAccess' 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', 'listVpcEndpointAccess_nextToken' - If your initial @ListVpcEndpointAccess@ operation returns a @nextToken@,
-- you can include the returned @nextToken@ in subsequent
-- @ListVpcEndpointAccess@ operations, which returns results in the next
-- page.
--
-- 'domainName', 'listVpcEndpointAccess_domainName' - The name of the OpenSearch Service domain to retrieve access information
-- for.
newListVpcEndpointAccess ::
  -- | 'domainName'
  Prelude.Text ->
  ListVpcEndpointAccess
newListVpcEndpointAccess :: Text -> ListVpcEndpointAccess
newListVpcEndpointAccess Text
pDomainName_ =
  ListVpcEndpointAccess'
    { $sel:nextToken:ListVpcEndpointAccess' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:ListVpcEndpointAccess' :: Text
domainName = Text
pDomainName_
    }

-- | If your initial @ListVpcEndpointAccess@ operation returns a @nextToken@,
-- you can include the returned @nextToken@ in subsequent
-- @ListVpcEndpointAccess@ operations, which returns results in the next
-- page.
listVpcEndpointAccess_nextToken :: Lens.Lens' ListVpcEndpointAccess (Prelude.Maybe Prelude.Text)
listVpcEndpointAccess_nextToken :: Lens' ListVpcEndpointAccess (Maybe Text)
listVpcEndpointAccess_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListVpcEndpointAccess' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListVpcEndpointAccess' :: ListVpcEndpointAccess -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListVpcEndpointAccess
s@ListVpcEndpointAccess' {} Maybe Text
a -> ListVpcEndpointAccess
s {$sel:nextToken:ListVpcEndpointAccess' :: Maybe Text
nextToken = Maybe Text
a} :: ListVpcEndpointAccess)

-- | The name of the OpenSearch Service domain to retrieve access information
-- for.
listVpcEndpointAccess_domainName :: Lens.Lens' ListVpcEndpointAccess Prelude.Text
listVpcEndpointAccess_domainName :: Lens' ListVpcEndpointAccess Text
listVpcEndpointAccess_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListVpcEndpointAccess' {Text
domainName :: Text
$sel:domainName:ListVpcEndpointAccess' :: ListVpcEndpointAccess -> Text
domainName} -> Text
domainName) (\s :: ListVpcEndpointAccess
s@ListVpcEndpointAccess' {} Text
a -> ListVpcEndpointAccess
s {$sel:domainName:ListVpcEndpointAccess' :: Text
domainName = Text
a} :: ListVpcEndpointAccess)

instance Core.AWSRequest ListVpcEndpointAccess where
  type
    AWSResponse ListVpcEndpointAccess =
      ListVpcEndpointAccessResponse
  request :: (Service -> Service)
-> ListVpcEndpointAccess -> Request ListVpcEndpointAccess
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 ListVpcEndpointAccess
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListVpcEndpointAccess)))
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 ->
          Int
-> [AuthorizedPrincipal] -> Text -> ListVpcEndpointAccessResponse
ListVpcEndpointAccessResponse'
            forall (f :: * -> *) a b. Functor 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))
            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
"AuthorizedPrincipalList"
                            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 a
Data..:> Key
"NextToken")
      )

instance Prelude.Hashable ListVpcEndpointAccess where
  hashWithSalt :: Int -> ListVpcEndpointAccess -> Int
hashWithSalt Int
_salt ListVpcEndpointAccess' {Maybe Text
Text
domainName :: Text
nextToken :: Maybe Text
$sel:domainName:ListVpcEndpointAccess' :: ListVpcEndpointAccess -> Text
$sel:nextToken:ListVpcEndpointAccess' :: ListVpcEndpointAccess -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData ListVpcEndpointAccess where
  rnf :: ListVpcEndpointAccess -> ()
rnf ListVpcEndpointAccess' {Maybe Text
Text
domainName :: Text
nextToken :: Maybe Text
$sel:domainName:ListVpcEndpointAccess' :: ListVpcEndpointAccess -> Text
$sel:nextToken:ListVpcEndpointAccess' :: ListVpcEndpointAccess -> Maybe Text
..} =
    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 Text
domainName

instance Data.ToHeaders ListVpcEndpointAccess where
  toHeaders :: ListVpcEndpointAccess -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath ListVpcEndpointAccess where
  toPath :: ListVpcEndpointAccess -> ByteString
toPath ListVpcEndpointAccess' {Maybe Text
Text
domainName :: Text
nextToken :: Maybe Text
$sel:domainName:ListVpcEndpointAccess' :: ListVpcEndpointAccess -> Text
$sel:nextToken:ListVpcEndpointAccess' :: ListVpcEndpointAccess -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2021-01-01/opensearch/domain/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
domainName,
        ByteString
"/listVpcEndpointAccess"
      ]

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

-- | /See:/ 'newListVpcEndpointAccessResponse' smart constructor.
data ListVpcEndpointAccessResponse = ListVpcEndpointAccessResponse'
  { -- | The response's http status code.
    ListVpcEndpointAccessResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html IAM principals>
    -- that can currently access the domain.
    ListVpcEndpointAccessResponse -> [AuthorizedPrincipal]
authorizedPrincipalList :: [AuthorizedPrincipal],
    -- | When @nextToken@ is returned, there are more results available. The
    -- value of @nextToken@ is a unique pagination token for each page. Make
    -- the call again using the returned token to retrieve the next page.
    ListVpcEndpointAccessResponse -> Text
nextToken :: Prelude.Text
  }
  deriving (ListVpcEndpointAccessResponse
-> ListVpcEndpointAccessResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListVpcEndpointAccessResponse
-> ListVpcEndpointAccessResponse -> Bool
$c/= :: ListVpcEndpointAccessResponse
-> ListVpcEndpointAccessResponse -> Bool
== :: ListVpcEndpointAccessResponse
-> ListVpcEndpointAccessResponse -> Bool
$c== :: ListVpcEndpointAccessResponse
-> ListVpcEndpointAccessResponse -> Bool
Prelude.Eq, ReadPrec [ListVpcEndpointAccessResponse]
ReadPrec ListVpcEndpointAccessResponse
Int -> ReadS ListVpcEndpointAccessResponse
ReadS [ListVpcEndpointAccessResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListVpcEndpointAccessResponse]
$creadListPrec :: ReadPrec [ListVpcEndpointAccessResponse]
readPrec :: ReadPrec ListVpcEndpointAccessResponse
$creadPrec :: ReadPrec ListVpcEndpointAccessResponse
readList :: ReadS [ListVpcEndpointAccessResponse]
$creadList :: ReadS [ListVpcEndpointAccessResponse]
readsPrec :: Int -> ReadS ListVpcEndpointAccessResponse
$creadsPrec :: Int -> ReadS ListVpcEndpointAccessResponse
Prelude.Read, Int -> ListVpcEndpointAccessResponse -> ShowS
[ListVpcEndpointAccessResponse] -> ShowS
ListVpcEndpointAccessResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListVpcEndpointAccessResponse] -> ShowS
$cshowList :: [ListVpcEndpointAccessResponse] -> ShowS
show :: ListVpcEndpointAccessResponse -> String
$cshow :: ListVpcEndpointAccessResponse -> String
showsPrec :: Int -> ListVpcEndpointAccessResponse -> ShowS
$cshowsPrec :: Int -> ListVpcEndpointAccessResponse -> ShowS
Prelude.Show, forall x.
Rep ListVpcEndpointAccessResponse x
-> ListVpcEndpointAccessResponse
forall x.
ListVpcEndpointAccessResponse
-> Rep ListVpcEndpointAccessResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListVpcEndpointAccessResponse x
-> ListVpcEndpointAccessResponse
$cfrom :: forall x.
ListVpcEndpointAccessResponse
-> Rep ListVpcEndpointAccessResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListVpcEndpointAccessResponse' 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:
--
-- 'httpStatus', 'listVpcEndpointAccessResponse_httpStatus' - The response's http status code.
--
-- 'authorizedPrincipalList', 'listVpcEndpointAccessResponse_authorizedPrincipalList' - A list of
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html IAM principals>
-- that can currently access the domain.
--
-- 'nextToken', 'listVpcEndpointAccessResponse_nextToken' - When @nextToken@ is returned, there are more results available. The
-- value of @nextToken@ is a unique pagination token for each page. Make
-- the call again using the returned token to retrieve the next page.
newListVpcEndpointAccessResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'nextToken'
  Prelude.Text ->
  ListVpcEndpointAccessResponse
newListVpcEndpointAccessResponse :: Int -> Text -> ListVpcEndpointAccessResponse
newListVpcEndpointAccessResponse
  Int
pHttpStatus_
  Text
pNextToken_ =
    ListVpcEndpointAccessResponse'
      { $sel:httpStatus:ListVpcEndpointAccessResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:authorizedPrincipalList:ListVpcEndpointAccessResponse' :: [AuthorizedPrincipal]
authorizedPrincipalList = forall a. Monoid a => a
Prelude.mempty,
        $sel:nextToken:ListVpcEndpointAccessResponse' :: Text
nextToken = Text
pNextToken_
      }

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

-- | A list of
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html IAM principals>
-- that can currently access the domain.
listVpcEndpointAccessResponse_authorizedPrincipalList :: Lens.Lens' ListVpcEndpointAccessResponse [AuthorizedPrincipal]
listVpcEndpointAccessResponse_authorizedPrincipalList :: Lens' ListVpcEndpointAccessResponse [AuthorizedPrincipal]
listVpcEndpointAccessResponse_authorizedPrincipalList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListVpcEndpointAccessResponse' {[AuthorizedPrincipal]
authorizedPrincipalList :: [AuthorizedPrincipal]
$sel:authorizedPrincipalList:ListVpcEndpointAccessResponse' :: ListVpcEndpointAccessResponse -> [AuthorizedPrincipal]
authorizedPrincipalList} -> [AuthorizedPrincipal]
authorizedPrincipalList) (\s :: ListVpcEndpointAccessResponse
s@ListVpcEndpointAccessResponse' {} [AuthorizedPrincipal]
a -> ListVpcEndpointAccessResponse
s {$sel:authorizedPrincipalList:ListVpcEndpointAccessResponse' :: [AuthorizedPrincipal]
authorizedPrincipalList = [AuthorizedPrincipal]
a} :: ListVpcEndpointAccessResponse) 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

-- | When @nextToken@ is returned, there are more results available. The
-- value of @nextToken@ is a unique pagination token for each page. Make
-- the call again using the returned token to retrieve the next page.
listVpcEndpointAccessResponse_nextToken :: Lens.Lens' ListVpcEndpointAccessResponse Prelude.Text
listVpcEndpointAccessResponse_nextToken :: Lens' ListVpcEndpointAccessResponse Text
listVpcEndpointAccessResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListVpcEndpointAccessResponse' {Text
nextToken :: Text
$sel:nextToken:ListVpcEndpointAccessResponse' :: ListVpcEndpointAccessResponse -> Text
nextToken} -> Text
nextToken) (\s :: ListVpcEndpointAccessResponse
s@ListVpcEndpointAccessResponse' {} Text
a -> ListVpcEndpointAccessResponse
s {$sel:nextToken:ListVpcEndpointAccessResponse' :: Text
nextToken = Text
a} :: ListVpcEndpointAccessResponse)

instance Prelude.NFData ListVpcEndpointAccessResponse where
  rnf :: ListVpcEndpointAccessResponse -> ()
rnf ListVpcEndpointAccessResponse' {Int
[AuthorizedPrincipal]
Text
nextToken :: Text
authorizedPrincipalList :: [AuthorizedPrincipal]
httpStatus :: Int
$sel:nextToken:ListVpcEndpointAccessResponse' :: ListVpcEndpointAccessResponse -> Text
$sel:authorizedPrincipalList:ListVpcEndpointAccessResponse' :: ListVpcEndpointAccessResponse -> [AuthorizedPrincipal]
$sel:httpStatus:ListVpcEndpointAccessResponse' :: ListVpcEndpointAccessResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AuthorizedPrincipal]
authorizedPrincipalList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
nextToken