{-# 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.GetExportJobs
-- 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 export
-- jobs for an application.
module Amazonka.Pinpoint.GetExportJobs
  ( -- * Creating a Request
    GetExportJobs (..),
    newGetExportJobs,

    -- * Request Lenses
    getExportJobs_token,
    getExportJobs_pageSize,
    getExportJobs_applicationId,

    -- * Destructuring the Response
    GetExportJobsResponse (..),
    newGetExportJobsResponse,

    -- * Response Lenses
    getExportJobsResponse_httpStatus,
    getExportJobsResponse_exportJobsResponse,
  )
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:/ 'newGetExportJobs' smart constructor.
data GetExportJobs = GetExportJobs'
  { -- | The NextToken string that specifies which page of results to return in a
    -- paginated response.
    GetExportJobs -> 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.
    GetExportJobs -> 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.
    GetExportJobs -> Text
applicationId :: Prelude.Text
  }
  deriving (GetExportJobs -> GetExportJobs -> Bool
(GetExportJobs -> GetExportJobs -> Bool)
-> (GetExportJobs -> GetExportJobs -> Bool) -> Eq GetExportJobs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetExportJobs -> GetExportJobs -> Bool
$c/= :: GetExportJobs -> GetExportJobs -> Bool
== :: GetExportJobs -> GetExportJobs -> Bool
$c== :: GetExportJobs -> GetExportJobs -> Bool
Prelude.Eq, ReadPrec [GetExportJobs]
ReadPrec GetExportJobs
Int -> ReadS GetExportJobs
ReadS [GetExportJobs]
(Int -> ReadS GetExportJobs)
-> ReadS [GetExportJobs]
-> ReadPrec GetExportJobs
-> ReadPrec [GetExportJobs]
-> Read GetExportJobs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetExportJobs]
$creadListPrec :: ReadPrec [GetExportJobs]
readPrec :: ReadPrec GetExportJobs
$creadPrec :: ReadPrec GetExportJobs
readList :: ReadS [GetExportJobs]
$creadList :: ReadS [GetExportJobs]
readsPrec :: Int -> ReadS GetExportJobs
$creadsPrec :: Int -> ReadS GetExportJobs
Prelude.Read, Int -> GetExportJobs -> ShowS
[GetExportJobs] -> ShowS
GetExportJobs -> String
(Int -> GetExportJobs -> ShowS)
-> (GetExportJobs -> String)
-> ([GetExportJobs] -> ShowS)
-> Show GetExportJobs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetExportJobs] -> ShowS
$cshowList :: [GetExportJobs] -> ShowS
show :: GetExportJobs -> String
$cshow :: GetExportJobs -> String
showsPrec :: Int -> GetExportJobs -> ShowS
$cshowsPrec :: Int -> GetExportJobs -> ShowS
Prelude.Show, (forall x. GetExportJobs -> Rep GetExportJobs x)
-> (forall x. Rep GetExportJobs x -> GetExportJobs)
-> Generic GetExportJobs
forall x. Rep GetExportJobs x -> GetExportJobs
forall x. GetExportJobs -> Rep GetExportJobs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetExportJobs x -> GetExportJobs
$cfrom :: forall x. GetExportJobs -> Rep GetExportJobs x
Prelude.Generic)

-- |
-- Create a value of 'GetExportJobs' 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', 'getExportJobs_token' - The NextToken string that specifies which page of results to return in a
-- paginated response.
--
-- 'pageSize', 'getExportJobs_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', 'getExportJobs_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newGetExportJobs ::
  -- | 'applicationId'
  Prelude.Text ->
  GetExportJobs
newGetExportJobs :: Text -> GetExportJobs
newGetExportJobs Text
pApplicationId_ =
  GetExportJobs' :: Maybe Text -> Maybe Text -> Text -> GetExportJobs
GetExportJobs'
    { $sel:token:GetExportJobs' :: Maybe Text
token = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:GetExportJobs' :: Maybe Text
pageSize = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:GetExportJobs' :: Text
applicationId = Text
pApplicationId_
    }

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

-- | 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.
getExportJobs_pageSize :: Lens.Lens' GetExportJobs (Prelude.Maybe Prelude.Text)
getExportJobs_pageSize :: (Maybe Text -> f (Maybe Text)) -> GetExportJobs -> f GetExportJobs
getExportJobs_pageSize = (GetExportJobs -> Maybe Text)
-> (GetExportJobs -> Maybe Text -> GetExportJobs)
-> Lens GetExportJobs GetExportJobs (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExportJobs' {Maybe Text
pageSize :: Maybe Text
$sel:pageSize:GetExportJobs' :: GetExportJobs -> Maybe Text
pageSize} -> Maybe Text
pageSize) (\s :: GetExportJobs
s@GetExportJobs' {} Maybe Text
a -> GetExportJobs
s {$sel:pageSize:GetExportJobs' :: Maybe Text
pageSize = Maybe Text
a} :: GetExportJobs)

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

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

instance Prelude.Hashable GetExportJobs

instance Prelude.NFData GetExportJobs

instance Core.ToHeaders GetExportJobs where
  toHeaders :: GetExportJobs -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetExportJobs -> 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 GetExportJobs where
  toPath :: GetExportJobs -> ByteString
toPath GetExportJobs' {Maybe Text
Text
applicationId :: Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:applicationId:GetExportJobs' :: GetExportJobs -> Text
$sel:pageSize:GetExportJobs' :: GetExportJobs -> Maybe Text
$sel:token:GetExportJobs' :: GetExportJobs -> 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/export"
      ]

instance Core.ToQuery GetExportJobs where
  toQuery :: GetExportJobs -> QueryString
toQuery GetExportJobs' {Maybe Text
Text
applicationId :: Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:applicationId:GetExportJobs' :: GetExportJobs -> Text
$sel:pageSize:GetExportJobs' :: GetExportJobs -> Maybe Text
$sel:token:GetExportJobs' :: GetExportJobs -> 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:/ 'newGetExportJobsResponse' smart constructor.
data GetExportJobsResponse = GetExportJobsResponse'
  { -- | The response's http status code.
    GetExportJobsResponse -> Int
httpStatus :: Prelude.Int,
    GetExportJobsResponse -> ExportJobsResponse
exportJobsResponse :: ExportJobsResponse
  }
  deriving (GetExportJobsResponse -> GetExportJobsResponse -> Bool
(GetExportJobsResponse -> GetExportJobsResponse -> Bool)
-> (GetExportJobsResponse -> GetExportJobsResponse -> Bool)
-> Eq GetExportJobsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetExportJobsResponse -> GetExportJobsResponse -> Bool
$c/= :: GetExportJobsResponse -> GetExportJobsResponse -> Bool
== :: GetExportJobsResponse -> GetExportJobsResponse -> Bool
$c== :: GetExportJobsResponse -> GetExportJobsResponse -> Bool
Prelude.Eq, ReadPrec [GetExportJobsResponse]
ReadPrec GetExportJobsResponse
Int -> ReadS GetExportJobsResponse
ReadS [GetExportJobsResponse]
(Int -> ReadS GetExportJobsResponse)
-> ReadS [GetExportJobsResponse]
-> ReadPrec GetExportJobsResponse
-> ReadPrec [GetExportJobsResponse]
-> Read GetExportJobsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetExportJobsResponse]
$creadListPrec :: ReadPrec [GetExportJobsResponse]
readPrec :: ReadPrec GetExportJobsResponse
$creadPrec :: ReadPrec GetExportJobsResponse
readList :: ReadS [GetExportJobsResponse]
$creadList :: ReadS [GetExportJobsResponse]
readsPrec :: Int -> ReadS GetExportJobsResponse
$creadsPrec :: Int -> ReadS GetExportJobsResponse
Prelude.Read, Int -> GetExportJobsResponse -> ShowS
[GetExportJobsResponse] -> ShowS
GetExportJobsResponse -> String
(Int -> GetExportJobsResponse -> ShowS)
-> (GetExportJobsResponse -> String)
-> ([GetExportJobsResponse] -> ShowS)
-> Show GetExportJobsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetExportJobsResponse] -> ShowS
$cshowList :: [GetExportJobsResponse] -> ShowS
show :: GetExportJobsResponse -> String
$cshow :: GetExportJobsResponse -> String
showsPrec :: Int -> GetExportJobsResponse -> ShowS
$cshowsPrec :: Int -> GetExportJobsResponse -> ShowS
Prelude.Show, (forall x. GetExportJobsResponse -> Rep GetExportJobsResponse x)
-> (forall x. Rep GetExportJobsResponse x -> GetExportJobsResponse)
-> Generic GetExportJobsResponse
forall x. Rep GetExportJobsResponse x -> GetExportJobsResponse
forall x. GetExportJobsResponse -> Rep GetExportJobsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetExportJobsResponse x -> GetExportJobsResponse
$cfrom :: forall x. GetExportJobsResponse -> Rep GetExportJobsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetExportJobsResponse' 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', 'getExportJobsResponse_httpStatus' - The response's http status code.
--
-- 'exportJobsResponse', 'getExportJobsResponse_exportJobsResponse' - Undocumented member.
newGetExportJobsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'exportJobsResponse'
  ExportJobsResponse ->
  GetExportJobsResponse
newGetExportJobsResponse :: Int -> ExportJobsResponse -> GetExportJobsResponse
newGetExportJobsResponse
  Int
pHttpStatus_
  ExportJobsResponse
pExportJobsResponse_ =
    GetExportJobsResponse' :: Int -> ExportJobsResponse -> GetExportJobsResponse
GetExportJobsResponse'
      { $sel:httpStatus:GetExportJobsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:exportJobsResponse:GetExportJobsResponse' :: ExportJobsResponse
exportJobsResponse = ExportJobsResponse
pExportJobsResponse_
      }

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

-- | Undocumented member.
getExportJobsResponse_exportJobsResponse :: Lens.Lens' GetExportJobsResponse ExportJobsResponse
getExportJobsResponse_exportJobsResponse :: (ExportJobsResponse -> f ExportJobsResponse)
-> GetExportJobsResponse -> f GetExportJobsResponse
getExportJobsResponse_exportJobsResponse = (GetExportJobsResponse -> ExportJobsResponse)
-> (GetExportJobsResponse
    -> ExportJobsResponse -> GetExportJobsResponse)
-> Lens
     GetExportJobsResponse
     GetExportJobsResponse
     ExportJobsResponse
     ExportJobsResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExportJobsResponse' {ExportJobsResponse
exportJobsResponse :: ExportJobsResponse
$sel:exportJobsResponse:GetExportJobsResponse' :: GetExportJobsResponse -> ExportJobsResponse
exportJobsResponse} -> ExportJobsResponse
exportJobsResponse) (\s :: GetExportJobsResponse
s@GetExportJobsResponse' {} ExportJobsResponse
a -> GetExportJobsResponse
s {$sel:exportJobsResponse:GetExportJobsResponse' :: ExportJobsResponse
exportJobsResponse = ExportJobsResponse
a} :: GetExportJobsResponse)

instance Prelude.NFData GetExportJobsResponse