{-# 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.IoT.CancelAuditMitigationActionsTask
-- 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)
--
-- Cancels a mitigation action task that is in progress. If the task is not
-- in progress, an InvalidRequestException occurs.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions CancelAuditMitigationActionsTask>
-- action.
module Amazonka.IoT.CancelAuditMitigationActionsTask
  ( -- * Creating a Request
    CancelAuditMitigationActionsTask (..),
    newCancelAuditMitigationActionsTask,

    -- * Request Lenses
    cancelAuditMitigationActionsTask_taskId,

    -- * Destructuring the Response
    CancelAuditMitigationActionsTaskResponse (..),
    newCancelAuditMitigationActionsTaskResponse,

    -- * Response Lenses
    cancelAuditMitigationActionsTaskResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCancelAuditMitigationActionsTask' smart constructor.
data CancelAuditMitigationActionsTask = CancelAuditMitigationActionsTask'
  { -- | The unique identifier for the task that you want to cancel.
    CancelAuditMitigationActionsTask -> Text
taskId :: Prelude.Text
  }
  deriving (CancelAuditMitigationActionsTask
-> CancelAuditMitigationActionsTask -> Bool
(CancelAuditMitigationActionsTask
 -> CancelAuditMitigationActionsTask -> Bool)
-> (CancelAuditMitigationActionsTask
    -> CancelAuditMitigationActionsTask -> Bool)
-> Eq CancelAuditMitigationActionsTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelAuditMitigationActionsTask
-> CancelAuditMitigationActionsTask -> Bool
$c/= :: CancelAuditMitigationActionsTask
-> CancelAuditMitigationActionsTask -> Bool
== :: CancelAuditMitigationActionsTask
-> CancelAuditMitigationActionsTask -> Bool
$c== :: CancelAuditMitigationActionsTask
-> CancelAuditMitigationActionsTask -> Bool
Prelude.Eq, ReadPrec [CancelAuditMitigationActionsTask]
ReadPrec CancelAuditMitigationActionsTask
Int -> ReadS CancelAuditMitigationActionsTask
ReadS [CancelAuditMitigationActionsTask]
(Int -> ReadS CancelAuditMitigationActionsTask)
-> ReadS [CancelAuditMitigationActionsTask]
-> ReadPrec CancelAuditMitigationActionsTask
-> ReadPrec [CancelAuditMitigationActionsTask]
-> Read CancelAuditMitigationActionsTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelAuditMitigationActionsTask]
$creadListPrec :: ReadPrec [CancelAuditMitigationActionsTask]
readPrec :: ReadPrec CancelAuditMitigationActionsTask
$creadPrec :: ReadPrec CancelAuditMitigationActionsTask
readList :: ReadS [CancelAuditMitigationActionsTask]
$creadList :: ReadS [CancelAuditMitigationActionsTask]
readsPrec :: Int -> ReadS CancelAuditMitigationActionsTask
$creadsPrec :: Int -> ReadS CancelAuditMitigationActionsTask
Prelude.Read, Int -> CancelAuditMitigationActionsTask -> ShowS
[CancelAuditMitigationActionsTask] -> ShowS
CancelAuditMitigationActionsTask -> String
(Int -> CancelAuditMitigationActionsTask -> ShowS)
-> (CancelAuditMitigationActionsTask -> String)
-> ([CancelAuditMitigationActionsTask] -> ShowS)
-> Show CancelAuditMitigationActionsTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelAuditMitigationActionsTask] -> ShowS
$cshowList :: [CancelAuditMitigationActionsTask] -> ShowS
show :: CancelAuditMitigationActionsTask -> String
$cshow :: CancelAuditMitigationActionsTask -> String
showsPrec :: Int -> CancelAuditMitigationActionsTask -> ShowS
$cshowsPrec :: Int -> CancelAuditMitigationActionsTask -> ShowS
Prelude.Show, (forall x.
 CancelAuditMitigationActionsTask
 -> Rep CancelAuditMitigationActionsTask x)
-> (forall x.
    Rep CancelAuditMitigationActionsTask x
    -> CancelAuditMitigationActionsTask)
-> Generic CancelAuditMitigationActionsTask
forall x.
Rep CancelAuditMitigationActionsTask x
-> CancelAuditMitigationActionsTask
forall x.
CancelAuditMitigationActionsTask
-> Rep CancelAuditMitigationActionsTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelAuditMitigationActionsTask x
-> CancelAuditMitigationActionsTask
$cfrom :: forall x.
CancelAuditMitigationActionsTask
-> Rep CancelAuditMitigationActionsTask x
Prelude.Generic)

-- |
-- Create a value of 'CancelAuditMitigationActionsTask' 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:
--
-- 'taskId', 'cancelAuditMitigationActionsTask_taskId' - The unique identifier for the task that you want to cancel.
newCancelAuditMitigationActionsTask ::
  -- | 'taskId'
  Prelude.Text ->
  CancelAuditMitigationActionsTask
newCancelAuditMitigationActionsTask :: Text -> CancelAuditMitigationActionsTask
newCancelAuditMitigationActionsTask Text
pTaskId_ =
  CancelAuditMitigationActionsTask' :: Text -> CancelAuditMitigationActionsTask
CancelAuditMitigationActionsTask'
    { $sel:taskId:CancelAuditMitigationActionsTask' :: Text
taskId =
        Text
pTaskId_
    }

-- | The unique identifier for the task that you want to cancel.
cancelAuditMitigationActionsTask_taskId :: Lens.Lens' CancelAuditMitigationActionsTask Prelude.Text
cancelAuditMitigationActionsTask_taskId :: (Text -> f Text)
-> CancelAuditMitigationActionsTask
-> f CancelAuditMitigationActionsTask
cancelAuditMitigationActionsTask_taskId = (CancelAuditMitigationActionsTask -> Text)
-> (CancelAuditMitigationActionsTask
    -> Text -> CancelAuditMitigationActionsTask)
-> Lens
     CancelAuditMitigationActionsTask
     CancelAuditMitigationActionsTask
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelAuditMitigationActionsTask' {Text
taskId :: Text
$sel:taskId:CancelAuditMitigationActionsTask' :: CancelAuditMitigationActionsTask -> Text
taskId} -> Text
taskId) (\s :: CancelAuditMitigationActionsTask
s@CancelAuditMitigationActionsTask' {} Text
a -> CancelAuditMitigationActionsTask
s {$sel:taskId:CancelAuditMitigationActionsTask' :: Text
taskId = Text
a} :: CancelAuditMitigationActionsTask)

instance
  Core.AWSRequest
    CancelAuditMitigationActionsTask
  where
  type
    AWSResponse CancelAuditMitigationActionsTask =
      CancelAuditMitigationActionsTaskResponse
  request :: CancelAuditMitigationActionsTask
-> Request CancelAuditMitigationActionsTask
request = Service
-> CancelAuditMitigationActionsTask
-> Request CancelAuditMitigationActionsTask
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelAuditMitigationActionsTask
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse CancelAuditMitigationActionsTask)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CancelAuditMitigationActionsTask))
-> Logger
-> Service
-> Proxy CancelAuditMitigationActionsTask
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse CancelAuditMitigationActionsTask)))
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 -> CancelAuditMitigationActionsTaskResponse
CancelAuditMitigationActionsTaskResponse'
            (Int -> CancelAuditMitigationActionsTaskResponse)
-> Either String Int
-> Either String CancelAuditMitigationActionsTaskResponse
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
    CancelAuditMitigationActionsTask

instance
  Prelude.NFData
    CancelAuditMitigationActionsTask

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

instance Core.ToJSON CancelAuditMitigationActionsTask where
  toJSON :: CancelAuditMitigationActionsTask -> Value
toJSON = Value -> CancelAuditMitigationActionsTask -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath CancelAuditMitigationActionsTask where
  toPath :: CancelAuditMitigationActionsTask -> ByteString
toPath CancelAuditMitigationActionsTask' {Text
taskId :: Text
$sel:taskId:CancelAuditMitigationActionsTask' :: CancelAuditMitigationActionsTask -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/audit/mitigationactions/tasks/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
taskId,
        ByteString
"/cancel"
      ]

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

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

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

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

instance
  Prelude.NFData
    CancelAuditMitigationActionsTaskResponse