{-# 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-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)
--
-- 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.Lens as Lens
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
(StopBuildBatch -> StopBuildBatch -> Bool)
-> (StopBuildBatch -> StopBuildBatch -> Bool) -> Eq StopBuildBatch
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]
(Int -> ReadS StopBuildBatch)
-> ReadS [StopBuildBatch]
-> ReadPrec StopBuildBatch
-> ReadPrec [StopBuildBatch]
-> Read 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
(Int -> StopBuildBatch -> ShowS)
-> (StopBuildBatch -> String)
-> ([StopBuildBatch] -> ShowS)
-> Show StopBuildBatch
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. StopBuildBatch -> Rep StopBuildBatch x)
-> (forall x. Rep StopBuildBatch x -> StopBuildBatch)
-> Generic StopBuildBatch
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' :: Text -> StopBuildBatch
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 :: (Text -> f Text) -> StopBuildBatch -> f StopBuildBatch
stopBuildBatch_id = (StopBuildBatch -> Text)
-> (StopBuildBatch -> Text -> StopBuildBatch)
-> Lens StopBuildBatch StopBuildBatch Text Text
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 :: StopBuildBatch -> Request StopBuildBatch
request = Service -> StopBuildBatch -> Request StopBuildBatch
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopBuildBatch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopBuildBatch)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopBuildBatch))
-> Logger
-> Service
-> Proxy StopBuildBatch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopBuildBatch)))
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 ->
          Maybe BuildBatch -> Int -> StopBuildBatchResponse
StopBuildBatchResponse'
            (Maybe BuildBatch -> Int -> StopBuildBatchResponse)
-> Either String (Maybe BuildBatch)
-> Either String (Int -> StopBuildBatchResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe BuildBatch)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"buildBatch")
            Either String (Int -> StopBuildBatchResponse)
-> Either String Int -> Either String StopBuildBatchResponse
forall (f :: * -> *) a b. Applicative f => 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 StopBuildBatch

instance Prelude.NFData StopBuildBatch

instance Core.ToHeaders StopBuildBatch where
  toHeaders :: StopBuildBatch -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopBuildBatch -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CodeBuild_20161006.StopBuildBatch" ::
                          Prelude.ByteString
                      ),
            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 StopBuildBatch where
  toJSON :: StopBuildBatch -> Value
toJSON StopBuildBatch' {Text
id :: Text
$sel:id:StopBuildBatch' :: StopBuildBatch -> 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
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)])

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

instance Core.ToQuery StopBuildBatch where
  toQuery :: StopBuildBatch -> QueryString
toQuery = QueryString -> StopBuildBatch -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(StopBuildBatchResponse -> StopBuildBatchResponse -> Bool)
-> (StopBuildBatchResponse -> StopBuildBatchResponse -> Bool)
-> Eq StopBuildBatchResponse
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]
(Int -> ReadS StopBuildBatchResponse)
-> ReadS [StopBuildBatchResponse]
-> ReadPrec StopBuildBatchResponse
-> ReadPrec [StopBuildBatchResponse]
-> Read 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
(Int -> StopBuildBatchResponse -> ShowS)
-> (StopBuildBatchResponse -> String)
-> ([StopBuildBatchResponse] -> ShowS)
-> Show StopBuildBatchResponse
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. StopBuildBatchResponse -> Rep StopBuildBatchResponse x)
-> (forall x.
    Rep StopBuildBatchResponse x -> StopBuildBatchResponse)
-> Generic StopBuildBatchResponse
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' :: Maybe BuildBatch -> Int -> StopBuildBatchResponse
StopBuildBatchResponse'
    { $sel:buildBatch:StopBuildBatchResponse' :: Maybe BuildBatch
buildBatch =
        Maybe 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 :: (Maybe BuildBatch -> f (Maybe BuildBatch))
-> StopBuildBatchResponse -> f StopBuildBatchResponse
stopBuildBatchResponse_buildBatch = (StopBuildBatchResponse -> Maybe BuildBatch)
-> (StopBuildBatchResponse
    -> Maybe BuildBatch -> StopBuildBatchResponse)
-> Lens
     StopBuildBatchResponse
     StopBuildBatchResponse
     (Maybe BuildBatch)
     (Maybe 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 :: (Int -> f Int)
-> StopBuildBatchResponse -> f StopBuildBatchResponse
stopBuildBatchResponse_httpStatus = (StopBuildBatchResponse -> Int)
-> (StopBuildBatchResponse -> Int -> StopBuildBatchResponse)
-> Lens StopBuildBatchResponse StopBuildBatchResponse Int Int
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