{-# 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-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)
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.Lens as Lens
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
(BatchReadOperationResponse -> BatchReadOperationResponse -> Bool)
-> (BatchReadOperationResponse
    -> BatchReadOperationResponse -> Bool)
-> Eq BatchReadOperationResponse
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]
(Int -> ReadS BatchReadOperationResponse)
-> ReadS [BatchReadOperationResponse]
-> ReadPrec BatchReadOperationResponse
-> ReadPrec [BatchReadOperationResponse]
-> Read 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
(Int -> BatchReadOperationResponse -> ShowS)
-> (BatchReadOperationResponse -> String)
-> ([BatchReadOperationResponse] -> ShowS)
-> Show BatchReadOperationResponse
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.
 BatchReadOperationResponse -> Rep BatchReadOperationResponse x)
-> (forall x.
    Rep BatchReadOperationResponse x -> BatchReadOperationResponse)
-> Generic BatchReadOperationResponse
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' :: Maybe BatchReadException
-> Maybe BatchReadSuccessfulResponse -> BatchReadOperationResponse
BatchReadOperationResponse'
    { $sel:exceptionResponse:BatchReadOperationResponse' :: Maybe BatchReadException
exceptionResponse =
        Maybe BatchReadException
forall a. Maybe a
Prelude.Nothing,
      $sel:successfulResponse:BatchReadOperationResponse' :: Maybe BatchReadSuccessfulResponse
successfulResponse = Maybe BatchReadSuccessfulResponse
forall a. Maybe a
Prelude.Nothing
    }

-- | Identifies which operation in a batch has failed.
batchReadOperationResponse_exceptionResponse :: Lens.Lens' BatchReadOperationResponse (Prelude.Maybe BatchReadException)
batchReadOperationResponse_exceptionResponse :: (Maybe BatchReadException -> f (Maybe BatchReadException))
-> BatchReadOperationResponse -> f BatchReadOperationResponse
batchReadOperationResponse_exceptionResponse = (BatchReadOperationResponse -> Maybe BatchReadException)
-> (BatchReadOperationResponse
    -> Maybe BatchReadException -> BatchReadOperationResponse)
-> Lens
     BatchReadOperationResponse
     BatchReadOperationResponse
     (Maybe BatchReadException)
     (Maybe BatchReadException)
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 :: (Maybe BatchReadSuccessfulResponse
 -> f (Maybe BatchReadSuccessfulResponse))
-> BatchReadOperationResponse -> f BatchReadOperationResponse
batchReadOperationResponse_successfulResponse = (BatchReadOperationResponse -> Maybe BatchReadSuccessfulResponse)
-> (BatchReadOperationResponse
    -> Maybe BatchReadSuccessfulResponse -> BatchReadOperationResponse)
-> Lens
     BatchReadOperationResponse
     BatchReadOperationResponse
     (Maybe BatchReadSuccessfulResponse)
     (Maybe BatchReadSuccessfulResponse)
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 Core.FromJSON BatchReadOperationResponse where
  parseJSON :: Value -> Parser BatchReadOperationResponse
parseJSON =
    String
-> (Object -> Parser BatchReadOperationResponse)
-> Value
-> Parser BatchReadOperationResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchReadOperationResponse"
      ( \Object
x ->
          Maybe BatchReadException
-> Maybe BatchReadSuccessfulResponse -> BatchReadOperationResponse
BatchReadOperationResponse'
            (Maybe BatchReadException
 -> Maybe BatchReadSuccessfulResponse -> BatchReadOperationResponse)
-> Parser (Maybe BatchReadException)
-> Parser
     (Maybe BatchReadSuccessfulResponse -> BatchReadOperationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe BatchReadException)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExceptionResponse")
            Parser
  (Maybe BatchReadSuccessfulResponse -> BatchReadOperationResponse)
-> Parser (Maybe BatchReadSuccessfulResponse)
-> Parser BatchReadOperationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BatchReadSuccessfulResponse)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SuccessfulResponse")
      )

instance Prelude.Hashable BatchReadOperationResponse

instance Prelude.NFData BatchReadOperationResponse