{-# 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.Pinpoint.GetImportJobs
-- 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)
--
-- Retrieves information about the status and settings of all the import
-- jobs for an application.
module Amazonka.Pinpoint.GetImportJobs
  ( -- * Creating a Request
    GetImportJobs (..),
    newGetImportJobs,

    -- * Request Lenses
    getImportJobs_token,
    getImportJobs_pageSize,
    getImportJobs_applicationId,

    -- * Destructuring the Response
    GetImportJobsResponse (..),
    newGetImportJobsResponse,

    -- * Response Lenses
    getImportJobsResponse_httpStatus,
    getImportJobsResponse_importJobsResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetImportJobs' smart constructor.
data GetImportJobs = GetImportJobs'
  { -- | The NextToken string that specifies which page of results to return in a
    -- paginated response.
    GetImportJobs -> Maybe Text
token :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to include in each page of a paginated
    -- response. This parameter is not supported for application, campaign, and
    -- journey metrics.
    GetImportJobs -> Maybe Text
pageSize :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    GetImportJobs -> Text
applicationId :: Prelude.Text
  }
  deriving (GetImportJobs -> GetImportJobs -> Bool
(GetImportJobs -> GetImportJobs -> Bool)
-> (GetImportJobs -> GetImportJobs -> Bool) -> Eq GetImportJobs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetImportJobs -> GetImportJobs -> Bool
$c/= :: GetImportJobs -> GetImportJobs -> Bool
== :: GetImportJobs -> GetImportJobs -> Bool
$c== :: GetImportJobs -> GetImportJobs -> Bool
Prelude.Eq, ReadPrec [GetImportJobs]
ReadPrec GetImportJobs
Int -> ReadS GetImportJobs
ReadS [GetImportJobs]
(Int -> ReadS GetImportJobs)
-> ReadS [GetImportJobs]
-> ReadPrec GetImportJobs
-> ReadPrec [GetImportJobs]
-> Read GetImportJobs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetImportJobs]
$creadListPrec :: ReadPrec [GetImportJobs]
readPrec :: ReadPrec GetImportJobs
$creadPrec :: ReadPrec GetImportJobs
readList :: ReadS [GetImportJobs]
$creadList :: ReadS [GetImportJobs]
readsPrec :: Int -> ReadS GetImportJobs
$creadsPrec :: Int -> ReadS GetImportJobs
Prelude.Read, Int -> GetImportJobs -> ShowS
[GetImportJobs] -> ShowS
GetImportJobs -> String
(Int -> GetImportJobs -> ShowS)
-> (GetImportJobs -> String)
-> ([GetImportJobs] -> ShowS)
-> Show GetImportJobs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetImportJobs] -> ShowS
$cshowList :: [GetImportJobs] -> ShowS
show :: GetImportJobs -> String
$cshow :: GetImportJobs -> String
showsPrec :: Int -> GetImportJobs -> ShowS
$cshowsPrec :: Int -> GetImportJobs -> ShowS
Prelude.Show, (forall x. GetImportJobs -> Rep GetImportJobs x)
-> (forall x. Rep GetImportJobs x -> GetImportJobs)
-> Generic GetImportJobs
forall x. Rep GetImportJobs x -> GetImportJobs
forall x. GetImportJobs -> Rep GetImportJobs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetImportJobs x -> GetImportJobs
$cfrom :: forall x. GetImportJobs -> Rep GetImportJobs x
Prelude.Generic)

-- |
-- Create a value of 'GetImportJobs' 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:
--
-- 'token', 'getImportJobs_token' - The NextToken string that specifies which page of results to return in a
-- paginated response.
--
-- 'pageSize', 'getImportJobs_pageSize' - The maximum number of items to include in each page of a paginated
-- response. This parameter is not supported for application, campaign, and
-- journey metrics.
--
-- 'applicationId', 'getImportJobs_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newGetImportJobs ::
  -- | 'applicationId'
  Prelude.Text ->
  GetImportJobs
newGetImportJobs :: Text -> GetImportJobs
newGetImportJobs Text
pApplicationId_ =
  GetImportJobs' :: Maybe Text -> Maybe Text -> Text -> GetImportJobs
GetImportJobs'
    { $sel:token:GetImportJobs' :: Maybe Text
token = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:GetImportJobs' :: Maybe Text
pageSize = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:GetImportJobs' :: Text
applicationId = Text
pApplicationId_
    }

-- | The NextToken string that specifies which page of results to return in a
-- paginated response.
getImportJobs_token :: Lens.Lens' GetImportJobs (Prelude.Maybe Prelude.Text)
getImportJobs_token :: (Maybe Text -> f (Maybe Text)) -> GetImportJobs -> f GetImportJobs
getImportJobs_token = (GetImportJobs -> Maybe Text)
-> (GetImportJobs -> Maybe Text -> GetImportJobs)
-> Lens GetImportJobs GetImportJobs (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetImportJobs' {Maybe Text
token :: Maybe Text
$sel:token:GetImportJobs' :: GetImportJobs -> Maybe Text
token} -> Maybe Text
token) (\s :: GetImportJobs
s@GetImportJobs' {} Maybe Text
a -> GetImportJobs
s {$sel:token:GetImportJobs' :: Maybe Text
token = Maybe Text
a} :: GetImportJobs)

-- | The maximum number of items to include in each page of a paginated
-- response. This parameter is not supported for application, campaign, and
-- journey metrics.
getImportJobs_pageSize :: Lens.Lens' GetImportJobs (Prelude.Maybe Prelude.Text)
getImportJobs_pageSize :: (Maybe Text -> f (Maybe Text)) -> GetImportJobs -> f GetImportJobs
getImportJobs_pageSize = (GetImportJobs -> Maybe Text)
-> (GetImportJobs -> Maybe Text -> GetImportJobs)
-> Lens GetImportJobs GetImportJobs (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetImportJobs' {Maybe Text
pageSize :: Maybe Text
$sel:pageSize:GetImportJobs' :: GetImportJobs -> Maybe Text
pageSize} -> Maybe Text
pageSize) (\s :: GetImportJobs
s@GetImportJobs' {} Maybe Text
a -> GetImportJobs
s {$sel:pageSize:GetImportJobs' :: Maybe Text
pageSize = Maybe Text
a} :: GetImportJobs)

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
getImportJobs_applicationId :: Lens.Lens' GetImportJobs Prelude.Text
getImportJobs_applicationId :: (Text -> f Text) -> GetImportJobs -> f GetImportJobs
getImportJobs_applicationId = (GetImportJobs -> Text)
-> (GetImportJobs -> Text -> GetImportJobs)
-> Lens GetImportJobs GetImportJobs Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetImportJobs' {Text
applicationId :: Text
$sel:applicationId:GetImportJobs' :: GetImportJobs -> Text
applicationId} -> Text
applicationId) (\s :: GetImportJobs
s@GetImportJobs' {} Text
a -> GetImportJobs
s {$sel:applicationId:GetImportJobs' :: Text
applicationId = Text
a} :: GetImportJobs)

instance Core.AWSRequest GetImportJobs where
  type
    AWSResponse GetImportJobs =
      GetImportJobsResponse
  request :: GetImportJobs -> Request GetImportJobs
request = Service -> GetImportJobs -> Request GetImportJobs
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetImportJobs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetImportJobs)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetImportJobs))
-> Logger
-> Service
-> Proxy GetImportJobs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetImportJobs)))
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 ->
          Int -> ImportJobsResponse -> GetImportJobsResponse
GetImportJobsResponse'
            (Int -> ImportJobsResponse -> GetImportJobsResponse)
-> Either String Int
-> Either String (ImportJobsResponse -> GetImportJobsResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (ImportJobsResponse -> GetImportJobsResponse)
-> Either String ImportJobsResponse
-> Either String GetImportJobsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String ImportJobsResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable GetImportJobs

instance Prelude.NFData GetImportJobs

instance Core.ToHeaders GetImportJobs where
  toHeaders :: GetImportJobs -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetImportJobs -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetImportJobs where
  toPath :: GetImportJobs -> ByteString
toPath GetImportJobs' {Maybe Text
Text
applicationId :: Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:applicationId:GetImportJobs' :: GetImportJobs -> Text
$sel:pageSize:GetImportJobs' :: GetImportJobs -> Maybe Text
$sel:token:GetImportJobs' :: GetImportJobs -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/jobs/import"
      ]

instance Core.ToQuery GetImportJobs where
  toQuery :: GetImportJobs -> QueryString
toQuery GetImportJobs' {Maybe Text
Text
applicationId :: Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:applicationId:GetImportJobs' :: GetImportJobs -> Text
$sel:pageSize:GetImportJobs' :: GetImportJobs -> Maybe Text
$sel:token:GetImportJobs' :: GetImportJobs -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"token" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
token, ByteString
"page-size" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
pageSize]

-- | /See:/ 'newGetImportJobsResponse' smart constructor.
data GetImportJobsResponse = GetImportJobsResponse'
  { -- | The response's http status code.
    GetImportJobsResponse -> Int
httpStatus :: Prelude.Int,
    GetImportJobsResponse -> ImportJobsResponse
importJobsResponse :: ImportJobsResponse
  }
  deriving (GetImportJobsResponse -> GetImportJobsResponse -> Bool
(GetImportJobsResponse -> GetImportJobsResponse -> Bool)
-> (GetImportJobsResponse -> GetImportJobsResponse -> Bool)
-> Eq GetImportJobsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetImportJobsResponse -> GetImportJobsResponse -> Bool
$c/= :: GetImportJobsResponse -> GetImportJobsResponse -> Bool
== :: GetImportJobsResponse -> GetImportJobsResponse -> Bool
$c== :: GetImportJobsResponse -> GetImportJobsResponse -> Bool
Prelude.Eq, ReadPrec [GetImportJobsResponse]
ReadPrec GetImportJobsResponse
Int -> ReadS GetImportJobsResponse
ReadS [GetImportJobsResponse]
(Int -> ReadS GetImportJobsResponse)
-> ReadS [GetImportJobsResponse]
-> ReadPrec GetImportJobsResponse
-> ReadPrec [GetImportJobsResponse]
-> Read GetImportJobsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetImportJobsResponse]
$creadListPrec :: ReadPrec [GetImportJobsResponse]
readPrec :: ReadPrec GetImportJobsResponse
$creadPrec :: ReadPrec GetImportJobsResponse
readList :: ReadS [GetImportJobsResponse]
$creadList :: ReadS [GetImportJobsResponse]
readsPrec :: Int -> ReadS GetImportJobsResponse
$creadsPrec :: Int -> ReadS GetImportJobsResponse
Prelude.Read, Int -> GetImportJobsResponse -> ShowS
[GetImportJobsResponse] -> ShowS
GetImportJobsResponse -> String
(Int -> GetImportJobsResponse -> ShowS)
-> (GetImportJobsResponse -> String)
-> ([GetImportJobsResponse] -> ShowS)
-> Show GetImportJobsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetImportJobsResponse] -> ShowS
$cshowList :: [GetImportJobsResponse] -> ShowS
show :: GetImportJobsResponse -> String
$cshow :: GetImportJobsResponse -> String
showsPrec :: Int -> GetImportJobsResponse -> ShowS
$cshowsPrec :: Int -> GetImportJobsResponse -> ShowS
Prelude.Show, (forall x. GetImportJobsResponse -> Rep GetImportJobsResponse x)
-> (forall x. Rep GetImportJobsResponse x -> GetImportJobsResponse)
-> Generic GetImportJobsResponse
forall x. Rep GetImportJobsResponse x -> GetImportJobsResponse
forall x. GetImportJobsResponse -> Rep GetImportJobsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetImportJobsResponse x -> GetImportJobsResponse
$cfrom :: forall x. GetImportJobsResponse -> Rep GetImportJobsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetImportJobsResponse' 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:
--
-- 'httpStatus', 'getImportJobsResponse_httpStatus' - The response's http status code.
--
-- 'importJobsResponse', 'getImportJobsResponse_importJobsResponse' - Undocumented member.
newGetImportJobsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'importJobsResponse'
  ImportJobsResponse ->
  GetImportJobsResponse
newGetImportJobsResponse :: Int -> ImportJobsResponse -> GetImportJobsResponse
newGetImportJobsResponse
  Int
pHttpStatus_
  ImportJobsResponse
pImportJobsResponse_ =
    GetImportJobsResponse' :: Int -> ImportJobsResponse -> GetImportJobsResponse
GetImportJobsResponse'
      { $sel:httpStatus:GetImportJobsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:importJobsResponse:GetImportJobsResponse' :: ImportJobsResponse
importJobsResponse = ImportJobsResponse
pImportJobsResponse_
      }

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

-- | Undocumented member.
getImportJobsResponse_importJobsResponse :: Lens.Lens' GetImportJobsResponse ImportJobsResponse
getImportJobsResponse_importJobsResponse :: (ImportJobsResponse -> f ImportJobsResponse)
-> GetImportJobsResponse -> f GetImportJobsResponse
getImportJobsResponse_importJobsResponse = (GetImportJobsResponse -> ImportJobsResponse)
-> (GetImportJobsResponse
    -> ImportJobsResponse -> GetImportJobsResponse)
-> Lens
     GetImportJobsResponse
     GetImportJobsResponse
     ImportJobsResponse
     ImportJobsResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetImportJobsResponse' {ImportJobsResponse
importJobsResponse :: ImportJobsResponse
$sel:importJobsResponse:GetImportJobsResponse' :: GetImportJobsResponse -> ImportJobsResponse
importJobsResponse} -> ImportJobsResponse
importJobsResponse) (\s :: GetImportJobsResponse
s@GetImportJobsResponse' {} ImportJobsResponse
a -> GetImportJobsResponse
s {$sel:importJobsResponse:GetImportJobsResponse' :: ImportJobsResponse
importJobsResponse = ImportJobsResponse
a} :: GetImportJobsResponse)

instance Prelude.NFData GetImportJobsResponse