{-# 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.CancelAuditTask
-- 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 an audit that is in progress. The audit can be either scheduled
-- or on demand. If the audit isn\'t 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 CancelAuditTask>
-- action.
module Amazonka.IoT.CancelAuditTask
  ( -- * Creating a Request
    CancelAuditTask (..),
    newCancelAuditTask,

    -- * Request Lenses
    cancelAuditTask_taskId,

    -- * Destructuring the Response
    CancelAuditTaskResponse (..),
    newCancelAuditTaskResponse,

    -- * Response Lenses
    cancelAuditTaskResponse_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:/ 'newCancelAuditTask' smart constructor.
data CancelAuditTask = CancelAuditTask'
  { -- | The ID of the audit you want to cancel. You can only cancel an audit
    -- that is \"IN_PROGRESS\".
    CancelAuditTask -> Text
taskId :: Prelude.Text
  }
  deriving (CancelAuditTask -> CancelAuditTask -> Bool
(CancelAuditTask -> CancelAuditTask -> Bool)
-> (CancelAuditTask -> CancelAuditTask -> Bool)
-> Eq CancelAuditTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelAuditTask -> CancelAuditTask -> Bool
$c/= :: CancelAuditTask -> CancelAuditTask -> Bool
== :: CancelAuditTask -> CancelAuditTask -> Bool
$c== :: CancelAuditTask -> CancelAuditTask -> Bool
Prelude.Eq, ReadPrec [CancelAuditTask]
ReadPrec CancelAuditTask
Int -> ReadS CancelAuditTask
ReadS [CancelAuditTask]
(Int -> ReadS CancelAuditTask)
-> ReadS [CancelAuditTask]
-> ReadPrec CancelAuditTask
-> ReadPrec [CancelAuditTask]
-> Read CancelAuditTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelAuditTask]
$creadListPrec :: ReadPrec [CancelAuditTask]
readPrec :: ReadPrec CancelAuditTask
$creadPrec :: ReadPrec CancelAuditTask
readList :: ReadS [CancelAuditTask]
$creadList :: ReadS [CancelAuditTask]
readsPrec :: Int -> ReadS CancelAuditTask
$creadsPrec :: Int -> ReadS CancelAuditTask
Prelude.Read, Int -> CancelAuditTask -> ShowS
[CancelAuditTask] -> ShowS
CancelAuditTask -> String
(Int -> CancelAuditTask -> ShowS)
-> (CancelAuditTask -> String)
-> ([CancelAuditTask] -> ShowS)
-> Show CancelAuditTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelAuditTask] -> ShowS
$cshowList :: [CancelAuditTask] -> ShowS
show :: CancelAuditTask -> String
$cshow :: CancelAuditTask -> String
showsPrec :: Int -> CancelAuditTask -> ShowS
$cshowsPrec :: Int -> CancelAuditTask -> ShowS
Prelude.Show, (forall x. CancelAuditTask -> Rep CancelAuditTask x)
-> (forall x. Rep CancelAuditTask x -> CancelAuditTask)
-> Generic CancelAuditTask
forall x. Rep CancelAuditTask x -> CancelAuditTask
forall x. CancelAuditTask -> Rep CancelAuditTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelAuditTask x -> CancelAuditTask
$cfrom :: forall x. CancelAuditTask -> Rep CancelAuditTask x
Prelude.Generic)

-- |
-- Create a value of 'CancelAuditTask' 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', 'cancelAuditTask_taskId' - The ID of the audit you want to cancel. You can only cancel an audit
-- that is \"IN_PROGRESS\".
newCancelAuditTask ::
  -- | 'taskId'
  Prelude.Text ->
  CancelAuditTask
newCancelAuditTask :: Text -> CancelAuditTask
newCancelAuditTask Text
pTaskId_ =
  CancelAuditTask' :: Text -> CancelAuditTask
CancelAuditTask' {$sel:taskId:CancelAuditTask' :: Text
taskId = Text
pTaskId_}

-- | The ID of the audit you want to cancel. You can only cancel an audit
-- that is \"IN_PROGRESS\".
cancelAuditTask_taskId :: Lens.Lens' CancelAuditTask Prelude.Text
cancelAuditTask_taskId :: (Text -> f Text) -> CancelAuditTask -> f CancelAuditTask
cancelAuditTask_taskId = (CancelAuditTask -> Text)
-> (CancelAuditTask -> Text -> CancelAuditTask)
-> Lens CancelAuditTask CancelAuditTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelAuditTask' {Text
taskId :: Text
$sel:taskId:CancelAuditTask' :: CancelAuditTask -> Text
taskId} -> Text
taskId) (\s :: CancelAuditTask
s@CancelAuditTask' {} Text
a -> CancelAuditTask
s {$sel:taskId:CancelAuditTask' :: Text
taskId = Text
a} :: CancelAuditTask)

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

instance Prelude.NFData CancelAuditTask

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

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

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

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

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

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

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

instance Prelude.NFData CancelAuditTaskResponse