{-# 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.Snowball.CancelCluster
-- 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 cluster job. You can only cancel a cluster job while it\'s in
-- the @AwaitingQuorum@ status. You\'ll have at least an hour after
-- creating a cluster job to cancel it.
module Amazonka.Snowball.CancelCluster
  ( -- * Creating a Request
    CancelCluster (..),
    newCancelCluster,

    -- * Request Lenses
    cancelCluster_clusterId,

    -- * Destructuring the Response
    CancelClusterResponse (..),
    newCancelClusterResponse,

    -- * Response Lenses
    cancelClusterResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Snowball.Types

-- | /See:/ 'newCancelCluster' smart constructor.
data CancelCluster = CancelCluster'
  { -- | The 39-character ID for the cluster that you want to cancel, for example
    -- @CID123e4567-e89b-12d3-a456-426655440000@.
    CancelCluster -> Text
clusterId :: Prelude.Text
  }
  deriving (CancelCluster -> CancelCluster -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelCluster -> CancelCluster -> Bool
$c/= :: CancelCluster -> CancelCluster -> Bool
== :: CancelCluster -> CancelCluster -> Bool
$c== :: CancelCluster -> CancelCluster -> Bool
Prelude.Eq, ReadPrec [CancelCluster]
ReadPrec CancelCluster
Int -> ReadS CancelCluster
ReadS [CancelCluster]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelCluster]
$creadListPrec :: ReadPrec [CancelCluster]
readPrec :: ReadPrec CancelCluster
$creadPrec :: ReadPrec CancelCluster
readList :: ReadS [CancelCluster]
$creadList :: ReadS [CancelCluster]
readsPrec :: Int -> ReadS CancelCluster
$creadsPrec :: Int -> ReadS CancelCluster
Prelude.Read, Int -> CancelCluster -> ShowS
[CancelCluster] -> ShowS
CancelCluster -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelCluster] -> ShowS
$cshowList :: [CancelCluster] -> ShowS
show :: CancelCluster -> String
$cshow :: CancelCluster -> String
showsPrec :: Int -> CancelCluster -> ShowS
$cshowsPrec :: Int -> CancelCluster -> ShowS
Prelude.Show, forall x. Rep CancelCluster x -> CancelCluster
forall x. CancelCluster -> Rep CancelCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelCluster x -> CancelCluster
$cfrom :: forall x. CancelCluster -> Rep CancelCluster x
Prelude.Generic)

-- |
-- Create a value of 'CancelCluster' 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:
--
-- 'clusterId', 'cancelCluster_clusterId' - The 39-character ID for the cluster that you want to cancel, for example
-- @CID123e4567-e89b-12d3-a456-426655440000@.
newCancelCluster ::
  -- | 'clusterId'
  Prelude.Text ->
  CancelCluster
newCancelCluster :: Text -> CancelCluster
newCancelCluster Text
pClusterId_ =
  CancelCluster' {$sel:clusterId:CancelCluster' :: Text
clusterId = Text
pClusterId_}

-- | The 39-character ID for the cluster that you want to cancel, for example
-- @CID123e4567-e89b-12d3-a456-426655440000@.
cancelCluster_clusterId :: Lens.Lens' CancelCluster Prelude.Text
cancelCluster_clusterId :: Lens' CancelCluster Text
cancelCluster_clusterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelCluster' {Text
clusterId :: Text
$sel:clusterId:CancelCluster' :: CancelCluster -> Text
clusterId} -> Text
clusterId) (\s :: CancelCluster
s@CancelCluster' {} Text
a -> CancelCluster
s {$sel:clusterId:CancelCluster' :: Text
clusterId = Text
a} :: CancelCluster)

instance Core.AWSRequest CancelCluster where
  type
    AWSResponse CancelCluster =
      CancelClusterResponse
  request :: (Service -> Service) -> CancelCluster -> Request CancelCluster
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CancelCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelCluster)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CancelClusterResponse
CancelClusterResponse'
            forall (f :: * -> *) a b. Functor 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 CancelCluster where
  hashWithSalt :: Int -> CancelCluster -> Int
hashWithSalt Int
_salt CancelCluster' {Text
clusterId :: Text
$sel:clusterId:CancelCluster' :: CancelCluster -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterId

instance Prelude.NFData CancelCluster where
  rnf :: CancelCluster -> ()
rnf CancelCluster' {Text
clusterId :: Text
$sel:clusterId:CancelCluster' :: CancelCluster -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
clusterId

instance Data.ToHeaders CancelCluster where
  toHeaders :: CancelCluster -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSIESnowballJobManagementService.CancelCluster" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CancelCluster where
  toJSON :: CancelCluster -> Value
toJSON CancelCluster' {Text
clusterId :: Text
$sel:clusterId:CancelCluster' :: CancelCluster -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ClusterId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clusterId)]
      )

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

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

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

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

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

instance Prelude.NFData CancelClusterResponse where
  rnf :: CancelClusterResponse -> ()
rnf CancelClusterResponse' {Int
httpStatus :: Int
$sel:httpStatus:CancelClusterResponse' :: CancelClusterResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus