{-# 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.StopJobRun
-- 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)
--
-- Stops a particular run of a job.
module Amazonka.DataBrew.StopJobRun
  ( -- * Creating a Request
    StopJobRun (..),
    newStopJobRun,

    -- * Request Lenses
    stopJobRun_name,
    stopJobRun_runId,

    -- * Destructuring the Response
    StopJobRunResponse (..),
    newStopJobRunResponse,

    -- * Response Lenses
    stopJobRunResponse_httpStatus,
    stopJobRunResponse_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:/ 'newStopJobRun' smart constructor.
data StopJobRun = StopJobRun'
  { -- | The name of the job to be stopped.
    StopJobRun -> Text
name :: Prelude.Text,
    -- | The ID of the job run to be stopped.
    StopJobRun -> Text
runId :: Prelude.Text
  }
  deriving (StopJobRun -> StopJobRun -> Bool
(StopJobRun -> StopJobRun -> Bool)
-> (StopJobRun -> StopJobRun -> Bool) -> Eq StopJobRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopJobRun -> StopJobRun -> Bool
$c/= :: StopJobRun -> StopJobRun -> Bool
== :: StopJobRun -> StopJobRun -> Bool
$c== :: StopJobRun -> StopJobRun -> Bool
Prelude.Eq, ReadPrec [StopJobRun]
ReadPrec StopJobRun
Int -> ReadS StopJobRun
ReadS [StopJobRun]
(Int -> ReadS StopJobRun)
-> ReadS [StopJobRun]
-> ReadPrec StopJobRun
-> ReadPrec [StopJobRun]
-> Read StopJobRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopJobRun]
$creadListPrec :: ReadPrec [StopJobRun]
readPrec :: ReadPrec StopJobRun
$creadPrec :: ReadPrec StopJobRun
readList :: ReadS [StopJobRun]
$creadList :: ReadS [StopJobRun]
readsPrec :: Int -> ReadS StopJobRun
$creadsPrec :: Int -> ReadS StopJobRun
Prelude.Read, Int -> StopJobRun -> ShowS
[StopJobRun] -> ShowS
StopJobRun -> String
(Int -> StopJobRun -> ShowS)
-> (StopJobRun -> String)
-> ([StopJobRun] -> ShowS)
-> Show StopJobRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopJobRun] -> ShowS
$cshowList :: [StopJobRun] -> ShowS
show :: StopJobRun -> String
$cshow :: StopJobRun -> String
showsPrec :: Int -> StopJobRun -> ShowS
$cshowsPrec :: Int -> StopJobRun -> ShowS
Prelude.Show, (forall x. StopJobRun -> Rep StopJobRun x)
-> (forall x. Rep StopJobRun x -> StopJobRun) -> Generic StopJobRun
forall x. Rep StopJobRun x -> StopJobRun
forall x. StopJobRun -> Rep StopJobRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopJobRun x -> StopJobRun
$cfrom :: forall x. StopJobRun -> Rep StopJobRun x
Prelude.Generic)

-- |
-- Create a value of 'StopJobRun' 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', 'stopJobRun_name' - The name of the job to be stopped.
--
-- 'runId', 'stopJobRun_runId' - The ID of the job run to be stopped.
newStopJobRun ::
  -- | 'name'
  Prelude.Text ->
  -- | 'runId'
  Prelude.Text ->
  StopJobRun
newStopJobRun :: Text -> Text -> StopJobRun
newStopJobRun Text
pName_ Text
pRunId_ =
  StopJobRun' :: Text -> Text -> StopJobRun
StopJobRun' {$sel:name:StopJobRun' :: Text
name = Text
pName_, $sel:runId:StopJobRun' :: Text
runId = Text
pRunId_}

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

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

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

instance Prelude.NFData StopJobRun

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

instance Core.ToPath StopJobRun where
  toPath :: StopJobRun -> ByteString
toPath StopJobRun' {Text
runId :: Text
name :: Text
$sel:runId:StopJobRun' :: StopJobRun -> Text
$sel:name:StopJobRun' :: StopJobRun -> 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
"/jobRun/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
runId,
        ByteString
"/stopJobRun"
      ]

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

-- | /See:/ 'newStopJobRunResponse' smart constructor.
data StopJobRunResponse = StopJobRunResponse'
  { -- | The response's http status code.
    StopJobRunResponse -> Int
httpStatus :: Prelude.Int,
    -- | The ID of the job run that you stopped.
    StopJobRunResponse -> Text
runId :: Prelude.Text
  }
  deriving (StopJobRunResponse -> StopJobRunResponse -> Bool
(StopJobRunResponse -> StopJobRunResponse -> Bool)
-> (StopJobRunResponse -> StopJobRunResponse -> Bool)
-> Eq StopJobRunResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopJobRunResponse -> StopJobRunResponse -> Bool
$c/= :: StopJobRunResponse -> StopJobRunResponse -> Bool
== :: StopJobRunResponse -> StopJobRunResponse -> Bool
$c== :: StopJobRunResponse -> StopJobRunResponse -> Bool
Prelude.Eq, ReadPrec [StopJobRunResponse]
ReadPrec StopJobRunResponse
Int -> ReadS StopJobRunResponse
ReadS [StopJobRunResponse]
(Int -> ReadS StopJobRunResponse)
-> ReadS [StopJobRunResponse]
-> ReadPrec StopJobRunResponse
-> ReadPrec [StopJobRunResponse]
-> Read StopJobRunResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopJobRunResponse]
$creadListPrec :: ReadPrec [StopJobRunResponse]
readPrec :: ReadPrec StopJobRunResponse
$creadPrec :: ReadPrec StopJobRunResponse
readList :: ReadS [StopJobRunResponse]
$creadList :: ReadS [StopJobRunResponse]
readsPrec :: Int -> ReadS StopJobRunResponse
$creadsPrec :: Int -> ReadS StopJobRunResponse
Prelude.Read, Int -> StopJobRunResponse -> ShowS
[StopJobRunResponse] -> ShowS
StopJobRunResponse -> String
(Int -> StopJobRunResponse -> ShowS)
-> (StopJobRunResponse -> String)
-> ([StopJobRunResponse] -> ShowS)
-> Show StopJobRunResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopJobRunResponse] -> ShowS
$cshowList :: [StopJobRunResponse] -> ShowS
show :: StopJobRunResponse -> String
$cshow :: StopJobRunResponse -> String
showsPrec :: Int -> StopJobRunResponse -> ShowS
$cshowsPrec :: Int -> StopJobRunResponse -> ShowS
Prelude.Show, (forall x. StopJobRunResponse -> Rep StopJobRunResponse x)
-> (forall x. Rep StopJobRunResponse x -> StopJobRunResponse)
-> Generic StopJobRunResponse
forall x. Rep StopJobRunResponse x -> StopJobRunResponse
forall x. StopJobRunResponse -> Rep StopJobRunResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopJobRunResponse x -> StopJobRunResponse
$cfrom :: forall x. StopJobRunResponse -> Rep StopJobRunResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopJobRunResponse' 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', 'stopJobRunResponse_httpStatus' - The response's http status code.
--
-- 'runId', 'stopJobRunResponse_runId' - The ID of the job run that you stopped.
newStopJobRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'runId'
  Prelude.Text ->
  StopJobRunResponse
newStopJobRunResponse :: Int -> Text -> StopJobRunResponse
newStopJobRunResponse Int
pHttpStatus_ Text
pRunId_ =
  StopJobRunResponse' :: Int -> Text -> StopJobRunResponse
StopJobRunResponse'
    { $sel:httpStatus:StopJobRunResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:runId:StopJobRunResponse' :: Text
runId = Text
pRunId_
    }

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

-- | The ID of the job run that you stopped.
stopJobRunResponse_runId :: Lens.Lens' StopJobRunResponse Prelude.Text
stopJobRunResponse_runId :: (Text -> f Text) -> StopJobRunResponse -> f StopJobRunResponse
stopJobRunResponse_runId = (StopJobRunResponse -> Text)
-> (StopJobRunResponse -> Text -> StopJobRunResponse)
-> Lens StopJobRunResponse StopJobRunResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopJobRunResponse' {Text
runId :: Text
$sel:runId:StopJobRunResponse' :: StopJobRunResponse -> Text
runId} -> Text
runId) (\s :: StopJobRunResponse
s@StopJobRunResponse' {} Text
a -> StopJobRunResponse
s {$sel:runId:StopJobRunResponse' :: Text
runId = Text
a} :: StopJobRunResponse)

instance Prelude.NFData StopJobRunResponse