{-# 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.StartMLEvaluationTaskRun
-- 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)
--
-- Starts a task to estimate the quality of the transform.
--
-- When you provide label sets as examples of truth, Glue machine learning
-- uses some of those examples to learn from them. The rest of the labels
-- are used as a test to estimate quality.
--
-- Returns a unique identifier for the run. You can call @GetMLTaskRun@ to
-- get more information about the stats of the @EvaluationTaskRun@.
module Amazonka.Glue.StartMLEvaluationTaskRun
  ( -- * Creating a Request
    StartMLEvaluationTaskRun (..),
    newStartMLEvaluationTaskRun,

    -- * Request Lenses
    startMLEvaluationTaskRun_transformId,

    -- * Destructuring the Response
    StartMLEvaluationTaskRunResponse (..),
    newStartMLEvaluationTaskRunResponse,

    -- * Response Lenses
    startMLEvaluationTaskRunResponse_taskRunId,
    startMLEvaluationTaskRunResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStartMLEvaluationTaskRun' smart constructor.
data StartMLEvaluationTaskRun = StartMLEvaluationTaskRun'
  { -- | The unique identifier of the machine learning transform.
    StartMLEvaluationTaskRun -> Text
transformId :: Prelude.Text
  }
  deriving (StartMLEvaluationTaskRun -> StartMLEvaluationTaskRun -> Bool
(StartMLEvaluationTaskRun -> StartMLEvaluationTaskRun -> Bool)
-> (StartMLEvaluationTaskRun -> StartMLEvaluationTaskRun -> Bool)
-> Eq StartMLEvaluationTaskRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartMLEvaluationTaskRun -> StartMLEvaluationTaskRun -> Bool
$c/= :: StartMLEvaluationTaskRun -> StartMLEvaluationTaskRun -> Bool
== :: StartMLEvaluationTaskRun -> StartMLEvaluationTaskRun -> Bool
$c== :: StartMLEvaluationTaskRun -> StartMLEvaluationTaskRun -> Bool
Prelude.Eq, ReadPrec [StartMLEvaluationTaskRun]
ReadPrec StartMLEvaluationTaskRun
Int -> ReadS StartMLEvaluationTaskRun
ReadS [StartMLEvaluationTaskRun]
(Int -> ReadS StartMLEvaluationTaskRun)
-> ReadS [StartMLEvaluationTaskRun]
-> ReadPrec StartMLEvaluationTaskRun
-> ReadPrec [StartMLEvaluationTaskRun]
-> Read StartMLEvaluationTaskRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartMLEvaluationTaskRun]
$creadListPrec :: ReadPrec [StartMLEvaluationTaskRun]
readPrec :: ReadPrec StartMLEvaluationTaskRun
$creadPrec :: ReadPrec StartMLEvaluationTaskRun
readList :: ReadS [StartMLEvaluationTaskRun]
$creadList :: ReadS [StartMLEvaluationTaskRun]
readsPrec :: Int -> ReadS StartMLEvaluationTaskRun
$creadsPrec :: Int -> ReadS StartMLEvaluationTaskRun
Prelude.Read, Int -> StartMLEvaluationTaskRun -> ShowS
[StartMLEvaluationTaskRun] -> ShowS
StartMLEvaluationTaskRun -> String
(Int -> StartMLEvaluationTaskRun -> ShowS)
-> (StartMLEvaluationTaskRun -> String)
-> ([StartMLEvaluationTaskRun] -> ShowS)
-> Show StartMLEvaluationTaskRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartMLEvaluationTaskRun] -> ShowS
$cshowList :: [StartMLEvaluationTaskRun] -> ShowS
show :: StartMLEvaluationTaskRun -> String
$cshow :: StartMLEvaluationTaskRun -> String
showsPrec :: Int -> StartMLEvaluationTaskRun -> ShowS
$cshowsPrec :: Int -> StartMLEvaluationTaskRun -> ShowS
Prelude.Show, (forall x.
 StartMLEvaluationTaskRun -> Rep StartMLEvaluationTaskRun x)
-> (forall x.
    Rep StartMLEvaluationTaskRun x -> StartMLEvaluationTaskRun)
-> Generic StartMLEvaluationTaskRun
forall x.
Rep StartMLEvaluationTaskRun x -> StartMLEvaluationTaskRun
forall x.
StartMLEvaluationTaskRun -> Rep StartMLEvaluationTaskRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartMLEvaluationTaskRun x -> StartMLEvaluationTaskRun
$cfrom :: forall x.
StartMLEvaluationTaskRun -> Rep StartMLEvaluationTaskRun x
Prelude.Generic)

-- |
-- Create a value of 'StartMLEvaluationTaskRun' 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:
--
-- 'transformId', 'startMLEvaluationTaskRun_transformId' - The unique identifier of the machine learning transform.
newStartMLEvaluationTaskRun ::
  -- | 'transformId'
  Prelude.Text ->
  StartMLEvaluationTaskRun
newStartMLEvaluationTaskRun :: Text -> StartMLEvaluationTaskRun
newStartMLEvaluationTaskRun Text
pTransformId_ =
  StartMLEvaluationTaskRun' :: Text -> StartMLEvaluationTaskRun
StartMLEvaluationTaskRun'
    { $sel:transformId:StartMLEvaluationTaskRun' :: Text
transformId =
        Text
pTransformId_
    }

-- | The unique identifier of the machine learning transform.
startMLEvaluationTaskRun_transformId :: Lens.Lens' StartMLEvaluationTaskRun Prelude.Text
startMLEvaluationTaskRun_transformId :: (Text -> f Text)
-> StartMLEvaluationTaskRun -> f StartMLEvaluationTaskRun
startMLEvaluationTaskRun_transformId = (StartMLEvaluationTaskRun -> Text)
-> (StartMLEvaluationTaskRun -> Text -> StartMLEvaluationTaskRun)
-> Lens StartMLEvaluationTaskRun StartMLEvaluationTaskRun Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartMLEvaluationTaskRun' {Text
transformId :: Text
$sel:transformId:StartMLEvaluationTaskRun' :: StartMLEvaluationTaskRun -> Text
transformId} -> Text
transformId) (\s :: StartMLEvaluationTaskRun
s@StartMLEvaluationTaskRun' {} Text
a -> StartMLEvaluationTaskRun
s {$sel:transformId:StartMLEvaluationTaskRun' :: Text
transformId = Text
a} :: StartMLEvaluationTaskRun)

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

instance Prelude.NFData StartMLEvaluationTaskRun

instance Core.ToHeaders StartMLEvaluationTaskRun where
  toHeaders :: StartMLEvaluationTaskRun -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartMLEvaluationTaskRun -> 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
"AWSGlue.StartMLEvaluationTaskRun" ::
                          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 StartMLEvaluationTaskRun where
  toJSON :: StartMLEvaluationTaskRun -> Value
toJSON StartMLEvaluationTaskRun' {Text
transformId :: Text
$sel:transformId:StartMLEvaluationTaskRun' :: StartMLEvaluationTaskRun -> 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
"TransformId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
transformId)]
      )

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

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

-- | /See:/ 'newStartMLEvaluationTaskRunResponse' smart constructor.
data StartMLEvaluationTaskRunResponse = StartMLEvaluationTaskRunResponse'
  { -- | The unique identifier associated with this run.
    StartMLEvaluationTaskRunResponse -> Maybe Text
taskRunId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartMLEvaluationTaskRunResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartMLEvaluationTaskRunResponse
-> StartMLEvaluationTaskRunResponse -> Bool
(StartMLEvaluationTaskRunResponse
 -> StartMLEvaluationTaskRunResponse -> Bool)
-> (StartMLEvaluationTaskRunResponse
    -> StartMLEvaluationTaskRunResponse -> Bool)
-> Eq StartMLEvaluationTaskRunResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartMLEvaluationTaskRunResponse
-> StartMLEvaluationTaskRunResponse -> Bool
$c/= :: StartMLEvaluationTaskRunResponse
-> StartMLEvaluationTaskRunResponse -> Bool
== :: StartMLEvaluationTaskRunResponse
-> StartMLEvaluationTaskRunResponse -> Bool
$c== :: StartMLEvaluationTaskRunResponse
-> StartMLEvaluationTaskRunResponse -> Bool
Prelude.Eq, ReadPrec [StartMLEvaluationTaskRunResponse]
ReadPrec StartMLEvaluationTaskRunResponse
Int -> ReadS StartMLEvaluationTaskRunResponse
ReadS [StartMLEvaluationTaskRunResponse]
(Int -> ReadS StartMLEvaluationTaskRunResponse)
-> ReadS [StartMLEvaluationTaskRunResponse]
-> ReadPrec StartMLEvaluationTaskRunResponse
-> ReadPrec [StartMLEvaluationTaskRunResponse]
-> Read StartMLEvaluationTaskRunResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartMLEvaluationTaskRunResponse]
$creadListPrec :: ReadPrec [StartMLEvaluationTaskRunResponse]
readPrec :: ReadPrec StartMLEvaluationTaskRunResponse
$creadPrec :: ReadPrec StartMLEvaluationTaskRunResponse
readList :: ReadS [StartMLEvaluationTaskRunResponse]
$creadList :: ReadS [StartMLEvaluationTaskRunResponse]
readsPrec :: Int -> ReadS StartMLEvaluationTaskRunResponse
$creadsPrec :: Int -> ReadS StartMLEvaluationTaskRunResponse
Prelude.Read, Int -> StartMLEvaluationTaskRunResponse -> ShowS
[StartMLEvaluationTaskRunResponse] -> ShowS
StartMLEvaluationTaskRunResponse -> String
(Int -> StartMLEvaluationTaskRunResponse -> ShowS)
-> (StartMLEvaluationTaskRunResponse -> String)
-> ([StartMLEvaluationTaskRunResponse] -> ShowS)
-> Show StartMLEvaluationTaskRunResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartMLEvaluationTaskRunResponse] -> ShowS
$cshowList :: [StartMLEvaluationTaskRunResponse] -> ShowS
show :: StartMLEvaluationTaskRunResponse -> String
$cshow :: StartMLEvaluationTaskRunResponse -> String
showsPrec :: Int -> StartMLEvaluationTaskRunResponse -> ShowS
$cshowsPrec :: Int -> StartMLEvaluationTaskRunResponse -> ShowS
Prelude.Show, (forall x.
 StartMLEvaluationTaskRunResponse
 -> Rep StartMLEvaluationTaskRunResponse x)
-> (forall x.
    Rep StartMLEvaluationTaskRunResponse x
    -> StartMLEvaluationTaskRunResponse)
-> Generic StartMLEvaluationTaskRunResponse
forall x.
Rep StartMLEvaluationTaskRunResponse x
-> StartMLEvaluationTaskRunResponse
forall x.
StartMLEvaluationTaskRunResponse
-> Rep StartMLEvaluationTaskRunResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartMLEvaluationTaskRunResponse x
-> StartMLEvaluationTaskRunResponse
$cfrom :: forall x.
StartMLEvaluationTaskRunResponse
-> Rep StartMLEvaluationTaskRunResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartMLEvaluationTaskRunResponse' 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:
--
-- 'taskRunId', 'startMLEvaluationTaskRunResponse_taskRunId' - The unique identifier associated with this run.
--
-- 'httpStatus', 'startMLEvaluationTaskRunResponse_httpStatus' - The response's http status code.
newStartMLEvaluationTaskRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartMLEvaluationTaskRunResponse
newStartMLEvaluationTaskRunResponse :: Int -> StartMLEvaluationTaskRunResponse
newStartMLEvaluationTaskRunResponse Int
pHttpStatus_ =
  StartMLEvaluationTaskRunResponse' :: Maybe Text -> Int -> StartMLEvaluationTaskRunResponse
StartMLEvaluationTaskRunResponse'
    { $sel:taskRunId:StartMLEvaluationTaskRunResponse' :: Maybe Text
taskRunId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartMLEvaluationTaskRunResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique identifier associated with this run.
startMLEvaluationTaskRunResponse_taskRunId :: Lens.Lens' StartMLEvaluationTaskRunResponse (Prelude.Maybe Prelude.Text)
startMLEvaluationTaskRunResponse_taskRunId :: (Maybe Text -> f (Maybe Text))
-> StartMLEvaluationTaskRunResponse
-> f StartMLEvaluationTaskRunResponse
startMLEvaluationTaskRunResponse_taskRunId = (StartMLEvaluationTaskRunResponse -> Maybe Text)
-> (StartMLEvaluationTaskRunResponse
    -> Maybe Text -> StartMLEvaluationTaskRunResponse)
-> Lens
     StartMLEvaluationTaskRunResponse
     StartMLEvaluationTaskRunResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartMLEvaluationTaskRunResponse' {Maybe Text
taskRunId :: Maybe Text
$sel:taskRunId:StartMLEvaluationTaskRunResponse' :: StartMLEvaluationTaskRunResponse -> Maybe Text
taskRunId} -> Maybe Text
taskRunId) (\s :: StartMLEvaluationTaskRunResponse
s@StartMLEvaluationTaskRunResponse' {} Maybe Text
a -> StartMLEvaluationTaskRunResponse
s {$sel:taskRunId:StartMLEvaluationTaskRunResponse' :: Maybe Text
taskRunId = Maybe Text
a} :: StartMLEvaluationTaskRunResponse)

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

instance
  Prelude.NFData
    StartMLEvaluationTaskRunResponse