{-# 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.DataExchange.StartJob
-- 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)
--
-- This operation starts a job.
module Amazonka.DataExchange.StartJob
  ( -- * Creating a Request
    StartJob (..),
    newStartJob,

    -- * Request Lenses
    startJob_jobId,

    -- * Destructuring the Response
    StartJobResponse (..),
    newStartJobResponse,

    -- * Response Lenses
    startJobResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStartJob' smart constructor.
data StartJob = StartJob'
  { -- | The unique identifier for a job.
    StartJob -> Text
jobId :: Prelude.Text
  }
  deriving (StartJob -> StartJob -> Bool
(StartJob -> StartJob -> Bool)
-> (StartJob -> StartJob -> Bool) -> Eq StartJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartJob -> StartJob -> Bool
$c/= :: StartJob -> StartJob -> Bool
== :: StartJob -> StartJob -> Bool
$c== :: StartJob -> StartJob -> Bool
Prelude.Eq, ReadPrec [StartJob]
ReadPrec StartJob
Int -> ReadS StartJob
ReadS [StartJob]
(Int -> ReadS StartJob)
-> ReadS [StartJob]
-> ReadPrec StartJob
-> ReadPrec [StartJob]
-> Read StartJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartJob]
$creadListPrec :: ReadPrec [StartJob]
readPrec :: ReadPrec StartJob
$creadPrec :: ReadPrec StartJob
readList :: ReadS [StartJob]
$creadList :: ReadS [StartJob]
readsPrec :: Int -> ReadS StartJob
$creadsPrec :: Int -> ReadS StartJob
Prelude.Read, Int -> StartJob -> ShowS
[StartJob] -> ShowS
StartJob -> String
(Int -> StartJob -> ShowS)
-> (StartJob -> String) -> ([StartJob] -> ShowS) -> Show StartJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartJob] -> ShowS
$cshowList :: [StartJob] -> ShowS
show :: StartJob -> String
$cshow :: StartJob -> String
showsPrec :: Int -> StartJob -> ShowS
$cshowsPrec :: Int -> StartJob -> ShowS
Prelude.Show, (forall x. StartJob -> Rep StartJob x)
-> (forall x. Rep StartJob x -> StartJob) -> Generic StartJob
forall x. Rep StartJob x -> StartJob
forall x. StartJob -> Rep StartJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartJob x -> StartJob
$cfrom :: forall x. StartJob -> Rep StartJob x
Prelude.Generic)

-- |
-- Create a value of 'StartJob' 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:
--
-- 'jobId', 'startJob_jobId' - The unique identifier for a job.
newStartJob ::
  -- | 'jobId'
  Prelude.Text ->
  StartJob
newStartJob :: Text -> StartJob
newStartJob Text
pJobId_ = StartJob' :: Text -> StartJob
StartJob' {$sel:jobId:StartJob' :: Text
jobId = Text
pJobId_}

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

instance Core.AWSRequest StartJob where
  type AWSResponse StartJob = StartJobResponse
  request :: StartJob -> Request StartJob
request = Service -> StartJob -> Request StartJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartJob)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse StartJob))
-> Logger
-> Service
-> Proxy StartJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartJob)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartJobResponse
StartJobResponse'
            (Int -> StartJobResponse)
-> Either String Int -> Either String StartJobResponse
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))
      )

instance Prelude.Hashable StartJob

instance Prelude.NFData StartJob

instance Core.ToHeaders StartJob where
  toHeaders :: StartJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartJob -> 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 StartJob where
  toJSON :: StartJob -> Value
toJSON = Value -> StartJob -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath StartJob where
  toPath :: StartJob -> ByteString
toPath StartJob' {Text
jobId :: Text
$sel:jobId:StartJob' :: StartJob -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/v1/jobs/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
jobId]

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

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

-- |
-- Create a value of 'StartJobResponse' 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', 'startJobResponse_httpStatus' - The response's http status code.
newStartJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartJobResponse
newStartJobResponse :: Int -> StartJobResponse
newStartJobResponse Int
pHttpStatus_ =
  StartJobResponse' :: Int -> StartJobResponse
StartJobResponse' {$sel:httpStatus:StartJobResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData StartJobResponse