{-# 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.MachineLearning.UpdateBatchPrediction
-- 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)
--
-- Updates the @BatchPredictionName@ of a @BatchPrediction@.
--
-- You can use the @GetBatchPrediction@ operation to view the contents of
-- the updated data element.
module Amazonka.MachineLearning.UpdateBatchPrediction
  ( -- * Creating a Request
    UpdateBatchPrediction (..),
    newUpdateBatchPrediction,

    -- * Request Lenses
    updateBatchPrediction_batchPredictionId,
    updateBatchPrediction_batchPredictionName,

    -- * Destructuring the Response
    UpdateBatchPredictionResponse (..),
    newUpdateBatchPredictionResponse,

    -- * Response Lenses
    updateBatchPredictionResponse_batchPredictionId,
    updateBatchPredictionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateBatchPrediction' smart constructor.
data UpdateBatchPrediction = UpdateBatchPrediction'
  { -- | The ID assigned to the @BatchPrediction@ during creation.
    UpdateBatchPrediction -> Text
batchPredictionId :: Prelude.Text,
    -- | A new user-supplied name or description of the @BatchPrediction@.
    UpdateBatchPrediction -> Text
batchPredictionName :: Prelude.Text
  }
  deriving (UpdateBatchPrediction -> UpdateBatchPrediction -> Bool
(UpdateBatchPrediction -> UpdateBatchPrediction -> Bool)
-> (UpdateBatchPrediction -> UpdateBatchPrediction -> Bool)
-> Eq UpdateBatchPrediction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateBatchPrediction -> UpdateBatchPrediction -> Bool
$c/= :: UpdateBatchPrediction -> UpdateBatchPrediction -> Bool
== :: UpdateBatchPrediction -> UpdateBatchPrediction -> Bool
$c== :: UpdateBatchPrediction -> UpdateBatchPrediction -> Bool
Prelude.Eq, ReadPrec [UpdateBatchPrediction]
ReadPrec UpdateBatchPrediction
Int -> ReadS UpdateBatchPrediction
ReadS [UpdateBatchPrediction]
(Int -> ReadS UpdateBatchPrediction)
-> ReadS [UpdateBatchPrediction]
-> ReadPrec UpdateBatchPrediction
-> ReadPrec [UpdateBatchPrediction]
-> Read UpdateBatchPrediction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateBatchPrediction]
$creadListPrec :: ReadPrec [UpdateBatchPrediction]
readPrec :: ReadPrec UpdateBatchPrediction
$creadPrec :: ReadPrec UpdateBatchPrediction
readList :: ReadS [UpdateBatchPrediction]
$creadList :: ReadS [UpdateBatchPrediction]
readsPrec :: Int -> ReadS UpdateBatchPrediction
$creadsPrec :: Int -> ReadS UpdateBatchPrediction
Prelude.Read, Int -> UpdateBatchPrediction -> ShowS
[UpdateBatchPrediction] -> ShowS
UpdateBatchPrediction -> String
(Int -> UpdateBatchPrediction -> ShowS)
-> (UpdateBatchPrediction -> String)
-> ([UpdateBatchPrediction] -> ShowS)
-> Show UpdateBatchPrediction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateBatchPrediction] -> ShowS
$cshowList :: [UpdateBatchPrediction] -> ShowS
show :: UpdateBatchPrediction -> String
$cshow :: UpdateBatchPrediction -> String
showsPrec :: Int -> UpdateBatchPrediction -> ShowS
$cshowsPrec :: Int -> UpdateBatchPrediction -> ShowS
Prelude.Show, (forall x. UpdateBatchPrediction -> Rep UpdateBatchPrediction x)
-> (forall x. Rep UpdateBatchPrediction x -> UpdateBatchPrediction)
-> Generic UpdateBatchPrediction
forall x. Rep UpdateBatchPrediction x -> UpdateBatchPrediction
forall x. UpdateBatchPrediction -> Rep UpdateBatchPrediction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateBatchPrediction x -> UpdateBatchPrediction
$cfrom :: forall x. UpdateBatchPrediction -> Rep UpdateBatchPrediction x
Prelude.Generic)

-- |
-- Create a value of 'UpdateBatchPrediction' 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:
--
-- 'batchPredictionId', 'updateBatchPrediction_batchPredictionId' - The ID assigned to the @BatchPrediction@ during creation.
--
-- 'batchPredictionName', 'updateBatchPrediction_batchPredictionName' - A new user-supplied name or description of the @BatchPrediction@.
newUpdateBatchPrediction ::
  -- | 'batchPredictionId'
  Prelude.Text ->
  -- | 'batchPredictionName'
  Prelude.Text ->
  UpdateBatchPrediction
newUpdateBatchPrediction :: Text -> Text -> UpdateBatchPrediction
newUpdateBatchPrediction
  Text
pBatchPredictionId_
  Text
pBatchPredictionName_ =
    UpdateBatchPrediction' :: Text -> Text -> UpdateBatchPrediction
UpdateBatchPrediction'
      { $sel:batchPredictionId:UpdateBatchPrediction' :: Text
batchPredictionId =
          Text
pBatchPredictionId_,
        $sel:batchPredictionName:UpdateBatchPrediction' :: Text
batchPredictionName = Text
pBatchPredictionName_
      }

-- | The ID assigned to the @BatchPrediction@ during creation.
updateBatchPrediction_batchPredictionId :: Lens.Lens' UpdateBatchPrediction Prelude.Text
updateBatchPrediction_batchPredictionId :: (Text -> f Text)
-> UpdateBatchPrediction -> f UpdateBatchPrediction
updateBatchPrediction_batchPredictionId = (UpdateBatchPrediction -> Text)
-> (UpdateBatchPrediction -> Text -> UpdateBatchPrediction)
-> Lens UpdateBatchPrediction UpdateBatchPrediction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBatchPrediction' {Text
batchPredictionId :: Text
$sel:batchPredictionId:UpdateBatchPrediction' :: UpdateBatchPrediction -> Text
batchPredictionId} -> Text
batchPredictionId) (\s :: UpdateBatchPrediction
s@UpdateBatchPrediction' {} Text
a -> UpdateBatchPrediction
s {$sel:batchPredictionId:UpdateBatchPrediction' :: Text
batchPredictionId = Text
a} :: UpdateBatchPrediction)

-- | A new user-supplied name or description of the @BatchPrediction@.
updateBatchPrediction_batchPredictionName :: Lens.Lens' UpdateBatchPrediction Prelude.Text
updateBatchPrediction_batchPredictionName :: (Text -> f Text)
-> UpdateBatchPrediction -> f UpdateBatchPrediction
updateBatchPrediction_batchPredictionName = (UpdateBatchPrediction -> Text)
-> (UpdateBatchPrediction -> Text -> UpdateBatchPrediction)
-> Lens UpdateBatchPrediction UpdateBatchPrediction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBatchPrediction' {Text
batchPredictionName :: Text
$sel:batchPredictionName:UpdateBatchPrediction' :: UpdateBatchPrediction -> Text
batchPredictionName} -> Text
batchPredictionName) (\s :: UpdateBatchPrediction
s@UpdateBatchPrediction' {} Text
a -> UpdateBatchPrediction
s {$sel:batchPredictionName:UpdateBatchPrediction' :: Text
batchPredictionName = Text
a} :: UpdateBatchPrediction)

instance Core.AWSRequest UpdateBatchPrediction where
  type
    AWSResponse UpdateBatchPrediction =
      UpdateBatchPredictionResponse
  request :: UpdateBatchPrediction -> Request UpdateBatchPrediction
request = Service -> UpdateBatchPrediction -> Request UpdateBatchPrediction
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateBatchPrediction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateBatchPrediction)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateBatchPrediction))
-> Logger
-> Service
-> Proxy UpdateBatchPrediction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateBatchPrediction)))
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 -> Int -> UpdateBatchPredictionResponse
UpdateBatchPredictionResponse'
            (Maybe Text -> Int -> UpdateBatchPredictionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateBatchPredictionResponse)
forall (f :: * -> *) a b. Functor 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
"BatchPredictionId")
            Either String (Int -> UpdateBatchPredictionResponse)
-> Either String Int -> Either String UpdateBatchPredictionResponse
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 UpdateBatchPrediction

instance Prelude.NFData UpdateBatchPrediction

instance Core.ToHeaders UpdateBatchPrediction where
  toHeaders :: UpdateBatchPrediction -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateBatchPrediction -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonML_20141212.UpdateBatchPrediction" ::
                          Prelude.ByteString
                      ),
            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 UpdateBatchPrediction where
  toJSON :: UpdateBatchPrediction -> Value
toJSON UpdateBatchPrediction' {Text
batchPredictionName :: Text
batchPredictionId :: Text
$sel:batchPredictionName:UpdateBatchPrediction' :: UpdateBatchPrediction -> Text
$sel:batchPredictionId:UpdateBatchPrediction' :: UpdateBatchPrediction -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"BatchPredictionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
batchPredictionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"BatchPredictionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
batchPredictionName)
          ]
      )

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

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

-- | Represents the output of an @UpdateBatchPrediction@ operation.
--
-- You can see the updated content by using the @GetBatchPrediction@
-- operation.
--
-- /See:/ 'newUpdateBatchPredictionResponse' smart constructor.
data UpdateBatchPredictionResponse = UpdateBatchPredictionResponse'
  { -- | The ID assigned to the @BatchPrediction@ during creation. This value
    -- should be identical to the value of the @BatchPredictionId@ in the
    -- request.
    UpdateBatchPredictionResponse -> Maybe Text
batchPredictionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateBatchPredictionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateBatchPredictionResponse
-> UpdateBatchPredictionResponse -> Bool
(UpdateBatchPredictionResponse
 -> UpdateBatchPredictionResponse -> Bool)
-> (UpdateBatchPredictionResponse
    -> UpdateBatchPredictionResponse -> Bool)
-> Eq UpdateBatchPredictionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateBatchPredictionResponse
-> UpdateBatchPredictionResponse -> Bool
$c/= :: UpdateBatchPredictionResponse
-> UpdateBatchPredictionResponse -> Bool
== :: UpdateBatchPredictionResponse
-> UpdateBatchPredictionResponse -> Bool
$c== :: UpdateBatchPredictionResponse
-> UpdateBatchPredictionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateBatchPredictionResponse]
ReadPrec UpdateBatchPredictionResponse
Int -> ReadS UpdateBatchPredictionResponse
ReadS [UpdateBatchPredictionResponse]
(Int -> ReadS UpdateBatchPredictionResponse)
-> ReadS [UpdateBatchPredictionResponse]
-> ReadPrec UpdateBatchPredictionResponse
-> ReadPrec [UpdateBatchPredictionResponse]
-> Read UpdateBatchPredictionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateBatchPredictionResponse]
$creadListPrec :: ReadPrec [UpdateBatchPredictionResponse]
readPrec :: ReadPrec UpdateBatchPredictionResponse
$creadPrec :: ReadPrec UpdateBatchPredictionResponse
readList :: ReadS [UpdateBatchPredictionResponse]
$creadList :: ReadS [UpdateBatchPredictionResponse]
readsPrec :: Int -> ReadS UpdateBatchPredictionResponse
$creadsPrec :: Int -> ReadS UpdateBatchPredictionResponse
Prelude.Read, Int -> UpdateBatchPredictionResponse -> ShowS
[UpdateBatchPredictionResponse] -> ShowS
UpdateBatchPredictionResponse -> String
(Int -> UpdateBatchPredictionResponse -> ShowS)
-> (UpdateBatchPredictionResponse -> String)
-> ([UpdateBatchPredictionResponse] -> ShowS)
-> Show UpdateBatchPredictionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateBatchPredictionResponse] -> ShowS
$cshowList :: [UpdateBatchPredictionResponse] -> ShowS
show :: UpdateBatchPredictionResponse -> String
$cshow :: UpdateBatchPredictionResponse -> String
showsPrec :: Int -> UpdateBatchPredictionResponse -> ShowS
$cshowsPrec :: Int -> UpdateBatchPredictionResponse -> ShowS
Prelude.Show, (forall x.
 UpdateBatchPredictionResponse
 -> Rep UpdateBatchPredictionResponse x)
-> (forall x.
    Rep UpdateBatchPredictionResponse x
    -> UpdateBatchPredictionResponse)
-> Generic UpdateBatchPredictionResponse
forall x.
Rep UpdateBatchPredictionResponse x
-> UpdateBatchPredictionResponse
forall x.
UpdateBatchPredictionResponse
-> Rep UpdateBatchPredictionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateBatchPredictionResponse x
-> UpdateBatchPredictionResponse
$cfrom :: forall x.
UpdateBatchPredictionResponse
-> Rep UpdateBatchPredictionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateBatchPredictionResponse' 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:
--
-- 'batchPredictionId', 'updateBatchPredictionResponse_batchPredictionId' - The ID assigned to the @BatchPrediction@ during creation. This value
-- should be identical to the value of the @BatchPredictionId@ in the
-- request.
--
-- 'httpStatus', 'updateBatchPredictionResponse_httpStatus' - The response's http status code.
newUpdateBatchPredictionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateBatchPredictionResponse
newUpdateBatchPredictionResponse :: Int -> UpdateBatchPredictionResponse
newUpdateBatchPredictionResponse Int
pHttpStatus_ =
  UpdateBatchPredictionResponse' :: Maybe Text -> Int -> UpdateBatchPredictionResponse
UpdateBatchPredictionResponse'
    { $sel:batchPredictionId:UpdateBatchPredictionResponse' :: Maybe Text
batchPredictionId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateBatchPredictionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID assigned to the @BatchPrediction@ during creation. This value
-- should be identical to the value of the @BatchPredictionId@ in the
-- request.
updateBatchPredictionResponse_batchPredictionId :: Lens.Lens' UpdateBatchPredictionResponse (Prelude.Maybe Prelude.Text)
updateBatchPredictionResponse_batchPredictionId :: (Maybe Text -> f (Maybe Text))
-> UpdateBatchPredictionResponse -> f UpdateBatchPredictionResponse
updateBatchPredictionResponse_batchPredictionId = (UpdateBatchPredictionResponse -> Maybe Text)
-> (UpdateBatchPredictionResponse
    -> Maybe Text -> UpdateBatchPredictionResponse)
-> Lens
     UpdateBatchPredictionResponse
     UpdateBatchPredictionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBatchPredictionResponse' {Maybe Text
batchPredictionId :: Maybe Text
$sel:batchPredictionId:UpdateBatchPredictionResponse' :: UpdateBatchPredictionResponse -> Maybe Text
batchPredictionId} -> Maybe Text
batchPredictionId) (\s :: UpdateBatchPredictionResponse
s@UpdateBatchPredictionResponse' {} Maybe Text
a -> UpdateBatchPredictionResponse
s {$sel:batchPredictionId:UpdateBatchPredictionResponse' :: Maybe Text
batchPredictionId = Maybe Text
a} :: UpdateBatchPredictionResponse)

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

instance Prelude.NFData UpdateBatchPredictionResponse