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

    -- * Request Lenses
    retryBuild_id,
    retryBuild_idempotencyToken,

    -- * Destructuring the Response
    RetryBuildResponse (..),
    newRetryBuildResponse,

    -- * Response Lenses
    retryBuildResponse_build,
    retryBuildResponse_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:/ 'newRetryBuild' smart constructor.
data RetryBuild = RetryBuild'
  { -- | Specifies the identifier of the build to restart.
    RetryBuild -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | A unique, case sensitive identifier you provide to ensure the
    -- idempotency of the @RetryBuild@ request. The token is included in the
    -- @RetryBuild@ request and is valid for five minutes. If you repeat the
    -- @RetryBuild@ request with the same token, but change a parameter,
    -- CodeBuild returns a parameter mismatch error.
    RetryBuild -> Maybe Text
idempotencyToken :: Prelude.Maybe Prelude.Text
  }
  deriving (RetryBuild -> RetryBuild -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetryBuild -> RetryBuild -> Bool
$c/= :: RetryBuild -> RetryBuild -> Bool
== :: RetryBuild -> RetryBuild -> Bool
$c== :: RetryBuild -> RetryBuild -> Bool
Prelude.Eq, ReadPrec [RetryBuild]
ReadPrec RetryBuild
Int -> ReadS RetryBuild
ReadS [RetryBuild]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetryBuild]
$creadListPrec :: ReadPrec [RetryBuild]
readPrec :: ReadPrec RetryBuild
$creadPrec :: ReadPrec RetryBuild
readList :: ReadS [RetryBuild]
$creadList :: ReadS [RetryBuild]
readsPrec :: Int -> ReadS RetryBuild
$creadsPrec :: Int -> ReadS RetryBuild
Prelude.Read, Int -> RetryBuild -> ShowS
[RetryBuild] -> ShowS
RetryBuild -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetryBuild] -> ShowS
$cshowList :: [RetryBuild] -> ShowS
show :: RetryBuild -> String
$cshow :: RetryBuild -> String
showsPrec :: Int -> RetryBuild -> ShowS
$cshowsPrec :: Int -> RetryBuild -> ShowS
Prelude.Show, forall x. Rep RetryBuild x -> RetryBuild
forall x. RetryBuild -> Rep RetryBuild x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetryBuild x -> RetryBuild
$cfrom :: forall x. RetryBuild -> Rep RetryBuild x
Prelude.Generic)

-- |
-- Create a value of 'RetryBuild' 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', 'retryBuild_id' - Specifies the identifier of the build to restart.
--
-- 'idempotencyToken', 'retryBuild_idempotencyToken' - A unique, case sensitive identifier you provide to ensure the
-- idempotency of the @RetryBuild@ request. The token is included in the
-- @RetryBuild@ request and is valid for five minutes. If you repeat the
-- @RetryBuild@ request with the same token, but change a parameter,
-- CodeBuild returns a parameter mismatch error.
newRetryBuild ::
  RetryBuild
newRetryBuild :: RetryBuild
newRetryBuild =
  RetryBuild'
    { $sel:id:RetryBuild' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:idempotencyToken:RetryBuild' :: Maybe Text
idempotencyToken = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the identifier of the build to restart.
retryBuild_id :: Lens.Lens' RetryBuild (Prelude.Maybe Prelude.Text)
retryBuild_id :: Lens' RetryBuild (Maybe Text)
retryBuild_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryBuild' {Maybe Text
id :: Maybe Text
$sel:id:RetryBuild' :: RetryBuild -> Maybe Text
id} -> Maybe Text
id) (\s :: RetryBuild
s@RetryBuild' {} Maybe Text
a -> RetryBuild
s {$sel:id:RetryBuild' :: Maybe Text
id = Maybe Text
a} :: RetryBuild)

-- | A unique, case sensitive identifier you provide to ensure the
-- idempotency of the @RetryBuild@ request. The token is included in the
-- @RetryBuild@ request and is valid for five minutes. If you repeat the
-- @RetryBuild@ request with the same token, but change a parameter,
-- CodeBuild returns a parameter mismatch error.
retryBuild_idempotencyToken :: Lens.Lens' RetryBuild (Prelude.Maybe Prelude.Text)
retryBuild_idempotencyToken :: Lens' RetryBuild (Maybe Text)
retryBuild_idempotencyToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryBuild' {Maybe Text
idempotencyToken :: Maybe Text
$sel:idempotencyToken:RetryBuild' :: RetryBuild -> Maybe Text
idempotencyToken} -> Maybe Text
idempotencyToken) (\s :: RetryBuild
s@RetryBuild' {} Maybe Text
a -> RetryBuild
s {$sel:idempotencyToken:RetryBuild' :: Maybe Text
idempotencyToken = Maybe Text
a} :: RetryBuild)

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

instance Prelude.NFData RetryBuild where
  rnf :: RetryBuild -> ()
rnf RetryBuild' {Maybe Text
idempotencyToken :: Maybe Text
id :: Maybe Text
$sel:idempotencyToken:RetryBuild' :: RetryBuild -> Maybe Text
$sel:id:RetryBuild' :: RetryBuild -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
idempotencyToken

instance Data.ToHeaders RetryBuild where
  toHeaders :: RetryBuild -> 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.RetryBuild" ::
                          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 RetryBuild where
  toJSON :: RetryBuild -> Value
toJSON RetryBuild' {Maybe Text
idempotencyToken :: Maybe Text
id :: Maybe Text
$sel:idempotencyToken:RetryBuild' :: RetryBuild -> Maybe Text
$sel:id:RetryBuild' :: RetryBuild -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
id,
            (Key
"idempotencyToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
idempotencyToken
          ]
      )

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

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

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

-- |
-- Create a value of 'RetryBuildResponse' 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', 'retryBuildResponse_build' - Undocumented member.
--
-- 'httpStatus', 'retryBuildResponse_httpStatus' - The response's http status code.
newRetryBuildResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RetryBuildResponse
newRetryBuildResponse :: Int -> RetryBuildResponse
newRetryBuildResponse Int
pHttpStatus_ =
  RetryBuildResponse'
    { $sel:build:RetryBuildResponse' :: Maybe Build
build = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RetryBuildResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
retryBuildResponse_build :: Lens.Lens' RetryBuildResponse (Prelude.Maybe Build)
retryBuildResponse_build :: Lens' RetryBuildResponse (Maybe Build)
retryBuildResponse_build = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryBuildResponse' {Maybe Build
build :: Maybe Build
$sel:build:RetryBuildResponse' :: RetryBuildResponse -> Maybe Build
build} -> Maybe Build
build) (\s :: RetryBuildResponse
s@RetryBuildResponse' {} Maybe Build
a -> RetryBuildResponse
s {$sel:build:RetryBuildResponse' :: Maybe Build
build = Maybe Build
a} :: RetryBuildResponse)

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

instance Prelude.NFData RetryBuildResponse where
  rnf :: RetryBuildResponse -> ()
rnf RetryBuildResponse' {Int
Maybe Build
httpStatus :: Int
build :: Maybe Build
$sel:httpStatus:RetryBuildResponse' :: RetryBuildResponse -> Int
$sel:build:RetryBuildResponse' :: RetryBuildResponse -> 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