{-# 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.SageMakerRuntime.InvokeEndpointAsync
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- After you deploy a model into production using Amazon SageMaker hosting
-- services, your client applications use this API to get inferences from
-- the model hosted at the specified endpoint in an asynchronous manner.
--
-- Inference requests sent to this API are enqueued for asynchronous
-- processing. The processing of the inference request may or may not
-- complete before the you receive a response from this API. The response
-- from this API will not contain the result of the inference request but
-- contain information about where you can locate it.
--
-- Amazon SageMaker strips all @POST@ headers except those supported by the
-- API. Amazon SageMaker might add additional headers. You should not rely
-- on the behavior of headers outside those enumerated in the request
-- syntax.
--
-- Calls to @InvokeEndpointAsync@ are authenticated by using AWS Signature
-- Version 4. For information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html Authenticating Requests (AWS Signature Version 4)>
-- in the /Amazon S3 API Reference/.
module Amazonka.SageMakerRuntime.InvokeEndpointAsync
  ( -- * Creating a Request
    InvokeEndpointAsync (..),
    newInvokeEndpointAsync,

    -- * Request Lenses
    invokeEndpointAsync_accept,
    invokeEndpointAsync_customAttributes,
    invokeEndpointAsync_inferenceId,
    invokeEndpointAsync_requestTTLSeconds,
    invokeEndpointAsync_contentType,
    invokeEndpointAsync_endpointName,
    invokeEndpointAsync_inputLocation,

    -- * Destructuring the Response
    InvokeEndpointAsyncResponse (..),
    newInvokeEndpointAsyncResponse,

    -- * Response Lenses
    invokeEndpointAsyncResponse_outputLocation,
    invokeEndpointAsyncResponse_inferenceId,
    invokeEndpointAsyncResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SageMakerRuntime.Types

-- | /See:/ 'newInvokeEndpointAsync' smart constructor.
data InvokeEndpointAsync = InvokeEndpointAsync'
  { -- | The desired MIME type of the inference in the response.
    InvokeEndpointAsync -> Maybe Text
accept :: Prelude.Maybe Prelude.Text,
    -- | Provides additional information about a request for an inference
    -- submitted to a model hosted at an Amazon SageMaker endpoint. The
    -- information is an opaque value that is forwarded verbatim. You could use
    -- this value, for example, to provide an ID that you can use to track a
    -- request or to provide other metadata that a service endpoint was
    -- programmed to process. The value must consist of no more than 1024
    -- visible US-ASCII characters as specified in
    -- <https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6 Section 3.3.6. Field Value Components>
    -- of the Hypertext Transfer Protocol (HTTP\/1.1).
    --
    -- The code in your model is responsible for setting or updating any custom
    -- attributes in the response. If your code does not set this value in the
    -- response, an empty value is returned. For example, if a custom attribute
    -- represents the trace ID, your model can prepend the custom attribute
    -- with @Trace ID@: in your post-processing function.
    --
    -- This feature is currently supported in the AWS SDKs but not in the
    -- Amazon SageMaker Python SDK.
    InvokeEndpointAsync -> Maybe (Sensitive Text)
customAttributes :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The identifier for the inference request. Amazon SageMaker will generate
    -- an identifier for you if none is specified.
    InvokeEndpointAsync -> Maybe Text
inferenceId :: Prelude.Maybe Prelude.Text,
    -- | Maximum age in seconds a request can be in the queue before it is marked
    -- as expired.
    InvokeEndpointAsync -> Maybe Natural
requestTTLSeconds :: Prelude.Maybe Prelude.Natural,
    -- | The MIME type of the input data in the request body.
    InvokeEndpointAsync -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
    -- | The name of the endpoint that you specified when you created the
    -- endpoint using the
    -- <https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html CreateEndpoint>
    -- API.
    InvokeEndpointAsync -> Text
endpointName :: Prelude.Text,
    -- | The Amazon S3 URI where the inference request payload is stored.
    InvokeEndpointAsync -> Text
inputLocation :: Prelude.Text
  }
  deriving (InvokeEndpointAsync -> InvokeEndpointAsync -> Bool
(InvokeEndpointAsync -> InvokeEndpointAsync -> Bool)
-> (InvokeEndpointAsync -> InvokeEndpointAsync -> Bool)
-> Eq InvokeEndpointAsync
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InvokeEndpointAsync -> InvokeEndpointAsync -> Bool
$c/= :: InvokeEndpointAsync -> InvokeEndpointAsync -> Bool
== :: InvokeEndpointAsync -> InvokeEndpointAsync -> Bool
$c== :: InvokeEndpointAsync -> InvokeEndpointAsync -> Bool
Prelude.Eq, Int -> InvokeEndpointAsync -> ShowS
[InvokeEndpointAsync] -> ShowS
InvokeEndpointAsync -> String
(Int -> InvokeEndpointAsync -> ShowS)
-> (InvokeEndpointAsync -> String)
-> ([InvokeEndpointAsync] -> ShowS)
-> Show InvokeEndpointAsync
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InvokeEndpointAsync] -> ShowS
$cshowList :: [InvokeEndpointAsync] -> ShowS
show :: InvokeEndpointAsync -> String
$cshow :: InvokeEndpointAsync -> String
showsPrec :: Int -> InvokeEndpointAsync -> ShowS
$cshowsPrec :: Int -> InvokeEndpointAsync -> ShowS
Prelude.Show, (forall x. InvokeEndpointAsync -> Rep InvokeEndpointAsync x)
-> (forall x. Rep InvokeEndpointAsync x -> InvokeEndpointAsync)
-> Generic InvokeEndpointAsync
forall x. Rep InvokeEndpointAsync x -> InvokeEndpointAsync
forall x. InvokeEndpointAsync -> Rep InvokeEndpointAsync x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InvokeEndpointAsync x -> InvokeEndpointAsync
$cfrom :: forall x. InvokeEndpointAsync -> Rep InvokeEndpointAsync x
Prelude.Generic)

-- |
-- Create a value of 'InvokeEndpointAsync' 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:
--
-- 'accept', 'invokeEndpointAsync_accept' - The desired MIME type of the inference in the response.
--
-- 'customAttributes', 'invokeEndpointAsync_customAttributes' - Provides additional information about a request for an inference
-- submitted to a model hosted at an Amazon SageMaker endpoint. The
-- information is an opaque value that is forwarded verbatim. You could use
-- this value, for example, to provide an ID that you can use to track a
-- request or to provide other metadata that a service endpoint was
-- programmed to process. The value must consist of no more than 1024
-- visible US-ASCII characters as specified in
-- <https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6 Section 3.3.6. Field Value Components>
-- of the Hypertext Transfer Protocol (HTTP\/1.1).
--
-- The code in your model is responsible for setting or updating any custom
-- attributes in the response. If your code does not set this value in the
-- response, an empty value is returned. For example, if a custom attribute
-- represents the trace ID, your model can prepend the custom attribute
-- with @Trace ID@: in your post-processing function.
--
-- This feature is currently supported in the AWS SDKs but not in the
-- Amazon SageMaker Python SDK.
--
-- 'inferenceId', 'invokeEndpointAsync_inferenceId' - The identifier for the inference request. Amazon SageMaker will generate
-- an identifier for you if none is specified.
--
-- 'requestTTLSeconds', 'invokeEndpointAsync_requestTTLSeconds' - Maximum age in seconds a request can be in the queue before it is marked
-- as expired.
--
-- 'contentType', 'invokeEndpointAsync_contentType' - The MIME type of the input data in the request body.
--
-- 'endpointName', 'invokeEndpointAsync_endpointName' - The name of the endpoint that you specified when you created the
-- endpoint using the
-- <https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html CreateEndpoint>
-- API.
--
-- 'inputLocation', 'invokeEndpointAsync_inputLocation' - The Amazon S3 URI where the inference request payload is stored.
newInvokeEndpointAsync ::
  -- | 'endpointName'
  Prelude.Text ->
  -- | 'inputLocation'
  Prelude.Text ->
  InvokeEndpointAsync
newInvokeEndpointAsync :: Text -> Text -> InvokeEndpointAsync
newInvokeEndpointAsync Text
pEndpointName_ Text
pInputLocation_ =
  InvokeEndpointAsync' :: Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Text
-> Text
-> InvokeEndpointAsync
InvokeEndpointAsync'
    { $sel:accept:InvokeEndpointAsync' :: Maybe Text
accept = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:customAttributes:InvokeEndpointAsync' :: Maybe (Sensitive Text)
customAttributes = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:inferenceId:InvokeEndpointAsync' :: Maybe Text
inferenceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:requestTTLSeconds:InvokeEndpointAsync' :: Maybe Natural
requestTTLSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:contentType:InvokeEndpointAsync' :: Maybe Text
contentType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointName:InvokeEndpointAsync' :: Text
endpointName = Text
pEndpointName_,
      $sel:inputLocation:InvokeEndpointAsync' :: Text
inputLocation = Text
pInputLocation_
    }

-- | The desired MIME type of the inference in the response.
invokeEndpointAsync_accept :: Lens.Lens' InvokeEndpointAsync (Prelude.Maybe Prelude.Text)
invokeEndpointAsync_accept :: (Maybe Text -> f (Maybe Text))
-> InvokeEndpointAsync -> f InvokeEndpointAsync
invokeEndpointAsync_accept = (InvokeEndpointAsync -> Maybe Text)
-> (InvokeEndpointAsync -> Maybe Text -> InvokeEndpointAsync)
-> Lens
     InvokeEndpointAsync InvokeEndpointAsync (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsync' {Maybe Text
accept :: Maybe Text
$sel:accept:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
accept} -> Maybe Text
accept) (\s :: InvokeEndpointAsync
s@InvokeEndpointAsync' {} Maybe Text
a -> InvokeEndpointAsync
s {$sel:accept:InvokeEndpointAsync' :: Maybe Text
accept = Maybe Text
a} :: InvokeEndpointAsync)

-- | Provides additional information about a request for an inference
-- submitted to a model hosted at an Amazon SageMaker endpoint. The
-- information is an opaque value that is forwarded verbatim. You could use
-- this value, for example, to provide an ID that you can use to track a
-- request or to provide other metadata that a service endpoint was
-- programmed to process. The value must consist of no more than 1024
-- visible US-ASCII characters as specified in
-- <https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6 Section 3.3.6. Field Value Components>
-- of the Hypertext Transfer Protocol (HTTP\/1.1).
--
-- The code in your model is responsible for setting or updating any custom
-- attributes in the response. If your code does not set this value in the
-- response, an empty value is returned. For example, if a custom attribute
-- represents the trace ID, your model can prepend the custom attribute
-- with @Trace ID@: in your post-processing function.
--
-- This feature is currently supported in the AWS SDKs but not in the
-- Amazon SageMaker Python SDK.
invokeEndpointAsync_customAttributes :: Lens.Lens' InvokeEndpointAsync (Prelude.Maybe Prelude.Text)
invokeEndpointAsync_customAttributes :: (Maybe Text -> f (Maybe Text))
-> InvokeEndpointAsync -> f InvokeEndpointAsync
invokeEndpointAsync_customAttributes = (InvokeEndpointAsync -> Maybe (Sensitive Text))
-> (InvokeEndpointAsync
    -> Maybe (Sensitive Text) -> InvokeEndpointAsync)
-> Lens
     InvokeEndpointAsync
     InvokeEndpointAsync
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsync' {Maybe (Sensitive Text)
customAttributes :: Maybe (Sensitive Text)
$sel:customAttributes:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe (Sensitive Text)
customAttributes} -> Maybe (Sensitive Text)
customAttributes) (\s :: InvokeEndpointAsync
s@InvokeEndpointAsync' {} Maybe (Sensitive Text)
a -> InvokeEndpointAsync
s {$sel:customAttributes:InvokeEndpointAsync' :: Maybe (Sensitive Text)
customAttributes = Maybe (Sensitive Text)
a} :: InvokeEndpointAsync) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> InvokeEndpointAsync -> f InvokeEndpointAsync)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> InvokeEndpointAsync
-> f InvokeEndpointAsync
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The identifier for the inference request. Amazon SageMaker will generate
-- an identifier for you if none is specified.
invokeEndpointAsync_inferenceId :: Lens.Lens' InvokeEndpointAsync (Prelude.Maybe Prelude.Text)
invokeEndpointAsync_inferenceId :: (Maybe Text -> f (Maybe Text))
-> InvokeEndpointAsync -> f InvokeEndpointAsync
invokeEndpointAsync_inferenceId = (InvokeEndpointAsync -> Maybe Text)
-> (InvokeEndpointAsync -> Maybe Text -> InvokeEndpointAsync)
-> Lens
     InvokeEndpointAsync InvokeEndpointAsync (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsync' {Maybe Text
inferenceId :: Maybe Text
$sel:inferenceId:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
inferenceId} -> Maybe Text
inferenceId) (\s :: InvokeEndpointAsync
s@InvokeEndpointAsync' {} Maybe Text
a -> InvokeEndpointAsync
s {$sel:inferenceId:InvokeEndpointAsync' :: Maybe Text
inferenceId = Maybe Text
a} :: InvokeEndpointAsync)

-- | Maximum age in seconds a request can be in the queue before it is marked
-- as expired.
invokeEndpointAsync_requestTTLSeconds :: Lens.Lens' InvokeEndpointAsync (Prelude.Maybe Prelude.Natural)
invokeEndpointAsync_requestTTLSeconds :: (Maybe Natural -> f (Maybe Natural))
-> InvokeEndpointAsync -> f InvokeEndpointAsync
invokeEndpointAsync_requestTTLSeconds = (InvokeEndpointAsync -> Maybe Natural)
-> (InvokeEndpointAsync -> Maybe Natural -> InvokeEndpointAsync)
-> Lens
     InvokeEndpointAsync
     InvokeEndpointAsync
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsync' {Maybe Natural
requestTTLSeconds :: Maybe Natural
$sel:requestTTLSeconds:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Natural
requestTTLSeconds} -> Maybe Natural
requestTTLSeconds) (\s :: InvokeEndpointAsync
s@InvokeEndpointAsync' {} Maybe Natural
a -> InvokeEndpointAsync
s {$sel:requestTTLSeconds:InvokeEndpointAsync' :: Maybe Natural
requestTTLSeconds = Maybe Natural
a} :: InvokeEndpointAsync)

-- | The MIME type of the input data in the request body.
invokeEndpointAsync_contentType :: Lens.Lens' InvokeEndpointAsync (Prelude.Maybe Prelude.Text)
invokeEndpointAsync_contentType :: (Maybe Text -> f (Maybe Text))
-> InvokeEndpointAsync -> f InvokeEndpointAsync
invokeEndpointAsync_contentType = (InvokeEndpointAsync -> Maybe Text)
-> (InvokeEndpointAsync -> Maybe Text -> InvokeEndpointAsync)
-> Lens
     InvokeEndpointAsync InvokeEndpointAsync (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsync' {Maybe Text
contentType :: Maybe Text
$sel:contentType:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
contentType} -> Maybe Text
contentType) (\s :: InvokeEndpointAsync
s@InvokeEndpointAsync' {} Maybe Text
a -> InvokeEndpointAsync
s {$sel:contentType:InvokeEndpointAsync' :: Maybe Text
contentType = Maybe Text
a} :: InvokeEndpointAsync)

-- | The name of the endpoint that you specified when you created the
-- endpoint using the
-- <https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html CreateEndpoint>
-- API.
invokeEndpointAsync_endpointName :: Lens.Lens' InvokeEndpointAsync Prelude.Text
invokeEndpointAsync_endpointName :: (Text -> f Text) -> InvokeEndpointAsync -> f InvokeEndpointAsync
invokeEndpointAsync_endpointName = (InvokeEndpointAsync -> Text)
-> (InvokeEndpointAsync -> Text -> InvokeEndpointAsync)
-> Lens InvokeEndpointAsync InvokeEndpointAsync Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsync' {Text
endpointName :: Text
$sel:endpointName:InvokeEndpointAsync' :: InvokeEndpointAsync -> Text
endpointName} -> Text
endpointName) (\s :: InvokeEndpointAsync
s@InvokeEndpointAsync' {} Text
a -> InvokeEndpointAsync
s {$sel:endpointName:InvokeEndpointAsync' :: Text
endpointName = Text
a} :: InvokeEndpointAsync)

-- | The Amazon S3 URI where the inference request payload is stored.
invokeEndpointAsync_inputLocation :: Lens.Lens' InvokeEndpointAsync Prelude.Text
invokeEndpointAsync_inputLocation :: (Text -> f Text) -> InvokeEndpointAsync -> f InvokeEndpointAsync
invokeEndpointAsync_inputLocation = (InvokeEndpointAsync -> Text)
-> (InvokeEndpointAsync -> Text -> InvokeEndpointAsync)
-> Lens InvokeEndpointAsync InvokeEndpointAsync Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsync' {Text
inputLocation :: Text
$sel:inputLocation:InvokeEndpointAsync' :: InvokeEndpointAsync -> Text
inputLocation} -> Text
inputLocation) (\s :: InvokeEndpointAsync
s@InvokeEndpointAsync' {} Text
a -> InvokeEndpointAsync
s {$sel:inputLocation:InvokeEndpointAsync' :: Text
inputLocation = Text
a} :: InvokeEndpointAsync)

instance Core.AWSRequest InvokeEndpointAsync where
  type
    AWSResponse InvokeEndpointAsync =
      InvokeEndpointAsyncResponse
  request :: InvokeEndpointAsync -> Request InvokeEndpointAsync
request = Service -> InvokeEndpointAsync -> Request InvokeEndpointAsync
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy InvokeEndpointAsync
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse InvokeEndpointAsync)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse InvokeEndpointAsync))
-> Logger
-> Service
-> Proxy InvokeEndpointAsync
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse InvokeEndpointAsync)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Text -> Int -> InvokeEndpointAsyncResponse
InvokeEndpointAsyncResponse'
            (Maybe Text -> Maybe Text -> Int -> InvokeEndpointAsyncResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> InvokeEndpointAsyncResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"X-Amzn-SageMaker-OutputLocation")
            Either String (Maybe Text -> Int -> InvokeEndpointAsyncResponse)
-> Either String (Maybe Text)
-> Either String (Int -> InvokeEndpointAsyncResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"InferenceId")
            Either String (Int -> InvokeEndpointAsyncResponse)
-> Either String Int -> Either String InvokeEndpointAsyncResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable InvokeEndpointAsync

instance Prelude.NFData InvokeEndpointAsync

instance Core.ToHeaders InvokeEndpointAsync where
  toHeaders :: InvokeEndpointAsync -> ResponseHeaders
toHeaders InvokeEndpointAsync' {Maybe Natural
Maybe Text
Maybe (Sensitive Text)
Text
inputLocation :: Text
endpointName :: Text
contentType :: Maybe Text
requestTTLSeconds :: Maybe Natural
inferenceId :: Maybe Text
customAttributes :: Maybe (Sensitive Text)
accept :: Maybe Text
$sel:inputLocation:InvokeEndpointAsync' :: InvokeEndpointAsync -> Text
$sel:endpointName:InvokeEndpointAsync' :: InvokeEndpointAsync -> Text
$sel:contentType:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
$sel:requestTTLSeconds:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Natural
$sel:inferenceId:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
$sel:customAttributes:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe (Sensitive Text)
$sel:accept:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amzn-SageMaker-Accept" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
accept,
        HeaderName
"X-Amzn-SageMaker-Custom-Attributes"
          HeaderName -> Maybe (Sensitive Text) -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe (Sensitive Text)
customAttributes,
        HeaderName
"X-Amzn-SageMaker-Inference-Id" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
inferenceId,
        HeaderName
"X-Amzn-SageMaker-RequestTTLSeconds"
          HeaderName -> Maybe Natural -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Natural
requestTTLSeconds,
        HeaderName
"X-Amzn-SageMaker-Content-Type" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
contentType,
        HeaderName
"X-Amzn-SageMaker-InputLocation"
          HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
inputLocation,
        HeaderName
"Content-Type"
          HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Core.ToJSON InvokeEndpointAsync where
  toJSON :: InvokeEndpointAsync -> Value
toJSON = Value -> InvokeEndpointAsync -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath InvokeEndpointAsync where
  toPath :: InvokeEndpointAsync -> ByteString
toPath InvokeEndpointAsync' {Maybe Natural
Maybe Text
Maybe (Sensitive Text)
Text
inputLocation :: Text
endpointName :: Text
contentType :: Maybe Text
requestTTLSeconds :: Maybe Natural
inferenceId :: Maybe Text
customAttributes :: Maybe (Sensitive Text)
accept :: Maybe Text
$sel:inputLocation:InvokeEndpointAsync' :: InvokeEndpointAsync -> Text
$sel:endpointName:InvokeEndpointAsync' :: InvokeEndpointAsync -> Text
$sel:contentType:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
$sel:requestTTLSeconds:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Natural
$sel:inferenceId:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
$sel:customAttributes:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe (Sensitive Text)
$sel:accept:InvokeEndpointAsync' :: InvokeEndpointAsync -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/endpoints/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
endpointName,
        ByteString
"/async-invocations"
      ]

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

-- | /See:/ 'newInvokeEndpointAsyncResponse' smart constructor.
data InvokeEndpointAsyncResponse = InvokeEndpointAsyncResponse'
  { -- | The Amazon S3 URI where the inference response payload is stored.
    InvokeEndpointAsyncResponse -> Maybe Text
outputLocation :: Prelude.Maybe Prelude.Text,
    -- | Identifier for an inference request. This will be the same as the
    -- @InferenceId@ specified in the input. Amazon SageMaker will generate an
    -- identifier for you if you do not specify one.
    InvokeEndpointAsyncResponse -> Maybe Text
inferenceId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    InvokeEndpointAsyncResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (InvokeEndpointAsyncResponse -> InvokeEndpointAsyncResponse -> Bool
(InvokeEndpointAsyncResponse
 -> InvokeEndpointAsyncResponse -> Bool)
-> (InvokeEndpointAsyncResponse
    -> InvokeEndpointAsyncResponse -> Bool)
-> Eq InvokeEndpointAsyncResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InvokeEndpointAsyncResponse -> InvokeEndpointAsyncResponse -> Bool
$c/= :: InvokeEndpointAsyncResponse -> InvokeEndpointAsyncResponse -> Bool
== :: InvokeEndpointAsyncResponse -> InvokeEndpointAsyncResponse -> Bool
$c== :: InvokeEndpointAsyncResponse -> InvokeEndpointAsyncResponse -> Bool
Prelude.Eq, ReadPrec [InvokeEndpointAsyncResponse]
ReadPrec InvokeEndpointAsyncResponse
Int -> ReadS InvokeEndpointAsyncResponse
ReadS [InvokeEndpointAsyncResponse]
(Int -> ReadS InvokeEndpointAsyncResponse)
-> ReadS [InvokeEndpointAsyncResponse]
-> ReadPrec InvokeEndpointAsyncResponse
-> ReadPrec [InvokeEndpointAsyncResponse]
-> Read InvokeEndpointAsyncResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InvokeEndpointAsyncResponse]
$creadListPrec :: ReadPrec [InvokeEndpointAsyncResponse]
readPrec :: ReadPrec InvokeEndpointAsyncResponse
$creadPrec :: ReadPrec InvokeEndpointAsyncResponse
readList :: ReadS [InvokeEndpointAsyncResponse]
$creadList :: ReadS [InvokeEndpointAsyncResponse]
readsPrec :: Int -> ReadS InvokeEndpointAsyncResponse
$creadsPrec :: Int -> ReadS InvokeEndpointAsyncResponse
Prelude.Read, Int -> InvokeEndpointAsyncResponse -> ShowS
[InvokeEndpointAsyncResponse] -> ShowS
InvokeEndpointAsyncResponse -> String
(Int -> InvokeEndpointAsyncResponse -> ShowS)
-> (InvokeEndpointAsyncResponse -> String)
-> ([InvokeEndpointAsyncResponse] -> ShowS)
-> Show InvokeEndpointAsyncResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InvokeEndpointAsyncResponse] -> ShowS
$cshowList :: [InvokeEndpointAsyncResponse] -> ShowS
show :: InvokeEndpointAsyncResponse -> String
$cshow :: InvokeEndpointAsyncResponse -> String
showsPrec :: Int -> InvokeEndpointAsyncResponse -> ShowS
$cshowsPrec :: Int -> InvokeEndpointAsyncResponse -> ShowS
Prelude.Show, (forall x.
 InvokeEndpointAsyncResponse -> Rep InvokeEndpointAsyncResponse x)
-> (forall x.
    Rep InvokeEndpointAsyncResponse x -> InvokeEndpointAsyncResponse)
-> Generic InvokeEndpointAsyncResponse
forall x.
Rep InvokeEndpointAsyncResponse x -> InvokeEndpointAsyncResponse
forall x.
InvokeEndpointAsyncResponse -> Rep InvokeEndpointAsyncResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InvokeEndpointAsyncResponse x -> InvokeEndpointAsyncResponse
$cfrom :: forall x.
InvokeEndpointAsyncResponse -> Rep InvokeEndpointAsyncResponse x
Prelude.Generic)

-- |
-- Create a value of 'InvokeEndpointAsyncResponse' 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:
--
-- 'outputLocation', 'invokeEndpointAsyncResponse_outputLocation' - The Amazon S3 URI where the inference response payload is stored.
--
-- 'inferenceId', 'invokeEndpointAsyncResponse_inferenceId' - Identifier for an inference request. This will be the same as the
-- @InferenceId@ specified in the input. Amazon SageMaker will generate an
-- identifier for you if you do not specify one.
--
-- 'httpStatus', 'invokeEndpointAsyncResponse_httpStatus' - The response's http status code.
newInvokeEndpointAsyncResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  InvokeEndpointAsyncResponse
newInvokeEndpointAsyncResponse :: Int -> InvokeEndpointAsyncResponse
newInvokeEndpointAsyncResponse Int
pHttpStatus_ =
  InvokeEndpointAsyncResponse' :: Maybe Text -> Maybe Text -> Int -> InvokeEndpointAsyncResponse
InvokeEndpointAsyncResponse'
    { $sel:outputLocation:InvokeEndpointAsyncResponse' :: Maybe Text
outputLocation =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:inferenceId:InvokeEndpointAsyncResponse' :: Maybe Text
inferenceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:InvokeEndpointAsyncResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon S3 URI where the inference response payload is stored.
invokeEndpointAsyncResponse_outputLocation :: Lens.Lens' InvokeEndpointAsyncResponse (Prelude.Maybe Prelude.Text)
invokeEndpointAsyncResponse_outputLocation :: (Maybe Text -> f (Maybe Text))
-> InvokeEndpointAsyncResponse -> f InvokeEndpointAsyncResponse
invokeEndpointAsyncResponse_outputLocation = (InvokeEndpointAsyncResponse -> Maybe Text)
-> (InvokeEndpointAsyncResponse
    -> Maybe Text -> InvokeEndpointAsyncResponse)
-> Lens
     InvokeEndpointAsyncResponse
     InvokeEndpointAsyncResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsyncResponse' {Maybe Text
outputLocation :: Maybe Text
$sel:outputLocation:InvokeEndpointAsyncResponse' :: InvokeEndpointAsyncResponse -> Maybe Text
outputLocation} -> Maybe Text
outputLocation) (\s :: InvokeEndpointAsyncResponse
s@InvokeEndpointAsyncResponse' {} Maybe Text
a -> InvokeEndpointAsyncResponse
s {$sel:outputLocation:InvokeEndpointAsyncResponse' :: Maybe Text
outputLocation = Maybe Text
a} :: InvokeEndpointAsyncResponse)

-- | Identifier for an inference request. This will be the same as the
-- @InferenceId@ specified in the input. Amazon SageMaker will generate an
-- identifier for you if you do not specify one.
invokeEndpointAsyncResponse_inferenceId :: Lens.Lens' InvokeEndpointAsyncResponse (Prelude.Maybe Prelude.Text)
invokeEndpointAsyncResponse_inferenceId :: (Maybe Text -> f (Maybe Text))
-> InvokeEndpointAsyncResponse -> f InvokeEndpointAsyncResponse
invokeEndpointAsyncResponse_inferenceId = (InvokeEndpointAsyncResponse -> Maybe Text)
-> (InvokeEndpointAsyncResponse
    -> Maybe Text -> InvokeEndpointAsyncResponse)
-> Lens
     InvokeEndpointAsyncResponse
     InvokeEndpointAsyncResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeEndpointAsyncResponse' {Maybe Text
inferenceId :: Maybe Text
$sel:inferenceId:InvokeEndpointAsyncResponse' :: InvokeEndpointAsyncResponse -> Maybe Text
inferenceId} -> Maybe Text
inferenceId) (\s :: InvokeEndpointAsyncResponse
s@InvokeEndpointAsyncResponse' {} Maybe Text
a -> InvokeEndpointAsyncResponse
s {$sel:inferenceId:InvokeEndpointAsyncResponse' :: Maybe Text
inferenceId = Maybe Text
a} :: InvokeEndpointAsyncResponse)

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

instance Prelude.NFData InvokeEndpointAsyncResponse