{-# 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.MigrationHubStrategy.ListImportFileTask
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a list of all the imports performed.
--
-- This operation returns paginated results.
module Amazonka.MigrationHubStrategy.ListImportFileTask
  ( -- * Creating a Request
    ListImportFileTask (..),
    newListImportFileTask,

    -- * Request Lenses
    listImportFileTask_maxResults,
    listImportFileTask_nextToken,

    -- * Destructuring the Response
    ListImportFileTaskResponse (..),
    newListImportFileTaskResponse,

    -- * Response Lenses
    listImportFileTaskResponse_nextToken,
    listImportFileTaskResponse_taskInfos,
    listImportFileTaskResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MigrationHubStrategy.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListImportFileTask' smart constructor.
data ListImportFileTask = ListImportFileTask'
  { -- | The total number of items to return. The maximum value is 100.
    ListImportFileTask -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The token from a previous call that you use to retrieve the next set of
    -- results. For example, if a previous call to this action returned 100
    -- items, but you set @maxResults@ to 10. You\'ll receive a set of 10
    -- results along with a token. You then use the returned token to retrieve
    -- the next set of 10.
    ListImportFileTask -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListImportFileTask -> ListImportFileTask -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListImportFileTask -> ListImportFileTask -> Bool
$c/= :: ListImportFileTask -> ListImportFileTask -> Bool
== :: ListImportFileTask -> ListImportFileTask -> Bool
$c== :: ListImportFileTask -> ListImportFileTask -> Bool
Prelude.Eq, ReadPrec [ListImportFileTask]
ReadPrec ListImportFileTask
Int -> ReadS ListImportFileTask
ReadS [ListImportFileTask]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListImportFileTask]
$creadListPrec :: ReadPrec [ListImportFileTask]
readPrec :: ReadPrec ListImportFileTask
$creadPrec :: ReadPrec ListImportFileTask
readList :: ReadS [ListImportFileTask]
$creadList :: ReadS [ListImportFileTask]
readsPrec :: Int -> ReadS ListImportFileTask
$creadsPrec :: Int -> ReadS ListImportFileTask
Prelude.Read, Int -> ListImportFileTask -> ShowS
[ListImportFileTask] -> ShowS
ListImportFileTask -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListImportFileTask] -> ShowS
$cshowList :: [ListImportFileTask] -> ShowS
show :: ListImportFileTask -> String
$cshow :: ListImportFileTask -> String
showsPrec :: Int -> ListImportFileTask -> ShowS
$cshowsPrec :: Int -> ListImportFileTask -> ShowS
Prelude.Show, forall x. Rep ListImportFileTask x -> ListImportFileTask
forall x. ListImportFileTask -> Rep ListImportFileTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListImportFileTask x -> ListImportFileTask
$cfrom :: forall x. ListImportFileTask -> Rep ListImportFileTask x
Prelude.Generic)

-- |
-- Create a value of 'ListImportFileTask' 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:
--
-- 'maxResults', 'listImportFileTask_maxResults' - The total number of items to return. The maximum value is 100.
--
-- 'nextToken', 'listImportFileTask_nextToken' - The token from a previous call that you use to retrieve the next set of
-- results. For example, if a previous call to this action returned 100
-- items, but you set @maxResults@ to 10. You\'ll receive a set of 10
-- results along with a token. You then use the returned token to retrieve
-- the next set of 10.
newListImportFileTask ::
  ListImportFileTask
newListImportFileTask :: ListImportFileTask
newListImportFileTask =
  ListImportFileTask'
    { $sel:maxResults:ListImportFileTask' :: Maybe Int
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListImportFileTask' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The total number of items to return. The maximum value is 100.
listImportFileTask_maxResults :: Lens.Lens' ListImportFileTask (Prelude.Maybe Prelude.Int)
listImportFileTask_maxResults :: Lens' ListImportFileTask (Maybe Int)
listImportFileTask_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImportFileTask' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:ListImportFileTask' :: ListImportFileTask -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: ListImportFileTask
s@ListImportFileTask' {} Maybe Int
a -> ListImportFileTask
s {$sel:maxResults:ListImportFileTask' :: Maybe Int
maxResults = Maybe Int
a} :: ListImportFileTask)

-- | The token from a previous call that you use to retrieve the next set of
-- results. For example, if a previous call to this action returned 100
-- items, but you set @maxResults@ to 10. You\'ll receive a set of 10
-- results along with a token. You then use the returned token to retrieve
-- the next set of 10.
listImportFileTask_nextToken :: Lens.Lens' ListImportFileTask (Prelude.Maybe Prelude.Text)
listImportFileTask_nextToken :: Lens' ListImportFileTask (Maybe Text)
listImportFileTask_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImportFileTask' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListImportFileTask' :: ListImportFileTask -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListImportFileTask
s@ListImportFileTask' {} Maybe Text
a -> ListImportFileTask
s {$sel:nextToken:ListImportFileTask' :: Maybe Text
nextToken = Maybe Text
a} :: ListImportFileTask)

instance Core.AWSPager ListImportFileTask where
  page :: ListImportFileTask
-> AWSResponse ListImportFileTask -> Maybe ListImportFileTask
page ListImportFileTask
rq AWSResponse ListImportFileTask
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListImportFileTask
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListImportFileTaskResponse (Maybe Text)
listImportFileTaskResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListImportFileTask
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens'
  ListImportFileTaskResponse (Maybe [ImportFileTaskInformation])
listImportFileTaskResponse_taskInfos
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListImportFileTask
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListImportFileTask (Maybe Text)
listImportFileTask_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListImportFileTask
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListImportFileTaskResponse (Maybe Text)
listImportFileTaskResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListImportFileTask where
  type
    AWSResponse ListImportFileTask =
      ListImportFileTaskResponse
  request :: (Service -> Service)
-> ListImportFileTask -> Request ListImportFileTask
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListImportFileTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListImportFileTask)))
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 [ImportFileTaskInformation]
-> Int
-> ListImportFileTaskResponse
ListImportFileTaskResponse'
            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
"nextToken")
            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
"taskInfos" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListImportFileTask where
  hashWithSalt :: Int -> ListImportFileTask -> Int
hashWithSalt Int
_salt ListImportFileTask' {Maybe Int
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Int
$sel:nextToken:ListImportFileTask' :: ListImportFileTask -> Maybe Text
$sel:maxResults:ListImportFileTask' :: ListImportFileTask -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListImportFileTask where
  rnf :: ListImportFileTask -> ()
rnf ListImportFileTask' {Maybe Int
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Int
$sel:nextToken:ListImportFileTask' :: ListImportFileTask -> Maybe Text
$sel:maxResults:ListImportFileTask' :: ListImportFileTask -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

instance Data.ToPath ListImportFileTask where
  toPath :: ListImportFileTask -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/list-import-file-task"

instance Data.ToQuery ListImportFileTask where
  toQuery :: ListImportFileTask -> QueryString
toQuery ListImportFileTask' {Maybe Int
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Int
$sel:nextToken:ListImportFileTask' :: ListImportFileTask -> Maybe Text
$sel:maxResults:ListImportFileTask' :: ListImportFileTask -> Maybe Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListImportFileTaskResponse' smart constructor.
data ListImportFileTaskResponse = ListImportFileTaskResponse'
  { -- | The token you use to retrieve the next set of results, or null if there
    -- are no more results.
    ListImportFileTaskResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Lists information about the files you import.
    ListImportFileTaskResponse -> Maybe [ImportFileTaskInformation]
taskInfos :: Prelude.Maybe [ImportFileTaskInformation],
    -- | The response's http status code.
    ListImportFileTaskResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListImportFileTaskResponse -> ListImportFileTaskResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListImportFileTaskResponse -> ListImportFileTaskResponse -> Bool
$c/= :: ListImportFileTaskResponse -> ListImportFileTaskResponse -> Bool
== :: ListImportFileTaskResponse -> ListImportFileTaskResponse -> Bool
$c== :: ListImportFileTaskResponse -> ListImportFileTaskResponse -> Bool
Prelude.Eq, ReadPrec [ListImportFileTaskResponse]
ReadPrec ListImportFileTaskResponse
Int -> ReadS ListImportFileTaskResponse
ReadS [ListImportFileTaskResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListImportFileTaskResponse]
$creadListPrec :: ReadPrec [ListImportFileTaskResponse]
readPrec :: ReadPrec ListImportFileTaskResponse
$creadPrec :: ReadPrec ListImportFileTaskResponse
readList :: ReadS [ListImportFileTaskResponse]
$creadList :: ReadS [ListImportFileTaskResponse]
readsPrec :: Int -> ReadS ListImportFileTaskResponse
$creadsPrec :: Int -> ReadS ListImportFileTaskResponse
Prelude.Read, Int -> ListImportFileTaskResponse -> ShowS
[ListImportFileTaskResponse] -> ShowS
ListImportFileTaskResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListImportFileTaskResponse] -> ShowS
$cshowList :: [ListImportFileTaskResponse] -> ShowS
show :: ListImportFileTaskResponse -> String
$cshow :: ListImportFileTaskResponse -> String
showsPrec :: Int -> ListImportFileTaskResponse -> ShowS
$cshowsPrec :: Int -> ListImportFileTaskResponse -> ShowS
Prelude.Show, forall x.
Rep ListImportFileTaskResponse x -> ListImportFileTaskResponse
forall x.
ListImportFileTaskResponse -> Rep ListImportFileTaskResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListImportFileTaskResponse x -> ListImportFileTaskResponse
$cfrom :: forall x.
ListImportFileTaskResponse -> Rep ListImportFileTaskResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListImportFileTaskResponse' 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:
--
-- 'nextToken', 'listImportFileTaskResponse_nextToken' - The token you use to retrieve the next set of results, or null if there
-- are no more results.
--
-- 'taskInfos', 'listImportFileTaskResponse_taskInfos' - Lists information about the files you import.
--
-- 'httpStatus', 'listImportFileTaskResponse_httpStatus' - The response's http status code.
newListImportFileTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListImportFileTaskResponse
newListImportFileTaskResponse :: Int -> ListImportFileTaskResponse
newListImportFileTaskResponse Int
pHttpStatus_ =
  ListImportFileTaskResponse'
    { $sel:nextToken:ListImportFileTaskResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:taskInfos:ListImportFileTaskResponse' :: Maybe [ImportFileTaskInformation]
taskInfos = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListImportFileTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token you use to retrieve the next set of results, or null if there
-- are no more results.
listImportFileTaskResponse_nextToken :: Lens.Lens' ListImportFileTaskResponse (Prelude.Maybe Prelude.Text)
listImportFileTaskResponse_nextToken :: Lens' ListImportFileTaskResponse (Maybe Text)
listImportFileTaskResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImportFileTaskResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListImportFileTaskResponse' :: ListImportFileTaskResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListImportFileTaskResponse
s@ListImportFileTaskResponse' {} Maybe Text
a -> ListImportFileTaskResponse
s {$sel:nextToken:ListImportFileTaskResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListImportFileTaskResponse)

-- | Lists information about the files you import.
listImportFileTaskResponse_taskInfos :: Lens.Lens' ListImportFileTaskResponse (Prelude.Maybe [ImportFileTaskInformation])
listImportFileTaskResponse_taskInfos :: Lens'
  ListImportFileTaskResponse (Maybe [ImportFileTaskInformation])
listImportFileTaskResponse_taskInfos = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImportFileTaskResponse' {Maybe [ImportFileTaskInformation]
taskInfos :: Maybe [ImportFileTaskInformation]
$sel:taskInfos:ListImportFileTaskResponse' :: ListImportFileTaskResponse -> Maybe [ImportFileTaskInformation]
taskInfos} -> Maybe [ImportFileTaskInformation]
taskInfos) (\s :: ListImportFileTaskResponse
s@ListImportFileTaskResponse' {} Maybe [ImportFileTaskInformation]
a -> ListImportFileTaskResponse
s {$sel:taskInfos:ListImportFileTaskResponse' :: Maybe [ImportFileTaskInformation]
taskInfos = Maybe [ImportFileTaskInformation]
a} :: ListImportFileTaskResponse) 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 response's http status code.
listImportFileTaskResponse_httpStatus :: Lens.Lens' ListImportFileTaskResponse Prelude.Int
listImportFileTaskResponse_httpStatus :: Lens' ListImportFileTaskResponse Int
listImportFileTaskResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImportFileTaskResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListImportFileTaskResponse' :: ListImportFileTaskResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListImportFileTaskResponse
s@ListImportFileTaskResponse' {} Int
a -> ListImportFileTaskResponse
s {$sel:httpStatus:ListImportFileTaskResponse' :: Int
httpStatus = Int
a} :: ListImportFileTaskResponse)

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