{-# 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.CreateUserImportJob
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates the user import job.
module Amazonka.CognitoIdentityProvider.CreateUserImportJob
  ( -- * Creating a Request
    CreateUserImportJob (..),
    newCreateUserImportJob,

    -- * Request Lenses
    createUserImportJob_jobName,
    createUserImportJob_userPoolId,
    createUserImportJob_cloudWatchLogsRoleArn,

    -- * Destructuring the Response
    CreateUserImportJobResponse (..),
    newCreateUserImportJobResponse,

    -- * Response Lenses
    createUserImportJobResponse_userImportJob,
    createUserImportJobResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'CreateUserImportJob' 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:
--
-- 'jobName', 'createUserImportJob_jobName' - The job name for the user import job.
--
-- 'userPoolId', 'createUserImportJob_userPoolId' - The user pool ID for the user pool that the users are being imported
-- into.
--
-- 'cloudWatchLogsRoleArn', 'createUserImportJob_cloudWatchLogsRoleArn' - The role ARN for the Amazon CloudWatch Logs Logging role for the user
-- import job.
newCreateUserImportJob ::
  -- | 'jobName'
  Prelude.Text ->
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'cloudWatchLogsRoleArn'
  Prelude.Text ->
  CreateUserImportJob
newCreateUserImportJob :: Text -> Text -> Text -> CreateUserImportJob
newCreateUserImportJob
  Text
pJobName_
  Text
pUserPoolId_
  Text
pCloudWatchLogsRoleArn_ =
    CreateUserImportJob'
      { $sel:jobName:CreateUserImportJob' :: Text
jobName = Text
pJobName_,
        $sel:userPoolId:CreateUserImportJob' :: Text
userPoolId = Text
pUserPoolId_,
        $sel:cloudWatchLogsRoleArn:CreateUserImportJob' :: Text
cloudWatchLogsRoleArn = Text
pCloudWatchLogsRoleArn_
      }

-- | The job name for the user import job.
createUserImportJob_jobName :: Lens.Lens' CreateUserImportJob Prelude.Text
createUserImportJob_jobName :: Lens' CreateUserImportJob Text
createUserImportJob_jobName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUserImportJob' {Text
jobName :: Text
$sel:jobName:CreateUserImportJob' :: CreateUserImportJob -> Text
jobName} -> Text
jobName) (\s :: CreateUserImportJob
s@CreateUserImportJob' {} Text
a -> CreateUserImportJob
s {$sel:jobName:CreateUserImportJob' :: Text
jobName = Text
a} :: CreateUserImportJob)

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

-- | The role ARN for the Amazon CloudWatch Logs Logging role for the user
-- import job.
createUserImportJob_cloudWatchLogsRoleArn :: Lens.Lens' CreateUserImportJob Prelude.Text
createUserImportJob_cloudWatchLogsRoleArn :: Lens' CreateUserImportJob Text
createUserImportJob_cloudWatchLogsRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUserImportJob' {Text
cloudWatchLogsRoleArn :: Text
$sel:cloudWatchLogsRoleArn:CreateUserImportJob' :: CreateUserImportJob -> Text
cloudWatchLogsRoleArn} -> Text
cloudWatchLogsRoleArn) (\s :: CreateUserImportJob
s@CreateUserImportJob' {} Text
a -> CreateUserImportJob
s {$sel:cloudWatchLogsRoleArn:CreateUserImportJob' :: Text
cloudWatchLogsRoleArn = Text
a} :: CreateUserImportJob)

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

instance Prelude.Hashable CreateUserImportJob where
  hashWithSalt :: Int -> CreateUserImportJob -> Int
hashWithSalt Int
_salt CreateUserImportJob' {Text
cloudWatchLogsRoleArn :: Text
userPoolId :: Text
jobName :: Text
$sel:cloudWatchLogsRoleArn:CreateUserImportJob' :: CreateUserImportJob -> Text
$sel:userPoolId:CreateUserImportJob' :: CreateUserImportJob -> Text
$sel:jobName:CreateUserImportJob' :: CreateUserImportJob -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jobName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userPoolId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
cloudWatchLogsRoleArn

instance Prelude.NFData CreateUserImportJob where
  rnf :: CreateUserImportJob -> ()
rnf CreateUserImportJob' {Text
cloudWatchLogsRoleArn :: Text
userPoolId :: Text
jobName :: Text
$sel:cloudWatchLogsRoleArn:CreateUserImportJob' :: CreateUserImportJob -> Text
$sel:userPoolId:CreateUserImportJob' :: CreateUserImportJob -> Text
$sel:jobName:CreateUserImportJob' :: CreateUserImportJob -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
jobName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userPoolId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
cloudWatchLogsRoleArn

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

instance Data.ToJSON CreateUserImportJob where
  toJSON :: CreateUserImportJob -> Value
toJSON CreateUserImportJob' {Text
cloudWatchLogsRoleArn :: Text
userPoolId :: Text
jobName :: Text
$sel:cloudWatchLogsRoleArn:CreateUserImportJob' :: CreateUserImportJob -> Text
$sel:userPoolId:CreateUserImportJob' :: CreateUserImportJob -> Text
$sel:jobName:CreateUserImportJob' :: CreateUserImportJob -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"JobName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
jobName),
            forall a. a -> Maybe a
Prelude.Just (Key
"UserPoolId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userPoolId),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"CloudWatchLogsRoleArn"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
cloudWatchLogsRoleArn
              )
          ]
      )

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

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

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

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

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

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

instance Prelude.NFData CreateUserImportJobResponse where
  rnf :: CreateUserImportJobResponse -> ()
rnf CreateUserImportJobResponse' {Int
Maybe UserImportJobType
httpStatus :: Int
userImportJob :: Maybe UserImportJobType
$sel:httpStatus:CreateUserImportJobResponse' :: CreateUserImportJobResponse -> Int
$sel:userImportJob:CreateUserImportJobResponse' :: CreateUserImportJobResponse -> Maybe UserImportJobType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe UserImportJobType
userImportJob
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus