{-# 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.StartExportLabelsTaskRun
-- 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)
--
-- Begins an asynchronous task to export all labeled data for a particular
-- transform. This task is the only label-related API call that is not part
-- of the typical active learning workflow. You typically use
-- @StartExportLabelsTaskRun@ when you want to work with all of your
-- existing labels at the same time, such as when you want to remove or
-- change labels that were previously submitted as truth. This API
-- operation accepts the @TransformId@ whose labels you want to export and
-- an Amazon Simple Storage Service (Amazon S3) path to export the labels
-- to. The operation returns a @TaskRunId@. You can check on the status of
-- your task run by calling the @GetMLTaskRun@ API.
module Amazonka.Glue.StartExportLabelsTaskRun
  ( -- * Creating a Request
    StartExportLabelsTaskRun (..),
    newStartExportLabelsTaskRun,

    -- * Request Lenses
    startExportLabelsTaskRun_transformId,
    startExportLabelsTaskRun_outputS3Path,

    -- * Destructuring the Response
    StartExportLabelsTaskRunResponse (..),
    newStartExportLabelsTaskRunResponse,

    -- * Response Lenses
    startExportLabelsTaskRunResponse_taskRunId,
    startExportLabelsTaskRunResponse_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:/ 'newStartExportLabelsTaskRun' smart constructor.
data StartExportLabelsTaskRun = StartExportLabelsTaskRun'
  { -- | The unique identifier of the machine learning transform.
    StartExportLabelsTaskRun -> Text
transformId :: Prelude.Text,
    -- | The Amazon S3 path where you export the labels.
    StartExportLabelsTaskRun -> Text
outputS3Path :: Prelude.Text
  }
  deriving (StartExportLabelsTaskRun -> StartExportLabelsTaskRun -> Bool
(StartExportLabelsTaskRun -> StartExportLabelsTaskRun -> Bool)
-> (StartExportLabelsTaskRun -> StartExportLabelsTaskRun -> Bool)
-> Eq StartExportLabelsTaskRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartExportLabelsTaskRun -> StartExportLabelsTaskRun -> Bool
$c/= :: StartExportLabelsTaskRun -> StartExportLabelsTaskRun -> Bool
== :: StartExportLabelsTaskRun -> StartExportLabelsTaskRun -> Bool
$c== :: StartExportLabelsTaskRun -> StartExportLabelsTaskRun -> Bool
Prelude.Eq, ReadPrec [StartExportLabelsTaskRun]
ReadPrec StartExportLabelsTaskRun
Int -> ReadS StartExportLabelsTaskRun
ReadS [StartExportLabelsTaskRun]
(Int -> ReadS StartExportLabelsTaskRun)
-> ReadS [StartExportLabelsTaskRun]
-> ReadPrec StartExportLabelsTaskRun
-> ReadPrec [StartExportLabelsTaskRun]
-> Read StartExportLabelsTaskRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartExportLabelsTaskRun]
$creadListPrec :: ReadPrec [StartExportLabelsTaskRun]
readPrec :: ReadPrec StartExportLabelsTaskRun
$creadPrec :: ReadPrec StartExportLabelsTaskRun
readList :: ReadS [StartExportLabelsTaskRun]
$creadList :: ReadS [StartExportLabelsTaskRun]
readsPrec :: Int -> ReadS StartExportLabelsTaskRun
$creadsPrec :: Int -> ReadS StartExportLabelsTaskRun
Prelude.Read, Int -> StartExportLabelsTaskRun -> ShowS
[StartExportLabelsTaskRun] -> ShowS
StartExportLabelsTaskRun -> String
(Int -> StartExportLabelsTaskRun -> ShowS)
-> (StartExportLabelsTaskRun -> String)
-> ([StartExportLabelsTaskRun] -> ShowS)
-> Show StartExportLabelsTaskRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartExportLabelsTaskRun] -> ShowS
$cshowList :: [StartExportLabelsTaskRun] -> ShowS
show :: StartExportLabelsTaskRun -> String
$cshow :: StartExportLabelsTaskRun -> String
showsPrec :: Int -> StartExportLabelsTaskRun -> ShowS
$cshowsPrec :: Int -> StartExportLabelsTaskRun -> ShowS
Prelude.Show, (forall x.
 StartExportLabelsTaskRun -> Rep StartExportLabelsTaskRun x)
-> (forall x.
    Rep StartExportLabelsTaskRun x -> StartExportLabelsTaskRun)
-> Generic StartExportLabelsTaskRun
forall x.
Rep StartExportLabelsTaskRun x -> StartExportLabelsTaskRun
forall x.
StartExportLabelsTaskRun -> Rep StartExportLabelsTaskRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartExportLabelsTaskRun x -> StartExportLabelsTaskRun
$cfrom :: forall x.
StartExportLabelsTaskRun -> Rep StartExportLabelsTaskRun x
Prelude.Generic)

-- |
-- Create a value of 'StartExportLabelsTaskRun' 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', 'startExportLabelsTaskRun_transformId' - The unique identifier of the machine learning transform.
--
-- 'outputS3Path', 'startExportLabelsTaskRun_outputS3Path' - The Amazon S3 path where you export the labels.
newStartExportLabelsTaskRun ::
  -- | 'transformId'
  Prelude.Text ->
  -- | 'outputS3Path'
  Prelude.Text ->
  StartExportLabelsTaskRun
newStartExportLabelsTaskRun :: Text -> Text -> StartExportLabelsTaskRun
newStartExportLabelsTaskRun
  Text
pTransformId_
  Text
pOutputS3Path_ =
    StartExportLabelsTaskRun' :: Text -> Text -> StartExportLabelsTaskRun
StartExportLabelsTaskRun'
      { $sel:transformId:StartExportLabelsTaskRun' :: Text
transformId =
          Text
pTransformId_,
        $sel:outputS3Path:StartExportLabelsTaskRun' :: Text
outputS3Path = Text
pOutputS3Path_
      }

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

-- | The Amazon S3 path where you export the labels.
startExportLabelsTaskRun_outputS3Path :: Lens.Lens' StartExportLabelsTaskRun Prelude.Text
startExportLabelsTaskRun_outputS3Path :: (Text -> f Text)
-> StartExportLabelsTaskRun -> f StartExportLabelsTaskRun
startExportLabelsTaskRun_outputS3Path = (StartExportLabelsTaskRun -> Text)
-> (StartExportLabelsTaskRun -> Text -> StartExportLabelsTaskRun)
-> Lens StartExportLabelsTaskRun StartExportLabelsTaskRun Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartExportLabelsTaskRun' {Text
outputS3Path :: Text
$sel:outputS3Path:StartExportLabelsTaskRun' :: StartExportLabelsTaskRun -> Text
outputS3Path} -> Text
outputS3Path) (\s :: StartExportLabelsTaskRun
s@StartExportLabelsTaskRun' {} Text
a -> StartExportLabelsTaskRun
s {$sel:outputS3Path:StartExportLabelsTaskRun' :: Text
outputS3Path = Text
a} :: StartExportLabelsTaskRun)

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

instance Prelude.NFData StartExportLabelsTaskRun

instance Core.ToHeaders StartExportLabelsTaskRun where
  toHeaders :: StartExportLabelsTaskRun -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartExportLabelsTaskRun -> 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.StartExportLabelsTaskRun" ::
                          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 StartExportLabelsTaskRun where
  toJSON :: StartExportLabelsTaskRun -> Value
toJSON StartExportLabelsTaskRun' {Text
outputS3Path :: Text
transformId :: Text
$sel:outputS3Path:StartExportLabelsTaskRun' :: StartExportLabelsTaskRun -> Text
$sel:transformId:StartExportLabelsTaskRun' :: StartExportLabelsTaskRun -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"OutputS3Path" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
outputS3Path)
          ]
      )

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

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

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

-- |
-- Create a value of 'StartExportLabelsTaskRunResponse' 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', 'startExportLabelsTaskRunResponse_taskRunId' - The unique identifier for the task run.
--
-- 'httpStatus', 'startExportLabelsTaskRunResponse_httpStatus' - The response's http status code.
newStartExportLabelsTaskRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartExportLabelsTaskRunResponse
newStartExportLabelsTaskRunResponse :: Int -> StartExportLabelsTaskRunResponse
newStartExportLabelsTaskRunResponse Int
pHttpStatus_ =
  StartExportLabelsTaskRunResponse' :: Maybe Text -> Int -> StartExportLabelsTaskRunResponse
StartExportLabelsTaskRunResponse'
    { $sel:taskRunId:StartExportLabelsTaskRunResponse' :: Maybe Text
taskRunId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartExportLabelsTaskRunResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique identifier for the task run.
startExportLabelsTaskRunResponse_taskRunId :: Lens.Lens' StartExportLabelsTaskRunResponse (Prelude.Maybe Prelude.Text)
startExportLabelsTaskRunResponse_taskRunId :: (Maybe Text -> f (Maybe Text))
-> StartExportLabelsTaskRunResponse
-> f StartExportLabelsTaskRunResponse
startExportLabelsTaskRunResponse_taskRunId = (StartExportLabelsTaskRunResponse -> Maybe Text)
-> (StartExportLabelsTaskRunResponse
    -> Maybe Text -> StartExportLabelsTaskRunResponse)
-> Lens
     StartExportLabelsTaskRunResponse
     StartExportLabelsTaskRunResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartExportLabelsTaskRunResponse' {Maybe Text
taskRunId :: Maybe Text
$sel:taskRunId:StartExportLabelsTaskRunResponse' :: StartExportLabelsTaskRunResponse -> Maybe Text
taskRunId} -> Maybe Text
taskRunId) (\s :: StartExportLabelsTaskRunResponse
s@StartExportLabelsTaskRunResponse' {} Maybe Text
a -> StartExportLabelsTaskRunResponse
s {$sel:taskRunId:StartExportLabelsTaskRunResponse' :: Maybe Text
taskRunId = Maybe Text
a} :: StartExportLabelsTaskRunResponse)

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

instance
  Prelude.NFData
    StartExportLabelsTaskRunResponse