{-# 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.RetryBuildBatch
-- 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 failed batch build. Only batch builds that have failed can be
-- retried.
module Amazonka.CodeBuild.RetryBuildBatch
  ( -- * Creating a Request
    RetryBuildBatch (..),
    newRetryBuildBatch,

    -- * Request Lenses
    retryBuildBatch_id,
    retryBuildBatch_idempotencyToken,
    retryBuildBatch_retryType,

    -- * Destructuring the Response
    RetryBuildBatchResponse (..),
    newRetryBuildBatchResponse,

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

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

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

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

-- | Specifies the type of retry to perform.
retryBuildBatch_retryType :: Lens.Lens' RetryBuildBatch (Prelude.Maybe RetryBuildBatchType)
retryBuildBatch_retryType :: Lens' RetryBuildBatch (Maybe RetryBuildBatchType)
retryBuildBatch_retryType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryBuildBatch' {Maybe RetryBuildBatchType
retryType :: Maybe RetryBuildBatchType
$sel:retryType:RetryBuildBatch' :: RetryBuildBatch -> Maybe RetryBuildBatchType
retryType} -> Maybe RetryBuildBatchType
retryType) (\s :: RetryBuildBatch
s@RetryBuildBatch' {} Maybe RetryBuildBatchType
a -> RetryBuildBatch
s {$sel:retryType:RetryBuildBatch' :: Maybe RetryBuildBatchType
retryType = Maybe RetryBuildBatchType
a} :: RetryBuildBatch)

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

instance Prelude.NFData RetryBuildBatch where
  rnf :: RetryBuildBatch -> ()
rnf RetryBuildBatch' {Maybe Text
Maybe RetryBuildBatchType
retryType :: Maybe RetryBuildBatchType
idempotencyToken :: Maybe Text
id :: Maybe Text
$sel:retryType:RetryBuildBatch' :: RetryBuildBatch -> Maybe RetryBuildBatchType
$sel:idempotencyToken:RetryBuildBatch' :: RetryBuildBatch -> Maybe Text
$sel:id:RetryBuildBatch' :: RetryBuildBatch -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RetryBuildBatchType
retryType

instance Data.ToHeaders RetryBuildBatch where
  toHeaders :: RetryBuildBatch -> 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.RetryBuildBatch" ::
                          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 RetryBuildBatch where
  toJSON :: RetryBuildBatch -> Value
toJSON RetryBuildBatch' {Maybe Text
Maybe RetryBuildBatchType
retryType :: Maybe RetryBuildBatchType
idempotencyToken :: Maybe Text
id :: Maybe Text
$sel:retryType:RetryBuildBatch' :: RetryBuildBatch -> Maybe RetryBuildBatchType
$sel:idempotencyToken:RetryBuildBatch' :: RetryBuildBatch -> Maybe Text
$sel:id:RetryBuildBatch' :: RetryBuildBatch -> 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,
            (Key
"retryType" 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 RetryBuildBatchType
retryType
          ]
      )

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

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

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

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

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

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

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