{-# 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.FraudDetector.CancelBatchImportJob
-- 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 an in-progress batch import job.
module Amazonka.FraudDetector.CancelBatchImportJob
  ( -- * Creating a Request
    CancelBatchImportJob (..),
    newCancelBatchImportJob,

    -- * Request Lenses
    cancelBatchImportJob_jobId,

    -- * Destructuring the Response
    CancelBatchImportJobResponse (..),
    newCancelBatchImportJobResponse,

    -- * Response Lenses
    cancelBatchImportJobResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.FraudDetector.Types
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:/ 'newCancelBatchImportJob' smart constructor.
data CancelBatchImportJob = CancelBatchImportJob'
  { -- | The ID of an in-progress batch import job to cancel.
    --
    -- Amazon Fraud Detector will throw an error if the batch import job is in
    -- @FAILED@, @CANCELED@, or @COMPLETED@ state.
    CancelBatchImportJob -> Text
jobId :: Prelude.Text
  }
  deriving (CancelBatchImportJob -> CancelBatchImportJob -> Bool
(CancelBatchImportJob -> CancelBatchImportJob -> Bool)
-> (CancelBatchImportJob -> CancelBatchImportJob -> Bool)
-> Eq CancelBatchImportJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelBatchImportJob -> CancelBatchImportJob -> Bool
$c/= :: CancelBatchImportJob -> CancelBatchImportJob -> Bool
== :: CancelBatchImportJob -> CancelBatchImportJob -> Bool
$c== :: CancelBatchImportJob -> CancelBatchImportJob -> Bool
Prelude.Eq, ReadPrec [CancelBatchImportJob]
ReadPrec CancelBatchImportJob
Int -> ReadS CancelBatchImportJob
ReadS [CancelBatchImportJob]
(Int -> ReadS CancelBatchImportJob)
-> ReadS [CancelBatchImportJob]
-> ReadPrec CancelBatchImportJob
-> ReadPrec [CancelBatchImportJob]
-> Read CancelBatchImportJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelBatchImportJob]
$creadListPrec :: ReadPrec [CancelBatchImportJob]
readPrec :: ReadPrec CancelBatchImportJob
$creadPrec :: ReadPrec CancelBatchImportJob
readList :: ReadS [CancelBatchImportJob]
$creadList :: ReadS [CancelBatchImportJob]
readsPrec :: Int -> ReadS CancelBatchImportJob
$creadsPrec :: Int -> ReadS CancelBatchImportJob
Prelude.Read, Int -> CancelBatchImportJob -> ShowS
[CancelBatchImportJob] -> ShowS
CancelBatchImportJob -> String
(Int -> CancelBatchImportJob -> ShowS)
-> (CancelBatchImportJob -> String)
-> ([CancelBatchImportJob] -> ShowS)
-> Show CancelBatchImportJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelBatchImportJob] -> ShowS
$cshowList :: [CancelBatchImportJob] -> ShowS
show :: CancelBatchImportJob -> String
$cshow :: CancelBatchImportJob -> String
showsPrec :: Int -> CancelBatchImportJob -> ShowS
$cshowsPrec :: Int -> CancelBatchImportJob -> ShowS
Prelude.Show, (forall x. CancelBatchImportJob -> Rep CancelBatchImportJob x)
-> (forall x. Rep CancelBatchImportJob x -> CancelBatchImportJob)
-> Generic CancelBatchImportJob
forall x. Rep CancelBatchImportJob x -> CancelBatchImportJob
forall x. CancelBatchImportJob -> Rep CancelBatchImportJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelBatchImportJob x -> CancelBatchImportJob
$cfrom :: forall x. CancelBatchImportJob -> Rep CancelBatchImportJob x
Prelude.Generic)

-- |
-- Create a value of 'CancelBatchImportJob' 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:
--
-- 'jobId', 'cancelBatchImportJob_jobId' - The ID of an in-progress batch import job to cancel.
--
-- Amazon Fraud Detector will throw an error if the batch import job is in
-- @FAILED@, @CANCELED@, or @COMPLETED@ state.
newCancelBatchImportJob ::
  -- | 'jobId'
  Prelude.Text ->
  CancelBatchImportJob
newCancelBatchImportJob :: Text -> CancelBatchImportJob
newCancelBatchImportJob Text
pJobId_ =
  CancelBatchImportJob' :: Text -> CancelBatchImportJob
CancelBatchImportJob' {$sel:jobId:CancelBatchImportJob' :: Text
jobId = Text
pJobId_}

-- | The ID of an in-progress batch import job to cancel.
--
-- Amazon Fraud Detector will throw an error if the batch import job is in
-- @FAILED@, @CANCELED@, or @COMPLETED@ state.
cancelBatchImportJob_jobId :: Lens.Lens' CancelBatchImportJob Prelude.Text
cancelBatchImportJob_jobId :: (Text -> f Text) -> CancelBatchImportJob -> f CancelBatchImportJob
cancelBatchImportJob_jobId = (CancelBatchImportJob -> Text)
-> (CancelBatchImportJob -> Text -> CancelBatchImportJob)
-> Lens CancelBatchImportJob CancelBatchImportJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelBatchImportJob' {Text
jobId :: Text
$sel:jobId:CancelBatchImportJob' :: CancelBatchImportJob -> Text
jobId} -> Text
jobId) (\s :: CancelBatchImportJob
s@CancelBatchImportJob' {} Text
a -> CancelBatchImportJob
s {$sel:jobId:CancelBatchImportJob' :: Text
jobId = Text
a} :: CancelBatchImportJob)

instance Core.AWSRequest CancelBatchImportJob where
  type
    AWSResponse CancelBatchImportJob =
      CancelBatchImportJobResponse
  request :: CancelBatchImportJob -> Request CancelBatchImportJob
request = Service -> CancelBatchImportJob -> Request CancelBatchImportJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelBatchImportJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelBatchImportJob)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CancelBatchImportJob))
-> Logger
-> Service
-> Proxy CancelBatchImportJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelBatchImportJob)))
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 -> CancelBatchImportJobResponse
CancelBatchImportJobResponse'
            (Int -> CancelBatchImportJobResponse)
-> Either String Int -> Either String CancelBatchImportJobResponse
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 CancelBatchImportJob

instance Prelude.NFData CancelBatchImportJob

instance Core.ToHeaders CancelBatchImportJob where
  toHeaders :: CancelBatchImportJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CancelBatchImportJob -> 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
"AWSHawksNestServiceFacade.CancelBatchImportJob" ::
                          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 CancelBatchImportJob where
  toJSON :: CancelBatchImportJob -> Value
toJSON CancelBatchImportJob' {Text
jobId :: Text
$sel:jobId:CancelBatchImportJob' :: CancelBatchImportJob -> 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
"jobId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jobId)]
      )

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

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

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

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

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

instance Prelude.NFData CancelBatchImportJobResponse