{-# 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.DataBrew.StartJobRun
-- 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)
--
-- Runs a DataBrew job.
module Amazonka.DataBrew.StartJobRun
  ( -- * Creating a Request
    StartJobRun (..),
    newStartJobRun,

    -- * Request Lenses
    startJobRun_name,

    -- * Destructuring the Response
    StartJobRunResponse (..),
    newStartJobRunResponse,

    -- * Response Lenses
    startJobRunResponse_httpStatus,
    startJobRunResponse_runId,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.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:/ 'newStartJobRun' smart constructor.
data StartJobRun = StartJobRun'
  { -- | The name of the job to be run.
    StartJobRun -> Text
name :: Prelude.Text
  }
  deriving (StartJobRun -> StartJobRun -> Bool
(StartJobRun -> StartJobRun -> Bool)
-> (StartJobRun -> StartJobRun -> Bool) -> Eq StartJobRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartJobRun -> StartJobRun -> Bool
$c/= :: StartJobRun -> StartJobRun -> Bool
== :: StartJobRun -> StartJobRun -> Bool
$c== :: StartJobRun -> StartJobRun -> Bool
Prelude.Eq, ReadPrec [StartJobRun]
ReadPrec StartJobRun
Int -> ReadS StartJobRun
ReadS [StartJobRun]
(Int -> ReadS StartJobRun)
-> ReadS [StartJobRun]
-> ReadPrec StartJobRun
-> ReadPrec [StartJobRun]
-> Read StartJobRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartJobRun]
$creadListPrec :: ReadPrec [StartJobRun]
readPrec :: ReadPrec StartJobRun
$creadPrec :: ReadPrec StartJobRun
readList :: ReadS [StartJobRun]
$creadList :: ReadS [StartJobRun]
readsPrec :: Int -> ReadS StartJobRun
$creadsPrec :: Int -> ReadS StartJobRun
Prelude.Read, Int -> StartJobRun -> ShowS
[StartJobRun] -> ShowS
StartJobRun -> String
(Int -> StartJobRun -> ShowS)
-> (StartJobRun -> String)
-> ([StartJobRun] -> ShowS)
-> Show StartJobRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartJobRun] -> ShowS
$cshowList :: [StartJobRun] -> ShowS
show :: StartJobRun -> String
$cshow :: StartJobRun -> String
showsPrec :: Int -> StartJobRun -> ShowS
$cshowsPrec :: Int -> StartJobRun -> ShowS
Prelude.Show, (forall x. StartJobRun -> Rep StartJobRun x)
-> (forall x. Rep StartJobRun x -> StartJobRun)
-> Generic StartJobRun
forall x. Rep StartJobRun x -> StartJobRun
forall x. StartJobRun -> Rep StartJobRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartJobRun x -> StartJobRun
$cfrom :: forall x. StartJobRun -> Rep StartJobRun x
Prelude.Generic)

-- |
-- Create a value of 'StartJobRun' 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:
--
-- 'name', 'startJobRun_name' - The name of the job to be run.
newStartJobRun ::
  -- | 'name'
  Prelude.Text ->
  StartJobRun
newStartJobRun :: Text -> StartJobRun
newStartJobRun Text
pName_ = StartJobRun' :: Text -> StartJobRun
StartJobRun' {$sel:name:StartJobRun' :: Text
name = Text
pName_}

-- | The name of the job to be run.
startJobRun_name :: Lens.Lens' StartJobRun Prelude.Text
startJobRun_name :: (Text -> f Text) -> StartJobRun -> f StartJobRun
startJobRun_name = (StartJobRun -> Text)
-> (StartJobRun -> Text -> StartJobRun)
-> Lens StartJobRun StartJobRun Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartJobRun' {Text
name :: Text
$sel:name:StartJobRun' :: StartJobRun -> Text
name} -> Text
name) (\s :: StartJobRun
s@StartJobRun' {} Text
a -> StartJobRun
s {$sel:name:StartJobRun' :: Text
name = Text
a} :: StartJobRun)

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

instance Prelude.Hashable StartJobRun

instance Prelude.NFData StartJobRun

instance Core.ToHeaders StartJobRun where
  toHeaders :: StartJobRun -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartJobRun -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 StartJobRun where
  toJSON :: StartJobRun -> Value
toJSON = Value -> StartJobRun -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath StartJobRun where
  toPath :: StartJobRun -> ByteString
toPath StartJobRun' {Text
name :: Text
$sel:name:StartJobRun' :: StartJobRun -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/jobs/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name, ByteString
"/startJobRun"]

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

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

-- |
-- Create a value of 'StartJobRunResponse' 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', 'startJobRunResponse_httpStatus' - The response's http status code.
--
-- 'runId', 'startJobRunResponse_runId' - A system-generated identifier for this particular job run.
newStartJobRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'runId'
  Prelude.Text ->
  StartJobRunResponse
newStartJobRunResponse :: Int -> Text -> StartJobRunResponse
newStartJobRunResponse Int
pHttpStatus_ Text
pRunId_ =
  StartJobRunResponse' :: Int -> Text -> StartJobRunResponse
StartJobRunResponse'
    { $sel:httpStatus:StartJobRunResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:runId:StartJobRunResponse' :: Text
runId = Text
pRunId_
    }

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

-- | A system-generated identifier for this particular job run.
startJobRunResponse_runId :: Lens.Lens' StartJobRunResponse Prelude.Text
startJobRunResponse_runId :: (Text -> f Text) -> StartJobRunResponse -> f StartJobRunResponse
startJobRunResponse_runId = (StartJobRunResponse -> Text)
-> (StartJobRunResponse -> Text -> StartJobRunResponse)
-> Lens StartJobRunResponse StartJobRunResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartJobRunResponse' {Text
runId :: Text
$sel:runId:StartJobRunResponse' :: StartJobRunResponse -> Text
runId} -> Text
runId) (\s :: StartJobRunResponse
s@StartJobRunResponse' {} Text
a -> StartJobRunResponse
s {$sel:runId:StartJobRunResponse' :: Text
runId = Text
a} :: StartJobRunResponse)

instance Prelude.NFData StartJobRunResponse