{-# 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-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 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 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:/ '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
(StopWorkflowRun -> StopWorkflowRun -> Bool)
-> (StopWorkflowRun -> StopWorkflowRun -> Bool)
-> Eq StopWorkflowRun
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]
(Int -> ReadS StopWorkflowRun)
-> ReadS [StopWorkflowRun]
-> ReadPrec StopWorkflowRun
-> ReadPrec [StopWorkflowRun]
-> Read 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
(Int -> StopWorkflowRun -> ShowS)
-> (StopWorkflowRun -> String)
-> ([StopWorkflowRun] -> ShowS)
-> Show StopWorkflowRun
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. StopWorkflowRun -> Rep StopWorkflowRun x)
-> (forall x. Rep StopWorkflowRun x -> StopWorkflowRun)
-> Generic StopWorkflowRun
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' :: Text -> Text -> StopWorkflowRun
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 :: (Text -> f Text) -> StopWorkflowRun -> f StopWorkflowRun
stopWorkflowRun_name = (StopWorkflowRun -> Text)
-> (StopWorkflowRun -> Text -> StopWorkflowRun)
-> Lens StopWorkflowRun StopWorkflowRun Text Text
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 :: (Text -> f Text) -> StopWorkflowRun -> f StopWorkflowRun
stopWorkflowRun_runId = (StopWorkflowRun -> Text)
-> (StopWorkflowRun -> Text -> StopWorkflowRun)
-> Lens StopWorkflowRun StopWorkflowRun Text Text
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 :: StopWorkflowRun -> Request StopWorkflowRun
request = Service -> StopWorkflowRun -> Request StopWorkflowRun
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopWorkflowRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopWorkflowRun)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StopWorkflowRun))
-> Logger
-> Service
-> Proxy StopWorkflowRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopWorkflowRun)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StopWorkflowRunResponse
StopWorkflowRunResponse'
            (Int -> StopWorkflowRunResponse)
-> Either String Int -> Either String StopWorkflowRunResponse
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))
      )

instance Prelude.Hashable StopWorkflowRun

instance Prelude.NFData StopWorkflowRun

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

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

instance Core.ToQuery StopWorkflowRun where
  toQuery :: StopWorkflowRun -> QueryString
toQuery = QueryString -> StopWorkflowRun -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(StopWorkflowRunResponse -> StopWorkflowRunResponse -> Bool)
-> (StopWorkflowRunResponse -> StopWorkflowRunResponse -> Bool)
-> Eq StopWorkflowRunResponse
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]
(Int -> ReadS StopWorkflowRunResponse)
-> ReadS [StopWorkflowRunResponse]
-> ReadPrec StopWorkflowRunResponse
-> ReadPrec [StopWorkflowRunResponse]
-> Read 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
(Int -> StopWorkflowRunResponse -> ShowS)
-> (StopWorkflowRunResponse -> String)
-> ([StopWorkflowRunResponse] -> ShowS)
-> Show StopWorkflowRunResponse
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.
 StopWorkflowRunResponse -> Rep StopWorkflowRunResponse x)
-> (forall x.
    Rep StopWorkflowRunResponse x -> StopWorkflowRunResponse)
-> Generic StopWorkflowRunResponse
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' :: Int -> StopWorkflowRunResponse
StopWorkflowRunResponse' {$sel:httpStatus:StopWorkflowRunResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
stopWorkflowRunResponse_httpStatus :: Lens.Lens' StopWorkflowRunResponse Prelude.Int
stopWorkflowRunResponse_httpStatus :: (Int -> f Int)
-> StopWorkflowRunResponse -> f StopWorkflowRunResponse
stopWorkflowRunResponse_httpStatus = (StopWorkflowRunResponse -> Int)
-> (StopWorkflowRunResponse -> Int -> StopWorkflowRunResponse)
-> Lens StopWorkflowRunResponse StopWorkflowRunResponse Int Int
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