{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataExchange.Types
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
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]
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
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. 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' {$sel:jobId:StartJob' :: Text
jobId = Text
pJobId_}

-- | The unique identifier for a job.
startJob_jobId :: Lens.Lens' StartJob Prelude.Text
startJob_jobId :: Lens' StartJob Text
startJob_jobId = 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 :: (Service -> Service) -> StartJob -> Request StartJob
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartJob)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartJobResponse
StartJobResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartJob where
  hashWithSalt :: Int -> StartJob -> Int
hashWithSalt Int
_salt StartJob' {Text
jobId :: Text
$sel:jobId:StartJob' :: StartJob -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jobId

instance Prelude.NFData StartJob where
  rnf :: StartJob -> ()
rnf StartJob' {Text
jobId :: Text
$sel:jobId:StartJob' :: StartJob -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
jobId

instance Data.ToHeaders StartJob where
  toHeaders :: StartJob -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartJob where
  toJSON :: StartJob -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

instance Data.ToQuery StartJob where
  toQuery :: StartJob -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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' {$sel:httpStatus:StartJobResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
startJobResponse_httpStatus :: Lens.Lens' StartJobResponse Prelude.Int
startJobResponse_httpStatus :: Lens' StartJobResponse Int
startJobResponse_httpStatus = 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 where
  rnf :: StartJobResponse -> ()
rnf StartJobResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartJobResponse' :: StartJobResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus