{-# 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-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 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.Lens as Lens
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
(CancelCluster -> CancelCluster -> Bool)
-> (CancelCluster -> CancelCluster -> Bool) -> Eq CancelCluster
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]
(Int -> ReadS CancelCluster)
-> ReadS [CancelCluster]
-> ReadPrec CancelCluster
-> ReadPrec [CancelCluster]
-> Read 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
(Int -> CancelCluster -> ShowS)
-> (CancelCluster -> String)
-> ([CancelCluster] -> ShowS)
-> Show CancelCluster
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. CancelCluster -> Rep CancelCluster x)
-> (forall x. Rep CancelCluster x -> CancelCluster)
-> Generic CancelCluster
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' :: Text -> CancelCluster
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 :: (Text -> f Text) -> CancelCluster -> f CancelCluster
cancelCluster_clusterId = (CancelCluster -> Text)
-> (CancelCluster -> Text -> CancelCluster)
-> Lens CancelCluster CancelCluster Text Text
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 :: CancelCluster -> Request CancelCluster
request = Service -> CancelCluster -> Request CancelCluster
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelCluster)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CancelCluster))
-> Logger
-> Service
-> Proxy CancelCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelCluster)))
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 -> CancelClusterResponse
CancelClusterResponse'
            (Int -> CancelClusterResponse)
-> Either String Int -> Either String CancelClusterResponse
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 CancelCluster

instance Prelude.NFData CancelCluster

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

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

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

instance Core.ToQuery CancelCluster where
  toQuery :: CancelCluster -> QueryString
toQuery = QueryString -> CancelCluster -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(CancelClusterResponse -> CancelClusterResponse -> Bool)
-> (CancelClusterResponse -> CancelClusterResponse -> Bool)
-> Eq CancelClusterResponse
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]
(Int -> ReadS CancelClusterResponse)
-> ReadS [CancelClusterResponse]
-> ReadPrec CancelClusterResponse
-> ReadPrec [CancelClusterResponse]
-> Read 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
(Int -> CancelClusterResponse -> ShowS)
-> (CancelClusterResponse -> String)
-> ([CancelClusterResponse] -> ShowS)
-> Show CancelClusterResponse
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. CancelClusterResponse -> Rep CancelClusterResponse x)
-> (forall x. Rep CancelClusterResponse x -> CancelClusterResponse)
-> Generic CancelClusterResponse
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' :: Int -> CancelClusterResponse
CancelClusterResponse' {$sel:httpStatus:CancelClusterResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
cancelClusterResponse_httpStatus :: Lens.Lens' CancelClusterResponse Prelude.Int
cancelClusterResponse_httpStatus :: (Int -> f Int) -> CancelClusterResponse -> f CancelClusterResponse
cancelClusterResponse_httpStatus = (CancelClusterResponse -> Int)
-> (CancelClusterResponse -> Int -> CancelClusterResponse)
-> Lens CancelClusterResponse CancelClusterResponse Int Int
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