{-# 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.CancelDetectMitigationActionsTask
-- 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 Device Defender ML Detect mitigation action.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions CancelDetectMitigationActionsTask>
-- action.
module Amazonka.IoT.CancelDetectMitigationActionsTask
  ( -- * Creating a Request
    CancelDetectMitigationActionsTask (..),
    newCancelDetectMitigationActionsTask,

    -- * Request Lenses
    cancelDetectMitigationActionsTask_taskId,

    -- * Destructuring the Response
    CancelDetectMitigationActionsTaskResponse (..),
    newCancelDetectMitigationActionsTaskResponse,

    -- * Response Lenses
    cancelDetectMitigationActionsTaskResponse_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:/ 'newCancelDetectMitigationActionsTask' smart constructor.
data CancelDetectMitigationActionsTask = CancelDetectMitigationActionsTask'
  { -- | The unique identifier of the task.
    CancelDetectMitigationActionsTask -> Text
taskId :: Prelude.Text
  }
  deriving (CancelDetectMitigationActionsTask
-> CancelDetectMitigationActionsTask -> Bool
(CancelDetectMitigationActionsTask
 -> CancelDetectMitigationActionsTask -> Bool)
-> (CancelDetectMitigationActionsTask
    -> CancelDetectMitigationActionsTask -> Bool)
-> Eq CancelDetectMitigationActionsTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelDetectMitigationActionsTask
-> CancelDetectMitigationActionsTask -> Bool
$c/= :: CancelDetectMitigationActionsTask
-> CancelDetectMitigationActionsTask -> Bool
== :: CancelDetectMitigationActionsTask
-> CancelDetectMitigationActionsTask -> Bool
$c== :: CancelDetectMitigationActionsTask
-> CancelDetectMitigationActionsTask -> Bool
Prelude.Eq, ReadPrec [CancelDetectMitigationActionsTask]
ReadPrec CancelDetectMitigationActionsTask
Int -> ReadS CancelDetectMitigationActionsTask
ReadS [CancelDetectMitigationActionsTask]
(Int -> ReadS CancelDetectMitigationActionsTask)
-> ReadS [CancelDetectMitigationActionsTask]
-> ReadPrec CancelDetectMitigationActionsTask
-> ReadPrec [CancelDetectMitigationActionsTask]
-> Read CancelDetectMitigationActionsTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelDetectMitigationActionsTask]
$creadListPrec :: ReadPrec [CancelDetectMitigationActionsTask]
readPrec :: ReadPrec CancelDetectMitigationActionsTask
$creadPrec :: ReadPrec CancelDetectMitigationActionsTask
readList :: ReadS [CancelDetectMitigationActionsTask]
$creadList :: ReadS [CancelDetectMitigationActionsTask]
readsPrec :: Int -> ReadS CancelDetectMitigationActionsTask
$creadsPrec :: Int -> ReadS CancelDetectMitigationActionsTask
Prelude.Read, Int -> CancelDetectMitigationActionsTask -> ShowS
[CancelDetectMitigationActionsTask] -> ShowS
CancelDetectMitigationActionsTask -> String
(Int -> CancelDetectMitigationActionsTask -> ShowS)
-> (CancelDetectMitigationActionsTask -> String)
-> ([CancelDetectMitigationActionsTask] -> ShowS)
-> Show CancelDetectMitigationActionsTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelDetectMitigationActionsTask] -> ShowS
$cshowList :: [CancelDetectMitigationActionsTask] -> ShowS
show :: CancelDetectMitigationActionsTask -> String
$cshow :: CancelDetectMitigationActionsTask -> String
showsPrec :: Int -> CancelDetectMitigationActionsTask -> ShowS
$cshowsPrec :: Int -> CancelDetectMitigationActionsTask -> ShowS
Prelude.Show, (forall x.
 CancelDetectMitigationActionsTask
 -> Rep CancelDetectMitigationActionsTask x)
-> (forall x.
    Rep CancelDetectMitigationActionsTask x
    -> CancelDetectMitigationActionsTask)
-> Generic CancelDetectMitigationActionsTask
forall x.
Rep CancelDetectMitigationActionsTask x
-> CancelDetectMitigationActionsTask
forall x.
CancelDetectMitigationActionsTask
-> Rep CancelDetectMitigationActionsTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelDetectMitigationActionsTask x
-> CancelDetectMitigationActionsTask
$cfrom :: forall x.
CancelDetectMitigationActionsTask
-> Rep CancelDetectMitigationActionsTask x
Prelude.Generic)

-- |
-- Create a value of 'CancelDetectMitigationActionsTask' 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', 'cancelDetectMitigationActionsTask_taskId' - The unique identifier of the task.
newCancelDetectMitigationActionsTask ::
  -- | 'taskId'
  Prelude.Text ->
  CancelDetectMitigationActionsTask
newCancelDetectMitigationActionsTask :: Text -> CancelDetectMitigationActionsTask
newCancelDetectMitigationActionsTask Text
pTaskId_ =
  CancelDetectMitigationActionsTask' :: Text -> CancelDetectMitigationActionsTask
CancelDetectMitigationActionsTask'
    { $sel:taskId:CancelDetectMitigationActionsTask' :: Text
taskId =
        Text
pTaskId_
    }

-- | The unique identifier of the task.
cancelDetectMitigationActionsTask_taskId :: Lens.Lens' CancelDetectMitigationActionsTask Prelude.Text
cancelDetectMitigationActionsTask_taskId :: (Text -> f Text)
-> CancelDetectMitigationActionsTask
-> f CancelDetectMitigationActionsTask
cancelDetectMitigationActionsTask_taskId = (CancelDetectMitigationActionsTask -> Text)
-> (CancelDetectMitigationActionsTask
    -> Text -> CancelDetectMitigationActionsTask)
-> Lens
     CancelDetectMitigationActionsTask
     CancelDetectMitigationActionsTask
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelDetectMitigationActionsTask' {Text
taskId :: Text
$sel:taskId:CancelDetectMitigationActionsTask' :: CancelDetectMitigationActionsTask -> Text
taskId} -> Text
taskId) (\s :: CancelDetectMitigationActionsTask
s@CancelDetectMitigationActionsTask' {} Text
a -> CancelDetectMitigationActionsTask
s {$sel:taskId:CancelDetectMitigationActionsTask' :: Text
taskId = Text
a} :: CancelDetectMitigationActionsTask)

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

instance
  Prelude.NFData
    CancelDetectMitigationActionsTask

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

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

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

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

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

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

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

instance
  Prelude.NFData
    CancelDetectMitigationActionsTaskResponse