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

    -- * Request Lenses
    createExportJob_applicationId,
    createExportJob_exportJobRequest,

    -- * Destructuring the Response
    CreateExportJobResponse (..),
    newCreateExportJobResponse,

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

-- |
-- Create a value of 'CreateExportJob' 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', 'createExportJob_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'exportJobRequest', 'createExportJob_exportJobRequest' - Undocumented member.
newCreateExportJob ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'exportJobRequest'
  ExportJobRequest ->
  CreateExportJob
newCreateExportJob :: Text -> ExportJobRequest -> CreateExportJob
newCreateExportJob Text
pApplicationId_ ExportJobRequest
pExportJobRequest_ =
  CreateExportJob' :: Text -> ExportJobRequest -> CreateExportJob
CreateExportJob'
    { $sel:applicationId:CreateExportJob' :: Text
applicationId = Text
pApplicationId_,
      $sel:exportJobRequest:CreateExportJob' :: ExportJobRequest
exportJobRequest = ExportJobRequest
pExportJobRequest_
    }

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

-- | Undocumented member.
createExportJob_exportJobRequest :: Lens.Lens' CreateExportJob ExportJobRequest
createExportJob_exportJobRequest :: (ExportJobRequest -> f ExportJobRequest)
-> CreateExportJob -> f CreateExportJob
createExportJob_exportJobRequest = (CreateExportJob -> ExportJobRequest)
-> (CreateExportJob -> ExportJobRequest -> CreateExportJob)
-> Lens
     CreateExportJob CreateExportJob ExportJobRequest ExportJobRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExportJob' {ExportJobRequest
exportJobRequest :: ExportJobRequest
$sel:exportJobRequest:CreateExportJob' :: CreateExportJob -> ExportJobRequest
exportJobRequest} -> ExportJobRequest
exportJobRequest) (\s :: CreateExportJob
s@CreateExportJob' {} ExportJobRequest
a -> CreateExportJob
s {$sel:exportJobRequest:CreateExportJob' :: ExportJobRequest
exportJobRequest = ExportJobRequest
a} :: CreateExportJob)

instance Core.AWSRequest CreateExportJob where
  type
    AWSResponse CreateExportJob =
      CreateExportJobResponse
  request :: CreateExportJob -> Request CreateExportJob
request = Service -> CreateExportJob -> Request CreateExportJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateExportJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateExportJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateExportJob))
-> Logger
-> Service
-> Proxy CreateExportJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateExportJob)))
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 -> CreateExportJobResponse
CreateExportJobResponse'
            (Int -> ExportJobResponse -> CreateExportJobResponse)
-> Either String Int
-> Either String (ExportJobResponse -> CreateExportJobResponse)
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 -> CreateExportJobResponse)
-> Either String ExportJobResponse
-> Either String CreateExportJobResponse
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 CreateExportJob

instance Prelude.NFData CreateExportJob

instance Core.ToHeaders CreateExportJob where
  toHeaders :: CreateExportJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateExportJob -> 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.ToJSON CreateExportJob where
  toJSON :: CreateExportJob -> Value
toJSON CreateExportJob' {Text
ExportJobRequest
exportJobRequest :: ExportJobRequest
applicationId :: Text
$sel:exportJobRequest:CreateExportJob' :: CreateExportJob -> ExportJobRequest
$sel:applicationId:CreateExportJob' :: CreateExportJob -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ExportJobRequest" Text -> ExportJobRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ExportJobRequest
exportJobRequest)
          ]
      )

instance Core.ToPath CreateExportJob where
  toPath :: CreateExportJob -> ByteString
toPath CreateExportJob' {Text
ExportJobRequest
exportJobRequest :: ExportJobRequest
applicationId :: Text
$sel:exportJobRequest:CreateExportJob' :: CreateExportJob -> ExportJobRequest
$sel:applicationId:CreateExportJob' :: CreateExportJob -> 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 CreateExportJob where
  toQuery :: CreateExportJob -> QueryString
toQuery = QueryString -> CreateExportJob -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

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

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

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

instance Prelude.NFData CreateExportJobResponse