{-# 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.GetExportJob
-- 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 a specific export
-- job for an application.
module Amazonka.Pinpoint.GetExportJob
  ( -- * Creating a Request
    GetExportJob (..),
    newGetExportJob,

    -- * Request Lenses
    getExportJob_applicationId,
    getExportJob_jobId,

    -- * Destructuring the Response
    GetExportJobResponse (..),
    newGetExportJobResponse,

    -- * Response Lenses
    getExportJobResponse_httpStatus,
    getExportJobResponse_exportJobResponse,
  )
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:/ 'newGetExportJob' smart constructor.
data GetExportJob = GetExportJob'
  { -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    GetExportJob -> Text
applicationId :: Prelude.Text,
    -- | The unique identifier for the job.
    GetExportJob -> Text
jobId :: Prelude.Text
  }
  deriving (GetExportJob -> GetExportJob -> Bool
(GetExportJob -> GetExportJob -> Bool)
-> (GetExportJob -> GetExportJob -> Bool) -> Eq GetExportJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetExportJob -> GetExportJob -> Bool
$c/= :: GetExportJob -> GetExportJob -> Bool
== :: GetExportJob -> GetExportJob -> Bool
$c== :: GetExportJob -> GetExportJob -> Bool
Prelude.Eq, ReadPrec [GetExportJob]
ReadPrec GetExportJob
Int -> ReadS GetExportJob
ReadS [GetExportJob]
(Int -> ReadS GetExportJob)
-> ReadS [GetExportJob]
-> ReadPrec GetExportJob
-> ReadPrec [GetExportJob]
-> Read GetExportJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetExportJob]
$creadListPrec :: ReadPrec [GetExportJob]
readPrec :: ReadPrec GetExportJob
$creadPrec :: ReadPrec GetExportJob
readList :: ReadS [GetExportJob]
$creadList :: ReadS [GetExportJob]
readsPrec :: Int -> ReadS GetExportJob
$creadsPrec :: Int -> ReadS GetExportJob
Prelude.Read, Int -> GetExportJob -> ShowS
[GetExportJob] -> ShowS
GetExportJob -> String
(Int -> GetExportJob -> ShowS)
-> (GetExportJob -> String)
-> ([GetExportJob] -> ShowS)
-> Show GetExportJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetExportJob] -> ShowS
$cshowList :: [GetExportJob] -> ShowS
show :: GetExportJob -> String
$cshow :: GetExportJob -> String
showsPrec :: Int -> GetExportJob -> ShowS
$cshowsPrec :: Int -> GetExportJob -> ShowS
Prelude.Show, (forall x. GetExportJob -> Rep GetExportJob x)
-> (forall x. Rep GetExportJob x -> GetExportJob)
-> Generic GetExportJob
forall x. Rep GetExportJob x -> GetExportJob
forall x. GetExportJob -> Rep GetExportJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetExportJob x -> GetExportJob
$cfrom :: forall x. GetExportJob -> Rep GetExportJob x
Prelude.Generic)

-- |
-- Create a value of 'GetExportJob' 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:
--
-- 'applicationId', 'getExportJob_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'jobId', 'getExportJob_jobId' - The unique identifier for the job.
newGetExportJob ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'jobId'
  Prelude.Text ->
  GetExportJob
newGetExportJob :: Text -> Text -> GetExportJob
newGetExportJob Text
pApplicationId_ Text
pJobId_ =
  GetExportJob' :: Text -> Text -> GetExportJob
GetExportJob'
    { $sel:applicationId:GetExportJob' :: Text
applicationId = Text
pApplicationId_,
      $sel:jobId:GetExportJob' :: Text
jobId = Text
pJobId_
    }

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

-- | The unique identifier for the job.
getExportJob_jobId :: Lens.Lens' GetExportJob Prelude.Text
getExportJob_jobId :: (Text -> f Text) -> GetExportJob -> f GetExportJob
getExportJob_jobId = (GetExportJob -> Text)
-> (GetExportJob -> Text -> GetExportJob)
-> Lens GetExportJob GetExportJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExportJob' {Text
jobId :: Text
$sel:jobId:GetExportJob' :: GetExportJob -> Text
jobId} -> Text
jobId) (\s :: GetExportJob
s@GetExportJob' {} Text
a -> GetExportJob
s {$sel:jobId:GetExportJob' :: Text
jobId = Text
a} :: GetExportJob)

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

instance Prelude.Hashable GetExportJob

instance Prelude.NFData GetExportJob

instance Core.ToHeaders GetExportJob where
  toHeaders :: GetExportJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetExportJob -> 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 GetExportJob where
  toPath :: GetExportJob -> ByteString
toPath GetExportJob' {Text
jobId :: Text
applicationId :: Text
$sel:jobId:GetExportJob' :: GetExportJob -> Text
$sel:applicationId:GetExportJob' :: GetExportJob -> 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/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
jobId
      ]

instance Core.ToQuery GetExportJob where
  toQuery :: GetExportJob -> QueryString
toQuery = QueryString -> GetExportJob -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'GetExportJobResponse' 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', 'getExportJobResponse_httpStatus' - The response's http status code.
--
-- 'exportJobResponse', 'getExportJobResponse_exportJobResponse' - Undocumented member.
newGetExportJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'exportJobResponse'
  ExportJobResponse ->
  GetExportJobResponse
newGetExportJobResponse :: Int -> ExportJobResponse -> GetExportJobResponse
newGetExportJobResponse
  Int
pHttpStatus_
  ExportJobResponse
pExportJobResponse_ =
    GetExportJobResponse' :: Int -> ExportJobResponse -> GetExportJobResponse
GetExportJobResponse'
      { $sel:httpStatus:GetExportJobResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:exportJobResponse:GetExportJobResponse' :: ExportJobResponse
exportJobResponse = ExportJobResponse
pExportJobResponse_
      }

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

-- | Undocumented member.
getExportJobResponse_exportJobResponse :: Lens.Lens' GetExportJobResponse ExportJobResponse
getExportJobResponse_exportJobResponse :: (ExportJobResponse -> f ExportJobResponse)
-> GetExportJobResponse -> f GetExportJobResponse
getExportJobResponse_exportJobResponse = (GetExportJobResponse -> ExportJobResponse)
-> (GetExportJobResponse
    -> ExportJobResponse -> GetExportJobResponse)
-> Lens
     GetExportJobResponse
     GetExportJobResponse
     ExportJobResponse
     ExportJobResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExportJobResponse' {ExportJobResponse
exportJobResponse :: ExportJobResponse
$sel:exportJobResponse:GetExportJobResponse' :: GetExportJobResponse -> ExportJobResponse
exportJobResponse} -> ExportJobResponse
exportJobResponse) (\s :: GetExportJobResponse
s@GetExportJobResponse' {} ExportJobResponse
a -> GetExportJobResponse
s {$sel:exportJobResponse:GetExportJobResponse' :: ExportJobResponse
exportJobResponse = ExportJobResponse
a} :: GetExportJobResponse)

instance Prelude.NFData GetExportJobResponse