{-# 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.CodeBuild.StopBuildBatch
-- 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 running batch build.
module Amazonka.CodeBuild.StopBuildBatch
  ( -- * Creating a Request
    StopBuildBatch (..),
    newStopBuildBatch,

    -- * Request Lenses
    stopBuildBatch_id,

    -- * Destructuring the Response
    StopBuildBatchResponse (..),
    newStopBuildBatchResponse,

    -- * Response Lenses
    stopBuildBatchResponse_buildBatch,
    stopBuildBatchResponse_httpStatus,
  )
where

import Amazonka.CodeBuild.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

-- | /See:/ 'newStopBuildBatch' smart constructor.
data StopBuildBatch = StopBuildBatch'
  { -- | The identifier of the batch build to stop.
    StopBuildBatch -> Text
id :: Prelude.Text
  }
  deriving (StopBuildBatch -> StopBuildBatch -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopBuildBatch -> StopBuildBatch -> Bool
$c/= :: StopBuildBatch -> StopBuildBatch -> Bool
== :: StopBuildBatch -> StopBuildBatch -> Bool
$c== :: StopBuildBatch -> StopBuildBatch -> Bool
Prelude.Eq, ReadPrec [StopBuildBatch]
ReadPrec StopBuildBatch
Int -> ReadS StopBuildBatch
ReadS [StopBuildBatch]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopBuildBatch]
$creadListPrec :: ReadPrec [StopBuildBatch]
readPrec :: ReadPrec StopBuildBatch
$creadPrec :: ReadPrec StopBuildBatch
readList :: ReadS [StopBuildBatch]
$creadList :: ReadS [StopBuildBatch]
readsPrec :: Int -> ReadS StopBuildBatch
$creadsPrec :: Int -> ReadS StopBuildBatch
Prelude.Read, Int -> StopBuildBatch -> ShowS
[StopBuildBatch] -> ShowS
StopBuildBatch -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopBuildBatch] -> ShowS
$cshowList :: [StopBuildBatch] -> ShowS
show :: StopBuildBatch -> String
$cshow :: StopBuildBatch -> String
showsPrec :: Int -> StopBuildBatch -> ShowS
$cshowsPrec :: Int -> StopBuildBatch -> ShowS
Prelude.Show, forall x. Rep StopBuildBatch x -> StopBuildBatch
forall x. StopBuildBatch -> Rep StopBuildBatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopBuildBatch x -> StopBuildBatch
$cfrom :: forall x. StopBuildBatch -> Rep StopBuildBatch x
Prelude.Generic)

-- |
-- Create a value of 'StopBuildBatch' 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:
--
-- 'id', 'stopBuildBatch_id' - The identifier of the batch build to stop.
newStopBuildBatch ::
  -- | 'id'
  Prelude.Text ->
  StopBuildBatch
newStopBuildBatch :: Text -> StopBuildBatch
newStopBuildBatch Text
pId_ = StopBuildBatch' {$sel:id:StopBuildBatch' :: Text
id = Text
pId_}

-- | The identifier of the batch build to stop.
stopBuildBatch_id :: Lens.Lens' StopBuildBatch Prelude.Text
stopBuildBatch_id :: Lens' StopBuildBatch Text
stopBuildBatch_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopBuildBatch' {Text
id :: Text
$sel:id:StopBuildBatch' :: StopBuildBatch -> Text
id} -> Text
id) (\s :: StopBuildBatch
s@StopBuildBatch' {} Text
a -> StopBuildBatch
s {$sel:id:StopBuildBatch' :: Text
id = Text
a} :: StopBuildBatch)

instance Core.AWSRequest StopBuildBatch where
  type
    AWSResponse StopBuildBatch =
      StopBuildBatchResponse
  request :: (Service -> Service) -> StopBuildBatch -> Request StopBuildBatch
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StopBuildBatch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopBuildBatch)))
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 ->
          Maybe BuildBatch -> Int -> StopBuildBatchResponse
StopBuildBatchResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"buildBatch")
            forall (f :: * -> *) a b. Applicative f => 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 StopBuildBatch where
  hashWithSalt :: Int -> StopBuildBatch -> Int
hashWithSalt Int
_salt StopBuildBatch' {Text
id :: Text
$sel:id:StopBuildBatch' :: StopBuildBatch -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

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

instance Data.ToJSON StopBuildBatch where
  toJSON :: StopBuildBatch -> Value
toJSON StopBuildBatch' {Text
id :: Text
$sel:id:StopBuildBatch' :: StopBuildBatch -> Text
..} =
    [Pair] -> Value
Data.object
      (forall a. [Maybe a] -> [a]
Prelude.catMaybes [forall a. a -> Maybe a
Prelude.Just (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)])

instance Data.ToPath StopBuildBatch where
  toPath :: StopBuildBatch -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'StopBuildBatchResponse' 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:
--
-- 'buildBatch', 'stopBuildBatchResponse_buildBatch' - Undocumented member.
--
-- 'httpStatus', 'stopBuildBatchResponse_httpStatus' - The response's http status code.
newStopBuildBatchResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopBuildBatchResponse
newStopBuildBatchResponse :: Int -> StopBuildBatchResponse
newStopBuildBatchResponse Int
pHttpStatus_ =
  StopBuildBatchResponse'
    { $sel:buildBatch:StopBuildBatchResponse' :: Maybe BuildBatch
buildBatch =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopBuildBatchResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
stopBuildBatchResponse_buildBatch :: Lens.Lens' StopBuildBatchResponse (Prelude.Maybe BuildBatch)
stopBuildBatchResponse_buildBatch :: Lens' StopBuildBatchResponse (Maybe BuildBatch)
stopBuildBatchResponse_buildBatch = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopBuildBatchResponse' {Maybe BuildBatch
buildBatch :: Maybe BuildBatch
$sel:buildBatch:StopBuildBatchResponse' :: StopBuildBatchResponse -> Maybe BuildBatch
buildBatch} -> Maybe BuildBatch
buildBatch) (\s :: StopBuildBatchResponse
s@StopBuildBatchResponse' {} Maybe BuildBatch
a -> StopBuildBatchResponse
s {$sel:buildBatch:StopBuildBatchResponse' :: Maybe BuildBatch
buildBatch = Maybe BuildBatch
a} :: StopBuildBatchResponse)

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

instance Prelude.NFData StopBuildBatchResponse where
  rnf :: StopBuildBatchResponse -> ()
rnf StopBuildBatchResponse' {Int
Maybe BuildBatch
httpStatus :: Int
buildBatch :: Maybe BuildBatch
$sel:httpStatus:StopBuildBatchResponse' :: StopBuildBatchResponse -> Int
$sel:buildBatch:StopBuildBatchResponse' :: StopBuildBatchResponse -> Maybe BuildBatch
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BuildBatch
buildBatch
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus