{-# 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.CognitoIdentityProvider.StopUserImportJob
-- 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)
--
-- Stops the user import job.
module Amazonka.CognitoIdentityProvider.StopUserImportJob
  ( -- * Creating a Request
    StopUserImportJob (..),
    newStopUserImportJob,

    -- * Request Lenses
    stopUserImportJob_userPoolId,
    stopUserImportJob_jobId,

    -- * Destructuring the Response
    StopUserImportJobResponse (..),
    newStopUserImportJobResponse,

    -- * Response Lenses
    stopUserImportJobResponse_userImportJob,
    stopUserImportJobResponse_httpStatus,
  )
where

import Amazonka.CognitoIdentityProvider.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

-- | Represents the request to stop the user import job.
--
-- /See:/ 'newStopUserImportJob' smart constructor.
data StopUserImportJob = StopUserImportJob'
  { -- | The user pool ID for the user pool that the users are being imported
    -- into.
    StopUserImportJob -> Text
userPoolId :: Prelude.Text,
    -- | The job ID for the user import job.
    StopUserImportJob -> Text
jobId :: Prelude.Text
  }
  deriving (StopUserImportJob -> StopUserImportJob -> Bool
(StopUserImportJob -> StopUserImportJob -> Bool)
-> (StopUserImportJob -> StopUserImportJob -> Bool)
-> Eq StopUserImportJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopUserImportJob -> StopUserImportJob -> Bool
$c/= :: StopUserImportJob -> StopUserImportJob -> Bool
== :: StopUserImportJob -> StopUserImportJob -> Bool
$c== :: StopUserImportJob -> StopUserImportJob -> Bool
Prelude.Eq, ReadPrec [StopUserImportJob]
ReadPrec StopUserImportJob
Int -> ReadS StopUserImportJob
ReadS [StopUserImportJob]
(Int -> ReadS StopUserImportJob)
-> ReadS [StopUserImportJob]
-> ReadPrec StopUserImportJob
-> ReadPrec [StopUserImportJob]
-> Read StopUserImportJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopUserImportJob]
$creadListPrec :: ReadPrec [StopUserImportJob]
readPrec :: ReadPrec StopUserImportJob
$creadPrec :: ReadPrec StopUserImportJob
readList :: ReadS [StopUserImportJob]
$creadList :: ReadS [StopUserImportJob]
readsPrec :: Int -> ReadS StopUserImportJob
$creadsPrec :: Int -> ReadS StopUserImportJob
Prelude.Read, Int -> StopUserImportJob -> ShowS
[StopUserImportJob] -> ShowS
StopUserImportJob -> String
(Int -> StopUserImportJob -> ShowS)
-> (StopUserImportJob -> String)
-> ([StopUserImportJob] -> ShowS)
-> Show StopUserImportJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopUserImportJob] -> ShowS
$cshowList :: [StopUserImportJob] -> ShowS
show :: StopUserImportJob -> String
$cshow :: StopUserImportJob -> String
showsPrec :: Int -> StopUserImportJob -> ShowS
$cshowsPrec :: Int -> StopUserImportJob -> ShowS
Prelude.Show, (forall x. StopUserImportJob -> Rep StopUserImportJob x)
-> (forall x. Rep StopUserImportJob x -> StopUserImportJob)
-> Generic StopUserImportJob
forall x. Rep StopUserImportJob x -> StopUserImportJob
forall x. StopUserImportJob -> Rep StopUserImportJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopUserImportJob x -> StopUserImportJob
$cfrom :: forall x. StopUserImportJob -> Rep StopUserImportJob x
Prelude.Generic)

-- |
-- Create a value of 'StopUserImportJob' 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:
--
-- 'userPoolId', 'stopUserImportJob_userPoolId' - The user pool ID for the user pool that the users are being imported
-- into.
--
-- 'jobId', 'stopUserImportJob_jobId' - The job ID for the user import job.
newStopUserImportJob ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'jobId'
  Prelude.Text ->
  StopUserImportJob
newStopUserImportJob :: Text -> Text -> StopUserImportJob
newStopUserImportJob Text
pUserPoolId_ Text
pJobId_ =
  StopUserImportJob' :: Text -> Text -> StopUserImportJob
StopUserImportJob'
    { $sel:userPoolId:StopUserImportJob' :: Text
userPoolId = Text
pUserPoolId_,
      $sel:jobId:StopUserImportJob' :: Text
jobId = Text
pJobId_
    }

-- | The user pool ID for the user pool that the users are being imported
-- into.
stopUserImportJob_userPoolId :: Lens.Lens' StopUserImportJob Prelude.Text
stopUserImportJob_userPoolId :: (Text -> f Text) -> StopUserImportJob -> f StopUserImportJob
stopUserImportJob_userPoolId = (StopUserImportJob -> Text)
-> (StopUserImportJob -> Text -> StopUserImportJob)
-> Lens StopUserImportJob StopUserImportJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopUserImportJob' {Text
userPoolId :: Text
$sel:userPoolId:StopUserImportJob' :: StopUserImportJob -> Text
userPoolId} -> Text
userPoolId) (\s :: StopUserImportJob
s@StopUserImportJob' {} Text
a -> StopUserImportJob
s {$sel:userPoolId:StopUserImportJob' :: Text
userPoolId = Text
a} :: StopUserImportJob)

-- | The job ID for the user import job.
stopUserImportJob_jobId :: Lens.Lens' StopUserImportJob Prelude.Text
stopUserImportJob_jobId :: (Text -> f Text) -> StopUserImportJob -> f StopUserImportJob
stopUserImportJob_jobId = (StopUserImportJob -> Text)
-> (StopUserImportJob -> Text -> StopUserImportJob)
-> Lens StopUserImportJob StopUserImportJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopUserImportJob' {Text
jobId :: Text
$sel:jobId:StopUserImportJob' :: StopUserImportJob -> Text
jobId} -> Text
jobId) (\s :: StopUserImportJob
s@StopUserImportJob' {} Text
a -> StopUserImportJob
s {$sel:jobId:StopUserImportJob' :: Text
jobId = Text
a} :: StopUserImportJob)

instance Core.AWSRequest StopUserImportJob where
  type
    AWSResponse StopUserImportJob =
      StopUserImportJobResponse
  request :: StopUserImportJob -> Request StopUserImportJob
request = Service -> StopUserImportJob -> Request StopUserImportJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopUserImportJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopUserImportJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopUserImportJob))
-> Logger
-> Service
-> Proxy StopUserImportJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopUserImportJob)))
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 ->
          Maybe UserImportJobType -> Int -> StopUserImportJobResponse
StopUserImportJobResponse'
            (Maybe UserImportJobType -> Int -> StopUserImportJobResponse)
-> Either String (Maybe UserImportJobType)
-> Either String (Int -> StopUserImportJobResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe UserImportJobType)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"UserImportJob")
            Either String (Int -> StopUserImportJobResponse)
-> Either String Int -> Either String StopUserImportJobResponse
forall (f :: * -> *) a b. Applicative f => 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 StopUserImportJob

instance Prelude.NFData StopUserImportJob

instance Core.ToHeaders StopUserImportJob where
  toHeaders :: StopUserImportJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopUserImportJob -> 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
"AWSCognitoIdentityProviderService.StopUserImportJob" ::
                          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 StopUserImportJob where
  toJSON :: StopUserImportJob -> Value
toJSON StopUserImportJob' {Text
jobId :: Text
userPoolId :: Text
$sel:jobId:StopUserImportJob' :: StopUserImportJob -> Text
$sel:userPoolId:StopUserImportJob' :: StopUserImportJob -> 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
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId),
            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 StopUserImportJob where
  toPath :: StopUserImportJob -> ByteString
toPath = ByteString -> StopUserImportJob -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Represents the response from the server to the request to stop the user
-- import job.
--
-- /See:/ 'newStopUserImportJobResponse' smart constructor.
data StopUserImportJobResponse = StopUserImportJobResponse'
  { -- | The job object that represents the user import job.
    StopUserImportJobResponse -> Maybe UserImportJobType
userImportJob :: Prelude.Maybe UserImportJobType,
    -- | The response's http status code.
    StopUserImportJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopUserImportJobResponse -> StopUserImportJobResponse -> Bool
(StopUserImportJobResponse -> StopUserImportJobResponse -> Bool)
-> (StopUserImportJobResponse -> StopUserImportJobResponse -> Bool)
-> Eq StopUserImportJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopUserImportJobResponse -> StopUserImportJobResponse -> Bool
$c/= :: StopUserImportJobResponse -> StopUserImportJobResponse -> Bool
== :: StopUserImportJobResponse -> StopUserImportJobResponse -> Bool
$c== :: StopUserImportJobResponse -> StopUserImportJobResponse -> Bool
Prelude.Eq, ReadPrec [StopUserImportJobResponse]
ReadPrec StopUserImportJobResponse
Int -> ReadS StopUserImportJobResponse
ReadS [StopUserImportJobResponse]
(Int -> ReadS StopUserImportJobResponse)
-> ReadS [StopUserImportJobResponse]
-> ReadPrec StopUserImportJobResponse
-> ReadPrec [StopUserImportJobResponse]
-> Read StopUserImportJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopUserImportJobResponse]
$creadListPrec :: ReadPrec [StopUserImportJobResponse]
readPrec :: ReadPrec StopUserImportJobResponse
$creadPrec :: ReadPrec StopUserImportJobResponse
readList :: ReadS [StopUserImportJobResponse]
$creadList :: ReadS [StopUserImportJobResponse]
readsPrec :: Int -> ReadS StopUserImportJobResponse
$creadsPrec :: Int -> ReadS StopUserImportJobResponse
Prelude.Read, Int -> StopUserImportJobResponse -> ShowS
[StopUserImportJobResponse] -> ShowS
StopUserImportJobResponse -> String
(Int -> StopUserImportJobResponse -> ShowS)
-> (StopUserImportJobResponse -> String)
-> ([StopUserImportJobResponse] -> ShowS)
-> Show StopUserImportJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopUserImportJobResponse] -> ShowS
$cshowList :: [StopUserImportJobResponse] -> ShowS
show :: StopUserImportJobResponse -> String
$cshow :: StopUserImportJobResponse -> String
showsPrec :: Int -> StopUserImportJobResponse -> ShowS
$cshowsPrec :: Int -> StopUserImportJobResponse -> ShowS
Prelude.Show, (forall x.
 StopUserImportJobResponse -> Rep StopUserImportJobResponse x)
-> (forall x.
    Rep StopUserImportJobResponse x -> StopUserImportJobResponse)
-> Generic StopUserImportJobResponse
forall x.
Rep StopUserImportJobResponse x -> StopUserImportJobResponse
forall x.
StopUserImportJobResponse -> Rep StopUserImportJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopUserImportJobResponse x -> StopUserImportJobResponse
$cfrom :: forall x.
StopUserImportJobResponse -> Rep StopUserImportJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopUserImportJobResponse' 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:
--
-- 'userImportJob', 'stopUserImportJobResponse_userImportJob' - The job object that represents the user import job.
--
-- 'httpStatus', 'stopUserImportJobResponse_httpStatus' - The response's http status code.
newStopUserImportJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopUserImportJobResponse
newStopUserImportJobResponse :: Int -> StopUserImportJobResponse
newStopUserImportJobResponse Int
pHttpStatus_ =
  StopUserImportJobResponse' :: Maybe UserImportJobType -> Int -> StopUserImportJobResponse
StopUserImportJobResponse'
    { $sel:userImportJob:StopUserImportJobResponse' :: Maybe UserImportJobType
userImportJob =
        Maybe UserImportJobType
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopUserImportJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The job object that represents the user import job.
stopUserImportJobResponse_userImportJob :: Lens.Lens' StopUserImportJobResponse (Prelude.Maybe UserImportJobType)
stopUserImportJobResponse_userImportJob :: (Maybe UserImportJobType -> f (Maybe UserImportJobType))
-> StopUserImportJobResponse -> f StopUserImportJobResponse
stopUserImportJobResponse_userImportJob = (StopUserImportJobResponse -> Maybe UserImportJobType)
-> (StopUserImportJobResponse
    -> Maybe UserImportJobType -> StopUserImportJobResponse)
-> Lens
     StopUserImportJobResponse
     StopUserImportJobResponse
     (Maybe UserImportJobType)
     (Maybe UserImportJobType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopUserImportJobResponse' {Maybe UserImportJobType
userImportJob :: Maybe UserImportJobType
$sel:userImportJob:StopUserImportJobResponse' :: StopUserImportJobResponse -> Maybe UserImportJobType
userImportJob} -> Maybe UserImportJobType
userImportJob) (\s :: StopUserImportJobResponse
s@StopUserImportJobResponse' {} Maybe UserImportJobType
a -> StopUserImportJobResponse
s {$sel:userImportJob:StopUserImportJobResponse' :: Maybe UserImportJobType
userImportJob = Maybe UserImportJobType
a} :: StopUserImportJobResponse)

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

instance Prelude.NFData StopUserImportJobResponse