{-# 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.SendDiagnosticInterrupt
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sends a diagnostic interrupt to the specified Amazon EC2 instance to
-- trigger a /kernel panic/ (on Linux instances), or a /blue screen/\//stop
-- error/ (on Windows instances). For instances based on Intel and AMD
-- processors, the interrupt is received as a /non-maskable interrupt/
-- (NMI).
--
-- In general, the operating system crashes and reboots when a kernel panic
-- or stop error is triggered. The operating system can also be configured
-- to perform diagnostic tasks, such as generating a memory dump file,
-- loading a secondary kernel, or obtaining a call trace.
--
-- Before sending a diagnostic interrupt to your instance, ensure that its
-- operating system is configured to perform the required diagnostic tasks.
--
-- For more information about configuring your operating system to generate
-- a crash dump when a kernel panic or stop error occurs, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/diagnostic-interrupt.html Send a diagnostic interrupt (for advanced users)>
-- (Linux instances) or
-- <https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/diagnostic-interrupt.html Send a diagnostic interrupt (for advanced users)>
-- (Windows instances).
module Amazonka.EC2.SendDiagnosticInterrupt
  ( -- * Creating a Request
    SendDiagnosticInterrupt (..),
    newSendDiagnosticInterrupt,

    -- * Request Lenses
    sendDiagnosticInterrupt_dryRun,
    sendDiagnosticInterrupt_instanceId,

    -- * Destructuring the Response
    SendDiagnosticInterruptResponse (..),
    newSendDiagnosticInterruptResponse,
  )
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:/ 'newSendDiagnosticInterrupt' smart constructor.
data SendDiagnosticInterrupt = SendDiagnosticInterrupt'
  { -- | 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@.
    SendDiagnosticInterrupt -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the instance.
    SendDiagnosticInterrupt -> Text
instanceId :: Prelude.Text
  }
  deriving (SendDiagnosticInterrupt -> SendDiagnosticInterrupt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendDiagnosticInterrupt -> SendDiagnosticInterrupt -> Bool
$c/= :: SendDiagnosticInterrupt -> SendDiagnosticInterrupt -> Bool
== :: SendDiagnosticInterrupt -> SendDiagnosticInterrupt -> Bool
$c== :: SendDiagnosticInterrupt -> SendDiagnosticInterrupt -> Bool
Prelude.Eq, ReadPrec [SendDiagnosticInterrupt]
ReadPrec SendDiagnosticInterrupt
Int -> ReadS SendDiagnosticInterrupt
ReadS [SendDiagnosticInterrupt]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendDiagnosticInterrupt]
$creadListPrec :: ReadPrec [SendDiagnosticInterrupt]
readPrec :: ReadPrec SendDiagnosticInterrupt
$creadPrec :: ReadPrec SendDiagnosticInterrupt
readList :: ReadS [SendDiagnosticInterrupt]
$creadList :: ReadS [SendDiagnosticInterrupt]
readsPrec :: Int -> ReadS SendDiagnosticInterrupt
$creadsPrec :: Int -> ReadS SendDiagnosticInterrupt
Prelude.Read, Int -> SendDiagnosticInterrupt -> ShowS
[SendDiagnosticInterrupt] -> ShowS
SendDiagnosticInterrupt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendDiagnosticInterrupt] -> ShowS
$cshowList :: [SendDiagnosticInterrupt] -> ShowS
show :: SendDiagnosticInterrupt -> String
$cshow :: SendDiagnosticInterrupt -> String
showsPrec :: Int -> SendDiagnosticInterrupt -> ShowS
$cshowsPrec :: Int -> SendDiagnosticInterrupt -> ShowS
Prelude.Show, forall x. Rep SendDiagnosticInterrupt x -> SendDiagnosticInterrupt
forall x. SendDiagnosticInterrupt -> Rep SendDiagnosticInterrupt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendDiagnosticInterrupt x -> SendDiagnosticInterrupt
$cfrom :: forall x. SendDiagnosticInterrupt -> Rep SendDiagnosticInterrupt x
Prelude.Generic)

-- |
-- Create a value of 'SendDiagnosticInterrupt' 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', 'sendDiagnosticInterrupt_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@.
--
-- 'instanceId', 'sendDiagnosticInterrupt_instanceId' - The ID of the instance.
newSendDiagnosticInterrupt ::
  -- | 'instanceId'
  Prelude.Text ->
  SendDiagnosticInterrupt
newSendDiagnosticInterrupt :: Text -> SendDiagnosticInterrupt
newSendDiagnosticInterrupt Text
pInstanceId_ =
  SendDiagnosticInterrupt'
    { $sel:dryRun:SendDiagnosticInterrupt' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:SendDiagnosticInterrupt' :: Text
instanceId = Text
pInstanceId_
    }

-- | 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@.
sendDiagnosticInterrupt_dryRun :: Lens.Lens' SendDiagnosticInterrupt (Prelude.Maybe Prelude.Bool)
sendDiagnosticInterrupt_dryRun :: Lens' SendDiagnosticInterrupt (Maybe Bool)
sendDiagnosticInterrupt_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendDiagnosticInterrupt' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:SendDiagnosticInterrupt' :: SendDiagnosticInterrupt -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: SendDiagnosticInterrupt
s@SendDiagnosticInterrupt' {} Maybe Bool
a -> SendDiagnosticInterrupt
s {$sel:dryRun:SendDiagnosticInterrupt' :: Maybe Bool
dryRun = Maybe Bool
a} :: SendDiagnosticInterrupt)

-- | The ID of the instance.
sendDiagnosticInterrupt_instanceId :: Lens.Lens' SendDiagnosticInterrupt Prelude.Text
sendDiagnosticInterrupt_instanceId :: Lens' SendDiagnosticInterrupt Text
sendDiagnosticInterrupt_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendDiagnosticInterrupt' {Text
instanceId :: Text
$sel:instanceId:SendDiagnosticInterrupt' :: SendDiagnosticInterrupt -> Text
instanceId} -> Text
instanceId) (\s :: SendDiagnosticInterrupt
s@SendDiagnosticInterrupt' {} Text
a -> SendDiagnosticInterrupt
s {$sel:instanceId:SendDiagnosticInterrupt' :: Text
instanceId = Text
a} :: SendDiagnosticInterrupt)

instance Core.AWSRequest SendDiagnosticInterrupt where
  type
    AWSResponse SendDiagnosticInterrupt =
      SendDiagnosticInterruptResponse
  request :: (Service -> Service)
-> SendDiagnosticInterrupt -> Request SendDiagnosticInterrupt
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 SendDiagnosticInterrupt
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SendDiagnosticInterrupt)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      SendDiagnosticInterruptResponse
SendDiagnosticInterruptResponse'

instance Prelude.Hashable SendDiagnosticInterrupt where
  hashWithSalt :: Int -> SendDiagnosticInterrupt -> Int
hashWithSalt Int
_salt SendDiagnosticInterrupt' {Maybe Bool
Text
instanceId :: Text
dryRun :: Maybe Bool
$sel:instanceId:SendDiagnosticInterrupt' :: SendDiagnosticInterrupt -> Text
$sel:dryRun:SendDiagnosticInterrupt' :: SendDiagnosticInterrupt -> 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` Text
instanceId

instance Prelude.NFData SendDiagnosticInterrupt where
  rnf :: SendDiagnosticInterrupt -> ()
rnf SendDiagnosticInterrupt' {Maybe Bool
Text
instanceId :: Text
dryRun :: Maybe Bool
$sel:instanceId:SendDiagnosticInterrupt' :: SendDiagnosticInterrupt -> Text
$sel:dryRun:SendDiagnosticInterrupt' :: SendDiagnosticInterrupt -> 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 Text
instanceId

instance Data.ToHeaders SendDiagnosticInterrupt where
  toHeaders :: SendDiagnosticInterrupt -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery SendDiagnosticInterrupt where
  toQuery :: SendDiagnosticInterrupt -> QueryString
toQuery SendDiagnosticInterrupt' {Maybe Bool
Text
instanceId :: Text
dryRun :: Maybe Bool
$sel:instanceId:SendDiagnosticInterrupt' :: SendDiagnosticInterrupt -> Text
$sel:dryRun:SendDiagnosticInterrupt' :: SendDiagnosticInterrupt -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"SendDiagnosticInterrupt" :: 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
"InstanceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
instanceId
      ]

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

-- |
-- Create a value of 'SendDiagnosticInterruptResponse' 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.
newSendDiagnosticInterruptResponse ::
  SendDiagnosticInterruptResponse
newSendDiagnosticInterruptResponse :: SendDiagnosticInterruptResponse
newSendDiagnosticInterruptResponse =
  SendDiagnosticInterruptResponse
SendDiagnosticInterruptResponse'

instance
  Prelude.NFData
    SendDiagnosticInterruptResponse
  where
  rnf :: SendDiagnosticInterruptResponse -> ()
rnf SendDiagnosticInterruptResponse
_ = ()