{-# 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.Braket.CancelQuantumTask
-- 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 the specified task.
module Amazonka.Braket.CancelQuantumTask
  ( -- * Creating a Request
    CancelQuantumTask (..),
    newCancelQuantumTask,

    -- * Request Lenses
    cancelQuantumTask_clientToken,
    cancelQuantumTask_quantumTaskArn,

    -- * Destructuring the Response
    CancelQuantumTaskResponse (..),
    newCancelQuantumTaskResponse,

    -- * Response Lenses
    cancelQuantumTaskResponse_httpStatus,
    cancelQuantumTaskResponse_cancellationStatus,
    cancelQuantumTaskResponse_quantumTaskArn,
  )
where

import Amazonka.Braket.Types
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

-- | /See:/ 'newCancelQuantumTask' smart constructor.
data CancelQuantumTask = CancelQuantumTask'
  { -- | The client token associated with the request.
    CancelQuantumTask -> Text
clientToken :: Prelude.Text,
    -- | The ARN of the task to cancel.
    CancelQuantumTask -> Text
quantumTaskArn :: Prelude.Text
  }
  deriving (CancelQuantumTask -> CancelQuantumTask -> Bool
(CancelQuantumTask -> CancelQuantumTask -> Bool)
-> (CancelQuantumTask -> CancelQuantumTask -> Bool)
-> Eq CancelQuantumTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelQuantumTask -> CancelQuantumTask -> Bool
$c/= :: CancelQuantumTask -> CancelQuantumTask -> Bool
== :: CancelQuantumTask -> CancelQuantumTask -> Bool
$c== :: CancelQuantumTask -> CancelQuantumTask -> Bool
Prelude.Eq, ReadPrec [CancelQuantumTask]
ReadPrec CancelQuantumTask
Int -> ReadS CancelQuantumTask
ReadS [CancelQuantumTask]
(Int -> ReadS CancelQuantumTask)
-> ReadS [CancelQuantumTask]
-> ReadPrec CancelQuantumTask
-> ReadPrec [CancelQuantumTask]
-> Read CancelQuantumTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelQuantumTask]
$creadListPrec :: ReadPrec [CancelQuantumTask]
readPrec :: ReadPrec CancelQuantumTask
$creadPrec :: ReadPrec CancelQuantumTask
readList :: ReadS [CancelQuantumTask]
$creadList :: ReadS [CancelQuantumTask]
readsPrec :: Int -> ReadS CancelQuantumTask
$creadsPrec :: Int -> ReadS CancelQuantumTask
Prelude.Read, Int -> CancelQuantumTask -> ShowS
[CancelQuantumTask] -> ShowS
CancelQuantumTask -> String
(Int -> CancelQuantumTask -> ShowS)
-> (CancelQuantumTask -> String)
-> ([CancelQuantumTask] -> ShowS)
-> Show CancelQuantumTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelQuantumTask] -> ShowS
$cshowList :: [CancelQuantumTask] -> ShowS
show :: CancelQuantumTask -> String
$cshow :: CancelQuantumTask -> String
showsPrec :: Int -> CancelQuantumTask -> ShowS
$cshowsPrec :: Int -> CancelQuantumTask -> ShowS
Prelude.Show, (forall x. CancelQuantumTask -> Rep CancelQuantumTask x)
-> (forall x. Rep CancelQuantumTask x -> CancelQuantumTask)
-> Generic CancelQuantumTask
forall x. Rep CancelQuantumTask x -> CancelQuantumTask
forall x. CancelQuantumTask -> Rep CancelQuantumTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelQuantumTask x -> CancelQuantumTask
$cfrom :: forall x. CancelQuantumTask -> Rep CancelQuantumTask x
Prelude.Generic)

-- |
-- Create a value of 'CancelQuantumTask' 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:
--
-- 'clientToken', 'cancelQuantumTask_clientToken' - The client token associated with the request.
--
-- 'quantumTaskArn', 'cancelQuantumTask_quantumTaskArn' - The ARN of the task to cancel.
newCancelQuantumTask ::
  -- | 'clientToken'
  Prelude.Text ->
  -- | 'quantumTaskArn'
  Prelude.Text ->
  CancelQuantumTask
newCancelQuantumTask :: Text -> Text -> CancelQuantumTask
newCancelQuantumTask Text
pClientToken_ Text
pQuantumTaskArn_ =
  CancelQuantumTask' :: Text -> Text -> CancelQuantumTask
CancelQuantumTask'
    { $sel:clientToken:CancelQuantumTask' :: Text
clientToken = Text
pClientToken_,
      $sel:quantumTaskArn:CancelQuantumTask' :: Text
quantumTaskArn = Text
pQuantumTaskArn_
    }

-- | The client token associated with the request.
cancelQuantumTask_clientToken :: Lens.Lens' CancelQuantumTask Prelude.Text
cancelQuantumTask_clientToken :: (Text -> f Text) -> CancelQuantumTask -> f CancelQuantumTask
cancelQuantumTask_clientToken = (CancelQuantumTask -> Text)
-> (CancelQuantumTask -> Text -> CancelQuantumTask)
-> Lens CancelQuantumTask CancelQuantumTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelQuantumTask' {Text
clientToken :: Text
$sel:clientToken:CancelQuantumTask' :: CancelQuantumTask -> Text
clientToken} -> Text
clientToken) (\s :: CancelQuantumTask
s@CancelQuantumTask' {} Text
a -> CancelQuantumTask
s {$sel:clientToken:CancelQuantumTask' :: Text
clientToken = Text
a} :: CancelQuantumTask)

-- | The ARN of the task to cancel.
cancelQuantumTask_quantumTaskArn :: Lens.Lens' CancelQuantumTask Prelude.Text
cancelQuantumTask_quantumTaskArn :: (Text -> f Text) -> CancelQuantumTask -> f CancelQuantumTask
cancelQuantumTask_quantumTaskArn = (CancelQuantumTask -> Text)
-> (CancelQuantumTask -> Text -> CancelQuantumTask)
-> Lens CancelQuantumTask CancelQuantumTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelQuantumTask' {Text
quantumTaskArn :: Text
$sel:quantumTaskArn:CancelQuantumTask' :: CancelQuantumTask -> Text
quantumTaskArn} -> Text
quantumTaskArn) (\s :: CancelQuantumTask
s@CancelQuantumTask' {} Text
a -> CancelQuantumTask
s {$sel:quantumTaskArn:CancelQuantumTask' :: Text
quantumTaskArn = Text
a} :: CancelQuantumTask)

instance Core.AWSRequest CancelQuantumTask where
  type
    AWSResponse CancelQuantumTask =
      CancelQuantumTaskResponse
  request :: CancelQuantumTask -> Request CancelQuantumTask
request = Service -> CancelQuantumTask -> Request CancelQuantumTask
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelQuantumTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelQuantumTask)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CancelQuantumTask))
-> Logger
-> Service
-> Proxy CancelQuantumTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelQuantumTask)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> CancellationStatus -> Text -> CancelQuantumTaskResponse
CancelQuantumTaskResponse'
            (Int -> CancellationStatus -> Text -> CancelQuantumTaskResponse)
-> Either String Int
-> Either
     String (CancellationStatus -> Text -> CancelQuantumTaskResponse)
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))
            Either
  String (CancellationStatus -> Text -> CancelQuantumTaskResponse)
-> Either String CancellationStatus
-> Either String (Text -> CancelQuantumTaskResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String CancellationStatus
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"cancellationStatus")
            Either String (Text -> CancelQuantumTaskResponse)
-> Either String Text -> Either String CancelQuantumTaskResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"quantumTaskArn")
      )

instance Prelude.Hashable CancelQuantumTask

instance Prelude.NFData CancelQuantumTask

instance Core.ToHeaders CancelQuantumTask where
  toHeaders :: CancelQuantumTask -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CancelQuantumTask -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 CancelQuantumTask where
  toJSON :: CancelQuantumTask -> Value
toJSON CancelQuantumTask' {Text
quantumTaskArn :: Text
clientToken :: Text
$sel:quantumTaskArn:CancelQuantumTask' :: CancelQuantumTask -> Text
$sel:clientToken:CancelQuantumTask' :: CancelQuantumTask -> 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
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientToken)]
      )

instance Core.ToPath CancelQuantumTask where
  toPath :: CancelQuantumTask -> ByteString
toPath CancelQuantumTask' {Text
quantumTaskArn :: Text
clientToken :: Text
$sel:quantumTaskArn:CancelQuantumTask' :: CancelQuantumTask -> Text
$sel:clientToken:CancelQuantumTask' :: CancelQuantumTask -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/quantum-task/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
quantumTaskArn,
        ByteString
"/cancel"
      ]

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

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

-- |
-- Create a value of 'CancelQuantumTaskResponse' 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', 'cancelQuantumTaskResponse_httpStatus' - The response's http status code.
--
-- 'cancellationStatus', 'cancelQuantumTaskResponse_cancellationStatus' - The status of the cancellation request.
--
-- 'quantumTaskArn', 'cancelQuantumTaskResponse_quantumTaskArn' - The ARN of the task.
newCancelQuantumTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'cancellationStatus'
  CancellationStatus ->
  -- | 'quantumTaskArn'
  Prelude.Text ->
  CancelQuantumTaskResponse
newCancelQuantumTaskResponse :: Int -> CancellationStatus -> Text -> CancelQuantumTaskResponse
newCancelQuantumTaskResponse
  Int
pHttpStatus_
  CancellationStatus
pCancellationStatus_
  Text
pQuantumTaskArn_ =
    CancelQuantumTaskResponse' :: Int -> CancellationStatus -> Text -> CancelQuantumTaskResponse
CancelQuantumTaskResponse'
      { $sel:httpStatus:CancelQuantumTaskResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:cancellationStatus:CancelQuantumTaskResponse' :: CancellationStatus
cancellationStatus = CancellationStatus
pCancellationStatus_,
        $sel:quantumTaskArn:CancelQuantumTaskResponse' :: Text
quantumTaskArn = Text
pQuantumTaskArn_
      }

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

-- | The status of the cancellation request.
cancelQuantumTaskResponse_cancellationStatus :: Lens.Lens' CancelQuantumTaskResponse CancellationStatus
cancelQuantumTaskResponse_cancellationStatus :: (CancellationStatus -> f CancellationStatus)
-> CancelQuantumTaskResponse -> f CancelQuantumTaskResponse
cancelQuantumTaskResponse_cancellationStatus = (CancelQuantumTaskResponse -> CancellationStatus)
-> (CancelQuantumTaskResponse
    -> CancellationStatus -> CancelQuantumTaskResponse)
-> Lens
     CancelQuantumTaskResponse
     CancelQuantumTaskResponse
     CancellationStatus
     CancellationStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelQuantumTaskResponse' {CancellationStatus
cancellationStatus :: CancellationStatus
$sel:cancellationStatus:CancelQuantumTaskResponse' :: CancelQuantumTaskResponse -> CancellationStatus
cancellationStatus} -> CancellationStatus
cancellationStatus) (\s :: CancelQuantumTaskResponse
s@CancelQuantumTaskResponse' {} CancellationStatus
a -> CancelQuantumTaskResponse
s {$sel:cancellationStatus:CancelQuantumTaskResponse' :: CancellationStatus
cancellationStatus = CancellationStatus
a} :: CancelQuantumTaskResponse)

-- | The ARN of the task.
cancelQuantumTaskResponse_quantumTaskArn :: Lens.Lens' CancelQuantumTaskResponse Prelude.Text
cancelQuantumTaskResponse_quantumTaskArn :: (Text -> f Text)
-> CancelQuantumTaskResponse -> f CancelQuantumTaskResponse
cancelQuantumTaskResponse_quantumTaskArn = (CancelQuantumTaskResponse -> Text)
-> (CancelQuantumTaskResponse -> Text -> CancelQuantumTaskResponse)
-> Lens
     CancelQuantumTaskResponse CancelQuantumTaskResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelQuantumTaskResponse' {Text
quantumTaskArn :: Text
$sel:quantumTaskArn:CancelQuantumTaskResponse' :: CancelQuantumTaskResponse -> Text
quantumTaskArn} -> Text
quantumTaskArn) (\s :: CancelQuantumTaskResponse
s@CancelQuantumTaskResponse' {} Text
a -> CancelQuantumTaskResponse
s {$sel:quantumTaskArn:CancelQuantumTaskResponse' :: Text
quantumTaskArn = Text
a} :: CancelQuantumTaskResponse)

instance Prelude.NFData CancelQuantumTaskResponse