{-# 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.BatchDeleteBuilds
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes one or more builds.
module Amazonka.CodeBuild.BatchDeleteBuilds
  ( -- * Creating a Request
    BatchDeleteBuilds (..),
    newBatchDeleteBuilds,

    -- * Request Lenses
    batchDeleteBuilds_ids,

    -- * Destructuring the Response
    BatchDeleteBuildsResponse (..),
    newBatchDeleteBuildsResponse,

    -- * Response Lenses
    batchDeleteBuildsResponse_buildsDeleted,
    batchDeleteBuildsResponse_buildsNotDeleted,
    batchDeleteBuildsResponse_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:/ 'newBatchDeleteBuilds' smart constructor.
data BatchDeleteBuilds = BatchDeleteBuilds'
  { -- | The IDs of the builds to delete.
    BatchDeleteBuilds -> NonEmpty Text
ids :: Prelude.NonEmpty Prelude.Text
  }
  deriving (BatchDeleteBuilds -> BatchDeleteBuilds -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDeleteBuilds -> BatchDeleteBuilds -> Bool
$c/= :: BatchDeleteBuilds -> BatchDeleteBuilds -> Bool
== :: BatchDeleteBuilds -> BatchDeleteBuilds -> Bool
$c== :: BatchDeleteBuilds -> BatchDeleteBuilds -> Bool
Prelude.Eq, ReadPrec [BatchDeleteBuilds]
ReadPrec BatchDeleteBuilds
Int -> ReadS BatchDeleteBuilds
ReadS [BatchDeleteBuilds]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDeleteBuilds]
$creadListPrec :: ReadPrec [BatchDeleteBuilds]
readPrec :: ReadPrec BatchDeleteBuilds
$creadPrec :: ReadPrec BatchDeleteBuilds
readList :: ReadS [BatchDeleteBuilds]
$creadList :: ReadS [BatchDeleteBuilds]
readsPrec :: Int -> ReadS BatchDeleteBuilds
$creadsPrec :: Int -> ReadS BatchDeleteBuilds
Prelude.Read, Int -> BatchDeleteBuilds -> ShowS
[BatchDeleteBuilds] -> ShowS
BatchDeleteBuilds -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDeleteBuilds] -> ShowS
$cshowList :: [BatchDeleteBuilds] -> ShowS
show :: BatchDeleteBuilds -> String
$cshow :: BatchDeleteBuilds -> String
showsPrec :: Int -> BatchDeleteBuilds -> ShowS
$cshowsPrec :: Int -> BatchDeleteBuilds -> ShowS
Prelude.Show, forall x. Rep BatchDeleteBuilds x -> BatchDeleteBuilds
forall x. BatchDeleteBuilds -> Rep BatchDeleteBuilds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchDeleteBuilds x -> BatchDeleteBuilds
$cfrom :: forall x. BatchDeleteBuilds -> Rep BatchDeleteBuilds x
Prelude.Generic)

-- |
-- Create a value of 'BatchDeleteBuilds' 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:
--
-- 'ids', 'batchDeleteBuilds_ids' - The IDs of the builds to delete.
newBatchDeleteBuilds ::
  -- | 'ids'
  Prelude.NonEmpty Prelude.Text ->
  BatchDeleteBuilds
newBatchDeleteBuilds :: NonEmpty Text -> BatchDeleteBuilds
newBatchDeleteBuilds NonEmpty Text
pIds_ =
  BatchDeleteBuilds' {$sel:ids:BatchDeleteBuilds' :: NonEmpty Text
ids = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pIds_}

-- | The IDs of the builds to delete.
batchDeleteBuilds_ids :: Lens.Lens' BatchDeleteBuilds (Prelude.NonEmpty Prelude.Text)
batchDeleteBuilds_ids :: Lens' BatchDeleteBuilds (NonEmpty Text)
batchDeleteBuilds_ids = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteBuilds' {NonEmpty Text
ids :: NonEmpty Text
$sel:ids:BatchDeleteBuilds' :: BatchDeleteBuilds -> NonEmpty Text
ids} -> NonEmpty Text
ids) (\s :: BatchDeleteBuilds
s@BatchDeleteBuilds' {} NonEmpty Text
a -> BatchDeleteBuilds
s {$sel:ids:BatchDeleteBuilds' :: NonEmpty Text
ids = NonEmpty Text
a} :: BatchDeleteBuilds) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchDeleteBuilds where
  type
    AWSResponse BatchDeleteBuilds =
      BatchDeleteBuildsResponse
  request :: (Service -> Service)
-> BatchDeleteBuilds -> Request BatchDeleteBuilds
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 BatchDeleteBuilds
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDeleteBuilds)))
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 (NonEmpty Text)
-> Maybe [BuildNotDeleted] -> Int -> BatchDeleteBuildsResponse
BatchDeleteBuildsResponse'
            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
"buildsDeleted")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"buildsNotDeleted"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            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 BatchDeleteBuilds where
  hashWithSalt :: Int -> BatchDeleteBuilds -> Int
hashWithSalt Int
_salt BatchDeleteBuilds' {NonEmpty Text
ids :: NonEmpty Text
$sel:ids:BatchDeleteBuilds' :: BatchDeleteBuilds -> NonEmpty Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
ids

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

instance Data.ToHeaders BatchDeleteBuilds where
  toHeaders :: BatchDeleteBuilds -> 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.BatchDeleteBuilds" ::
                          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 BatchDeleteBuilds where
  toJSON :: BatchDeleteBuilds -> Value
toJSON BatchDeleteBuilds' {NonEmpty Text
ids :: NonEmpty Text
$sel:ids:BatchDeleteBuilds' :: BatchDeleteBuilds -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ids" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
ids)]
      )

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

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

-- | /See:/ 'newBatchDeleteBuildsResponse' smart constructor.
data BatchDeleteBuildsResponse = BatchDeleteBuildsResponse'
  { -- | The IDs of the builds that were successfully deleted.
    BatchDeleteBuildsResponse -> Maybe (NonEmpty Text)
buildsDeleted :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | Information about any builds that could not be successfully deleted.
    BatchDeleteBuildsResponse -> Maybe [BuildNotDeleted]
buildsNotDeleted :: Prelude.Maybe [BuildNotDeleted],
    -- | The response's http status code.
    BatchDeleteBuildsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchDeleteBuildsResponse -> BatchDeleteBuildsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDeleteBuildsResponse -> BatchDeleteBuildsResponse -> Bool
$c/= :: BatchDeleteBuildsResponse -> BatchDeleteBuildsResponse -> Bool
== :: BatchDeleteBuildsResponse -> BatchDeleteBuildsResponse -> Bool
$c== :: BatchDeleteBuildsResponse -> BatchDeleteBuildsResponse -> Bool
Prelude.Eq, ReadPrec [BatchDeleteBuildsResponse]
ReadPrec BatchDeleteBuildsResponse
Int -> ReadS BatchDeleteBuildsResponse
ReadS [BatchDeleteBuildsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDeleteBuildsResponse]
$creadListPrec :: ReadPrec [BatchDeleteBuildsResponse]
readPrec :: ReadPrec BatchDeleteBuildsResponse
$creadPrec :: ReadPrec BatchDeleteBuildsResponse
readList :: ReadS [BatchDeleteBuildsResponse]
$creadList :: ReadS [BatchDeleteBuildsResponse]
readsPrec :: Int -> ReadS BatchDeleteBuildsResponse
$creadsPrec :: Int -> ReadS BatchDeleteBuildsResponse
Prelude.Read, Int -> BatchDeleteBuildsResponse -> ShowS
[BatchDeleteBuildsResponse] -> ShowS
BatchDeleteBuildsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDeleteBuildsResponse] -> ShowS
$cshowList :: [BatchDeleteBuildsResponse] -> ShowS
show :: BatchDeleteBuildsResponse -> String
$cshow :: BatchDeleteBuildsResponse -> String
showsPrec :: Int -> BatchDeleteBuildsResponse -> ShowS
$cshowsPrec :: Int -> BatchDeleteBuildsResponse -> ShowS
Prelude.Show, forall x.
Rep BatchDeleteBuildsResponse x -> BatchDeleteBuildsResponse
forall x.
BatchDeleteBuildsResponse -> Rep BatchDeleteBuildsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDeleteBuildsResponse x -> BatchDeleteBuildsResponse
$cfrom :: forall x.
BatchDeleteBuildsResponse -> Rep BatchDeleteBuildsResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchDeleteBuildsResponse' 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:
--
-- 'buildsDeleted', 'batchDeleteBuildsResponse_buildsDeleted' - The IDs of the builds that were successfully deleted.
--
-- 'buildsNotDeleted', 'batchDeleteBuildsResponse_buildsNotDeleted' - Information about any builds that could not be successfully deleted.
--
-- 'httpStatus', 'batchDeleteBuildsResponse_httpStatus' - The response's http status code.
newBatchDeleteBuildsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchDeleteBuildsResponse
newBatchDeleteBuildsResponse :: Int -> BatchDeleteBuildsResponse
newBatchDeleteBuildsResponse Int
pHttpStatus_ =
  BatchDeleteBuildsResponse'
    { $sel:buildsDeleted:BatchDeleteBuildsResponse' :: Maybe (NonEmpty Text)
buildsDeleted =
        forall a. Maybe a
Prelude.Nothing,
      $sel:buildsNotDeleted:BatchDeleteBuildsResponse' :: Maybe [BuildNotDeleted]
buildsNotDeleted = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchDeleteBuildsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The IDs of the builds that were successfully deleted.
batchDeleteBuildsResponse_buildsDeleted :: Lens.Lens' BatchDeleteBuildsResponse (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
batchDeleteBuildsResponse_buildsDeleted :: Lens' BatchDeleteBuildsResponse (Maybe (NonEmpty Text))
batchDeleteBuildsResponse_buildsDeleted = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteBuildsResponse' {Maybe (NonEmpty Text)
buildsDeleted :: Maybe (NonEmpty Text)
$sel:buildsDeleted:BatchDeleteBuildsResponse' :: BatchDeleteBuildsResponse -> Maybe (NonEmpty Text)
buildsDeleted} -> Maybe (NonEmpty Text)
buildsDeleted) (\s :: BatchDeleteBuildsResponse
s@BatchDeleteBuildsResponse' {} Maybe (NonEmpty Text)
a -> BatchDeleteBuildsResponse
s {$sel:buildsDeleted:BatchDeleteBuildsResponse' :: Maybe (NonEmpty Text)
buildsDeleted = Maybe (NonEmpty Text)
a} :: BatchDeleteBuildsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Information about any builds that could not be successfully deleted.
batchDeleteBuildsResponse_buildsNotDeleted :: Lens.Lens' BatchDeleteBuildsResponse (Prelude.Maybe [BuildNotDeleted])
batchDeleteBuildsResponse_buildsNotDeleted :: Lens' BatchDeleteBuildsResponse (Maybe [BuildNotDeleted])
batchDeleteBuildsResponse_buildsNotDeleted = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteBuildsResponse' {Maybe [BuildNotDeleted]
buildsNotDeleted :: Maybe [BuildNotDeleted]
$sel:buildsNotDeleted:BatchDeleteBuildsResponse' :: BatchDeleteBuildsResponse -> Maybe [BuildNotDeleted]
buildsNotDeleted} -> Maybe [BuildNotDeleted]
buildsNotDeleted) (\s :: BatchDeleteBuildsResponse
s@BatchDeleteBuildsResponse' {} Maybe [BuildNotDeleted]
a -> BatchDeleteBuildsResponse
s {$sel:buildsNotDeleted:BatchDeleteBuildsResponse' :: Maybe [BuildNotDeleted]
buildsNotDeleted = Maybe [BuildNotDeleted]
a} :: BatchDeleteBuildsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchDeleteBuildsResponse where
  rnf :: BatchDeleteBuildsResponse -> ()
rnf BatchDeleteBuildsResponse' {Int
Maybe [BuildNotDeleted]
Maybe (NonEmpty Text)
httpStatus :: Int
buildsNotDeleted :: Maybe [BuildNotDeleted]
buildsDeleted :: Maybe (NonEmpty Text)
$sel:httpStatus:BatchDeleteBuildsResponse' :: BatchDeleteBuildsResponse -> Int
$sel:buildsNotDeleted:BatchDeleteBuildsResponse' :: BatchDeleteBuildsResponse -> Maybe [BuildNotDeleted]
$sel:buildsDeleted:BatchDeleteBuildsResponse' :: BatchDeleteBuildsResponse -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
buildsDeleted
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [BuildNotDeleted]
buildsNotDeleted
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus