{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudDirectory.Types.BatchReadOperationResponse
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudDirectory.Types.BatchReadOperationResponse where

import Amazonka.CloudDirectory.Types.BatchReadException
import Amazonka.CloudDirectory.Types.BatchReadSuccessfulResponse
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

-- | Represents the output of a @BatchRead@ response operation.
--
-- /See:/ 'newBatchReadOperationResponse' smart constructor.
data BatchReadOperationResponse = BatchReadOperationResponse'
  { -- | Identifies which operation in a batch has failed.
    BatchReadOperationResponse -> Maybe BatchReadException
exceptionResponse :: Prelude.Maybe BatchReadException,
    -- | Identifies which operation in a batch has succeeded.
    BatchReadOperationResponse -> Maybe BatchReadSuccessfulResponse
successfulResponse :: Prelude.Maybe BatchReadSuccessfulResponse
  }
  deriving (BatchReadOperationResponse -> BatchReadOperationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchReadOperationResponse -> BatchReadOperationResponse -> Bool
$c/= :: BatchReadOperationResponse -> BatchReadOperationResponse -> Bool
== :: BatchReadOperationResponse -> BatchReadOperationResponse -> Bool
$c== :: BatchReadOperationResponse -> BatchReadOperationResponse -> Bool
Prelude.Eq, ReadPrec [BatchReadOperationResponse]
ReadPrec BatchReadOperationResponse
Int -> ReadS BatchReadOperationResponse
ReadS [BatchReadOperationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchReadOperationResponse]
$creadListPrec :: ReadPrec [BatchReadOperationResponse]
readPrec :: ReadPrec BatchReadOperationResponse
$creadPrec :: ReadPrec BatchReadOperationResponse
readList :: ReadS [BatchReadOperationResponse]
$creadList :: ReadS [BatchReadOperationResponse]
readsPrec :: Int -> ReadS BatchReadOperationResponse
$creadsPrec :: Int -> ReadS BatchReadOperationResponse
Prelude.Read, Int -> BatchReadOperationResponse -> ShowS
[BatchReadOperationResponse] -> ShowS
BatchReadOperationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchReadOperationResponse] -> ShowS
$cshowList :: [BatchReadOperationResponse] -> ShowS
show :: BatchReadOperationResponse -> String
$cshow :: BatchReadOperationResponse -> String
showsPrec :: Int -> BatchReadOperationResponse -> ShowS
$cshowsPrec :: Int -> BatchReadOperationResponse -> ShowS
Prelude.Show, forall x.
Rep BatchReadOperationResponse x -> BatchReadOperationResponse
forall x.
BatchReadOperationResponse -> Rep BatchReadOperationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchReadOperationResponse x -> BatchReadOperationResponse
$cfrom :: forall x.
BatchReadOperationResponse -> Rep BatchReadOperationResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchReadOperationResponse' 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:
--
-- 'exceptionResponse', 'batchReadOperationResponse_exceptionResponse' - Identifies which operation in a batch has failed.
--
-- 'successfulResponse', 'batchReadOperationResponse_successfulResponse' - Identifies which operation in a batch has succeeded.
newBatchReadOperationResponse ::
  BatchReadOperationResponse
newBatchReadOperationResponse :: BatchReadOperationResponse
newBatchReadOperationResponse =
  BatchReadOperationResponse'
    { $sel:exceptionResponse:BatchReadOperationResponse' :: Maybe BatchReadException
exceptionResponse =
        forall a. Maybe a
Prelude.Nothing,
      $sel:successfulResponse:BatchReadOperationResponse' :: Maybe BatchReadSuccessfulResponse
successfulResponse = forall a. Maybe a
Prelude.Nothing
    }

-- | Identifies which operation in a batch has failed.
batchReadOperationResponse_exceptionResponse :: Lens.Lens' BatchReadOperationResponse (Prelude.Maybe BatchReadException)
batchReadOperationResponse_exceptionResponse :: Lens' BatchReadOperationResponse (Maybe BatchReadException)
batchReadOperationResponse_exceptionResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchReadOperationResponse' {Maybe BatchReadException
exceptionResponse :: Maybe BatchReadException
$sel:exceptionResponse:BatchReadOperationResponse' :: BatchReadOperationResponse -> Maybe BatchReadException
exceptionResponse} -> Maybe BatchReadException
exceptionResponse) (\s :: BatchReadOperationResponse
s@BatchReadOperationResponse' {} Maybe BatchReadException
a -> BatchReadOperationResponse
s {$sel:exceptionResponse:BatchReadOperationResponse' :: Maybe BatchReadException
exceptionResponse = Maybe BatchReadException
a} :: BatchReadOperationResponse)

-- | Identifies which operation in a batch has succeeded.
batchReadOperationResponse_successfulResponse :: Lens.Lens' BatchReadOperationResponse (Prelude.Maybe BatchReadSuccessfulResponse)
batchReadOperationResponse_successfulResponse :: Lens'
  BatchReadOperationResponse (Maybe BatchReadSuccessfulResponse)
batchReadOperationResponse_successfulResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchReadOperationResponse' {Maybe BatchReadSuccessfulResponse
successfulResponse :: Maybe BatchReadSuccessfulResponse
$sel:successfulResponse:BatchReadOperationResponse' :: BatchReadOperationResponse -> Maybe BatchReadSuccessfulResponse
successfulResponse} -> Maybe BatchReadSuccessfulResponse
successfulResponse) (\s :: BatchReadOperationResponse
s@BatchReadOperationResponse' {} Maybe BatchReadSuccessfulResponse
a -> BatchReadOperationResponse
s {$sel:successfulResponse:BatchReadOperationResponse' :: Maybe BatchReadSuccessfulResponse
successfulResponse = Maybe BatchReadSuccessfulResponse
a} :: BatchReadOperationResponse)

instance Data.FromJSON BatchReadOperationResponse where
  parseJSON :: Value -> Parser BatchReadOperationResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchReadOperationResponse"
      ( \Object
x ->
          Maybe BatchReadException
-> Maybe BatchReadSuccessfulResponse -> BatchReadOperationResponse
BatchReadOperationResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExceptionResponse")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SuccessfulResponse")
      )

instance Prelude.Hashable BatchReadOperationResponse where
  hashWithSalt :: Int -> BatchReadOperationResponse -> Int
hashWithSalt Int
_salt BatchReadOperationResponse' {Maybe BatchReadException
Maybe BatchReadSuccessfulResponse
successfulResponse :: Maybe BatchReadSuccessfulResponse
exceptionResponse :: Maybe BatchReadException
$sel:successfulResponse:BatchReadOperationResponse' :: BatchReadOperationResponse -> Maybe BatchReadSuccessfulResponse
$sel:exceptionResponse:BatchReadOperationResponse' :: BatchReadOperationResponse -> Maybe BatchReadException
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BatchReadException
exceptionResponse
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BatchReadSuccessfulResponse
successfulResponse

instance Prelude.NFData BatchReadOperationResponse where
  rnf :: BatchReadOperationResponse -> ()
rnf BatchReadOperationResponse' {Maybe BatchReadException
Maybe BatchReadSuccessfulResponse
successfulResponse :: Maybe BatchReadSuccessfulResponse
exceptionResponse :: Maybe BatchReadException
$sel:successfulResponse:BatchReadOperationResponse' :: BatchReadOperationResponse -> Maybe BatchReadSuccessfulResponse
$sel:exceptionResponse:BatchReadOperationResponse' :: BatchReadOperationResponse -> Maybe BatchReadException
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BatchReadException
exceptionResponse
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BatchReadSuccessfulResponse
successfulResponse