{-# 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.MacieV2.UpdateClassificationJob
-- 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)
--
-- Changes the status of a classification job.
module Amazonka.MacieV2.UpdateClassificationJob
  ( -- * Creating a Request
    UpdateClassificationJob (..),
    newUpdateClassificationJob,

    -- * Request Lenses
    updateClassificationJob_jobId,
    updateClassificationJob_jobStatus,

    -- * Destructuring the Response
    UpdateClassificationJobResponse (..),
    newUpdateClassificationJobResponse,

    -- * Response Lenses
    updateClassificationJobResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateClassificationJob' smart constructor.
data UpdateClassificationJob = UpdateClassificationJob'
  { -- | The unique identifier for the classification job.
    UpdateClassificationJob -> Text
jobId :: Prelude.Text,
    -- | The new status for the job. Valid values are:
    --
    -- -   CANCELLED - Stops the job permanently and cancels it. This value is
    --     valid only if the job\'s current status is IDLE, PAUSED, RUNNING, or
    --     USER_PAUSED.
    --
    --     If you specify this value and the job\'s current status is RUNNING,
    --     Amazon Macie immediately begins to stop all processing tasks for the
    --     job. You can\'t resume or restart a job after you cancel it.
    --
    -- -   RUNNING - Resumes the job. This value is valid only if the job\'s
    --     current status is USER_PAUSED.
    --
    --     If you paused the job while it was actively running and you specify
    --     this value less than 30 days after you paused the job, Macie
    --     immediately resumes processing from the point where you paused the
    --     job. Otherwise, Macie resumes the job according to the schedule and
    --     other settings for the job.
    --
    -- -   USER_PAUSED - Pauses the job temporarily. This value is valid only
    --     if the job\'s current status is IDLE, PAUSED, or RUNNING. If you
    --     specify this value and the job\'s current status is RUNNING, Macie
    --     immediately begins to pause all processing tasks for the job.
    --
    --     If you pause a one-time job and you don\'t resume it within 30 days,
    --     the job expires and Macie cancels the job. If you pause a recurring
    --     job when its status is RUNNING and you don\'t resume it within 30
    --     days, the job run expires and Macie cancels the run. To check the
    --     expiration date, refer to the UserPausedDetails.jobExpiresAt
    --     property.
    UpdateClassificationJob -> JobStatus
jobStatus :: JobStatus
  }
  deriving (UpdateClassificationJob -> UpdateClassificationJob -> Bool
(UpdateClassificationJob -> UpdateClassificationJob -> Bool)
-> (UpdateClassificationJob -> UpdateClassificationJob -> Bool)
-> Eq UpdateClassificationJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateClassificationJob -> UpdateClassificationJob -> Bool
$c/= :: UpdateClassificationJob -> UpdateClassificationJob -> Bool
== :: UpdateClassificationJob -> UpdateClassificationJob -> Bool
$c== :: UpdateClassificationJob -> UpdateClassificationJob -> Bool
Prelude.Eq, ReadPrec [UpdateClassificationJob]
ReadPrec UpdateClassificationJob
Int -> ReadS UpdateClassificationJob
ReadS [UpdateClassificationJob]
(Int -> ReadS UpdateClassificationJob)
-> ReadS [UpdateClassificationJob]
-> ReadPrec UpdateClassificationJob
-> ReadPrec [UpdateClassificationJob]
-> Read UpdateClassificationJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateClassificationJob]
$creadListPrec :: ReadPrec [UpdateClassificationJob]
readPrec :: ReadPrec UpdateClassificationJob
$creadPrec :: ReadPrec UpdateClassificationJob
readList :: ReadS [UpdateClassificationJob]
$creadList :: ReadS [UpdateClassificationJob]
readsPrec :: Int -> ReadS UpdateClassificationJob
$creadsPrec :: Int -> ReadS UpdateClassificationJob
Prelude.Read, Int -> UpdateClassificationJob -> ShowS
[UpdateClassificationJob] -> ShowS
UpdateClassificationJob -> String
(Int -> UpdateClassificationJob -> ShowS)
-> (UpdateClassificationJob -> String)
-> ([UpdateClassificationJob] -> ShowS)
-> Show UpdateClassificationJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateClassificationJob] -> ShowS
$cshowList :: [UpdateClassificationJob] -> ShowS
show :: UpdateClassificationJob -> String
$cshow :: UpdateClassificationJob -> String
showsPrec :: Int -> UpdateClassificationJob -> ShowS
$cshowsPrec :: Int -> UpdateClassificationJob -> ShowS
Prelude.Show, (forall x.
 UpdateClassificationJob -> Rep UpdateClassificationJob x)
-> (forall x.
    Rep UpdateClassificationJob x -> UpdateClassificationJob)
-> Generic UpdateClassificationJob
forall x. Rep UpdateClassificationJob x -> UpdateClassificationJob
forall x. UpdateClassificationJob -> Rep UpdateClassificationJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateClassificationJob x -> UpdateClassificationJob
$cfrom :: forall x. UpdateClassificationJob -> Rep UpdateClassificationJob x
Prelude.Generic)

-- |
-- Create a value of 'UpdateClassificationJob' 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', 'updateClassificationJob_jobId' - The unique identifier for the classification job.
--
-- 'jobStatus', 'updateClassificationJob_jobStatus' - The new status for the job. Valid values are:
--
-- -   CANCELLED - Stops the job permanently and cancels it. This value is
--     valid only if the job\'s current status is IDLE, PAUSED, RUNNING, or
--     USER_PAUSED.
--
--     If you specify this value and the job\'s current status is RUNNING,
--     Amazon Macie immediately begins to stop all processing tasks for the
--     job. You can\'t resume or restart a job after you cancel it.
--
-- -   RUNNING - Resumes the job. This value is valid only if the job\'s
--     current status is USER_PAUSED.
--
--     If you paused the job while it was actively running and you specify
--     this value less than 30 days after you paused the job, Macie
--     immediately resumes processing from the point where you paused the
--     job. Otherwise, Macie resumes the job according to the schedule and
--     other settings for the job.
--
-- -   USER_PAUSED - Pauses the job temporarily. This value is valid only
--     if the job\'s current status is IDLE, PAUSED, or RUNNING. If you
--     specify this value and the job\'s current status is RUNNING, Macie
--     immediately begins to pause all processing tasks for the job.
--
--     If you pause a one-time job and you don\'t resume it within 30 days,
--     the job expires and Macie cancels the job. If you pause a recurring
--     job when its status is RUNNING and you don\'t resume it within 30
--     days, the job run expires and Macie cancels the run. To check the
--     expiration date, refer to the UserPausedDetails.jobExpiresAt
--     property.
newUpdateClassificationJob ::
  -- | 'jobId'
  Prelude.Text ->
  -- | 'jobStatus'
  JobStatus ->
  UpdateClassificationJob
newUpdateClassificationJob :: Text -> JobStatus -> UpdateClassificationJob
newUpdateClassificationJob Text
pJobId_ JobStatus
pJobStatus_ =
  UpdateClassificationJob' :: Text -> JobStatus -> UpdateClassificationJob
UpdateClassificationJob'
    { $sel:jobId:UpdateClassificationJob' :: Text
jobId = Text
pJobId_,
      $sel:jobStatus:UpdateClassificationJob' :: JobStatus
jobStatus = JobStatus
pJobStatus_
    }

-- | The unique identifier for the classification job.
updateClassificationJob_jobId :: Lens.Lens' UpdateClassificationJob Prelude.Text
updateClassificationJob_jobId :: (Text -> f Text)
-> UpdateClassificationJob -> f UpdateClassificationJob
updateClassificationJob_jobId = (UpdateClassificationJob -> Text)
-> (UpdateClassificationJob -> Text -> UpdateClassificationJob)
-> Lens UpdateClassificationJob UpdateClassificationJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateClassificationJob' {Text
jobId :: Text
$sel:jobId:UpdateClassificationJob' :: UpdateClassificationJob -> Text
jobId} -> Text
jobId) (\s :: UpdateClassificationJob
s@UpdateClassificationJob' {} Text
a -> UpdateClassificationJob
s {$sel:jobId:UpdateClassificationJob' :: Text
jobId = Text
a} :: UpdateClassificationJob)

-- | The new status for the job. Valid values are:
--
-- -   CANCELLED - Stops the job permanently and cancels it. This value is
--     valid only if the job\'s current status is IDLE, PAUSED, RUNNING, or
--     USER_PAUSED.
--
--     If you specify this value and the job\'s current status is RUNNING,
--     Amazon Macie immediately begins to stop all processing tasks for the
--     job. You can\'t resume or restart a job after you cancel it.
--
-- -   RUNNING - Resumes the job. This value is valid only if the job\'s
--     current status is USER_PAUSED.
--
--     If you paused the job while it was actively running and you specify
--     this value less than 30 days after you paused the job, Macie
--     immediately resumes processing from the point where you paused the
--     job. Otherwise, Macie resumes the job according to the schedule and
--     other settings for the job.
--
-- -   USER_PAUSED - Pauses the job temporarily. This value is valid only
--     if the job\'s current status is IDLE, PAUSED, or RUNNING. If you
--     specify this value and the job\'s current status is RUNNING, Macie
--     immediately begins to pause all processing tasks for the job.
--
--     If you pause a one-time job and you don\'t resume it within 30 days,
--     the job expires and Macie cancels the job. If you pause a recurring
--     job when its status is RUNNING and you don\'t resume it within 30
--     days, the job run expires and Macie cancels the run. To check the
--     expiration date, refer to the UserPausedDetails.jobExpiresAt
--     property.
updateClassificationJob_jobStatus :: Lens.Lens' UpdateClassificationJob JobStatus
updateClassificationJob_jobStatus :: (JobStatus -> f JobStatus)
-> UpdateClassificationJob -> f UpdateClassificationJob
updateClassificationJob_jobStatus = (UpdateClassificationJob -> JobStatus)
-> (UpdateClassificationJob
    -> JobStatus -> UpdateClassificationJob)
-> Lens
     UpdateClassificationJob UpdateClassificationJob JobStatus JobStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateClassificationJob' {JobStatus
jobStatus :: JobStatus
$sel:jobStatus:UpdateClassificationJob' :: UpdateClassificationJob -> JobStatus
jobStatus} -> JobStatus
jobStatus) (\s :: UpdateClassificationJob
s@UpdateClassificationJob' {} JobStatus
a -> UpdateClassificationJob
s {$sel:jobStatus:UpdateClassificationJob' :: JobStatus
jobStatus = JobStatus
a} :: UpdateClassificationJob)

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

instance Prelude.NFData UpdateClassificationJob

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

instance Core.ToPath UpdateClassificationJob where
  toPath :: UpdateClassificationJob -> ByteString
toPath UpdateClassificationJob' {Text
JobStatus
jobStatus :: JobStatus
jobId :: Text
$sel:jobStatus:UpdateClassificationJob' :: UpdateClassificationJob -> JobStatus
$sel:jobId:UpdateClassificationJob' :: UpdateClassificationJob -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/jobs/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
jobId]

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

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

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

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

instance
  Prelude.NFData
    UpdateClassificationJobResponse