{-# 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-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)
--
-- Restarts a build.
module Amazonka.CodeBuild.RetryBuild
  ( -- * Creating a Request
    RetryBuild (..),
    newRetryBuild,

    -- * Request Lenses
    retryBuild_idempotencyToken,
    retryBuild_id,

    -- * 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.Lens as Lens
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'
  { -- | 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,
    -- | Specifies the identifier of the build to restart.
    RetryBuild -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (RetryBuild -> RetryBuild -> Bool
(RetryBuild -> RetryBuild -> Bool)
-> (RetryBuild -> RetryBuild -> Bool) -> Eq RetryBuild
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]
(Int -> ReadS RetryBuild)
-> ReadS [RetryBuild]
-> ReadPrec RetryBuild
-> ReadPrec [RetryBuild]
-> Read 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
(Int -> RetryBuild -> ShowS)
-> (RetryBuild -> String)
-> ([RetryBuild] -> ShowS)
-> Show RetryBuild
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. RetryBuild -> Rep RetryBuild x)
-> (forall x. Rep RetryBuild x -> RetryBuild) -> Generic RetryBuild
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:
--
-- '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.
--
-- 'id', 'retryBuild_id' - Specifies the identifier of the build to restart.
newRetryBuild ::
  RetryBuild
newRetryBuild :: RetryBuild
newRetryBuild =
  RetryBuild' :: Maybe Text -> Maybe Text -> RetryBuild
RetryBuild'
    { $sel:idempotencyToken:RetryBuild' :: Maybe Text
idempotencyToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:RetryBuild' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> RetryBuild -> f RetryBuild
retryBuild_idempotencyToken = (RetryBuild -> Maybe Text)
-> (RetryBuild -> Maybe Text -> RetryBuild)
-> Lens RetryBuild RetryBuild (Maybe Text) (Maybe Text)
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)

-- | Specifies the identifier of the build to restart.
retryBuild_id :: Lens.Lens' RetryBuild (Prelude.Maybe Prelude.Text)
retryBuild_id :: (Maybe Text -> f (Maybe Text)) -> RetryBuild -> f RetryBuild
retryBuild_id = (RetryBuild -> Maybe Text)
-> (RetryBuild -> Maybe Text -> RetryBuild)
-> Lens RetryBuild RetryBuild (Maybe Text) (Maybe Text)
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)

instance Core.AWSRequest RetryBuild where
  type AWSResponse RetryBuild = RetryBuildResponse
  request :: RetryBuild -> Request RetryBuild
request = Service -> RetryBuild -> Request RetryBuild
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RetryBuild
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RetryBuild)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RetryBuild))
-> Logger
-> Service
-> Proxy RetryBuild
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RetryBuild)))
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 -> RetryBuildResponse
RetryBuildResponse'
            (Maybe Build -> Int -> RetryBuildResponse)
-> Either String (Maybe Build)
-> Either String (Int -> RetryBuildResponse)
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 -> RetryBuildResponse)
-> Either String Int -> Either String RetryBuildResponse
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 RetryBuild

instance Prelude.NFData RetryBuild

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

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

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