{-# 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-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)
--
-- 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.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 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 Logging role for the user import
    -- job.
    CreateUserImportJob -> Text
cloudWatchLogsRoleArn :: Prelude.Text
  }
  deriving (CreateUserImportJob -> CreateUserImportJob -> Bool
(CreateUserImportJob -> CreateUserImportJob -> Bool)
-> (CreateUserImportJob -> CreateUserImportJob -> Bool)
-> Eq CreateUserImportJob
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]
(Int -> ReadS CreateUserImportJob)
-> ReadS [CreateUserImportJob]
-> ReadPrec CreateUserImportJob
-> ReadPrec [CreateUserImportJob]
-> Read 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
(Int -> CreateUserImportJob -> ShowS)
-> (CreateUserImportJob -> String)
-> ([CreateUserImportJob] -> ShowS)
-> Show CreateUserImportJob
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. CreateUserImportJob -> Rep CreateUserImportJob x)
-> (forall x. Rep CreateUserImportJob x -> CreateUserImportJob)
-> Generic CreateUserImportJob
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 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' :: Text -> Text -> Text -> CreateUserImportJob
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 :: (Text -> f Text) -> CreateUserImportJob -> f CreateUserImportJob
createUserImportJob_jobName = (CreateUserImportJob -> Text)
-> (CreateUserImportJob -> Text -> CreateUserImportJob)
-> Lens CreateUserImportJob CreateUserImportJob Text Text
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 :: (Text -> f Text) -> CreateUserImportJob -> f CreateUserImportJob
createUserImportJob_userPoolId = (CreateUserImportJob -> Text)
-> (CreateUserImportJob -> Text -> CreateUserImportJob)
-> Lens CreateUserImportJob CreateUserImportJob Text Text
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 Logging role for the user import
-- job.
createUserImportJob_cloudWatchLogsRoleArn :: Lens.Lens' CreateUserImportJob Prelude.Text
createUserImportJob_cloudWatchLogsRoleArn :: (Text -> f Text) -> CreateUserImportJob -> f CreateUserImportJob
createUserImportJob_cloudWatchLogsRoleArn = (CreateUserImportJob -> Text)
-> (CreateUserImportJob -> Text -> CreateUserImportJob)
-> Lens CreateUserImportJob CreateUserImportJob Text Text
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 :: CreateUserImportJob -> Request CreateUserImportJob
request = Service -> CreateUserImportJob -> Request CreateUserImportJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateUserImportJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateUserImportJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateUserImportJob))
-> Logger
-> Service
-> Proxy CreateUserImportJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateUserImportJob)))
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 -> CreateUserImportJobResponse
CreateUserImportJobResponse'
            (Maybe UserImportJobType -> Int -> CreateUserImportJobResponse)
-> Either String (Maybe UserImportJobType)
-> Either String (Int -> CreateUserImportJobResponse)
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 -> CreateUserImportJobResponse)
-> Either String Int -> Either String CreateUserImportJobResponse
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 CreateUserImportJob

instance Prelude.NFData CreateUserImportJob

instance Core.ToHeaders CreateUserImportJob where
  toHeaders :: CreateUserImportJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateUserImportJob -> 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.CreateUserImportJob" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"JobName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jobName),
            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
"CloudWatchLogsRoleArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
cloudWatchLogsRoleArn
              )
          ]
      )

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

instance Core.ToQuery CreateUserImportJob where
  toQuery :: CreateUserImportJob -> QueryString
toQuery = QueryString -> CreateUserImportJob -> 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 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
(CreateUserImportJobResponse
 -> CreateUserImportJobResponse -> Bool)
-> (CreateUserImportJobResponse
    -> CreateUserImportJobResponse -> Bool)
-> Eq CreateUserImportJobResponse
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]
(Int -> ReadS CreateUserImportJobResponse)
-> ReadS [CreateUserImportJobResponse]
-> ReadPrec CreateUserImportJobResponse
-> ReadPrec [CreateUserImportJobResponse]
-> Read 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
(Int -> CreateUserImportJobResponse -> ShowS)
-> (CreateUserImportJobResponse -> String)
-> ([CreateUserImportJobResponse] -> ShowS)
-> Show CreateUserImportJobResponse
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.
 CreateUserImportJobResponse -> Rep CreateUserImportJobResponse x)
-> (forall x.
    Rep CreateUserImportJobResponse x -> CreateUserImportJobResponse)
-> Generic CreateUserImportJobResponse
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' :: Maybe UserImportJobType -> Int -> CreateUserImportJobResponse
CreateUserImportJobResponse'
    { $sel:userImportJob:CreateUserImportJobResponse' :: Maybe UserImportJobType
userImportJob =
        Maybe UserImportJobType
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 :: (Maybe UserImportJobType -> f (Maybe UserImportJobType))
-> CreateUserImportJobResponse -> f CreateUserImportJobResponse
createUserImportJobResponse_userImportJob = (CreateUserImportJobResponse -> Maybe UserImportJobType)
-> (CreateUserImportJobResponse
    -> Maybe UserImportJobType -> CreateUserImportJobResponse)
-> Lens
     CreateUserImportJobResponse
     CreateUserImportJobResponse
     (Maybe UserImportJobType)
     (Maybe UserImportJobType)
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 :: (Int -> f Int)
-> CreateUserImportJobResponse -> f CreateUserImportJobResponse
createUserImportJobResponse_httpStatus = (CreateUserImportJobResponse -> Int)
-> (CreateUserImportJobResponse
    -> Int -> CreateUserImportJobResponse)
-> Lens
     CreateUserImportJobResponse CreateUserImportJobResponse Int Int
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