{-# 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.EC2.DeleteInstanceEventWindow
-- 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 the specified event window.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/event-windows.html Define event windows for scheduled events>
-- in the /Amazon EC2 User Guide/.
module Amazonka.EC2.DeleteInstanceEventWindow
  ( -- * Creating a Request
    DeleteInstanceEventWindow (..),
    newDeleteInstanceEventWindow,

    -- * Request Lenses
    deleteInstanceEventWindow_dryRun,
    deleteInstanceEventWindow_forceDelete,
    deleteInstanceEventWindow_instanceEventWindowId,

    -- * Destructuring the Response
    DeleteInstanceEventWindowResponse (..),
    newDeleteInstanceEventWindowResponse,

    -- * Response Lenses
    deleteInstanceEventWindowResponse_instanceEventWindowState,
    deleteInstanceEventWindowResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteInstanceEventWindow' smart constructor.
data DeleteInstanceEventWindow = DeleteInstanceEventWindow'
  { -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    DeleteInstanceEventWindow -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | Specify @true@ to force delete the event window. Use the force delete
    -- parameter if the event window is currently associated with targets.
    DeleteInstanceEventWindow -> Maybe Bool
forceDelete :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the event window.
    DeleteInstanceEventWindow -> Text
instanceEventWindowId :: Prelude.Text
  }
  deriving (DeleteInstanceEventWindow -> DeleteInstanceEventWindow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInstanceEventWindow -> DeleteInstanceEventWindow -> Bool
$c/= :: DeleteInstanceEventWindow -> DeleteInstanceEventWindow -> Bool
== :: DeleteInstanceEventWindow -> DeleteInstanceEventWindow -> Bool
$c== :: DeleteInstanceEventWindow -> DeleteInstanceEventWindow -> Bool
Prelude.Eq, ReadPrec [DeleteInstanceEventWindow]
ReadPrec DeleteInstanceEventWindow
Int -> ReadS DeleteInstanceEventWindow
ReadS [DeleteInstanceEventWindow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInstanceEventWindow]
$creadListPrec :: ReadPrec [DeleteInstanceEventWindow]
readPrec :: ReadPrec DeleteInstanceEventWindow
$creadPrec :: ReadPrec DeleteInstanceEventWindow
readList :: ReadS [DeleteInstanceEventWindow]
$creadList :: ReadS [DeleteInstanceEventWindow]
readsPrec :: Int -> ReadS DeleteInstanceEventWindow
$creadsPrec :: Int -> ReadS DeleteInstanceEventWindow
Prelude.Read, Int -> DeleteInstanceEventWindow -> ShowS
[DeleteInstanceEventWindow] -> ShowS
DeleteInstanceEventWindow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInstanceEventWindow] -> ShowS
$cshowList :: [DeleteInstanceEventWindow] -> ShowS
show :: DeleteInstanceEventWindow -> String
$cshow :: DeleteInstanceEventWindow -> String
showsPrec :: Int -> DeleteInstanceEventWindow -> ShowS
$cshowsPrec :: Int -> DeleteInstanceEventWindow -> ShowS
Prelude.Show, forall x.
Rep DeleteInstanceEventWindow x -> DeleteInstanceEventWindow
forall x.
DeleteInstanceEventWindow -> Rep DeleteInstanceEventWindow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteInstanceEventWindow x -> DeleteInstanceEventWindow
$cfrom :: forall x.
DeleteInstanceEventWindow -> Rep DeleteInstanceEventWindow x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInstanceEventWindow' 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:
--
-- 'dryRun', 'deleteInstanceEventWindow_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'forceDelete', 'deleteInstanceEventWindow_forceDelete' - Specify @true@ to force delete the event window. Use the force delete
-- parameter if the event window is currently associated with targets.
--
-- 'instanceEventWindowId', 'deleteInstanceEventWindow_instanceEventWindowId' - The ID of the event window.
newDeleteInstanceEventWindow ::
  -- | 'instanceEventWindowId'
  Prelude.Text ->
  DeleteInstanceEventWindow
newDeleteInstanceEventWindow :: Text -> DeleteInstanceEventWindow
newDeleteInstanceEventWindow Text
pInstanceEventWindowId_ =
  DeleteInstanceEventWindow'
    { $sel:dryRun:DeleteInstanceEventWindow' :: Maybe Bool
dryRun =
        forall a. Maybe a
Prelude.Nothing,
      $sel:forceDelete:DeleteInstanceEventWindow' :: Maybe Bool
forceDelete = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceEventWindowId:DeleteInstanceEventWindow' :: Text
instanceEventWindowId = Text
pInstanceEventWindowId_
    }

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
deleteInstanceEventWindow_dryRun :: Lens.Lens' DeleteInstanceEventWindow (Prelude.Maybe Prelude.Bool)
deleteInstanceEventWindow_dryRun :: Lens' DeleteInstanceEventWindow (Maybe Bool)
deleteInstanceEventWindow_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInstanceEventWindow' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: DeleteInstanceEventWindow
s@DeleteInstanceEventWindow' {} Maybe Bool
a -> DeleteInstanceEventWindow
s {$sel:dryRun:DeleteInstanceEventWindow' :: Maybe Bool
dryRun = Maybe Bool
a} :: DeleteInstanceEventWindow)

-- | Specify @true@ to force delete the event window. Use the force delete
-- parameter if the event window is currently associated with targets.
deleteInstanceEventWindow_forceDelete :: Lens.Lens' DeleteInstanceEventWindow (Prelude.Maybe Prelude.Bool)
deleteInstanceEventWindow_forceDelete :: Lens' DeleteInstanceEventWindow (Maybe Bool)
deleteInstanceEventWindow_forceDelete = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInstanceEventWindow' {Maybe Bool
forceDelete :: Maybe Bool
$sel:forceDelete:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Maybe Bool
forceDelete} -> Maybe Bool
forceDelete) (\s :: DeleteInstanceEventWindow
s@DeleteInstanceEventWindow' {} Maybe Bool
a -> DeleteInstanceEventWindow
s {$sel:forceDelete:DeleteInstanceEventWindow' :: Maybe Bool
forceDelete = Maybe Bool
a} :: DeleteInstanceEventWindow)

-- | The ID of the event window.
deleteInstanceEventWindow_instanceEventWindowId :: Lens.Lens' DeleteInstanceEventWindow Prelude.Text
deleteInstanceEventWindow_instanceEventWindowId :: Lens' DeleteInstanceEventWindow Text
deleteInstanceEventWindow_instanceEventWindowId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInstanceEventWindow' {Text
instanceEventWindowId :: Text
$sel:instanceEventWindowId:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Text
instanceEventWindowId} -> Text
instanceEventWindowId) (\s :: DeleteInstanceEventWindow
s@DeleteInstanceEventWindow' {} Text
a -> DeleteInstanceEventWindow
s {$sel:instanceEventWindowId:DeleteInstanceEventWindow' :: Text
instanceEventWindowId = Text
a} :: DeleteInstanceEventWindow)

instance Core.AWSRequest DeleteInstanceEventWindow where
  type
    AWSResponse DeleteInstanceEventWindow =
      DeleteInstanceEventWindowResponse
  request :: (Service -> Service)
-> DeleteInstanceEventWindow -> Request DeleteInstanceEventWindow
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteInstanceEventWindow
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInstanceEventWindow)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe InstanceEventWindowStateChange
-> Int -> DeleteInstanceEventWindowResponse
DeleteInstanceEventWindowResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"instanceEventWindowState")
            forall (f :: * -> *) a b. Applicative f => 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 DeleteInstanceEventWindow where
  hashWithSalt :: Int -> DeleteInstanceEventWindow -> Int
hashWithSalt Int
_salt DeleteInstanceEventWindow' {Maybe Bool
Text
instanceEventWindowId :: Text
forceDelete :: Maybe Bool
dryRun :: Maybe Bool
$sel:instanceEventWindowId:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Text
$sel:forceDelete:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Maybe Bool
$sel:dryRun:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
forceDelete
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceEventWindowId

instance Prelude.NFData DeleteInstanceEventWindow where
  rnf :: DeleteInstanceEventWindow -> ()
rnf DeleteInstanceEventWindow' {Maybe Bool
Text
instanceEventWindowId :: Text
forceDelete :: Maybe Bool
dryRun :: Maybe Bool
$sel:instanceEventWindowId:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Text
$sel:forceDelete:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Maybe Bool
$sel:dryRun:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
forceDelete
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
instanceEventWindowId

instance Data.ToHeaders DeleteInstanceEventWindow where
  toHeaders :: DeleteInstanceEventWindow -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery DeleteInstanceEventWindow where
  toQuery :: DeleteInstanceEventWindow -> QueryString
toQuery DeleteInstanceEventWindow' {Maybe Bool
Text
instanceEventWindowId :: Text
forceDelete :: Maybe Bool
dryRun :: Maybe Bool
$sel:instanceEventWindowId:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Text
$sel:forceDelete:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Maybe Bool
$sel:dryRun:DeleteInstanceEventWindow' :: DeleteInstanceEventWindow -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteInstanceEventWindow" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        ByteString
"ForceDelete" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
forceDelete,
        ByteString
"InstanceEventWindowId"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
instanceEventWindowId
      ]

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

-- |
-- Create a value of 'DeleteInstanceEventWindowResponse' 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:
--
-- 'instanceEventWindowState', 'deleteInstanceEventWindowResponse_instanceEventWindowState' - The state of the event window.
--
-- 'httpStatus', 'deleteInstanceEventWindowResponse_httpStatus' - The response's http status code.
newDeleteInstanceEventWindowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteInstanceEventWindowResponse
newDeleteInstanceEventWindowResponse :: Int -> DeleteInstanceEventWindowResponse
newDeleteInstanceEventWindowResponse Int
pHttpStatus_ =
  DeleteInstanceEventWindowResponse'
    { $sel:instanceEventWindowState:DeleteInstanceEventWindowResponse' :: Maybe InstanceEventWindowStateChange
instanceEventWindowState =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteInstanceEventWindowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The state of the event window.
deleteInstanceEventWindowResponse_instanceEventWindowState :: Lens.Lens' DeleteInstanceEventWindowResponse (Prelude.Maybe InstanceEventWindowStateChange)
deleteInstanceEventWindowResponse_instanceEventWindowState :: Lens'
  DeleteInstanceEventWindowResponse
  (Maybe InstanceEventWindowStateChange)
deleteInstanceEventWindowResponse_instanceEventWindowState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInstanceEventWindowResponse' {Maybe InstanceEventWindowStateChange
instanceEventWindowState :: Maybe InstanceEventWindowStateChange
$sel:instanceEventWindowState:DeleteInstanceEventWindowResponse' :: DeleteInstanceEventWindowResponse
-> Maybe InstanceEventWindowStateChange
instanceEventWindowState} -> Maybe InstanceEventWindowStateChange
instanceEventWindowState) (\s :: DeleteInstanceEventWindowResponse
s@DeleteInstanceEventWindowResponse' {} Maybe InstanceEventWindowStateChange
a -> DeleteInstanceEventWindowResponse
s {$sel:instanceEventWindowState:DeleteInstanceEventWindowResponse' :: Maybe InstanceEventWindowStateChange
instanceEventWindowState = Maybe InstanceEventWindowStateChange
a} :: DeleteInstanceEventWindowResponse)

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

instance
  Prelude.NFData
    DeleteInstanceEventWindowResponse
  where
  rnf :: DeleteInstanceEventWindowResponse -> ()
rnf DeleteInstanceEventWindowResponse' {Int
Maybe InstanceEventWindowStateChange
httpStatus :: Int
instanceEventWindowState :: Maybe InstanceEventWindowStateChange
$sel:httpStatus:DeleteInstanceEventWindowResponse' :: DeleteInstanceEventWindowResponse -> Int
$sel:instanceEventWindowState:DeleteInstanceEventWindowResponse' :: DeleteInstanceEventWindowResponse
-> Maybe InstanceEventWindowStateChange
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceEventWindowStateChange
instanceEventWindowState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus