{-# 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.DeleteStateMachine
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a state machine. This is an asynchronous operation: It sets the
-- state machine\'s status to @DELETING@ and begins the deletion process.
--
-- If the given state machine Amazon Resource Name (ARN) is a qualified
-- state machine ARN, it will fail with ValidationException.
--
-- A qualified state machine ARN refers to a /Distributed Map state/
-- defined within a state machine. For example, the qualified state machine
-- ARN
-- @arn:partition:states:region:account-id:stateMachine:stateMachineName\/mapStateLabel@
-- refers to a /Distributed Map state/ with a label @mapStateLabel@ in the
-- state machine named @stateMachineName@.
--
-- For @EXPRESS@ state machines, the deletion will happen eventually
-- (usually less than a minute). Running executions may emit logs after
-- @DeleteStateMachine@ API is called.
module Amazonka.StepFunctions.DeleteStateMachine
  ( -- * Creating a Request
    DeleteStateMachine (..),
    newDeleteStateMachine,

    -- * Request Lenses
    deleteStateMachine_stateMachineArn,

    -- * Destructuring the Response
    DeleteStateMachineResponse (..),
    newDeleteStateMachineResponse,

    -- * Response Lenses
    deleteStateMachineResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteStateMachine' smart constructor.
data DeleteStateMachine = DeleteStateMachine'
  { -- | The Amazon Resource Name (ARN) of the state machine to delete.
    DeleteStateMachine -> Text
stateMachineArn :: Prelude.Text
  }
  deriving (DeleteStateMachine -> DeleteStateMachine -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteStateMachine -> DeleteStateMachine -> Bool
$c/= :: DeleteStateMachine -> DeleteStateMachine -> Bool
== :: DeleteStateMachine -> DeleteStateMachine -> Bool
$c== :: DeleteStateMachine -> DeleteStateMachine -> Bool
Prelude.Eq, ReadPrec [DeleteStateMachine]
ReadPrec DeleteStateMachine
Int -> ReadS DeleteStateMachine
ReadS [DeleteStateMachine]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteStateMachine]
$creadListPrec :: ReadPrec [DeleteStateMachine]
readPrec :: ReadPrec DeleteStateMachine
$creadPrec :: ReadPrec DeleteStateMachine
readList :: ReadS [DeleteStateMachine]
$creadList :: ReadS [DeleteStateMachine]
readsPrec :: Int -> ReadS DeleteStateMachine
$creadsPrec :: Int -> ReadS DeleteStateMachine
Prelude.Read, Int -> DeleteStateMachine -> ShowS
[DeleteStateMachine] -> ShowS
DeleteStateMachine -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteStateMachine] -> ShowS
$cshowList :: [DeleteStateMachine] -> ShowS
show :: DeleteStateMachine -> String
$cshow :: DeleteStateMachine -> String
showsPrec :: Int -> DeleteStateMachine -> ShowS
$cshowsPrec :: Int -> DeleteStateMachine -> ShowS
Prelude.Show, forall x. Rep DeleteStateMachine x -> DeleteStateMachine
forall x. DeleteStateMachine -> Rep DeleteStateMachine x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteStateMachine x -> DeleteStateMachine
$cfrom :: forall x. DeleteStateMachine -> Rep DeleteStateMachine x
Prelude.Generic)

-- |
-- Create a value of 'DeleteStateMachine' 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:
--
-- 'stateMachineArn', 'deleteStateMachine_stateMachineArn' - The Amazon Resource Name (ARN) of the state machine to delete.
newDeleteStateMachine ::
  -- | 'stateMachineArn'
  Prelude.Text ->
  DeleteStateMachine
newDeleteStateMachine :: Text -> DeleteStateMachine
newDeleteStateMachine Text
pStateMachineArn_ =
  DeleteStateMachine'
    { $sel:stateMachineArn:DeleteStateMachine' :: Text
stateMachineArn =
        Text
pStateMachineArn_
    }

-- | The Amazon Resource Name (ARN) of the state machine to delete.
deleteStateMachine_stateMachineArn :: Lens.Lens' DeleteStateMachine Prelude.Text
deleteStateMachine_stateMachineArn :: Lens' DeleteStateMachine Text
deleteStateMachine_stateMachineArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteStateMachine' {Text
stateMachineArn :: Text
$sel:stateMachineArn:DeleteStateMachine' :: DeleteStateMachine -> Text
stateMachineArn} -> Text
stateMachineArn) (\s :: DeleteStateMachine
s@DeleteStateMachine' {} Text
a -> DeleteStateMachine
s {$sel:stateMachineArn:DeleteStateMachine' :: Text
stateMachineArn = Text
a} :: DeleteStateMachine)

instance Core.AWSRequest DeleteStateMachine where
  type
    AWSResponse DeleteStateMachine =
      DeleteStateMachineResponse
  request :: (Service -> Service)
-> DeleteStateMachine -> Request DeleteStateMachine
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 DeleteStateMachine
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteStateMachine)))
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 -> DeleteStateMachineResponse
DeleteStateMachineResponse'
            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 DeleteStateMachine where
  hashWithSalt :: Int -> DeleteStateMachine -> Int
hashWithSalt Int
_salt DeleteStateMachine' {Text
stateMachineArn :: Text
$sel:stateMachineArn:DeleteStateMachine' :: DeleteStateMachine -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stateMachineArn

instance Prelude.NFData DeleteStateMachine where
  rnf :: DeleteStateMachine -> ()
rnf DeleteStateMachine' {Text
stateMachineArn :: Text
$sel:stateMachineArn:DeleteStateMachine' :: DeleteStateMachine -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
stateMachineArn

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

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

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

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

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

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

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

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