{-# 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.StopBuild
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Attempts to stop running a build.
module Amazonka.CodeBuild.StopBuild
  ( -- * Creating a Request
    StopBuild (..),
    newStopBuild,

    -- * Request Lenses
    stopBuild_id,

    -- * Destructuring the Response
    StopBuildResponse (..),
    newStopBuildResponse,

    -- * Response Lenses
    stopBuildResponse_build,
    stopBuildResponse_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:/ 'newStopBuild' smart constructor.
data StopBuild = StopBuild'
  { -- | The ID of the build.
    StopBuild -> Text
id :: Prelude.Text
  }
  deriving (StopBuild -> StopBuild -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopBuild -> StopBuild -> Bool
$c/= :: StopBuild -> StopBuild -> Bool
== :: StopBuild -> StopBuild -> Bool
$c== :: StopBuild -> StopBuild -> Bool
Prelude.Eq, ReadPrec [StopBuild]
ReadPrec StopBuild
Int -> ReadS StopBuild
ReadS [StopBuild]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopBuild]
$creadListPrec :: ReadPrec [StopBuild]
readPrec :: ReadPrec StopBuild
$creadPrec :: ReadPrec StopBuild
readList :: ReadS [StopBuild]
$creadList :: ReadS [StopBuild]
readsPrec :: Int -> ReadS StopBuild
$creadsPrec :: Int -> ReadS StopBuild
Prelude.Read, Int -> StopBuild -> ShowS
[StopBuild] -> ShowS
StopBuild -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopBuild] -> ShowS
$cshowList :: [StopBuild] -> ShowS
show :: StopBuild -> String
$cshow :: StopBuild -> String
showsPrec :: Int -> StopBuild -> ShowS
$cshowsPrec :: Int -> StopBuild -> ShowS
Prelude.Show, forall x. Rep StopBuild x -> StopBuild
forall x. StopBuild -> Rep StopBuild x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopBuild x -> StopBuild
$cfrom :: forall x. StopBuild -> Rep StopBuild x
Prelude.Generic)

-- |
-- Create a value of 'StopBuild' 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', 'stopBuild_id' - The ID of the build.
newStopBuild ::
  -- | 'id'
  Prelude.Text ->
  StopBuild
newStopBuild :: Text -> StopBuild
newStopBuild Text
pId_ = StopBuild' {$sel:id:StopBuild' :: Text
id = Text
pId_}

-- | The ID of the build.
stopBuild_id :: Lens.Lens' StopBuild Prelude.Text
stopBuild_id :: Lens' StopBuild Text
stopBuild_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopBuild' {Text
id :: Text
$sel:id:StopBuild' :: StopBuild -> Text
id} -> Text
id) (\s :: StopBuild
s@StopBuild' {} Text
a -> StopBuild
s {$sel:id:StopBuild' :: Text
id = Text
a} :: StopBuild)

instance Core.AWSRequest StopBuild where
  type AWSResponse StopBuild = StopBuildResponse
  request :: (Service -> Service) -> StopBuild -> Request StopBuild
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 StopBuild
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopBuild)))
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 Build -> Int -> StopBuildResponse
StopBuildResponse'
            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
"build")
            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 StopBuild where
  hashWithSalt :: Int -> StopBuild -> Int
hashWithSalt Int
_salt StopBuild' {Text
id :: Text
$sel:id:StopBuild' :: StopBuild -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

instance Data.ToHeaders StopBuild where
  toHeaders :: StopBuild -> 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.StopBuild" ::
                          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 StopBuild where
  toJSON :: StopBuild -> Value
toJSON StopBuild' {Text
id :: Text
$sel:id:StopBuild' :: StopBuild -> 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 StopBuild where
  toPath :: StopBuild -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'StopBuildResponse' 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:
--
-- 'build', 'stopBuildResponse_build' - Information about the build.
--
-- 'httpStatus', 'stopBuildResponse_httpStatus' - The response's http status code.
newStopBuildResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopBuildResponse
newStopBuildResponse :: Int -> StopBuildResponse
newStopBuildResponse Int
pHttpStatus_ =
  StopBuildResponse'
    { $sel:build:StopBuildResponse' :: Maybe Build
build = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopBuildResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the build.
stopBuildResponse_build :: Lens.Lens' StopBuildResponse (Prelude.Maybe Build)
stopBuildResponse_build :: Lens' StopBuildResponse (Maybe Build)
stopBuildResponse_build = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopBuildResponse' {Maybe Build
build :: Maybe Build
$sel:build:StopBuildResponse' :: StopBuildResponse -> Maybe Build
build} -> Maybe Build
build) (\s :: StopBuildResponse
s@StopBuildResponse' {} Maybe Build
a -> StopBuildResponse
s {$sel:build:StopBuildResponse' :: Maybe Build
build = Maybe Build
a} :: StopBuildResponse)

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

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