{-# 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-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)
--
-- 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.Lens as Lens
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
(StopBuild -> StopBuild -> Bool)
-> (StopBuild -> StopBuild -> Bool) -> Eq StopBuild
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]
(Int -> ReadS StopBuild)
-> ReadS [StopBuild]
-> ReadPrec StopBuild
-> ReadPrec [StopBuild]
-> Read 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
(Int -> StopBuild -> ShowS)
-> (StopBuild -> String)
-> ([StopBuild] -> ShowS)
-> Show StopBuild
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. StopBuild -> Rep StopBuild x)
-> (forall x. Rep StopBuild x -> StopBuild) -> Generic StopBuild
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' :: Text -> StopBuild
StopBuild' {$sel:id:StopBuild' :: Text
id = Text
pId_}

-- | The ID of the build.
stopBuild_id :: Lens.Lens' StopBuild Prelude.Text
stopBuild_id :: (Text -> f Text) -> StopBuild -> f StopBuild
stopBuild_id = (StopBuild -> Text)
-> (StopBuild -> Text -> StopBuild)
-> Lens StopBuild StopBuild Text Text
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 :: StopBuild -> Request StopBuild
request = Service -> StopBuild -> Request StopBuild
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopBuild
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopBuild)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopBuild))
-> Logger
-> Service
-> Proxy StopBuild
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopBuild)))
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 Build -> Int -> StopBuildResponse
StopBuildResponse'
            (Maybe Build -> Int -> StopBuildResponse)
-> Either String (Maybe Build)
-> Either String (Int -> StopBuildResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Build)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"build")
            Either String (Int -> StopBuildResponse)
-> Either String Int -> Either String StopBuildResponse
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 StopBuild

instance Prelude.NFData StopBuild

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

instance Core.ToQuery StopBuild where
  toQuery :: StopBuild -> QueryString
toQuery = QueryString -> StopBuild -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(StopBuildResponse -> StopBuildResponse -> Bool)
-> (StopBuildResponse -> StopBuildResponse -> Bool)
-> Eq StopBuildResponse
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]
(Int -> ReadS StopBuildResponse)
-> ReadS [StopBuildResponse]
-> ReadPrec StopBuildResponse
-> ReadPrec [StopBuildResponse]
-> Read 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
(Int -> StopBuildResponse -> ShowS)
-> (StopBuildResponse -> String)
-> ([StopBuildResponse] -> ShowS)
-> Show StopBuildResponse
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. StopBuildResponse -> Rep StopBuildResponse x)
-> (forall x. Rep StopBuildResponse x -> StopBuildResponse)
-> Generic StopBuildResponse
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' :: Maybe Build -> Int -> StopBuildResponse
StopBuildResponse'
    { $sel:build:StopBuildResponse' :: Maybe Build
build = Maybe 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 :: (Maybe Build -> f (Maybe Build))
-> StopBuildResponse -> f StopBuildResponse
stopBuildResponse_build = (StopBuildResponse -> Maybe Build)
-> (StopBuildResponse -> Maybe Build -> StopBuildResponse)
-> Lens
     StopBuildResponse StopBuildResponse (Maybe Build) (Maybe 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 :: (Int -> f Int) -> StopBuildResponse -> f StopBuildResponse
stopBuildResponse_httpStatus = (StopBuildResponse -> Int)
-> (StopBuildResponse -> Int -> StopBuildResponse)
-> Lens StopBuildResponse StopBuildResponse Int Int
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