{-# 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.SSM.StopAutomationExecution
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stop an Automation that is currently running.
module Amazonka.SSM.StopAutomationExecution
  ( -- * Creating a Request
    StopAutomationExecution (..),
    newStopAutomationExecution,

    -- * Request Lenses
    stopAutomationExecution_type,
    stopAutomationExecution_automationExecutionId,

    -- * Destructuring the Response
    StopAutomationExecutionResponse (..),
    newStopAutomationExecutionResponse,

    -- * Response Lenses
    stopAutomationExecutionResponse_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.SSM.Types

-- | /See:/ 'newStopAutomationExecution' smart constructor.
data StopAutomationExecution = StopAutomationExecution'
  { -- | The stop request type. Valid types include the following: Cancel and
    -- Complete. The default type is Cancel.
    StopAutomationExecution -> Maybe StopType
type' :: Prelude.Maybe StopType,
    -- | The execution ID of the Automation to stop.
    StopAutomationExecution -> Text
automationExecutionId :: Prelude.Text
  }
  deriving (StopAutomationExecution -> StopAutomationExecution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopAutomationExecution -> StopAutomationExecution -> Bool
$c/= :: StopAutomationExecution -> StopAutomationExecution -> Bool
== :: StopAutomationExecution -> StopAutomationExecution -> Bool
$c== :: StopAutomationExecution -> StopAutomationExecution -> Bool
Prelude.Eq, ReadPrec [StopAutomationExecution]
ReadPrec StopAutomationExecution
Int -> ReadS StopAutomationExecution
ReadS [StopAutomationExecution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopAutomationExecution]
$creadListPrec :: ReadPrec [StopAutomationExecution]
readPrec :: ReadPrec StopAutomationExecution
$creadPrec :: ReadPrec StopAutomationExecution
readList :: ReadS [StopAutomationExecution]
$creadList :: ReadS [StopAutomationExecution]
readsPrec :: Int -> ReadS StopAutomationExecution
$creadsPrec :: Int -> ReadS StopAutomationExecution
Prelude.Read, Int -> StopAutomationExecution -> ShowS
[StopAutomationExecution] -> ShowS
StopAutomationExecution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopAutomationExecution] -> ShowS
$cshowList :: [StopAutomationExecution] -> ShowS
show :: StopAutomationExecution -> String
$cshow :: StopAutomationExecution -> String
showsPrec :: Int -> StopAutomationExecution -> ShowS
$cshowsPrec :: Int -> StopAutomationExecution -> ShowS
Prelude.Show, forall x. Rep StopAutomationExecution x -> StopAutomationExecution
forall x. StopAutomationExecution -> Rep StopAutomationExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopAutomationExecution x -> StopAutomationExecution
$cfrom :: forall x. StopAutomationExecution -> Rep StopAutomationExecution x
Prelude.Generic)

-- |
-- Create a value of 'StopAutomationExecution' 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:
--
-- 'type'', 'stopAutomationExecution_type' - The stop request type. Valid types include the following: Cancel and
-- Complete. The default type is Cancel.
--
-- 'automationExecutionId', 'stopAutomationExecution_automationExecutionId' - The execution ID of the Automation to stop.
newStopAutomationExecution ::
  -- | 'automationExecutionId'
  Prelude.Text ->
  StopAutomationExecution
newStopAutomationExecution :: Text -> StopAutomationExecution
newStopAutomationExecution Text
pAutomationExecutionId_ =
  StopAutomationExecution'
    { $sel:type':StopAutomationExecution' :: Maybe StopType
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:automationExecutionId:StopAutomationExecution' :: Text
automationExecutionId = Text
pAutomationExecutionId_
    }

-- | The stop request type. Valid types include the following: Cancel and
-- Complete. The default type is Cancel.
stopAutomationExecution_type :: Lens.Lens' StopAutomationExecution (Prelude.Maybe StopType)
stopAutomationExecution_type :: Lens' StopAutomationExecution (Maybe StopType)
stopAutomationExecution_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopAutomationExecution' {Maybe StopType
type' :: Maybe StopType
$sel:type':StopAutomationExecution' :: StopAutomationExecution -> Maybe StopType
type'} -> Maybe StopType
type') (\s :: StopAutomationExecution
s@StopAutomationExecution' {} Maybe StopType
a -> StopAutomationExecution
s {$sel:type':StopAutomationExecution' :: Maybe StopType
type' = Maybe StopType
a} :: StopAutomationExecution)

-- | The execution ID of the Automation to stop.
stopAutomationExecution_automationExecutionId :: Lens.Lens' StopAutomationExecution Prelude.Text
stopAutomationExecution_automationExecutionId :: Lens' StopAutomationExecution Text
stopAutomationExecution_automationExecutionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopAutomationExecution' {Text
automationExecutionId :: Text
$sel:automationExecutionId:StopAutomationExecution' :: StopAutomationExecution -> Text
automationExecutionId} -> Text
automationExecutionId) (\s :: StopAutomationExecution
s@StopAutomationExecution' {} Text
a -> StopAutomationExecution
s {$sel:automationExecutionId:StopAutomationExecution' :: Text
automationExecutionId = Text
a} :: StopAutomationExecution)

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

instance Prelude.NFData StopAutomationExecution where
  rnf :: StopAutomationExecution -> ()
rnf StopAutomationExecution' {Maybe StopType
Text
automationExecutionId :: Text
type' :: Maybe StopType
$sel:automationExecutionId:StopAutomationExecution' :: StopAutomationExecution -> Text
$sel:type':StopAutomationExecution' :: StopAutomationExecution -> Maybe StopType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StopType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
automationExecutionId

instance Data.ToHeaders StopAutomationExecution where
  toHeaders :: StopAutomationExecution -> 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
"AmazonSSM.StopAutomationExecution" ::
                          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 StopAutomationExecution where
  toJSON :: StopAutomationExecution -> Value
toJSON StopAutomationExecution' {Maybe StopType
Text
automationExecutionId :: Text
type' :: Maybe StopType
$sel:automationExecutionId:StopAutomationExecution' :: StopAutomationExecution -> Text
$sel:type':StopAutomationExecution' :: StopAutomationExecution -> Maybe StopType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StopType
type',
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"AutomationExecutionId"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
automationExecutionId
              )
          ]
      )

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

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

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

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

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

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