{-# 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-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)
--
-- 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.Lens as Lens
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
(StopAutomationExecution -> StopAutomationExecution -> Bool)
-> (StopAutomationExecution -> StopAutomationExecution -> Bool)
-> Eq StopAutomationExecution
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]
(Int -> ReadS StopAutomationExecution)
-> ReadS [StopAutomationExecution]
-> ReadPrec StopAutomationExecution
-> ReadPrec [StopAutomationExecution]
-> Read 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
(Int -> StopAutomationExecution -> ShowS)
-> (StopAutomationExecution -> String)
-> ([StopAutomationExecution] -> ShowS)
-> Show StopAutomationExecution
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.
 StopAutomationExecution -> Rep StopAutomationExecution x)
-> (forall x.
    Rep StopAutomationExecution x -> StopAutomationExecution)
-> Generic StopAutomationExecution
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' :: Maybe StopType -> Text -> StopAutomationExecution
StopAutomationExecution'
    { $sel:type':StopAutomationExecution' :: Maybe StopType
type' = Maybe StopType
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 :: (Maybe StopType -> f (Maybe StopType))
-> StopAutomationExecution -> f StopAutomationExecution
stopAutomationExecution_type = (StopAutomationExecution -> Maybe StopType)
-> (StopAutomationExecution
    -> Maybe StopType -> StopAutomationExecution)
-> Lens
     StopAutomationExecution
     StopAutomationExecution
     (Maybe StopType)
     (Maybe StopType)
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 :: (Text -> f Text)
-> StopAutomationExecution -> f StopAutomationExecution
stopAutomationExecution_automationExecutionId = (StopAutomationExecution -> Text)
-> (StopAutomationExecution -> Text -> StopAutomationExecution)
-> Lens StopAutomationExecution StopAutomationExecution Text Text
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 :: StopAutomationExecution -> Request StopAutomationExecution
request = Service
-> StopAutomationExecution -> Request StopAutomationExecution
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopAutomationExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopAutomationExecution)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StopAutomationExecution))
-> Logger
-> Service
-> Proxy StopAutomationExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopAutomationExecution)))
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 -> StopAutomationExecutionResponse
StopAutomationExecutionResponse'
            (Int -> StopAutomationExecutionResponse)
-> Either String Int
-> Either String StopAutomationExecutionResponse
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 StopAutomationExecution

instance Prelude.NFData StopAutomationExecution

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

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

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

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