{-# 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.BatchGetCustomEntityTypes
-- 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 the details for the custom patterns specified by a list of
-- names.
module Amazonka.Glue.BatchGetCustomEntityTypes
  ( -- * Creating a Request
    BatchGetCustomEntityTypes (..),
    newBatchGetCustomEntityTypes,

    -- * Request Lenses
    batchGetCustomEntityTypes_names,

    -- * Destructuring the Response
    BatchGetCustomEntityTypesResponse (..),
    newBatchGetCustomEntityTypesResponse,

    -- * Response Lenses
    batchGetCustomEntityTypesResponse_customEntityTypes,
    batchGetCustomEntityTypesResponse_customEntityTypesNotFound,
    batchGetCustomEntityTypesResponse_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:/ 'newBatchGetCustomEntityTypes' smart constructor.
data BatchGetCustomEntityTypes = BatchGetCustomEntityTypes'
  { -- | A list of names of the custom patterns that you want to retrieve.
    BatchGetCustomEntityTypes -> NonEmpty Text
names :: Prelude.NonEmpty Prelude.Text
  }
  deriving (BatchGetCustomEntityTypes -> BatchGetCustomEntityTypes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetCustomEntityTypes -> BatchGetCustomEntityTypes -> Bool
$c/= :: BatchGetCustomEntityTypes -> BatchGetCustomEntityTypes -> Bool
== :: BatchGetCustomEntityTypes -> BatchGetCustomEntityTypes -> Bool
$c== :: BatchGetCustomEntityTypes -> BatchGetCustomEntityTypes -> Bool
Prelude.Eq, ReadPrec [BatchGetCustomEntityTypes]
ReadPrec BatchGetCustomEntityTypes
Int -> ReadS BatchGetCustomEntityTypes
ReadS [BatchGetCustomEntityTypes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetCustomEntityTypes]
$creadListPrec :: ReadPrec [BatchGetCustomEntityTypes]
readPrec :: ReadPrec BatchGetCustomEntityTypes
$creadPrec :: ReadPrec BatchGetCustomEntityTypes
readList :: ReadS [BatchGetCustomEntityTypes]
$creadList :: ReadS [BatchGetCustomEntityTypes]
readsPrec :: Int -> ReadS BatchGetCustomEntityTypes
$creadsPrec :: Int -> ReadS BatchGetCustomEntityTypes
Prelude.Read, Int -> BatchGetCustomEntityTypes -> ShowS
[BatchGetCustomEntityTypes] -> ShowS
BatchGetCustomEntityTypes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetCustomEntityTypes] -> ShowS
$cshowList :: [BatchGetCustomEntityTypes] -> ShowS
show :: BatchGetCustomEntityTypes -> String
$cshow :: BatchGetCustomEntityTypes -> String
showsPrec :: Int -> BatchGetCustomEntityTypes -> ShowS
$cshowsPrec :: Int -> BatchGetCustomEntityTypes -> ShowS
Prelude.Show, forall x.
Rep BatchGetCustomEntityTypes x -> BatchGetCustomEntityTypes
forall x.
BatchGetCustomEntityTypes -> Rep BatchGetCustomEntityTypes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchGetCustomEntityTypes x -> BatchGetCustomEntityTypes
$cfrom :: forall x.
BatchGetCustomEntityTypes -> Rep BatchGetCustomEntityTypes x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetCustomEntityTypes' 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:
--
-- 'names', 'batchGetCustomEntityTypes_names' - A list of names of the custom patterns that you want to retrieve.
newBatchGetCustomEntityTypes ::
  -- | 'names'
  Prelude.NonEmpty Prelude.Text ->
  BatchGetCustomEntityTypes
newBatchGetCustomEntityTypes :: NonEmpty Text -> BatchGetCustomEntityTypes
newBatchGetCustomEntityTypes NonEmpty Text
pNames_ =
  BatchGetCustomEntityTypes'
    { $sel:names:BatchGetCustomEntityTypes' :: NonEmpty Text
names =
        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
pNames_
    }

-- | A list of names of the custom patterns that you want to retrieve.
batchGetCustomEntityTypes_names :: Lens.Lens' BatchGetCustomEntityTypes (Prelude.NonEmpty Prelude.Text)
batchGetCustomEntityTypes_names :: Lens' BatchGetCustomEntityTypes (NonEmpty Text)
batchGetCustomEntityTypes_names = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCustomEntityTypes' {NonEmpty Text
names :: NonEmpty Text
$sel:names:BatchGetCustomEntityTypes' :: BatchGetCustomEntityTypes -> NonEmpty Text
names} -> NonEmpty Text
names) (\s :: BatchGetCustomEntityTypes
s@BatchGetCustomEntityTypes' {} NonEmpty Text
a -> BatchGetCustomEntityTypes
s {$sel:names:BatchGetCustomEntityTypes' :: NonEmpty Text
names = NonEmpty Text
a} :: BatchGetCustomEntityTypes) 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 BatchGetCustomEntityTypes where
  type
    AWSResponse BatchGetCustomEntityTypes =
      BatchGetCustomEntityTypesResponse
  request :: (Service -> Service)
-> BatchGetCustomEntityTypes -> Request BatchGetCustomEntityTypes
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 BatchGetCustomEntityTypes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetCustomEntityTypes)))
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 [CustomEntityType]
-> Maybe (NonEmpty Text)
-> Int
-> BatchGetCustomEntityTypesResponse
BatchGetCustomEntityTypesResponse'
            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
"CustomEntityTypes"
                            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
"CustomEntityTypesNotFound")
            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 BatchGetCustomEntityTypes where
  hashWithSalt :: Int -> BatchGetCustomEntityTypes -> Int
hashWithSalt Int
_salt BatchGetCustomEntityTypes' {NonEmpty Text
names :: NonEmpty Text
$sel:names:BatchGetCustomEntityTypes' :: BatchGetCustomEntityTypes -> NonEmpty Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
names

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

instance Data.ToHeaders BatchGetCustomEntityTypes where
  toHeaders :: BatchGetCustomEntityTypes -> 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.BatchGetCustomEntityTypes" ::
                          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 BatchGetCustomEntityTypes where
  toJSON :: BatchGetCustomEntityTypes -> Value
toJSON BatchGetCustomEntityTypes' {NonEmpty Text
names :: NonEmpty Text
$sel:names:BatchGetCustomEntityTypes' :: BatchGetCustomEntityTypes -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Names" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
names)]
      )

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

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

-- | /See:/ 'newBatchGetCustomEntityTypesResponse' smart constructor.
data BatchGetCustomEntityTypesResponse = BatchGetCustomEntityTypesResponse'
  { -- | A list of @CustomEntityType@ objects representing the custom patterns
    -- that have been created.
    BatchGetCustomEntityTypesResponse -> Maybe [CustomEntityType]
customEntityTypes :: Prelude.Maybe [CustomEntityType],
    -- | A list of the names of custom patterns that were not found.
    BatchGetCustomEntityTypesResponse -> Maybe (NonEmpty Text)
customEntityTypesNotFound :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The response's http status code.
    BatchGetCustomEntityTypesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchGetCustomEntityTypesResponse
-> BatchGetCustomEntityTypesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetCustomEntityTypesResponse
-> BatchGetCustomEntityTypesResponse -> Bool
$c/= :: BatchGetCustomEntityTypesResponse
-> BatchGetCustomEntityTypesResponse -> Bool
== :: BatchGetCustomEntityTypesResponse
-> BatchGetCustomEntityTypesResponse -> Bool
$c== :: BatchGetCustomEntityTypesResponse
-> BatchGetCustomEntityTypesResponse -> Bool
Prelude.Eq, ReadPrec [BatchGetCustomEntityTypesResponse]
ReadPrec BatchGetCustomEntityTypesResponse
Int -> ReadS BatchGetCustomEntityTypesResponse
ReadS [BatchGetCustomEntityTypesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetCustomEntityTypesResponse]
$creadListPrec :: ReadPrec [BatchGetCustomEntityTypesResponse]
readPrec :: ReadPrec BatchGetCustomEntityTypesResponse
$creadPrec :: ReadPrec BatchGetCustomEntityTypesResponse
readList :: ReadS [BatchGetCustomEntityTypesResponse]
$creadList :: ReadS [BatchGetCustomEntityTypesResponse]
readsPrec :: Int -> ReadS BatchGetCustomEntityTypesResponse
$creadsPrec :: Int -> ReadS BatchGetCustomEntityTypesResponse
Prelude.Read, Int -> BatchGetCustomEntityTypesResponse -> ShowS
[BatchGetCustomEntityTypesResponse] -> ShowS
BatchGetCustomEntityTypesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetCustomEntityTypesResponse] -> ShowS
$cshowList :: [BatchGetCustomEntityTypesResponse] -> ShowS
show :: BatchGetCustomEntityTypesResponse -> String
$cshow :: BatchGetCustomEntityTypesResponse -> String
showsPrec :: Int -> BatchGetCustomEntityTypesResponse -> ShowS
$cshowsPrec :: Int -> BatchGetCustomEntityTypesResponse -> ShowS
Prelude.Show, forall x.
Rep BatchGetCustomEntityTypesResponse x
-> BatchGetCustomEntityTypesResponse
forall x.
BatchGetCustomEntityTypesResponse
-> Rep BatchGetCustomEntityTypesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchGetCustomEntityTypesResponse x
-> BatchGetCustomEntityTypesResponse
$cfrom :: forall x.
BatchGetCustomEntityTypesResponse
-> Rep BatchGetCustomEntityTypesResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetCustomEntityTypesResponse' 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:
--
-- 'customEntityTypes', 'batchGetCustomEntityTypesResponse_customEntityTypes' - A list of @CustomEntityType@ objects representing the custom patterns
-- that have been created.
--
-- 'customEntityTypesNotFound', 'batchGetCustomEntityTypesResponse_customEntityTypesNotFound' - A list of the names of custom patterns that were not found.
--
-- 'httpStatus', 'batchGetCustomEntityTypesResponse_httpStatus' - The response's http status code.
newBatchGetCustomEntityTypesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetCustomEntityTypesResponse
newBatchGetCustomEntityTypesResponse :: Int -> BatchGetCustomEntityTypesResponse
newBatchGetCustomEntityTypesResponse Int
pHttpStatus_ =
  BatchGetCustomEntityTypesResponse'
    { $sel:customEntityTypes:BatchGetCustomEntityTypesResponse' :: Maybe [CustomEntityType]
customEntityTypes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:customEntityTypesNotFound:BatchGetCustomEntityTypesResponse' :: Maybe (NonEmpty Text)
customEntityTypesNotFound =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetCustomEntityTypesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of @CustomEntityType@ objects representing the custom patterns
-- that have been created.
batchGetCustomEntityTypesResponse_customEntityTypes :: Lens.Lens' BatchGetCustomEntityTypesResponse (Prelude.Maybe [CustomEntityType])
batchGetCustomEntityTypesResponse_customEntityTypes :: Lens' BatchGetCustomEntityTypesResponse (Maybe [CustomEntityType])
batchGetCustomEntityTypesResponse_customEntityTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCustomEntityTypesResponse' {Maybe [CustomEntityType]
customEntityTypes :: Maybe [CustomEntityType]
$sel:customEntityTypes:BatchGetCustomEntityTypesResponse' :: BatchGetCustomEntityTypesResponse -> Maybe [CustomEntityType]
customEntityTypes} -> Maybe [CustomEntityType]
customEntityTypes) (\s :: BatchGetCustomEntityTypesResponse
s@BatchGetCustomEntityTypesResponse' {} Maybe [CustomEntityType]
a -> BatchGetCustomEntityTypesResponse
s {$sel:customEntityTypes:BatchGetCustomEntityTypesResponse' :: Maybe [CustomEntityType]
customEntityTypes = Maybe [CustomEntityType]
a} :: BatchGetCustomEntityTypesResponse) 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 list of the names of custom patterns that were not found.
batchGetCustomEntityTypesResponse_customEntityTypesNotFound :: Lens.Lens' BatchGetCustomEntityTypesResponse (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
batchGetCustomEntityTypesResponse_customEntityTypesNotFound :: Lens' BatchGetCustomEntityTypesResponse (Maybe (NonEmpty Text))
batchGetCustomEntityTypesResponse_customEntityTypesNotFound = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCustomEntityTypesResponse' {Maybe (NonEmpty Text)
customEntityTypesNotFound :: Maybe (NonEmpty Text)
$sel:customEntityTypesNotFound:BatchGetCustomEntityTypesResponse' :: BatchGetCustomEntityTypesResponse -> Maybe (NonEmpty Text)
customEntityTypesNotFound} -> Maybe (NonEmpty Text)
customEntityTypesNotFound) (\s :: BatchGetCustomEntityTypesResponse
s@BatchGetCustomEntityTypesResponse' {} Maybe (NonEmpty Text)
a -> BatchGetCustomEntityTypesResponse
s {$sel:customEntityTypesNotFound:BatchGetCustomEntityTypesResponse' :: Maybe (NonEmpty Text)
customEntityTypesNotFound = Maybe (NonEmpty Text)
a} :: BatchGetCustomEntityTypesResponse) 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.
batchGetCustomEntityTypesResponse_httpStatus :: Lens.Lens' BatchGetCustomEntityTypesResponse Prelude.Int
batchGetCustomEntityTypesResponse_httpStatus :: Lens' BatchGetCustomEntityTypesResponse Int
batchGetCustomEntityTypesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCustomEntityTypesResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchGetCustomEntityTypesResponse' :: BatchGetCustomEntityTypesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchGetCustomEntityTypesResponse
s@BatchGetCustomEntityTypesResponse' {} Int
a -> BatchGetCustomEntityTypesResponse
s {$sel:httpStatus:BatchGetCustomEntityTypesResponse' :: Int
httpStatus = Int
a} :: BatchGetCustomEntityTypesResponse)

instance
  Prelude.NFData
    BatchGetCustomEntityTypesResponse
  where
  rnf :: BatchGetCustomEntityTypesResponse -> ()
rnf BatchGetCustomEntityTypesResponse' {Int
Maybe [CustomEntityType]
Maybe (NonEmpty Text)
httpStatus :: Int
customEntityTypesNotFound :: Maybe (NonEmpty Text)
customEntityTypes :: Maybe [CustomEntityType]
$sel:httpStatus:BatchGetCustomEntityTypesResponse' :: BatchGetCustomEntityTypesResponse -> Int
$sel:customEntityTypesNotFound:BatchGetCustomEntityTypesResponse' :: BatchGetCustomEntityTypesResponse -> Maybe (NonEmpty Text)
$sel:customEntityTypes:BatchGetCustomEntityTypesResponse' :: BatchGetCustomEntityTypesResponse -> Maybe [CustomEntityType]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CustomEntityType]
customEntityTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
customEntityTypesNotFound
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus