{-# 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.SageMakerFeatureStoreRuntime.BatchGetRecord
-- 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 a batch of @Records@ from a @FeatureGroup@.
module Amazonka.SageMakerFeatureStoreRuntime.BatchGetRecord
  ( -- * Creating a Request
    BatchGetRecord (..),
    newBatchGetRecord,

    -- * Request Lenses
    batchGetRecord_identifiers,

    -- * Destructuring the Response
    BatchGetRecordResponse (..),
    newBatchGetRecordResponse,

    -- * Response Lenses
    batchGetRecordResponse_httpStatus,
    batchGetRecordResponse_records,
    batchGetRecordResponse_errors,
    batchGetRecordResponse_unprocessedIdentifiers,
  )
where

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

-- | /See:/ 'newBatchGetRecord' smart constructor.
data BatchGetRecord = BatchGetRecord'
  { -- | A list of @FeatureGroup@ names, with their corresponding
    -- @RecordIdentifier@ value, and Feature name that have been requested to
    -- be retrieved in batch.
    BatchGetRecord -> NonEmpty BatchGetRecordIdentifier
identifiers :: Prelude.NonEmpty BatchGetRecordIdentifier
  }
  deriving (BatchGetRecord -> BatchGetRecord -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetRecord -> BatchGetRecord -> Bool
$c/= :: BatchGetRecord -> BatchGetRecord -> Bool
== :: BatchGetRecord -> BatchGetRecord -> Bool
$c== :: BatchGetRecord -> BatchGetRecord -> Bool
Prelude.Eq, ReadPrec [BatchGetRecord]
ReadPrec BatchGetRecord
Int -> ReadS BatchGetRecord
ReadS [BatchGetRecord]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetRecord]
$creadListPrec :: ReadPrec [BatchGetRecord]
readPrec :: ReadPrec BatchGetRecord
$creadPrec :: ReadPrec BatchGetRecord
readList :: ReadS [BatchGetRecord]
$creadList :: ReadS [BatchGetRecord]
readsPrec :: Int -> ReadS BatchGetRecord
$creadsPrec :: Int -> ReadS BatchGetRecord
Prelude.Read, Int -> BatchGetRecord -> ShowS
[BatchGetRecord] -> ShowS
BatchGetRecord -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetRecord] -> ShowS
$cshowList :: [BatchGetRecord] -> ShowS
show :: BatchGetRecord -> String
$cshow :: BatchGetRecord -> String
showsPrec :: Int -> BatchGetRecord -> ShowS
$cshowsPrec :: Int -> BatchGetRecord -> ShowS
Prelude.Show, forall x. Rep BatchGetRecord x -> BatchGetRecord
forall x. BatchGetRecord -> Rep BatchGetRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetRecord x -> BatchGetRecord
$cfrom :: forall x. BatchGetRecord -> Rep BatchGetRecord x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetRecord' 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:
--
-- 'identifiers', 'batchGetRecord_identifiers' - A list of @FeatureGroup@ names, with their corresponding
-- @RecordIdentifier@ value, and Feature name that have been requested to
-- be retrieved in batch.
newBatchGetRecord ::
  -- | 'identifiers'
  Prelude.NonEmpty BatchGetRecordIdentifier ->
  BatchGetRecord
newBatchGetRecord :: NonEmpty BatchGetRecordIdentifier -> BatchGetRecord
newBatchGetRecord NonEmpty BatchGetRecordIdentifier
pIdentifiers_ =
  BatchGetRecord'
    { $sel:identifiers:BatchGetRecord' :: NonEmpty BatchGetRecordIdentifier
identifiers =
        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 BatchGetRecordIdentifier
pIdentifiers_
    }

-- | A list of @FeatureGroup@ names, with their corresponding
-- @RecordIdentifier@ value, and Feature name that have been requested to
-- be retrieved in batch.
batchGetRecord_identifiers :: Lens.Lens' BatchGetRecord (Prelude.NonEmpty BatchGetRecordIdentifier)
batchGetRecord_identifiers :: Lens' BatchGetRecord (NonEmpty BatchGetRecordIdentifier)
batchGetRecord_identifiers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetRecord' {NonEmpty BatchGetRecordIdentifier
identifiers :: NonEmpty BatchGetRecordIdentifier
$sel:identifiers:BatchGetRecord' :: BatchGetRecord -> NonEmpty BatchGetRecordIdentifier
identifiers} -> NonEmpty BatchGetRecordIdentifier
identifiers) (\s :: BatchGetRecord
s@BatchGetRecord' {} NonEmpty BatchGetRecordIdentifier
a -> BatchGetRecord
s {$sel:identifiers:BatchGetRecord' :: NonEmpty BatchGetRecordIdentifier
identifiers = NonEmpty BatchGetRecordIdentifier
a} :: BatchGetRecord) 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 BatchGetRecord where
  type
    AWSResponse BatchGetRecord =
      BatchGetRecordResponse
  request :: (Service -> Service) -> BatchGetRecord -> Request BatchGetRecord
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 BatchGetRecord
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchGetRecord)))
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
-> [BatchGetRecordResultDetail]
-> [BatchGetRecordError]
-> [BatchGetRecordIdentifier]
-> BatchGetRecordResponse
BatchGetRecordResponse'
            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
"Records" 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
"Errors" 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
"UnprocessedIdentifiers"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable BatchGetRecord where
  hashWithSalt :: Int -> BatchGetRecord -> Int
hashWithSalt Int
_salt BatchGetRecord' {NonEmpty BatchGetRecordIdentifier
identifiers :: NonEmpty BatchGetRecordIdentifier
$sel:identifiers:BatchGetRecord' :: BatchGetRecord -> NonEmpty BatchGetRecordIdentifier
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty BatchGetRecordIdentifier
identifiers

instance Prelude.NFData BatchGetRecord where
  rnf :: BatchGetRecord -> ()
rnf BatchGetRecord' {NonEmpty BatchGetRecordIdentifier
identifiers :: NonEmpty BatchGetRecordIdentifier
$sel:identifiers:BatchGetRecord' :: BatchGetRecord -> NonEmpty BatchGetRecordIdentifier
..} = forall a. NFData a => a -> ()
Prelude.rnf NonEmpty BatchGetRecordIdentifier
identifiers

instance Data.ToHeaders BatchGetRecord where
  toHeaders :: BatchGetRecord -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

-- | /See:/ 'newBatchGetRecordResponse' smart constructor.
data BatchGetRecordResponse = BatchGetRecordResponse'
  { -- | The response's http status code.
    BatchGetRecordResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of Records you requested to be retrieved in batch.
    BatchGetRecordResponse -> [BatchGetRecordResultDetail]
records :: [BatchGetRecordResultDetail],
    -- | A list of errors that have occurred when retrieving a batch of Records.
    BatchGetRecordResponse -> [BatchGetRecordError]
errors :: [BatchGetRecordError],
    -- | A unprocessed list of @FeatureGroup@ names, with their corresponding
    -- @RecordIdentifier@ value, and Feature name.
    BatchGetRecordResponse -> [BatchGetRecordIdentifier]
unprocessedIdentifiers :: [BatchGetRecordIdentifier]
  }
  deriving (BatchGetRecordResponse -> BatchGetRecordResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetRecordResponse -> BatchGetRecordResponse -> Bool
$c/= :: BatchGetRecordResponse -> BatchGetRecordResponse -> Bool
== :: BatchGetRecordResponse -> BatchGetRecordResponse -> Bool
$c== :: BatchGetRecordResponse -> BatchGetRecordResponse -> Bool
Prelude.Eq, ReadPrec [BatchGetRecordResponse]
ReadPrec BatchGetRecordResponse
Int -> ReadS BatchGetRecordResponse
ReadS [BatchGetRecordResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetRecordResponse]
$creadListPrec :: ReadPrec [BatchGetRecordResponse]
readPrec :: ReadPrec BatchGetRecordResponse
$creadPrec :: ReadPrec BatchGetRecordResponse
readList :: ReadS [BatchGetRecordResponse]
$creadList :: ReadS [BatchGetRecordResponse]
readsPrec :: Int -> ReadS BatchGetRecordResponse
$creadsPrec :: Int -> ReadS BatchGetRecordResponse
Prelude.Read, Int -> BatchGetRecordResponse -> ShowS
[BatchGetRecordResponse] -> ShowS
BatchGetRecordResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetRecordResponse] -> ShowS
$cshowList :: [BatchGetRecordResponse] -> ShowS
show :: BatchGetRecordResponse -> String
$cshow :: BatchGetRecordResponse -> String
showsPrec :: Int -> BatchGetRecordResponse -> ShowS
$cshowsPrec :: Int -> BatchGetRecordResponse -> ShowS
Prelude.Show, forall x. Rep BatchGetRecordResponse x -> BatchGetRecordResponse
forall x. BatchGetRecordResponse -> Rep BatchGetRecordResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetRecordResponse x -> BatchGetRecordResponse
$cfrom :: forall x. BatchGetRecordResponse -> Rep BatchGetRecordResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetRecordResponse' 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', 'batchGetRecordResponse_httpStatus' - The response's http status code.
--
-- 'records', 'batchGetRecordResponse_records' - A list of Records you requested to be retrieved in batch.
--
-- 'errors', 'batchGetRecordResponse_errors' - A list of errors that have occurred when retrieving a batch of Records.
--
-- 'unprocessedIdentifiers', 'batchGetRecordResponse_unprocessedIdentifiers' - A unprocessed list of @FeatureGroup@ names, with their corresponding
-- @RecordIdentifier@ value, and Feature name.
newBatchGetRecordResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetRecordResponse
newBatchGetRecordResponse :: Int -> BatchGetRecordResponse
newBatchGetRecordResponse Int
pHttpStatus_ =
  BatchGetRecordResponse'
    { $sel:httpStatus:BatchGetRecordResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:records:BatchGetRecordResponse' :: [BatchGetRecordResultDetail]
records = forall a. Monoid a => a
Prelude.mempty,
      $sel:errors:BatchGetRecordResponse' :: [BatchGetRecordError]
errors = forall a. Monoid a => a
Prelude.mempty,
      $sel:unprocessedIdentifiers:BatchGetRecordResponse' :: [BatchGetRecordIdentifier]
unprocessedIdentifiers = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | A list of Records you requested to be retrieved in batch.
batchGetRecordResponse_records :: Lens.Lens' BatchGetRecordResponse [BatchGetRecordResultDetail]
batchGetRecordResponse_records :: Lens' BatchGetRecordResponse [BatchGetRecordResultDetail]
batchGetRecordResponse_records = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetRecordResponse' {[BatchGetRecordResultDetail]
records :: [BatchGetRecordResultDetail]
$sel:records:BatchGetRecordResponse' :: BatchGetRecordResponse -> [BatchGetRecordResultDetail]
records} -> [BatchGetRecordResultDetail]
records) (\s :: BatchGetRecordResponse
s@BatchGetRecordResponse' {} [BatchGetRecordResultDetail]
a -> BatchGetRecordResponse
s {$sel:records:BatchGetRecordResponse' :: [BatchGetRecordResultDetail]
records = [BatchGetRecordResultDetail]
a} :: BatchGetRecordResponse) 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

-- | A list of errors that have occurred when retrieving a batch of Records.
batchGetRecordResponse_errors :: Lens.Lens' BatchGetRecordResponse [BatchGetRecordError]
batchGetRecordResponse_errors :: Lens' BatchGetRecordResponse [BatchGetRecordError]
batchGetRecordResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetRecordResponse' {[BatchGetRecordError]
errors :: [BatchGetRecordError]
$sel:errors:BatchGetRecordResponse' :: BatchGetRecordResponse -> [BatchGetRecordError]
errors} -> [BatchGetRecordError]
errors) (\s :: BatchGetRecordResponse
s@BatchGetRecordResponse' {} [BatchGetRecordError]
a -> BatchGetRecordResponse
s {$sel:errors:BatchGetRecordResponse' :: [BatchGetRecordError]
errors = [BatchGetRecordError]
a} :: BatchGetRecordResponse) 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

-- | A unprocessed list of @FeatureGroup@ names, with their corresponding
-- @RecordIdentifier@ value, and Feature name.
batchGetRecordResponse_unprocessedIdentifiers :: Lens.Lens' BatchGetRecordResponse [BatchGetRecordIdentifier]
batchGetRecordResponse_unprocessedIdentifiers :: Lens' BatchGetRecordResponse [BatchGetRecordIdentifier]
batchGetRecordResponse_unprocessedIdentifiers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetRecordResponse' {[BatchGetRecordIdentifier]
unprocessedIdentifiers :: [BatchGetRecordIdentifier]
$sel:unprocessedIdentifiers:BatchGetRecordResponse' :: BatchGetRecordResponse -> [BatchGetRecordIdentifier]
unprocessedIdentifiers} -> [BatchGetRecordIdentifier]
unprocessedIdentifiers) (\s :: BatchGetRecordResponse
s@BatchGetRecordResponse' {} [BatchGetRecordIdentifier]
a -> BatchGetRecordResponse
s {$sel:unprocessedIdentifiers:BatchGetRecordResponse' :: [BatchGetRecordIdentifier]
unprocessedIdentifiers = [BatchGetRecordIdentifier]
a} :: BatchGetRecordResponse) 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 Prelude.NFData BatchGetRecordResponse where
  rnf :: BatchGetRecordResponse -> ()
rnf BatchGetRecordResponse' {Int
[BatchGetRecordError]
[BatchGetRecordIdentifier]
[BatchGetRecordResultDetail]
unprocessedIdentifiers :: [BatchGetRecordIdentifier]
errors :: [BatchGetRecordError]
records :: [BatchGetRecordResultDetail]
httpStatus :: Int
$sel:unprocessedIdentifiers:BatchGetRecordResponse' :: BatchGetRecordResponse -> [BatchGetRecordIdentifier]
$sel:errors:BatchGetRecordResponse' :: BatchGetRecordResponse -> [BatchGetRecordError]
$sel:records:BatchGetRecordResponse' :: BatchGetRecordResponse -> [BatchGetRecordResultDetail]
$sel:httpStatus:BatchGetRecordResponse' :: BatchGetRecordResponse -> 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 [BatchGetRecordResultDetail]
records
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [BatchGetRecordError]
errors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [BatchGetRecordIdentifier]
unprocessedIdentifiers