{-# 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.CancelJob
-- 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 an Amazon Braket job.
module Amazonka.Braket.CancelJob
  ( -- * Creating a Request
    CancelJob (..),
    newCancelJob,

    -- * Request Lenses
    cancelJob_jobArn,

    -- * Destructuring the Response
    CancelJobResponse (..),
    newCancelJobResponse,

    -- * Response Lenses
    cancelJobResponse_httpStatus,
    cancelJobResponse_cancellationStatus,
    cancelJobResponse_jobArn,
  )
where

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

-- | /See:/ 'newCancelJob' smart constructor.
data CancelJob = CancelJob'
  { -- | The ARN of the Amazon Braket job to cancel.
    CancelJob -> Text
jobArn :: Prelude.Text
  }
  deriving (CancelJob -> CancelJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelJob -> CancelJob -> Bool
$c/= :: CancelJob -> CancelJob -> Bool
== :: CancelJob -> CancelJob -> Bool
$c== :: CancelJob -> CancelJob -> Bool
Prelude.Eq, ReadPrec [CancelJob]
ReadPrec CancelJob
Int -> ReadS CancelJob
ReadS [CancelJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelJob]
$creadListPrec :: ReadPrec [CancelJob]
readPrec :: ReadPrec CancelJob
$creadPrec :: ReadPrec CancelJob
readList :: ReadS [CancelJob]
$creadList :: ReadS [CancelJob]
readsPrec :: Int -> ReadS CancelJob
$creadsPrec :: Int -> ReadS CancelJob
Prelude.Read, Int -> CancelJob -> ShowS
[CancelJob] -> ShowS
CancelJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelJob] -> ShowS
$cshowList :: [CancelJob] -> ShowS
show :: CancelJob -> String
$cshow :: CancelJob -> String
showsPrec :: Int -> CancelJob -> ShowS
$cshowsPrec :: Int -> CancelJob -> ShowS
Prelude.Show, forall x. Rep CancelJob x -> CancelJob
forall x. CancelJob -> Rep CancelJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelJob x -> CancelJob
$cfrom :: forall x. CancelJob -> Rep CancelJob x
Prelude.Generic)

-- |
-- Create a value of 'CancelJob' 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:
--
-- 'jobArn', 'cancelJob_jobArn' - The ARN of the Amazon Braket job to cancel.
newCancelJob ::
  -- | 'jobArn'
  Prelude.Text ->
  CancelJob
newCancelJob :: Text -> CancelJob
newCancelJob Text
pJobArn_ = CancelJob' {$sel:jobArn:CancelJob' :: Text
jobArn = Text
pJobArn_}

-- | The ARN of the Amazon Braket job to cancel.
cancelJob_jobArn :: Lens.Lens' CancelJob Prelude.Text
cancelJob_jobArn :: Lens' CancelJob Text
cancelJob_jobArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJob' {Text
jobArn :: Text
$sel:jobArn:CancelJob' :: CancelJob -> Text
jobArn} -> Text
jobArn) (\s :: CancelJob
s@CancelJob' {} Text
a -> CancelJob
s {$sel:jobArn:CancelJob' :: Text
jobArn = Text
a} :: CancelJob)

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

instance Prelude.Hashable CancelJob where
  hashWithSalt :: Int -> CancelJob -> Int
hashWithSalt Int
_salt CancelJob' {Text
jobArn :: Text
$sel:jobArn:CancelJob' :: CancelJob -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jobArn

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

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

instance Data.ToJSON CancelJob where
  toJSON :: CancelJob -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath CancelJob where
  toPath :: CancelJob -> ByteString
toPath CancelJob' {Text
jobArn :: Text
$sel:jobArn:CancelJob' :: CancelJob -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/job/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
jobArn, ByteString
"/cancel"]

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

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

-- |
-- Create a value of 'CancelJobResponse' 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', 'cancelJobResponse_httpStatus' - The response's http status code.
--
-- 'cancellationStatus', 'cancelJobResponse_cancellationStatus' - The status of the job cancellation request.
--
-- 'jobArn', 'cancelJobResponse_jobArn' - The ARN of the Amazon Braket job.
newCancelJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'cancellationStatus'
  CancellationStatus ->
  -- | 'jobArn'
  Prelude.Text ->
  CancelJobResponse
newCancelJobResponse :: Int -> CancellationStatus -> Text -> CancelJobResponse
newCancelJobResponse
  Int
pHttpStatus_
  CancellationStatus
pCancellationStatus_
  Text
pJobArn_ =
    CancelJobResponse'
      { $sel:httpStatus:CancelJobResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:cancellationStatus:CancelJobResponse' :: CancellationStatus
cancellationStatus = CancellationStatus
pCancellationStatus_,
        $sel:jobArn:CancelJobResponse' :: Text
jobArn = Text
pJobArn_
      }

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

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

-- | The ARN of the Amazon Braket job.
cancelJobResponse_jobArn :: Lens.Lens' CancelJobResponse Prelude.Text
cancelJobResponse_jobArn :: Lens' CancelJobResponse Text
cancelJobResponse_jobArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJobResponse' {Text
jobArn :: Text
$sel:jobArn:CancelJobResponse' :: CancelJobResponse -> Text
jobArn} -> Text
jobArn) (\s :: CancelJobResponse
s@CancelJobResponse' {} Text
a -> CancelJobResponse
s {$sel:jobArn:CancelJobResponse' :: Text
jobArn = Text
a} :: CancelJobResponse)

instance Prelude.NFData CancelJobResponse where
  rnf :: CancelJobResponse -> ()
rnf CancelJobResponse' {Int
Text
CancellationStatus
jobArn :: Text
cancellationStatus :: CancellationStatus
httpStatus :: Int
$sel:jobArn:CancelJobResponse' :: CancelJobResponse -> Text
$sel:cancellationStatus:CancelJobResponse' :: CancelJobResponse -> CancellationStatus
$sel:httpStatus:CancelJobResponse' :: CancelJobResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CancellationStatus
cancellationStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
jobArn