{-# 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.DeleteOTAUpdate
-- 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)
--
-- Delete an OTA update.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DeleteOTAUpdate>
-- action.
module Amazonka.IoT.DeleteOTAUpdate
  ( -- * Creating a Request
    DeleteOTAUpdate (..),
    newDeleteOTAUpdate,

    -- * Request Lenses
    deleteOTAUpdate_forceDeleteAWSJob,
    deleteOTAUpdate_deleteStream,
    deleteOTAUpdate_otaUpdateId,

    -- * Destructuring the Response
    DeleteOTAUpdateResponse (..),
    newDeleteOTAUpdateResponse,

    -- * Response Lenses
    deleteOTAUpdateResponse_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:/ 'newDeleteOTAUpdate' smart constructor.
data DeleteOTAUpdate = DeleteOTAUpdate'
  { -- | When true, deletes the IoT job created by the OTAUpdate process even if
    -- it is \"IN_PROGRESS\". Otherwise, if the job is not in a terminal state
    -- (\"COMPLETED\" or \"CANCELED\") an exception will occur. The default is
    -- false.
    DeleteOTAUpdate -> Maybe Bool
forceDeleteAWSJob :: Prelude.Maybe Prelude.Bool,
    -- | When true, the stream created by the OTAUpdate process is deleted when
    -- the OTA update is deleted. Ignored if the stream specified in the
    -- OTAUpdate is supplied by the user.
    DeleteOTAUpdate -> Maybe Bool
deleteStream :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the OTA update to delete.
    DeleteOTAUpdate -> Text
otaUpdateId :: Prelude.Text
  }
  deriving (DeleteOTAUpdate -> DeleteOTAUpdate -> Bool
(DeleteOTAUpdate -> DeleteOTAUpdate -> Bool)
-> (DeleteOTAUpdate -> DeleteOTAUpdate -> Bool)
-> Eq DeleteOTAUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteOTAUpdate -> DeleteOTAUpdate -> Bool
$c/= :: DeleteOTAUpdate -> DeleteOTAUpdate -> Bool
== :: DeleteOTAUpdate -> DeleteOTAUpdate -> Bool
$c== :: DeleteOTAUpdate -> DeleteOTAUpdate -> Bool
Prelude.Eq, ReadPrec [DeleteOTAUpdate]
ReadPrec DeleteOTAUpdate
Int -> ReadS DeleteOTAUpdate
ReadS [DeleteOTAUpdate]
(Int -> ReadS DeleteOTAUpdate)
-> ReadS [DeleteOTAUpdate]
-> ReadPrec DeleteOTAUpdate
-> ReadPrec [DeleteOTAUpdate]
-> Read DeleteOTAUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteOTAUpdate]
$creadListPrec :: ReadPrec [DeleteOTAUpdate]
readPrec :: ReadPrec DeleteOTAUpdate
$creadPrec :: ReadPrec DeleteOTAUpdate
readList :: ReadS [DeleteOTAUpdate]
$creadList :: ReadS [DeleteOTAUpdate]
readsPrec :: Int -> ReadS DeleteOTAUpdate
$creadsPrec :: Int -> ReadS DeleteOTAUpdate
Prelude.Read, Int -> DeleteOTAUpdate -> ShowS
[DeleteOTAUpdate] -> ShowS
DeleteOTAUpdate -> String
(Int -> DeleteOTAUpdate -> ShowS)
-> (DeleteOTAUpdate -> String)
-> ([DeleteOTAUpdate] -> ShowS)
-> Show DeleteOTAUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteOTAUpdate] -> ShowS
$cshowList :: [DeleteOTAUpdate] -> ShowS
show :: DeleteOTAUpdate -> String
$cshow :: DeleteOTAUpdate -> String
showsPrec :: Int -> DeleteOTAUpdate -> ShowS
$cshowsPrec :: Int -> DeleteOTAUpdate -> ShowS
Prelude.Show, (forall x. DeleteOTAUpdate -> Rep DeleteOTAUpdate x)
-> (forall x. Rep DeleteOTAUpdate x -> DeleteOTAUpdate)
-> Generic DeleteOTAUpdate
forall x. Rep DeleteOTAUpdate x -> DeleteOTAUpdate
forall x. DeleteOTAUpdate -> Rep DeleteOTAUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteOTAUpdate x -> DeleteOTAUpdate
$cfrom :: forall x. DeleteOTAUpdate -> Rep DeleteOTAUpdate x
Prelude.Generic)

-- |
-- Create a value of 'DeleteOTAUpdate' 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:
--
-- 'forceDeleteAWSJob', 'deleteOTAUpdate_forceDeleteAWSJob' - When true, deletes the IoT job created by the OTAUpdate process even if
-- it is \"IN_PROGRESS\". Otherwise, if the job is not in a terminal state
-- (\"COMPLETED\" or \"CANCELED\") an exception will occur. The default is
-- false.
--
-- 'deleteStream', 'deleteOTAUpdate_deleteStream' - When true, the stream created by the OTAUpdate process is deleted when
-- the OTA update is deleted. Ignored if the stream specified in the
-- OTAUpdate is supplied by the user.
--
-- 'otaUpdateId', 'deleteOTAUpdate_otaUpdateId' - The ID of the OTA update to delete.
newDeleteOTAUpdate ::
  -- | 'otaUpdateId'
  Prelude.Text ->
  DeleteOTAUpdate
newDeleteOTAUpdate :: Text -> DeleteOTAUpdate
newDeleteOTAUpdate Text
pOtaUpdateId_ =
  DeleteOTAUpdate' :: Maybe Bool -> Maybe Bool -> Text -> DeleteOTAUpdate
DeleteOTAUpdate'
    { $sel:forceDeleteAWSJob:DeleteOTAUpdate' :: Maybe Bool
forceDeleteAWSJob =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:deleteStream:DeleteOTAUpdate' :: Maybe Bool
deleteStream = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:otaUpdateId:DeleteOTAUpdate' :: Text
otaUpdateId = Text
pOtaUpdateId_
    }

-- | When true, deletes the IoT job created by the OTAUpdate process even if
-- it is \"IN_PROGRESS\". Otherwise, if the job is not in a terminal state
-- (\"COMPLETED\" or \"CANCELED\") an exception will occur. The default is
-- false.
deleteOTAUpdate_forceDeleteAWSJob :: Lens.Lens' DeleteOTAUpdate (Prelude.Maybe Prelude.Bool)
deleteOTAUpdate_forceDeleteAWSJob :: (Maybe Bool -> f (Maybe Bool))
-> DeleteOTAUpdate -> f DeleteOTAUpdate
deleteOTAUpdate_forceDeleteAWSJob = (DeleteOTAUpdate -> Maybe Bool)
-> (DeleteOTAUpdate -> Maybe Bool -> DeleteOTAUpdate)
-> Lens DeleteOTAUpdate DeleteOTAUpdate (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteOTAUpdate' {Maybe Bool
forceDeleteAWSJob :: Maybe Bool
$sel:forceDeleteAWSJob:DeleteOTAUpdate' :: DeleteOTAUpdate -> Maybe Bool
forceDeleteAWSJob} -> Maybe Bool
forceDeleteAWSJob) (\s :: DeleteOTAUpdate
s@DeleteOTAUpdate' {} Maybe Bool
a -> DeleteOTAUpdate
s {$sel:forceDeleteAWSJob:DeleteOTAUpdate' :: Maybe Bool
forceDeleteAWSJob = Maybe Bool
a} :: DeleteOTAUpdate)

-- | When true, the stream created by the OTAUpdate process is deleted when
-- the OTA update is deleted. Ignored if the stream specified in the
-- OTAUpdate is supplied by the user.
deleteOTAUpdate_deleteStream :: Lens.Lens' DeleteOTAUpdate (Prelude.Maybe Prelude.Bool)
deleteOTAUpdate_deleteStream :: (Maybe Bool -> f (Maybe Bool))
-> DeleteOTAUpdate -> f DeleteOTAUpdate
deleteOTAUpdate_deleteStream = (DeleteOTAUpdate -> Maybe Bool)
-> (DeleteOTAUpdate -> Maybe Bool -> DeleteOTAUpdate)
-> Lens DeleteOTAUpdate DeleteOTAUpdate (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteOTAUpdate' {Maybe Bool
deleteStream :: Maybe Bool
$sel:deleteStream:DeleteOTAUpdate' :: DeleteOTAUpdate -> Maybe Bool
deleteStream} -> Maybe Bool
deleteStream) (\s :: DeleteOTAUpdate
s@DeleteOTAUpdate' {} Maybe Bool
a -> DeleteOTAUpdate
s {$sel:deleteStream:DeleteOTAUpdate' :: Maybe Bool
deleteStream = Maybe Bool
a} :: DeleteOTAUpdate)

-- | The ID of the OTA update to delete.
deleteOTAUpdate_otaUpdateId :: Lens.Lens' DeleteOTAUpdate Prelude.Text
deleteOTAUpdate_otaUpdateId :: (Text -> f Text) -> DeleteOTAUpdate -> f DeleteOTAUpdate
deleteOTAUpdate_otaUpdateId = (DeleteOTAUpdate -> Text)
-> (DeleteOTAUpdate -> Text -> DeleteOTAUpdate)
-> Lens DeleteOTAUpdate DeleteOTAUpdate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteOTAUpdate' {Text
otaUpdateId :: Text
$sel:otaUpdateId:DeleteOTAUpdate' :: DeleteOTAUpdate -> Text
otaUpdateId} -> Text
otaUpdateId) (\s :: DeleteOTAUpdate
s@DeleteOTAUpdate' {} Text
a -> DeleteOTAUpdate
s {$sel:otaUpdateId:DeleteOTAUpdate' :: Text
otaUpdateId = Text
a} :: DeleteOTAUpdate)

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

instance Prelude.NFData DeleteOTAUpdate

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

instance Core.ToPath DeleteOTAUpdate where
  toPath :: DeleteOTAUpdate -> ByteString
toPath DeleteOTAUpdate' {Maybe Bool
Text
otaUpdateId :: Text
deleteStream :: Maybe Bool
forceDeleteAWSJob :: Maybe Bool
$sel:otaUpdateId:DeleteOTAUpdate' :: DeleteOTAUpdate -> Text
$sel:deleteStream:DeleteOTAUpdate' :: DeleteOTAUpdate -> Maybe Bool
$sel:forceDeleteAWSJob:DeleteOTAUpdate' :: DeleteOTAUpdate -> Maybe Bool
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/otaUpdates/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
otaUpdateId]

instance Core.ToQuery DeleteOTAUpdate where
  toQuery :: DeleteOTAUpdate -> QueryString
toQuery DeleteOTAUpdate' {Maybe Bool
Text
otaUpdateId :: Text
deleteStream :: Maybe Bool
forceDeleteAWSJob :: Maybe Bool
$sel:otaUpdateId:DeleteOTAUpdate' :: DeleteOTAUpdate -> Text
$sel:deleteStream:DeleteOTAUpdate' :: DeleteOTAUpdate -> Maybe Bool
$sel:forceDeleteAWSJob:DeleteOTAUpdate' :: DeleteOTAUpdate -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"forceDeleteAWSJob" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
forceDeleteAWSJob,
        ByteString
"deleteStream" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
deleteStream
      ]

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

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

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

instance Prelude.NFData DeleteOTAUpdateResponse