{-# 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.CancelBundleTask
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Cancels a bundling operation for an instance store-backed Windows
-- instance.
module Amazonka.EC2.CancelBundleTask
  ( -- * Creating a Request
    CancelBundleTask (..),
    newCancelBundleTask,

    -- * Request Lenses
    cancelBundleTask_dryRun,
    cancelBundleTask_bundleId,

    -- * Destructuring the Response
    CancelBundleTaskResponse (..),
    newCancelBundleTaskResponse,

    -- * Response Lenses
    cancelBundleTaskResponse_bundleTask,
    cancelBundleTaskResponse_httpStatus,
  )
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

-- | Contains the parameters for CancelBundleTask.
--
-- /See:/ 'newCancelBundleTask' smart constructor.
data CancelBundleTask = CancelBundleTask'
  { -- | 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@.
    CancelBundleTask -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the bundle task.
    CancelBundleTask -> Text
bundleId :: Prelude.Text
  }
  deriving (CancelBundleTask -> CancelBundleTask -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelBundleTask -> CancelBundleTask -> Bool
$c/= :: CancelBundleTask -> CancelBundleTask -> Bool
== :: CancelBundleTask -> CancelBundleTask -> Bool
$c== :: CancelBundleTask -> CancelBundleTask -> Bool
Prelude.Eq, ReadPrec [CancelBundleTask]
ReadPrec CancelBundleTask
Int -> ReadS CancelBundleTask
ReadS [CancelBundleTask]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelBundleTask]
$creadListPrec :: ReadPrec [CancelBundleTask]
readPrec :: ReadPrec CancelBundleTask
$creadPrec :: ReadPrec CancelBundleTask
readList :: ReadS [CancelBundleTask]
$creadList :: ReadS [CancelBundleTask]
readsPrec :: Int -> ReadS CancelBundleTask
$creadsPrec :: Int -> ReadS CancelBundleTask
Prelude.Read, Int -> CancelBundleTask -> ShowS
[CancelBundleTask] -> ShowS
CancelBundleTask -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelBundleTask] -> ShowS
$cshowList :: [CancelBundleTask] -> ShowS
show :: CancelBundleTask -> String
$cshow :: CancelBundleTask -> String
showsPrec :: Int -> CancelBundleTask -> ShowS
$cshowsPrec :: Int -> CancelBundleTask -> ShowS
Prelude.Show, forall x. Rep CancelBundleTask x -> CancelBundleTask
forall x. CancelBundleTask -> Rep CancelBundleTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelBundleTask x -> CancelBundleTask
$cfrom :: forall x. CancelBundleTask -> Rep CancelBundleTask x
Prelude.Generic)

-- |
-- Create a value of 'CancelBundleTask' 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', 'cancelBundleTask_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@.
--
-- 'bundleId', 'cancelBundleTask_bundleId' - The ID of the bundle task.
newCancelBundleTask ::
  -- | 'bundleId'
  Prelude.Text ->
  CancelBundleTask
newCancelBundleTask :: Text -> CancelBundleTask
newCancelBundleTask Text
pBundleId_ =
  CancelBundleTask'
    { $sel:dryRun:CancelBundleTask' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:bundleId:CancelBundleTask' :: Text
bundleId = Text
pBundleId_
    }

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

-- | The ID of the bundle task.
cancelBundleTask_bundleId :: Lens.Lens' CancelBundleTask Prelude.Text
cancelBundleTask_bundleId :: Lens' CancelBundleTask Text
cancelBundleTask_bundleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelBundleTask' {Text
bundleId :: Text
$sel:bundleId:CancelBundleTask' :: CancelBundleTask -> Text
bundleId} -> Text
bundleId) (\s :: CancelBundleTask
s@CancelBundleTask' {} Text
a -> CancelBundleTask
s {$sel:bundleId:CancelBundleTask' :: Text
bundleId = Text
a} :: CancelBundleTask)

instance Core.AWSRequest CancelBundleTask where
  type
    AWSResponse CancelBundleTask =
      CancelBundleTaskResponse
  request :: (Service -> Service)
-> CancelBundleTask -> Request CancelBundleTask
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 CancelBundleTask
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelBundleTask)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe BundleTask -> Int -> CancelBundleTaskResponse
CancelBundleTaskResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"bundleInstanceTask")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

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

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

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

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

-- | Contains the output of CancelBundleTask.
--
-- /See:/ 'newCancelBundleTaskResponse' smart constructor.
data CancelBundleTaskResponse = CancelBundleTaskResponse'
  { -- | Information about the bundle task.
    CancelBundleTaskResponse -> Maybe BundleTask
bundleTask :: Prelude.Maybe BundleTask,
    -- | The response's http status code.
    CancelBundleTaskResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CancelBundleTaskResponse -> CancelBundleTaskResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelBundleTaskResponse -> CancelBundleTaskResponse -> Bool
$c/= :: CancelBundleTaskResponse -> CancelBundleTaskResponse -> Bool
== :: CancelBundleTaskResponse -> CancelBundleTaskResponse -> Bool
$c== :: CancelBundleTaskResponse -> CancelBundleTaskResponse -> Bool
Prelude.Eq, ReadPrec [CancelBundleTaskResponse]
ReadPrec CancelBundleTaskResponse
Int -> ReadS CancelBundleTaskResponse
ReadS [CancelBundleTaskResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelBundleTaskResponse]
$creadListPrec :: ReadPrec [CancelBundleTaskResponse]
readPrec :: ReadPrec CancelBundleTaskResponse
$creadPrec :: ReadPrec CancelBundleTaskResponse
readList :: ReadS [CancelBundleTaskResponse]
$creadList :: ReadS [CancelBundleTaskResponse]
readsPrec :: Int -> ReadS CancelBundleTaskResponse
$creadsPrec :: Int -> ReadS CancelBundleTaskResponse
Prelude.Read, Int -> CancelBundleTaskResponse -> ShowS
[CancelBundleTaskResponse] -> ShowS
CancelBundleTaskResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelBundleTaskResponse] -> ShowS
$cshowList :: [CancelBundleTaskResponse] -> ShowS
show :: CancelBundleTaskResponse -> String
$cshow :: CancelBundleTaskResponse -> String
showsPrec :: Int -> CancelBundleTaskResponse -> ShowS
$cshowsPrec :: Int -> CancelBundleTaskResponse -> ShowS
Prelude.Show, forall x.
Rep CancelBundleTaskResponse x -> CancelBundleTaskResponse
forall x.
CancelBundleTaskResponse -> Rep CancelBundleTaskResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelBundleTaskResponse x -> CancelBundleTaskResponse
$cfrom :: forall x.
CancelBundleTaskResponse -> Rep CancelBundleTaskResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelBundleTaskResponse' 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:
--
-- 'bundleTask', 'cancelBundleTaskResponse_bundleTask' - Information about the bundle task.
--
-- 'httpStatus', 'cancelBundleTaskResponse_httpStatus' - The response's http status code.
newCancelBundleTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelBundleTaskResponse
newCancelBundleTaskResponse :: Int -> CancelBundleTaskResponse
newCancelBundleTaskResponse Int
pHttpStatus_ =
  CancelBundleTaskResponse'
    { $sel:bundleTask:CancelBundleTaskResponse' :: Maybe BundleTask
bundleTask =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CancelBundleTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the bundle task.
cancelBundleTaskResponse_bundleTask :: Lens.Lens' CancelBundleTaskResponse (Prelude.Maybe BundleTask)
cancelBundleTaskResponse_bundleTask :: Lens' CancelBundleTaskResponse (Maybe BundleTask)
cancelBundleTaskResponse_bundleTask = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelBundleTaskResponse' {Maybe BundleTask
bundleTask :: Maybe BundleTask
$sel:bundleTask:CancelBundleTaskResponse' :: CancelBundleTaskResponse -> Maybe BundleTask
bundleTask} -> Maybe BundleTask
bundleTask) (\s :: CancelBundleTaskResponse
s@CancelBundleTaskResponse' {} Maybe BundleTask
a -> CancelBundleTaskResponse
s {$sel:bundleTask:CancelBundleTaskResponse' :: Maybe BundleTask
bundleTask = Maybe BundleTask
a} :: CancelBundleTaskResponse)

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

instance Prelude.NFData CancelBundleTaskResponse where
  rnf :: CancelBundleTaskResponse -> ()
rnf CancelBundleTaskResponse' {Int
Maybe BundleTask
httpStatus :: Int
bundleTask :: Maybe BundleTask
$sel:httpStatus:CancelBundleTaskResponse' :: CancelBundleTaskResponse -> Int
$sel:bundleTask:CancelBundleTaskResponse' :: CancelBundleTaskResponse -> Maybe BundleTask
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BundleTask
bundleTask
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus