{-# 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-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)
--
-- Deletes a state machine. This is an asynchronous operation: It sets the
-- state machine\'s status to @DELETING@ and begins the deletion process.
--
-- 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.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:/ '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
(DeleteStateMachine -> DeleteStateMachine -> Bool)
-> (DeleteStateMachine -> DeleteStateMachine -> Bool)
-> Eq DeleteStateMachine
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]
(Int -> ReadS DeleteStateMachine)
-> ReadS [DeleteStateMachine]
-> ReadPrec DeleteStateMachine
-> ReadPrec [DeleteStateMachine]
-> Read 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
(Int -> DeleteStateMachine -> ShowS)
-> (DeleteStateMachine -> String)
-> ([DeleteStateMachine] -> ShowS)
-> Show DeleteStateMachine
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. DeleteStateMachine -> Rep DeleteStateMachine x)
-> (forall x. Rep DeleteStateMachine x -> DeleteStateMachine)
-> Generic DeleteStateMachine
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' :: Text -> DeleteStateMachine
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 :: (Text -> f Text) -> DeleteStateMachine -> f DeleteStateMachine
deleteStateMachine_stateMachineArn = (DeleteStateMachine -> Text)
-> (DeleteStateMachine -> Text -> DeleteStateMachine)
-> Lens DeleteStateMachine DeleteStateMachine Text Text
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 :: DeleteStateMachine -> Request DeleteStateMachine
request = Service -> DeleteStateMachine -> Request DeleteStateMachine
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteStateMachine
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteStateMachine)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteStateMachine))
-> Logger
-> Service
-> Proxy DeleteStateMachine
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteStateMachine)))
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 -> DeleteStateMachineResponse
DeleteStateMachineResponse'
            (Int -> DeleteStateMachineResponse)
-> Either String Int -> Either String DeleteStateMachineResponse
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 DeleteStateMachine

instance Prelude.NFData DeleteStateMachine

instance Core.ToHeaders DeleteStateMachine where
  toHeaders :: DeleteStateMachine -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteStateMachine -> 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.DeleteStateMachine" ::
                          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 DeleteStateMachine where
  toJSON :: DeleteStateMachine -> Value
toJSON DeleteStateMachine' {Text
stateMachineArn :: Text
$sel:stateMachineArn:DeleteStateMachine' :: DeleteStateMachine -> 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
"stateMachineArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
stateMachineArn)
          ]
      )

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

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

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