{-# 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.StepFunctions.StopExecution
-- 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 an execution.
--
-- This API action is not supported by @EXPRESS@ state machines.
module Amazonka.StepFunctions.StopExecution
  ( -- * Creating a Request
    StopExecution (..),
    newStopExecution,

    -- * Request Lenses
    stopExecution_error,
    stopExecution_cause,
    stopExecution_executionArn,

    -- * Destructuring the Response
    StopExecutionResponse (..),
    newStopExecutionResponse,

    -- * Response Lenses
    stopExecutionResponse_httpStatus,
    stopExecutionResponse_stopDate,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.StepFunctions.Types

-- | /See:/ 'newStopExecution' smart constructor.
data StopExecution = StopExecution'
  { -- | The error code of the failure.
    StopExecution -> Maybe (Sensitive Text)
error :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | A more detailed explanation of the cause of the failure.
    StopExecution -> Maybe (Sensitive Text)
cause :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The Amazon Resource Name (ARN) of the execution to stop.
    StopExecution -> Text
executionArn :: Prelude.Text
  }
  deriving (StopExecution -> StopExecution -> Bool
(StopExecution -> StopExecution -> Bool)
-> (StopExecution -> StopExecution -> Bool) -> Eq StopExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopExecution -> StopExecution -> Bool
$c/= :: StopExecution -> StopExecution -> Bool
== :: StopExecution -> StopExecution -> Bool
$c== :: StopExecution -> StopExecution -> Bool
Prelude.Eq, Int -> StopExecution -> ShowS
[StopExecution] -> ShowS
StopExecution -> String
(Int -> StopExecution -> ShowS)
-> (StopExecution -> String)
-> ([StopExecution] -> ShowS)
-> Show StopExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopExecution] -> ShowS
$cshowList :: [StopExecution] -> ShowS
show :: StopExecution -> String
$cshow :: StopExecution -> String
showsPrec :: Int -> StopExecution -> ShowS
$cshowsPrec :: Int -> StopExecution -> ShowS
Prelude.Show, (forall x. StopExecution -> Rep StopExecution x)
-> (forall x. Rep StopExecution x -> StopExecution)
-> Generic StopExecution
forall x. Rep StopExecution x -> StopExecution
forall x. StopExecution -> Rep StopExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopExecution x -> StopExecution
$cfrom :: forall x. StopExecution -> Rep StopExecution x
Prelude.Generic)

-- |
-- Create a value of 'StopExecution' 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:
--
-- 'error', 'stopExecution_error' - The error code of the failure.
--
-- 'cause', 'stopExecution_cause' - A more detailed explanation of the cause of the failure.
--
-- 'executionArn', 'stopExecution_executionArn' - The Amazon Resource Name (ARN) of the execution to stop.
newStopExecution ::
  -- | 'executionArn'
  Prelude.Text ->
  StopExecution
newStopExecution :: Text -> StopExecution
newStopExecution Text
pExecutionArn_ =
  StopExecution' :: Maybe (Sensitive Text)
-> Maybe (Sensitive Text) -> Text -> StopExecution
StopExecution'
    { $sel:error:StopExecution' :: Maybe (Sensitive Text)
error = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:cause:StopExecution' :: Maybe (Sensitive Text)
cause = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:executionArn:StopExecution' :: Text
executionArn = Text
pExecutionArn_
    }

-- | The error code of the failure.
stopExecution_error :: Lens.Lens' StopExecution (Prelude.Maybe Prelude.Text)
stopExecution_error :: (Maybe Text -> f (Maybe Text)) -> StopExecution -> f StopExecution
stopExecution_error = (StopExecution -> Maybe (Sensitive Text))
-> (StopExecution -> Maybe (Sensitive Text) -> StopExecution)
-> Lens
     StopExecution
     StopExecution
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopExecution' {Maybe (Sensitive Text)
error :: Maybe (Sensitive Text)
$sel:error:StopExecution' :: StopExecution -> Maybe (Sensitive Text)
error} -> Maybe (Sensitive Text)
error) (\s :: StopExecution
s@StopExecution' {} Maybe (Sensitive Text)
a -> StopExecution
s {$sel:error:StopExecution' :: Maybe (Sensitive Text)
error = Maybe (Sensitive Text)
a} :: StopExecution) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> StopExecution -> f StopExecution)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> StopExecution
-> f StopExecution
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | A more detailed explanation of the cause of the failure.
stopExecution_cause :: Lens.Lens' StopExecution (Prelude.Maybe Prelude.Text)
stopExecution_cause :: (Maybe Text -> f (Maybe Text)) -> StopExecution -> f StopExecution
stopExecution_cause = (StopExecution -> Maybe (Sensitive Text))
-> (StopExecution -> Maybe (Sensitive Text) -> StopExecution)
-> Lens
     StopExecution
     StopExecution
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopExecution' {Maybe (Sensitive Text)
cause :: Maybe (Sensitive Text)
$sel:cause:StopExecution' :: StopExecution -> Maybe (Sensitive Text)
cause} -> Maybe (Sensitive Text)
cause) (\s :: StopExecution
s@StopExecution' {} Maybe (Sensitive Text)
a -> StopExecution
s {$sel:cause:StopExecution' :: Maybe (Sensitive Text)
cause = Maybe (Sensitive Text)
a} :: StopExecution) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> StopExecution -> f StopExecution)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> StopExecution
-> f StopExecution
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The Amazon Resource Name (ARN) of the execution to stop.
stopExecution_executionArn :: Lens.Lens' StopExecution Prelude.Text
stopExecution_executionArn :: (Text -> f Text) -> StopExecution -> f StopExecution
stopExecution_executionArn = (StopExecution -> Text)
-> (StopExecution -> Text -> StopExecution)
-> Lens StopExecution StopExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopExecution' {Text
executionArn :: Text
$sel:executionArn:StopExecution' :: StopExecution -> Text
executionArn} -> Text
executionArn) (\s :: StopExecution
s@StopExecution' {} Text
a -> StopExecution
s {$sel:executionArn:StopExecution' :: Text
executionArn = Text
a} :: StopExecution)

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

instance Prelude.Hashable StopExecution

instance Prelude.NFData StopExecution

instance Core.ToHeaders StopExecution where
  toHeaders :: StopExecution -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopExecution -> 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
"AWSStepFunctions.StopExecution" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON StopExecution where
  toJSON :: StopExecution -> Value
toJSON StopExecution' {Maybe (Sensitive Text)
Text
executionArn :: Text
cause :: Maybe (Sensitive Text)
error :: Maybe (Sensitive Text)
$sel:executionArn:StopExecution' :: StopExecution -> Text
$sel:cause:StopExecution' :: StopExecution -> Maybe (Sensitive Text)
$sel:error:StopExecution' :: StopExecution -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"error" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
error,
            (Text
"cause" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
cause,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"executionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
executionArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'StopExecutionResponse' 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', 'stopExecutionResponse_httpStatus' - The response's http status code.
--
-- 'stopDate', 'stopExecutionResponse_stopDate' - The date the execution is stopped.
newStopExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'stopDate'
  Prelude.UTCTime ->
  StopExecutionResponse
newStopExecutionResponse :: Int -> UTCTime -> StopExecutionResponse
newStopExecutionResponse Int
pHttpStatus_ UTCTime
pStopDate_ =
  StopExecutionResponse' :: Int -> POSIX -> StopExecutionResponse
StopExecutionResponse'
    { $sel:httpStatus:StopExecutionResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:stopDate:StopExecutionResponse' :: POSIX
stopDate = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStopDate_
    }

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

-- | The date the execution is stopped.
stopExecutionResponse_stopDate :: Lens.Lens' StopExecutionResponse Prelude.UTCTime
stopExecutionResponse_stopDate :: (UTCTime -> f UTCTime)
-> StopExecutionResponse -> f StopExecutionResponse
stopExecutionResponse_stopDate = (StopExecutionResponse -> POSIX)
-> (StopExecutionResponse -> POSIX -> StopExecutionResponse)
-> Lens StopExecutionResponse StopExecutionResponse POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopExecutionResponse' {POSIX
stopDate :: POSIX
$sel:stopDate:StopExecutionResponse' :: StopExecutionResponse -> POSIX
stopDate} -> POSIX
stopDate) (\s :: StopExecutionResponse
s@StopExecutionResponse' {} POSIX
a -> StopExecutionResponse
s {$sel:stopDate:StopExecutionResponse' :: POSIX
stopDate = POSIX
a} :: StopExecutionResponse) ((POSIX -> f POSIX)
 -> StopExecutionResponse -> f StopExecutionResponse)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> StopExecutionResponse
-> f StopExecutionResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Prelude.NFData StopExecutionResponse