{-# 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.CancelMaintenanceWindowExecution
-- 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 a maintenance window execution that is already in progress and
-- cancels any tasks in the window that haven\'t already starting running.
-- Tasks already in progress will continue to completion.
module Amazonka.SSM.CancelMaintenanceWindowExecution
  ( -- * Creating a Request
    CancelMaintenanceWindowExecution (..),
    newCancelMaintenanceWindowExecution,

    -- * Request Lenses
    cancelMaintenanceWindowExecution_windowExecutionId,

    -- * Destructuring the Response
    CancelMaintenanceWindowExecutionResponse (..),
    newCancelMaintenanceWindowExecutionResponse,

    -- * Response Lenses
    cancelMaintenanceWindowExecutionResponse_windowExecutionId,
    cancelMaintenanceWindowExecutionResponse_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:/ 'newCancelMaintenanceWindowExecution' smart constructor.
data CancelMaintenanceWindowExecution = CancelMaintenanceWindowExecution'
  { -- | The ID of the maintenance window execution to stop.
    CancelMaintenanceWindowExecution -> Text
windowExecutionId :: Prelude.Text
  }
  deriving (CancelMaintenanceWindowExecution
-> CancelMaintenanceWindowExecution -> Bool
(CancelMaintenanceWindowExecution
 -> CancelMaintenanceWindowExecution -> Bool)
-> (CancelMaintenanceWindowExecution
    -> CancelMaintenanceWindowExecution -> Bool)
-> Eq CancelMaintenanceWindowExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelMaintenanceWindowExecution
-> CancelMaintenanceWindowExecution -> Bool
$c/= :: CancelMaintenanceWindowExecution
-> CancelMaintenanceWindowExecution -> Bool
== :: CancelMaintenanceWindowExecution
-> CancelMaintenanceWindowExecution -> Bool
$c== :: CancelMaintenanceWindowExecution
-> CancelMaintenanceWindowExecution -> Bool
Prelude.Eq, ReadPrec [CancelMaintenanceWindowExecution]
ReadPrec CancelMaintenanceWindowExecution
Int -> ReadS CancelMaintenanceWindowExecution
ReadS [CancelMaintenanceWindowExecution]
(Int -> ReadS CancelMaintenanceWindowExecution)
-> ReadS [CancelMaintenanceWindowExecution]
-> ReadPrec CancelMaintenanceWindowExecution
-> ReadPrec [CancelMaintenanceWindowExecution]
-> Read CancelMaintenanceWindowExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelMaintenanceWindowExecution]
$creadListPrec :: ReadPrec [CancelMaintenanceWindowExecution]
readPrec :: ReadPrec CancelMaintenanceWindowExecution
$creadPrec :: ReadPrec CancelMaintenanceWindowExecution
readList :: ReadS [CancelMaintenanceWindowExecution]
$creadList :: ReadS [CancelMaintenanceWindowExecution]
readsPrec :: Int -> ReadS CancelMaintenanceWindowExecution
$creadsPrec :: Int -> ReadS CancelMaintenanceWindowExecution
Prelude.Read, Int -> CancelMaintenanceWindowExecution -> ShowS
[CancelMaintenanceWindowExecution] -> ShowS
CancelMaintenanceWindowExecution -> String
(Int -> CancelMaintenanceWindowExecution -> ShowS)
-> (CancelMaintenanceWindowExecution -> String)
-> ([CancelMaintenanceWindowExecution] -> ShowS)
-> Show CancelMaintenanceWindowExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelMaintenanceWindowExecution] -> ShowS
$cshowList :: [CancelMaintenanceWindowExecution] -> ShowS
show :: CancelMaintenanceWindowExecution -> String
$cshow :: CancelMaintenanceWindowExecution -> String
showsPrec :: Int -> CancelMaintenanceWindowExecution -> ShowS
$cshowsPrec :: Int -> CancelMaintenanceWindowExecution -> ShowS
Prelude.Show, (forall x.
 CancelMaintenanceWindowExecution
 -> Rep CancelMaintenanceWindowExecution x)
-> (forall x.
    Rep CancelMaintenanceWindowExecution x
    -> CancelMaintenanceWindowExecution)
-> Generic CancelMaintenanceWindowExecution
forall x.
Rep CancelMaintenanceWindowExecution x
-> CancelMaintenanceWindowExecution
forall x.
CancelMaintenanceWindowExecution
-> Rep CancelMaintenanceWindowExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelMaintenanceWindowExecution x
-> CancelMaintenanceWindowExecution
$cfrom :: forall x.
CancelMaintenanceWindowExecution
-> Rep CancelMaintenanceWindowExecution x
Prelude.Generic)

-- |
-- Create a value of 'CancelMaintenanceWindowExecution' 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:
--
-- 'windowExecutionId', 'cancelMaintenanceWindowExecution_windowExecutionId' - The ID of the maintenance window execution to stop.
newCancelMaintenanceWindowExecution ::
  -- | 'windowExecutionId'
  Prelude.Text ->
  CancelMaintenanceWindowExecution
newCancelMaintenanceWindowExecution :: Text -> CancelMaintenanceWindowExecution
newCancelMaintenanceWindowExecution
  Text
pWindowExecutionId_ =
    CancelMaintenanceWindowExecution' :: Text -> CancelMaintenanceWindowExecution
CancelMaintenanceWindowExecution'
      { $sel:windowExecutionId:CancelMaintenanceWindowExecution' :: Text
windowExecutionId =
          Text
pWindowExecutionId_
      }

-- | The ID of the maintenance window execution to stop.
cancelMaintenanceWindowExecution_windowExecutionId :: Lens.Lens' CancelMaintenanceWindowExecution Prelude.Text
cancelMaintenanceWindowExecution_windowExecutionId :: (Text -> f Text)
-> CancelMaintenanceWindowExecution
-> f CancelMaintenanceWindowExecution
cancelMaintenanceWindowExecution_windowExecutionId = (CancelMaintenanceWindowExecution -> Text)
-> (CancelMaintenanceWindowExecution
    -> Text -> CancelMaintenanceWindowExecution)
-> Lens
     CancelMaintenanceWindowExecution
     CancelMaintenanceWindowExecution
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelMaintenanceWindowExecution' {Text
windowExecutionId :: Text
$sel:windowExecutionId:CancelMaintenanceWindowExecution' :: CancelMaintenanceWindowExecution -> Text
windowExecutionId} -> Text
windowExecutionId) (\s :: CancelMaintenanceWindowExecution
s@CancelMaintenanceWindowExecution' {} Text
a -> CancelMaintenanceWindowExecution
s {$sel:windowExecutionId:CancelMaintenanceWindowExecution' :: Text
windowExecutionId = Text
a} :: CancelMaintenanceWindowExecution)

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

instance
  Prelude.NFData
    CancelMaintenanceWindowExecution

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

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

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

-- | /See:/ 'newCancelMaintenanceWindowExecutionResponse' smart constructor.
data CancelMaintenanceWindowExecutionResponse = CancelMaintenanceWindowExecutionResponse'
  { -- | The ID of the maintenance window execution that has been stopped.
    CancelMaintenanceWindowExecutionResponse -> Maybe Text
windowExecutionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CancelMaintenanceWindowExecutionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CancelMaintenanceWindowExecutionResponse
-> CancelMaintenanceWindowExecutionResponse -> Bool
(CancelMaintenanceWindowExecutionResponse
 -> CancelMaintenanceWindowExecutionResponse -> Bool)
-> (CancelMaintenanceWindowExecutionResponse
    -> CancelMaintenanceWindowExecutionResponse -> Bool)
-> Eq CancelMaintenanceWindowExecutionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelMaintenanceWindowExecutionResponse
-> CancelMaintenanceWindowExecutionResponse -> Bool
$c/= :: CancelMaintenanceWindowExecutionResponse
-> CancelMaintenanceWindowExecutionResponse -> Bool
== :: CancelMaintenanceWindowExecutionResponse
-> CancelMaintenanceWindowExecutionResponse -> Bool
$c== :: CancelMaintenanceWindowExecutionResponse
-> CancelMaintenanceWindowExecutionResponse -> Bool
Prelude.Eq, ReadPrec [CancelMaintenanceWindowExecutionResponse]
ReadPrec CancelMaintenanceWindowExecutionResponse
Int -> ReadS CancelMaintenanceWindowExecutionResponse
ReadS [CancelMaintenanceWindowExecutionResponse]
(Int -> ReadS CancelMaintenanceWindowExecutionResponse)
-> ReadS [CancelMaintenanceWindowExecutionResponse]
-> ReadPrec CancelMaintenanceWindowExecutionResponse
-> ReadPrec [CancelMaintenanceWindowExecutionResponse]
-> Read CancelMaintenanceWindowExecutionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelMaintenanceWindowExecutionResponse]
$creadListPrec :: ReadPrec [CancelMaintenanceWindowExecutionResponse]
readPrec :: ReadPrec CancelMaintenanceWindowExecutionResponse
$creadPrec :: ReadPrec CancelMaintenanceWindowExecutionResponse
readList :: ReadS [CancelMaintenanceWindowExecutionResponse]
$creadList :: ReadS [CancelMaintenanceWindowExecutionResponse]
readsPrec :: Int -> ReadS CancelMaintenanceWindowExecutionResponse
$creadsPrec :: Int -> ReadS CancelMaintenanceWindowExecutionResponse
Prelude.Read, Int -> CancelMaintenanceWindowExecutionResponse -> ShowS
[CancelMaintenanceWindowExecutionResponse] -> ShowS
CancelMaintenanceWindowExecutionResponse -> String
(Int -> CancelMaintenanceWindowExecutionResponse -> ShowS)
-> (CancelMaintenanceWindowExecutionResponse -> String)
-> ([CancelMaintenanceWindowExecutionResponse] -> ShowS)
-> Show CancelMaintenanceWindowExecutionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelMaintenanceWindowExecutionResponse] -> ShowS
$cshowList :: [CancelMaintenanceWindowExecutionResponse] -> ShowS
show :: CancelMaintenanceWindowExecutionResponse -> String
$cshow :: CancelMaintenanceWindowExecutionResponse -> String
showsPrec :: Int -> CancelMaintenanceWindowExecutionResponse -> ShowS
$cshowsPrec :: Int -> CancelMaintenanceWindowExecutionResponse -> ShowS
Prelude.Show, (forall x.
 CancelMaintenanceWindowExecutionResponse
 -> Rep CancelMaintenanceWindowExecutionResponse x)
-> (forall x.
    Rep CancelMaintenanceWindowExecutionResponse x
    -> CancelMaintenanceWindowExecutionResponse)
-> Generic CancelMaintenanceWindowExecutionResponse
forall x.
Rep CancelMaintenanceWindowExecutionResponse x
-> CancelMaintenanceWindowExecutionResponse
forall x.
CancelMaintenanceWindowExecutionResponse
-> Rep CancelMaintenanceWindowExecutionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelMaintenanceWindowExecutionResponse x
-> CancelMaintenanceWindowExecutionResponse
$cfrom :: forall x.
CancelMaintenanceWindowExecutionResponse
-> Rep CancelMaintenanceWindowExecutionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelMaintenanceWindowExecutionResponse' 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:
--
-- 'windowExecutionId', 'cancelMaintenanceWindowExecutionResponse_windowExecutionId' - The ID of the maintenance window execution that has been stopped.
--
-- 'httpStatus', 'cancelMaintenanceWindowExecutionResponse_httpStatus' - The response's http status code.
newCancelMaintenanceWindowExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelMaintenanceWindowExecutionResponse
newCancelMaintenanceWindowExecutionResponse :: Int -> CancelMaintenanceWindowExecutionResponse
newCancelMaintenanceWindowExecutionResponse
  Int
pHttpStatus_ =
    CancelMaintenanceWindowExecutionResponse' :: Maybe Text -> Int -> CancelMaintenanceWindowExecutionResponse
CancelMaintenanceWindowExecutionResponse'
      { $sel:windowExecutionId:CancelMaintenanceWindowExecutionResponse' :: Maybe Text
windowExecutionId =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:CancelMaintenanceWindowExecutionResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The ID of the maintenance window execution that has been stopped.
cancelMaintenanceWindowExecutionResponse_windowExecutionId :: Lens.Lens' CancelMaintenanceWindowExecutionResponse (Prelude.Maybe Prelude.Text)
cancelMaintenanceWindowExecutionResponse_windowExecutionId :: (Maybe Text -> f (Maybe Text))
-> CancelMaintenanceWindowExecutionResponse
-> f CancelMaintenanceWindowExecutionResponse
cancelMaintenanceWindowExecutionResponse_windowExecutionId = (CancelMaintenanceWindowExecutionResponse -> Maybe Text)
-> (CancelMaintenanceWindowExecutionResponse
    -> Maybe Text -> CancelMaintenanceWindowExecutionResponse)
-> Lens
     CancelMaintenanceWindowExecutionResponse
     CancelMaintenanceWindowExecutionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelMaintenanceWindowExecutionResponse' {Maybe Text
windowExecutionId :: Maybe Text
$sel:windowExecutionId:CancelMaintenanceWindowExecutionResponse' :: CancelMaintenanceWindowExecutionResponse -> Maybe Text
windowExecutionId} -> Maybe Text
windowExecutionId) (\s :: CancelMaintenanceWindowExecutionResponse
s@CancelMaintenanceWindowExecutionResponse' {} Maybe Text
a -> CancelMaintenanceWindowExecutionResponse
s {$sel:windowExecutionId:CancelMaintenanceWindowExecutionResponse' :: Maybe Text
windowExecutionId = Maybe Text
a} :: CancelMaintenanceWindowExecutionResponse)

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

instance
  Prelude.NFData
    CancelMaintenanceWindowExecutionResponse