{-# 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.GetCSVHeader
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the header information for the comma-separated value (CSV) file to
-- be used as input for the user import job.
module Amazonka.CognitoIdentityProvider.GetCSVHeader
  ( -- * Creating a Request
    GetCSVHeader (..),
    newGetCSVHeader,

    -- * Request Lenses
    getCSVHeader_userPoolId,

    -- * Destructuring the Response
    GetCSVHeaderResponse (..),
    newGetCSVHeaderResponse,

    -- * Response Lenses
    getCSVHeaderResponse_cSVHeader,
    getCSVHeaderResponse_userPoolId,
    getCSVHeaderResponse_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 get the header information of the CSV file for
-- the user import job.
--
-- /See:/ 'newGetCSVHeader' smart constructor.
data GetCSVHeader = GetCSVHeader'
  { -- | The user pool ID for the user pool that the users are to be imported
    -- into.
    GetCSVHeader -> Text
userPoolId :: Prelude.Text
  }
  deriving (GetCSVHeader -> GetCSVHeader -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCSVHeader -> GetCSVHeader -> Bool
$c/= :: GetCSVHeader -> GetCSVHeader -> Bool
== :: GetCSVHeader -> GetCSVHeader -> Bool
$c== :: GetCSVHeader -> GetCSVHeader -> Bool
Prelude.Eq, ReadPrec [GetCSVHeader]
ReadPrec GetCSVHeader
Int -> ReadS GetCSVHeader
ReadS [GetCSVHeader]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCSVHeader]
$creadListPrec :: ReadPrec [GetCSVHeader]
readPrec :: ReadPrec GetCSVHeader
$creadPrec :: ReadPrec GetCSVHeader
readList :: ReadS [GetCSVHeader]
$creadList :: ReadS [GetCSVHeader]
readsPrec :: Int -> ReadS GetCSVHeader
$creadsPrec :: Int -> ReadS GetCSVHeader
Prelude.Read, Int -> GetCSVHeader -> ShowS
[GetCSVHeader] -> ShowS
GetCSVHeader -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCSVHeader] -> ShowS
$cshowList :: [GetCSVHeader] -> ShowS
show :: GetCSVHeader -> String
$cshow :: GetCSVHeader -> String
showsPrec :: Int -> GetCSVHeader -> ShowS
$cshowsPrec :: Int -> GetCSVHeader -> ShowS
Prelude.Show, forall x. Rep GetCSVHeader x -> GetCSVHeader
forall x. GetCSVHeader -> Rep GetCSVHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCSVHeader x -> GetCSVHeader
$cfrom :: forall x. GetCSVHeader -> Rep GetCSVHeader x
Prelude.Generic)

-- |
-- Create a value of 'GetCSVHeader' 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', 'getCSVHeader_userPoolId' - The user pool ID for the user pool that the users are to be imported
-- into.
newGetCSVHeader ::
  -- | 'userPoolId'
  Prelude.Text ->
  GetCSVHeader
newGetCSVHeader :: Text -> GetCSVHeader
newGetCSVHeader Text
pUserPoolId_ =
  GetCSVHeader' {$sel:userPoolId:GetCSVHeader' :: Text
userPoolId = Text
pUserPoolId_}

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

instance Core.AWSRequest GetCSVHeader where
  type AWSResponse GetCSVHeader = GetCSVHeaderResponse
  request :: (Service -> Service) -> GetCSVHeader -> Request GetCSVHeader
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 GetCSVHeader
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCSVHeader)))
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 [Text] -> Maybe Text -> Int -> GetCSVHeaderResponse
GetCSVHeaderResponse'
            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
"CSVHeader" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"UserPoolId")
            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 GetCSVHeader where
  hashWithSalt :: Int -> GetCSVHeader -> Int
hashWithSalt Int
_salt GetCSVHeader' {Text
userPoolId :: Text
$sel:userPoolId:GetCSVHeader' :: GetCSVHeader -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userPoolId

instance Prelude.NFData GetCSVHeader where
  rnf :: GetCSVHeader -> ()
rnf GetCSVHeader' {Text
userPoolId :: Text
$sel:userPoolId:GetCSVHeader' :: GetCSVHeader -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
userPoolId

instance Data.ToHeaders GetCSVHeader where
  toHeaders :: GetCSVHeader -> 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.GetCSVHeader" ::
                          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 GetCSVHeader where
  toJSON :: GetCSVHeader -> Value
toJSON GetCSVHeader' {Text
userPoolId :: Text
$sel:userPoolId:GetCSVHeader' :: GetCSVHeader -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"UserPoolId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userPoolId)]
      )

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

instance Data.ToQuery GetCSVHeader where
  toQuery :: GetCSVHeader -> 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 get the header
-- information of the CSV file for the user import job.
--
-- /See:/ 'newGetCSVHeaderResponse' smart constructor.
data GetCSVHeaderResponse = GetCSVHeaderResponse'
  { -- | The header information of the CSV file for the user import job.
    GetCSVHeaderResponse -> Maybe [Text]
cSVHeader :: Prelude.Maybe [Prelude.Text],
    -- | The user pool ID for the user pool that the users are to be imported
    -- into.
    GetCSVHeaderResponse -> Maybe Text
userPoolId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetCSVHeaderResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetCSVHeaderResponse -> GetCSVHeaderResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCSVHeaderResponse -> GetCSVHeaderResponse -> Bool
$c/= :: GetCSVHeaderResponse -> GetCSVHeaderResponse -> Bool
== :: GetCSVHeaderResponse -> GetCSVHeaderResponse -> Bool
$c== :: GetCSVHeaderResponse -> GetCSVHeaderResponse -> Bool
Prelude.Eq, ReadPrec [GetCSVHeaderResponse]
ReadPrec GetCSVHeaderResponse
Int -> ReadS GetCSVHeaderResponse
ReadS [GetCSVHeaderResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCSVHeaderResponse]
$creadListPrec :: ReadPrec [GetCSVHeaderResponse]
readPrec :: ReadPrec GetCSVHeaderResponse
$creadPrec :: ReadPrec GetCSVHeaderResponse
readList :: ReadS [GetCSVHeaderResponse]
$creadList :: ReadS [GetCSVHeaderResponse]
readsPrec :: Int -> ReadS GetCSVHeaderResponse
$creadsPrec :: Int -> ReadS GetCSVHeaderResponse
Prelude.Read, Int -> GetCSVHeaderResponse -> ShowS
[GetCSVHeaderResponse] -> ShowS
GetCSVHeaderResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCSVHeaderResponse] -> ShowS
$cshowList :: [GetCSVHeaderResponse] -> ShowS
show :: GetCSVHeaderResponse -> String
$cshow :: GetCSVHeaderResponse -> String
showsPrec :: Int -> GetCSVHeaderResponse -> ShowS
$cshowsPrec :: Int -> GetCSVHeaderResponse -> ShowS
Prelude.Show, forall x. Rep GetCSVHeaderResponse x -> GetCSVHeaderResponse
forall x. GetCSVHeaderResponse -> Rep GetCSVHeaderResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCSVHeaderResponse x -> GetCSVHeaderResponse
$cfrom :: forall x. GetCSVHeaderResponse -> Rep GetCSVHeaderResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetCSVHeaderResponse' 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:
--
-- 'cSVHeader', 'getCSVHeaderResponse_cSVHeader' - The header information of the CSV file for the user import job.
--
-- 'userPoolId', 'getCSVHeaderResponse_userPoolId' - The user pool ID for the user pool that the users are to be imported
-- into.
--
-- 'httpStatus', 'getCSVHeaderResponse_httpStatus' - The response's http status code.
newGetCSVHeaderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCSVHeaderResponse
newGetCSVHeaderResponse :: Int -> GetCSVHeaderResponse
newGetCSVHeaderResponse Int
pHttpStatus_ =
  GetCSVHeaderResponse'
    { $sel:cSVHeader:GetCSVHeaderResponse' :: Maybe [Text]
cSVHeader = forall a. Maybe a
Prelude.Nothing,
      $sel:userPoolId:GetCSVHeaderResponse' :: Maybe Text
userPoolId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCSVHeaderResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The header information of the CSV file for the user import job.
getCSVHeaderResponse_cSVHeader :: Lens.Lens' GetCSVHeaderResponse (Prelude.Maybe [Prelude.Text])
getCSVHeaderResponse_cSVHeader :: Lens' GetCSVHeaderResponse (Maybe [Text])
getCSVHeaderResponse_cSVHeader = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCSVHeaderResponse' {Maybe [Text]
cSVHeader :: Maybe [Text]
$sel:cSVHeader:GetCSVHeaderResponse' :: GetCSVHeaderResponse -> Maybe [Text]
cSVHeader} -> Maybe [Text]
cSVHeader) (\s :: GetCSVHeaderResponse
s@GetCSVHeaderResponse' {} Maybe [Text]
a -> GetCSVHeaderResponse
s {$sel:cSVHeader:GetCSVHeaderResponse' :: Maybe [Text]
cSVHeader = Maybe [Text]
a} :: GetCSVHeaderResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData GetCSVHeaderResponse where
  rnf :: GetCSVHeaderResponse -> ()
rnf GetCSVHeaderResponse' {Int
Maybe [Text]
Maybe Text
httpStatus :: Int
userPoolId :: Maybe Text
cSVHeader :: Maybe [Text]
$sel:httpStatus:GetCSVHeaderResponse' :: GetCSVHeaderResponse -> Int
$sel:userPoolId:GetCSVHeaderResponse' :: GetCSVHeaderResponse -> Maybe Text
$sel:cSVHeader:GetCSVHeaderResponse' :: GetCSVHeaderResponse -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
cSVHeader
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userPoolId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus