{-# 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.StopWorkflowRun
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stops the execution of the specified workflow run.
module Amazonka.Glue.StopWorkflowRun
  ( -- * Creating a Request
    StopWorkflowRun (..),
    newStopWorkflowRun,

    -- * Request Lenses
    stopWorkflowRun_name,
    stopWorkflowRun_runId,

    -- * Destructuring the Response
    StopWorkflowRunResponse (..),
    newStopWorkflowRunResponse,

    -- * Response Lenses
    stopWorkflowRunResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStopWorkflowRun' smart constructor.
data StopWorkflowRun = StopWorkflowRun'
  { -- | The name of the workflow to stop.
    StopWorkflowRun -> Text
name :: Prelude.Text,
    -- | The ID of the workflow run to stop.
    StopWorkflowRun -> Text
runId :: Prelude.Text
  }
  deriving (StopWorkflowRun -> StopWorkflowRun -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopWorkflowRun -> StopWorkflowRun -> Bool
$c/= :: StopWorkflowRun -> StopWorkflowRun -> Bool
== :: StopWorkflowRun -> StopWorkflowRun -> Bool
$c== :: StopWorkflowRun -> StopWorkflowRun -> Bool
Prelude.Eq, ReadPrec [StopWorkflowRun]
ReadPrec StopWorkflowRun
Int -> ReadS StopWorkflowRun
ReadS [StopWorkflowRun]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopWorkflowRun]
$creadListPrec :: ReadPrec [StopWorkflowRun]
readPrec :: ReadPrec StopWorkflowRun
$creadPrec :: ReadPrec StopWorkflowRun
readList :: ReadS [StopWorkflowRun]
$creadList :: ReadS [StopWorkflowRun]
readsPrec :: Int -> ReadS StopWorkflowRun
$creadsPrec :: Int -> ReadS StopWorkflowRun
Prelude.Read, Int -> StopWorkflowRun -> ShowS
[StopWorkflowRun] -> ShowS
StopWorkflowRun -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopWorkflowRun] -> ShowS
$cshowList :: [StopWorkflowRun] -> ShowS
show :: StopWorkflowRun -> String
$cshow :: StopWorkflowRun -> String
showsPrec :: Int -> StopWorkflowRun -> ShowS
$cshowsPrec :: Int -> StopWorkflowRun -> ShowS
Prelude.Show, forall x. Rep StopWorkflowRun x -> StopWorkflowRun
forall x. StopWorkflowRun -> Rep StopWorkflowRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopWorkflowRun x -> StopWorkflowRun
$cfrom :: forall x. StopWorkflowRun -> Rep StopWorkflowRun x
Prelude.Generic)

-- |
-- Create a value of 'StopWorkflowRun' 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', 'stopWorkflowRun_name' - The name of the workflow to stop.
--
-- 'runId', 'stopWorkflowRun_runId' - The ID of the workflow run to stop.
newStopWorkflowRun ::
  -- | 'name'
  Prelude.Text ->
  -- | 'runId'
  Prelude.Text ->
  StopWorkflowRun
newStopWorkflowRun :: Text -> Text -> StopWorkflowRun
newStopWorkflowRun Text
pName_ Text
pRunId_ =
  StopWorkflowRun' {$sel:name:StopWorkflowRun' :: Text
name = Text
pName_, $sel:runId:StopWorkflowRun' :: Text
runId = Text
pRunId_}

-- | The name of the workflow to stop.
stopWorkflowRun_name :: Lens.Lens' StopWorkflowRun Prelude.Text
stopWorkflowRun_name :: Lens' StopWorkflowRun Text
stopWorkflowRun_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopWorkflowRun' {Text
name :: Text
$sel:name:StopWorkflowRun' :: StopWorkflowRun -> Text
name} -> Text
name) (\s :: StopWorkflowRun
s@StopWorkflowRun' {} Text
a -> StopWorkflowRun
s {$sel:name:StopWorkflowRun' :: Text
name = Text
a} :: StopWorkflowRun)

-- | The ID of the workflow run to stop.
stopWorkflowRun_runId :: Lens.Lens' StopWorkflowRun Prelude.Text
stopWorkflowRun_runId :: Lens' StopWorkflowRun Text
stopWorkflowRun_runId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopWorkflowRun' {Text
runId :: Text
$sel:runId:StopWorkflowRun' :: StopWorkflowRun -> Text
runId} -> Text
runId) (\s :: StopWorkflowRun
s@StopWorkflowRun' {} Text
a -> StopWorkflowRun
s {$sel:runId:StopWorkflowRun' :: Text
runId = Text
a} :: StopWorkflowRun)

instance Core.AWSRequest StopWorkflowRun where
  type
    AWSResponse StopWorkflowRun =
      StopWorkflowRunResponse
  request :: (Service -> Service) -> StopWorkflowRun -> Request StopWorkflowRun
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StopWorkflowRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopWorkflowRun)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StopWorkflowRunResponse
StopWorkflowRunResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StopWorkflowRun where
  hashWithSalt :: Int -> StopWorkflowRun -> Int
hashWithSalt Int
_salt StopWorkflowRun' {Text
runId :: Text
name :: Text
$sel:runId:StopWorkflowRun' :: StopWorkflowRun -> Text
$sel:name:StopWorkflowRun' :: StopWorkflowRun -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
runId

instance Prelude.NFData StopWorkflowRun where
  rnf :: StopWorkflowRun -> ()
rnf StopWorkflowRun' {Text
runId :: Text
name :: Text
$sel:runId:StopWorkflowRun' :: StopWorkflowRun -> Text
$sel:name:StopWorkflowRun' :: StopWorkflowRun -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
runId

instance Data.ToHeaders StopWorkflowRun where
  toHeaders :: StopWorkflowRun -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"AWSGlue.StopWorkflowRun" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StopWorkflowRun where
  toJSON :: StopWorkflowRun -> Value
toJSON StopWorkflowRun' {Text
runId :: Text
name :: Text
$sel:runId:StopWorkflowRun' :: StopWorkflowRun -> Text
$sel:name:StopWorkflowRun' :: StopWorkflowRun -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"RunId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
runId)
          ]
      )

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

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

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

-- |
-- Create a value of 'StopWorkflowRunResponse' 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', 'stopWorkflowRunResponse_httpStatus' - The response's http status code.
newStopWorkflowRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopWorkflowRunResponse
newStopWorkflowRunResponse :: Int -> StopWorkflowRunResponse
newStopWorkflowRunResponse Int
pHttpStatus_ =
  StopWorkflowRunResponse' {$sel:httpStatus:StopWorkflowRunResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData StopWorkflowRunResponse where
  rnf :: StopWorkflowRunResponse -> ()
rnf StopWorkflowRunResponse' {Int
httpStatus :: Int
$sel:httpStatus:StopWorkflowRunResponse' :: StopWorkflowRunResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus