{-# 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.Amplify.StopJob
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stops a job that is in progress for a branch of an Amplify app.
module Amazonka.Amplify.StopJob
  ( -- * Creating a Request
    StopJob (..),
    newStopJob,

    -- * Request Lenses
    stopJob_appId,
    stopJob_branchName,
    stopJob_jobId,

    -- * Destructuring the Response
    StopJobResponse (..),
    newStopJobResponse,

    -- * Response Lenses
    stopJobResponse_httpStatus,
    stopJobResponse_jobSummary,
  )
where

import Amazonka.Amplify.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The request structure for the stop job request.
--
-- /See:/ 'newStopJob' smart constructor.
data StopJob = StopJob'
  { -- | The unique ID for an Amplify app.
    StopJob -> Text
appId :: Prelude.Text,
    -- | The name for the branch, for the job.
    StopJob -> Text
branchName :: Prelude.Text,
    -- | The unique id for the job.
    StopJob -> Text
jobId :: Prelude.Text
  }
  deriving (StopJob -> StopJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopJob -> StopJob -> Bool
$c/= :: StopJob -> StopJob -> Bool
== :: StopJob -> StopJob -> Bool
$c== :: StopJob -> StopJob -> Bool
Prelude.Eq, ReadPrec [StopJob]
ReadPrec StopJob
Int -> ReadS StopJob
ReadS [StopJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopJob]
$creadListPrec :: ReadPrec [StopJob]
readPrec :: ReadPrec StopJob
$creadPrec :: ReadPrec StopJob
readList :: ReadS [StopJob]
$creadList :: ReadS [StopJob]
readsPrec :: Int -> ReadS StopJob
$creadsPrec :: Int -> ReadS StopJob
Prelude.Read, Int -> StopJob -> ShowS
[StopJob] -> ShowS
StopJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopJob] -> ShowS
$cshowList :: [StopJob] -> ShowS
show :: StopJob -> String
$cshow :: StopJob -> String
showsPrec :: Int -> StopJob -> ShowS
$cshowsPrec :: Int -> StopJob -> ShowS
Prelude.Show, forall x. Rep StopJob x -> StopJob
forall x. StopJob -> Rep StopJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopJob x -> StopJob
$cfrom :: forall x. StopJob -> Rep StopJob x
Prelude.Generic)

-- |
-- Create a value of 'StopJob' 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:
--
-- 'appId', 'stopJob_appId' - The unique ID for an Amplify app.
--
-- 'branchName', 'stopJob_branchName' - The name for the branch, for the job.
--
-- 'jobId', 'stopJob_jobId' - The unique id for the job.
newStopJob ::
  -- | 'appId'
  Prelude.Text ->
  -- | 'branchName'
  Prelude.Text ->
  -- | 'jobId'
  Prelude.Text ->
  StopJob
newStopJob :: Text -> Text -> Text -> StopJob
newStopJob Text
pAppId_ Text
pBranchName_ Text
pJobId_ =
  StopJob'
    { $sel:appId:StopJob' :: Text
appId = Text
pAppId_,
      $sel:branchName:StopJob' :: Text
branchName = Text
pBranchName_,
      $sel:jobId:StopJob' :: Text
jobId = Text
pJobId_
    }

-- | The unique ID for an Amplify app.
stopJob_appId :: Lens.Lens' StopJob Prelude.Text
stopJob_appId :: Lens' StopJob Text
stopJob_appId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopJob' {Text
appId :: Text
$sel:appId:StopJob' :: StopJob -> Text
appId} -> Text
appId) (\s :: StopJob
s@StopJob' {} Text
a -> StopJob
s {$sel:appId:StopJob' :: Text
appId = Text
a} :: StopJob)

-- | The name for the branch, for the job.
stopJob_branchName :: Lens.Lens' StopJob Prelude.Text
stopJob_branchName :: Lens' StopJob Text
stopJob_branchName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopJob' {Text
branchName :: Text
$sel:branchName:StopJob' :: StopJob -> Text
branchName} -> Text
branchName) (\s :: StopJob
s@StopJob' {} Text
a -> StopJob
s {$sel:branchName:StopJob' :: Text
branchName = Text
a} :: StopJob)

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

instance Core.AWSRequest StopJob where
  type AWSResponse StopJob = StopJobResponse
  request :: (Service -> Service) -> StopJob -> Request StopJob
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StopJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopJob)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> JobSummary -> StopJobResponse
StopJobResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"jobSummary")
      )

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

instance Prelude.NFData StopJob where
  rnf :: StopJob -> ()
rnf StopJob' {Text
jobId :: Text
branchName :: Text
appId :: Text
$sel:jobId:StopJob' :: StopJob -> Text
$sel:branchName:StopJob' :: StopJob -> Text
$sel:appId:StopJob' :: StopJob -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
appId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
branchName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
jobId

instance Data.ToHeaders StopJob where
  toHeaders :: StopJob -> 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.ToPath StopJob where
  toPath :: StopJob -> ByteString
toPath StopJob' {Text
jobId :: Text
branchName :: Text
appId :: Text
$sel:jobId:StopJob' :: StopJob -> Text
$sel:branchName:StopJob' :: StopJob -> Text
$sel:appId:StopJob' :: StopJob -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/apps/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
appId,
        ByteString
"/branches/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
branchName,
        ByteString
"/jobs/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
jobId,
        ByteString
"/stop"
      ]

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

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

-- |
-- Create a value of 'StopJobResponse' 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', 'stopJobResponse_httpStatus' - The response's http status code.
--
-- 'jobSummary', 'stopJobResponse_jobSummary' - The summary for the job.
newStopJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'jobSummary'
  JobSummary ->
  StopJobResponse
newStopJobResponse :: Int -> JobSummary -> StopJobResponse
newStopJobResponse Int
pHttpStatus_ JobSummary
pJobSummary_ =
  StopJobResponse'
    { $sel:httpStatus:StopJobResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:jobSummary:StopJobResponse' :: JobSummary
jobSummary = JobSummary
pJobSummary_
    }

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

-- | The summary for the job.
stopJobResponse_jobSummary :: Lens.Lens' StopJobResponse JobSummary
stopJobResponse_jobSummary :: Lens' StopJobResponse JobSummary
stopJobResponse_jobSummary = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopJobResponse' {JobSummary
jobSummary :: JobSummary
$sel:jobSummary:StopJobResponse' :: StopJobResponse -> JobSummary
jobSummary} -> JobSummary
jobSummary) (\s :: StopJobResponse
s@StopJobResponse' {} JobSummary
a -> StopJobResponse
s {$sel:jobSummary:StopJobResponse' :: JobSummary
jobSummary = JobSummary
a} :: StopJobResponse)

instance Prelude.NFData StopJobResponse where
  rnf :: StopJobResponse -> ()
rnf StopJobResponse' {Int
JobSummary
jobSummary :: JobSummary
httpStatus :: Int
$sel:jobSummary:StopJobResponse' :: StopJobResponse -> JobSummary
$sel:httpStatus:StopJobResponse' :: StopJobResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf JobSummary
jobSummary