{-# 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.BatchGetReports
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns an array of reports.
module Amazonka.CodeBuild.BatchGetReports
  ( -- * Creating a Request
    BatchGetReports (..),
    newBatchGetReports,

    -- * Request Lenses
    batchGetReports_reportArns,

    -- * Destructuring the Response
    BatchGetReportsResponse (..),
    newBatchGetReportsResponse,

    -- * Response Lenses
    batchGetReportsResponse_reports,
    batchGetReportsResponse_reportsNotFound,
    batchGetReportsResponse_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:/ 'newBatchGetReports' smart constructor.
data BatchGetReports = BatchGetReports'
  { -- | An array of ARNs that identify the @Report@ objects to return.
    BatchGetReports -> NonEmpty Text
reportArns :: Prelude.NonEmpty Prelude.Text
  }
  deriving (BatchGetReports -> BatchGetReports -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetReports -> BatchGetReports -> Bool
$c/= :: BatchGetReports -> BatchGetReports -> Bool
== :: BatchGetReports -> BatchGetReports -> Bool
$c== :: BatchGetReports -> BatchGetReports -> Bool
Prelude.Eq, ReadPrec [BatchGetReports]
ReadPrec BatchGetReports
Int -> ReadS BatchGetReports
ReadS [BatchGetReports]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetReports]
$creadListPrec :: ReadPrec [BatchGetReports]
readPrec :: ReadPrec BatchGetReports
$creadPrec :: ReadPrec BatchGetReports
readList :: ReadS [BatchGetReports]
$creadList :: ReadS [BatchGetReports]
readsPrec :: Int -> ReadS BatchGetReports
$creadsPrec :: Int -> ReadS BatchGetReports
Prelude.Read, Int -> BatchGetReports -> ShowS
[BatchGetReports] -> ShowS
BatchGetReports -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetReports] -> ShowS
$cshowList :: [BatchGetReports] -> ShowS
show :: BatchGetReports -> String
$cshow :: BatchGetReports -> String
showsPrec :: Int -> BatchGetReports -> ShowS
$cshowsPrec :: Int -> BatchGetReports -> ShowS
Prelude.Show, forall x. Rep BatchGetReports x -> BatchGetReports
forall x. BatchGetReports -> Rep BatchGetReports x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetReports x -> BatchGetReports
$cfrom :: forall x. BatchGetReports -> Rep BatchGetReports x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetReports' 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:
--
-- 'reportArns', 'batchGetReports_reportArns' - An array of ARNs that identify the @Report@ objects to return.
newBatchGetReports ::
  -- | 'reportArns'
  Prelude.NonEmpty Prelude.Text ->
  BatchGetReports
newBatchGetReports :: NonEmpty Text -> BatchGetReports
newBatchGetReports NonEmpty Text
pReportArns_ =
  BatchGetReports'
    { $sel:reportArns:BatchGetReports' :: NonEmpty Text
reportArns =
        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
pReportArns_
    }

-- | An array of ARNs that identify the @Report@ objects to return.
batchGetReports_reportArns :: Lens.Lens' BatchGetReports (Prelude.NonEmpty Prelude.Text)
batchGetReports_reportArns :: Lens' BatchGetReports (NonEmpty Text)
batchGetReports_reportArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetReports' {NonEmpty Text
reportArns :: NonEmpty Text
$sel:reportArns:BatchGetReports' :: BatchGetReports -> NonEmpty Text
reportArns} -> NonEmpty Text
reportArns) (\s :: BatchGetReports
s@BatchGetReports' {} NonEmpty Text
a -> BatchGetReports
s {$sel:reportArns:BatchGetReports' :: NonEmpty Text
reportArns = NonEmpty Text
a} :: BatchGetReports) 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 BatchGetReports where
  type
    AWSResponse BatchGetReports =
      BatchGetReportsResponse
  request :: (Service -> Service) -> BatchGetReports -> Request BatchGetReports
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 BatchGetReports
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchGetReports)))
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 Report)
-> Maybe (NonEmpty Text) -> Int -> BatchGetReportsResponse
BatchGetReportsResponse'
            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
"reports")
            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
"reportsNotFound")
            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 BatchGetReports where
  hashWithSalt :: Int -> BatchGetReports -> Int
hashWithSalt Int
_salt BatchGetReports' {NonEmpty Text
reportArns :: NonEmpty Text
$sel:reportArns:BatchGetReports' :: BatchGetReports -> NonEmpty Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
reportArns

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

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

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

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

-- | /See:/ 'newBatchGetReportsResponse' smart constructor.
data BatchGetReportsResponse = BatchGetReportsResponse'
  { -- | The array of @Report@ objects returned by @BatchGetReports@.
    BatchGetReportsResponse -> Maybe (NonEmpty Report)
reports :: Prelude.Maybe (Prelude.NonEmpty Report),
    -- | An array of ARNs passed to @BatchGetReportGroups@ that are not
    -- associated with a @Report@.
    BatchGetReportsResponse -> Maybe (NonEmpty Text)
reportsNotFound :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The response's http status code.
    BatchGetReportsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchGetReportsResponse -> BatchGetReportsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetReportsResponse -> BatchGetReportsResponse -> Bool
$c/= :: BatchGetReportsResponse -> BatchGetReportsResponse -> Bool
== :: BatchGetReportsResponse -> BatchGetReportsResponse -> Bool
$c== :: BatchGetReportsResponse -> BatchGetReportsResponse -> Bool
Prelude.Eq, ReadPrec [BatchGetReportsResponse]
ReadPrec BatchGetReportsResponse
Int -> ReadS BatchGetReportsResponse
ReadS [BatchGetReportsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetReportsResponse]
$creadListPrec :: ReadPrec [BatchGetReportsResponse]
readPrec :: ReadPrec BatchGetReportsResponse
$creadPrec :: ReadPrec BatchGetReportsResponse
readList :: ReadS [BatchGetReportsResponse]
$creadList :: ReadS [BatchGetReportsResponse]
readsPrec :: Int -> ReadS BatchGetReportsResponse
$creadsPrec :: Int -> ReadS BatchGetReportsResponse
Prelude.Read, Int -> BatchGetReportsResponse -> ShowS
[BatchGetReportsResponse] -> ShowS
BatchGetReportsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetReportsResponse] -> ShowS
$cshowList :: [BatchGetReportsResponse] -> ShowS
show :: BatchGetReportsResponse -> String
$cshow :: BatchGetReportsResponse -> String
showsPrec :: Int -> BatchGetReportsResponse -> ShowS
$cshowsPrec :: Int -> BatchGetReportsResponse -> ShowS
Prelude.Show, forall x. Rep BatchGetReportsResponse x -> BatchGetReportsResponse
forall x. BatchGetReportsResponse -> Rep BatchGetReportsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetReportsResponse x -> BatchGetReportsResponse
$cfrom :: forall x. BatchGetReportsResponse -> Rep BatchGetReportsResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetReportsResponse' 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:
--
-- 'reports', 'batchGetReportsResponse_reports' - The array of @Report@ objects returned by @BatchGetReports@.
--
-- 'reportsNotFound', 'batchGetReportsResponse_reportsNotFound' - An array of ARNs passed to @BatchGetReportGroups@ that are not
-- associated with a @Report@.
--
-- 'httpStatus', 'batchGetReportsResponse_httpStatus' - The response's http status code.
newBatchGetReportsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetReportsResponse
newBatchGetReportsResponse :: Int -> BatchGetReportsResponse
newBatchGetReportsResponse Int
pHttpStatus_ =
  BatchGetReportsResponse'
    { $sel:reports:BatchGetReportsResponse' :: Maybe (NonEmpty Report)
reports = forall a. Maybe a
Prelude.Nothing,
      $sel:reportsNotFound:BatchGetReportsResponse' :: Maybe (NonEmpty Text)
reportsNotFound = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetReportsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The array of @Report@ objects returned by @BatchGetReports@.
batchGetReportsResponse_reports :: Lens.Lens' BatchGetReportsResponse (Prelude.Maybe (Prelude.NonEmpty Report))
batchGetReportsResponse_reports :: Lens' BatchGetReportsResponse (Maybe (NonEmpty Report))
batchGetReportsResponse_reports = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetReportsResponse' {Maybe (NonEmpty Report)
reports :: Maybe (NonEmpty Report)
$sel:reports:BatchGetReportsResponse' :: BatchGetReportsResponse -> Maybe (NonEmpty Report)
reports} -> Maybe (NonEmpty Report)
reports) (\s :: BatchGetReportsResponse
s@BatchGetReportsResponse' {} Maybe (NonEmpty Report)
a -> BatchGetReportsResponse
s {$sel:reports:BatchGetReportsResponse' :: Maybe (NonEmpty Report)
reports = Maybe (NonEmpty Report)
a} :: BatchGetReportsResponse) 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

-- | An array of ARNs passed to @BatchGetReportGroups@ that are not
-- associated with a @Report@.
batchGetReportsResponse_reportsNotFound :: Lens.Lens' BatchGetReportsResponse (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
batchGetReportsResponse_reportsNotFound :: Lens' BatchGetReportsResponse (Maybe (NonEmpty Text))
batchGetReportsResponse_reportsNotFound = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetReportsResponse' {Maybe (NonEmpty Text)
reportsNotFound :: Maybe (NonEmpty Text)
$sel:reportsNotFound:BatchGetReportsResponse' :: BatchGetReportsResponse -> Maybe (NonEmpty Text)
reportsNotFound} -> Maybe (NonEmpty Text)
reportsNotFound) (\s :: BatchGetReportsResponse
s@BatchGetReportsResponse' {} Maybe (NonEmpty Text)
a -> BatchGetReportsResponse
s {$sel:reportsNotFound:BatchGetReportsResponse' :: Maybe (NonEmpty Text)
reportsNotFound = Maybe (NonEmpty Text)
a} :: BatchGetReportsResponse) 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.
batchGetReportsResponse_httpStatus :: Lens.Lens' BatchGetReportsResponse Prelude.Int
batchGetReportsResponse_httpStatus :: Lens' BatchGetReportsResponse Int
batchGetReportsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetReportsResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchGetReportsResponse' :: BatchGetReportsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchGetReportsResponse
s@BatchGetReportsResponse' {} Int
a -> BatchGetReportsResponse
s {$sel:httpStatus:BatchGetReportsResponse' :: Int
httpStatus = Int
a} :: BatchGetReportsResponse)

instance Prelude.NFData BatchGetReportsResponse where
  rnf :: BatchGetReportsResponse -> ()
rnf BatchGetReportsResponse' {Int
Maybe (NonEmpty Text)
Maybe (NonEmpty Report)
httpStatus :: Int
reportsNotFound :: Maybe (NonEmpty Text)
reports :: Maybe (NonEmpty Report)
$sel:httpStatus:BatchGetReportsResponse' :: BatchGetReportsResponse -> Int
$sel:reportsNotFound:BatchGetReportsResponse' :: BatchGetReportsResponse -> Maybe (NonEmpty Text)
$sel:reports:BatchGetReportsResponse' :: BatchGetReportsResponse -> Maybe (NonEmpty Report)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Report)
reports
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
reportsNotFound
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus