{-# 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.WorkMail.CancelMailboxExportJob
-- 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 mailbox export job.
--
-- If the mailbox export job is near completion, it might not be possible
-- to cancel it.
module Amazonka.WorkMail.CancelMailboxExportJob
  ( -- * Creating a Request
    CancelMailboxExportJob (..),
    newCancelMailboxExportJob,

    -- * Request Lenses
    cancelMailboxExportJob_clientToken,
    cancelMailboxExportJob_jobId,
    cancelMailboxExportJob_organizationId,

    -- * Destructuring the Response
    CancelMailboxExportJobResponse (..),
    newCancelMailboxExportJobResponse,

    -- * Response Lenses
    cancelMailboxExportJobResponse_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.WorkMail.Types

-- | /See:/ 'newCancelMailboxExportJob' smart constructor.
data CancelMailboxExportJob = CancelMailboxExportJob'
  { -- | The idempotency token for the client request.
    CancelMailboxExportJob -> Text
clientToken :: Prelude.Text,
    -- | The job ID.
    CancelMailboxExportJob -> Text
jobId :: Prelude.Text,
    -- | The organization ID.
    CancelMailboxExportJob -> Text
organizationId :: Prelude.Text
  }
  deriving (CancelMailboxExportJob -> CancelMailboxExportJob -> Bool
(CancelMailboxExportJob -> CancelMailboxExportJob -> Bool)
-> (CancelMailboxExportJob -> CancelMailboxExportJob -> Bool)
-> Eq CancelMailboxExportJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelMailboxExportJob -> CancelMailboxExportJob -> Bool
$c/= :: CancelMailboxExportJob -> CancelMailboxExportJob -> Bool
== :: CancelMailboxExportJob -> CancelMailboxExportJob -> Bool
$c== :: CancelMailboxExportJob -> CancelMailboxExportJob -> Bool
Prelude.Eq, ReadPrec [CancelMailboxExportJob]
ReadPrec CancelMailboxExportJob
Int -> ReadS CancelMailboxExportJob
ReadS [CancelMailboxExportJob]
(Int -> ReadS CancelMailboxExportJob)
-> ReadS [CancelMailboxExportJob]
-> ReadPrec CancelMailboxExportJob
-> ReadPrec [CancelMailboxExportJob]
-> Read CancelMailboxExportJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelMailboxExportJob]
$creadListPrec :: ReadPrec [CancelMailboxExportJob]
readPrec :: ReadPrec CancelMailboxExportJob
$creadPrec :: ReadPrec CancelMailboxExportJob
readList :: ReadS [CancelMailboxExportJob]
$creadList :: ReadS [CancelMailboxExportJob]
readsPrec :: Int -> ReadS CancelMailboxExportJob
$creadsPrec :: Int -> ReadS CancelMailboxExportJob
Prelude.Read, Int -> CancelMailboxExportJob -> ShowS
[CancelMailboxExportJob] -> ShowS
CancelMailboxExportJob -> String
(Int -> CancelMailboxExportJob -> ShowS)
-> (CancelMailboxExportJob -> String)
-> ([CancelMailboxExportJob] -> ShowS)
-> Show CancelMailboxExportJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelMailboxExportJob] -> ShowS
$cshowList :: [CancelMailboxExportJob] -> ShowS
show :: CancelMailboxExportJob -> String
$cshow :: CancelMailboxExportJob -> String
showsPrec :: Int -> CancelMailboxExportJob -> ShowS
$cshowsPrec :: Int -> CancelMailboxExportJob -> ShowS
Prelude.Show, (forall x. CancelMailboxExportJob -> Rep CancelMailboxExportJob x)
-> (forall x.
    Rep CancelMailboxExportJob x -> CancelMailboxExportJob)
-> Generic CancelMailboxExportJob
forall x. Rep CancelMailboxExportJob x -> CancelMailboxExportJob
forall x. CancelMailboxExportJob -> Rep CancelMailboxExportJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelMailboxExportJob x -> CancelMailboxExportJob
$cfrom :: forall x. CancelMailboxExportJob -> Rep CancelMailboxExportJob x
Prelude.Generic)

-- |
-- Create a value of 'CancelMailboxExportJob' 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', 'cancelMailboxExportJob_clientToken' - The idempotency token for the client request.
--
-- 'jobId', 'cancelMailboxExportJob_jobId' - The job ID.
--
-- 'organizationId', 'cancelMailboxExportJob_organizationId' - The organization ID.
newCancelMailboxExportJob ::
  -- | 'clientToken'
  Prelude.Text ->
  -- | 'jobId'
  Prelude.Text ->
  -- | 'organizationId'
  Prelude.Text ->
  CancelMailboxExportJob
newCancelMailboxExportJob :: Text -> Text -> Text -> CancelMailboxExportJob
newCancelMailboxExportJob
  Text
pClientToken_
  Text
pJobId_
  Text
pOrganizationId_ =
    CancelMailboxExportJob' :: Text -> Text -> Text -> CancelMailboxExportJob
CancelMailboxExportJob'
      { $sel:clientToken:CancelMailboxExportJob' :: Text
clientToken =
          Text
pClientToken_,
        $sel:jobId:CancelMailboxExportJob' :: Text
jobId = Text
pJobId_,
        $sel:organizationId:CancelMailboxExportJob' :: Text
organizationId = Text
pOrganizationId_
      }

-- | The idempotency token for the client request.
cancelMailboxExportJob_clientToken :: Lens.Lens' CancelMailboxExportJob Prelude.Text
cancelMailboxExportJob_clientToken :: (Text -> f Text)
-> CancelMailboxExportJob -> f CancelMailboxExportJob
cancelMailboxExportJob_clientToken = (CancelMailboxExportJob -> Text)
-> (CancelMailboxExportJob -> Text -> CancelMailboxExportJob)
-> Lens CancelMailboxExportJob CancelMailboxExportJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelMailboxExportJob' {Text
clientToken :: Text
$sel:clientToken:CancelMailboxExportJob' :: CancelMailboxExportJob -> Text
clientToken} -> Text
clientToken) (\s :: CancelMailboxExportJob
s@CancelMailboxExportJob' {} Text
a -> CancelMailboxExportJob
s {$sel:clientToken:CancelMailboxExportJob' :: Text
clientToken = Text
a} :: CancelMailboxExportJob)

-- | The job ID.
cancelMailboxExportJob_jobId :: Lens.Lens' CancelMailboxExportJob Prelude.Text
cancelMailboxExportJob_jobId :: (Text -> f Text)
-> CancelMailboxExportJob -> f CancelMailboxExportJob
cancelMailboxExportJob_jobId = (CancelMailboxExportJob -> Text)
-> (CancelMailboxExportJob -> Text -> CancelMailboxExportJob)
-> Lens CancelMailboxExportJob CancelMailboxExportJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelMailboxExportJob' {Text
jobId :: Text
$sel:jobId:CancelMailboxExportJob' :: CancelMailboxExportJob -> Text
jobId} -> Text
jobId) (\s :: CancelMailboxExportJob
s@CancelMailboxExportJob' {} Text
a -> CancelMailboxExportJob
s {$sel:jobId:CancelMailboxExportJob' :: Text
jobId = Text
a} :: CancelMailboxExportJob)

-- | The organization ID.
cancelMailboxExportJob_organizationId :: Lens.Lens' CancelMailboxExportJob Prelude.Text
cancelMailboxExportJob_organizationId :: (Text -> f Text)
-> CancelMailboxExportJob -> f CancelMailboxExportJob
cancelMailboxExportJob_organizationId = (CancelMailboxExportJob -> Text)
-> (CancelMailboxExportJob -> Text -> CancelMailboxExportJob)
-> Lens CancelMailboxExportJob CancelMailboxExportJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelMailboxExportJob' {Text
organizationId :: Text
$sel:organizationId:CancelMailboxExportJob' :: CancelMailboxExportJob -> Text
organizationId} -> Text
organizationId) (\s :: CancelMailboxExportJob
s@CancelMailboxExportJob' {} Text
a -> CancelMailboxExportJob
s {$sel:organizationId:CancelMailboxExportJob' :: Text
organizationId = Text
a} :: CancelMailboxExportJob)

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

instance Prelude.NFData CancelMailboxExportJob

instance Core.ToHeaders CancelMailboxExportJob where
  toHeaders :: CancelMailboxExportJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CancelMailboxExportJob -> 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
"WorkMailService.CancelMailboxExportJob" ::
                          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 CancelMailboxExportJob where
  toJSON :: CancelMailboxExportJob -> Value
toJSON CancelMailboxExportJob' {Text
organizationId :: Text
jobId :: Text
clientToken :: Text
$sel:organizationId:CancelMailboxExportJob' :: CancelMailboxExportJob -> Text
$sel:jobId:CancelMailboxExportJob' :: CancelMailboxExportJob -> Text
$sel:clientToken:CancelMailboxExportJob' :: CancelMailboxExportJob -> 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),
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"OrganizationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
organizationId)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    CancelMailboxExportJobResponse