{-# 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.SecurityLake.Types.FailuresResponse
-- 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.SecurityLake.Types.FailuresResponse where

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 Amazonka.SecurityLake.Types.Failures

-- | Response element for actions that make changes, namely create, update,
-- or delete actions.
--
-- /See:/ 'newFailuresResponse' smart constructor.
data FailuresResponse = FailuresResponse'
  { -- | List of all failures.
    FailuresResponse -> Maybe [Failures]
failures :: Prelude.Maybe [Failures],
    -- | List of Amazon Web Services Regions where the failure occurred.
    FailuresResponse -> Maybe Text
region :: Prelude.Maybe Prelude.Text
  }
  deriving (FailuresResponse -> FailuresResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailuresResponse -> FailuresResponse -> Bool
$c/= :: FailuresResponse -> FailuresResponse -> Bool
== :: FailuresResponse -> FailuresResponse -> Bool
$c== :: FailuresResponse -> FailuresResponse -> Bool
Prelude.Eq, ReadPrec [FailuresResponse]
ReadPrec FailuresResponse
Int -> ReadS FailuresResponse
ReadS [FailuresResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailuresResponse]
$creadListPrec :: ReadPrec [FailuresResponse]
readPrec :: ReadPrec FailuresResponse
$creadPrec :: ReadPrec FailuresResponse
readList :: ReadS [FailuresResponse]
$creadList :: ReadS [FailuresResponse]
readsPrec :: Int -> ReadS FailuresResponse
$creadsPrec :: Int -> ReadS FailuresResponse
Prelude.Read, Int -> FailuresResponse -> ShowS
[FailuresResponse] -> ShowS
FailuresResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailuresResponse] -> ShowS
$cshowList :: [FailuresResponse] -> ShowS
show :: FailuresResponse -> String
$cshow :: FailuresResponse -> String
showsPrec :: Int -> FailuresResponse -> ShowS
$cshowsPrec :: Int -> FailuresResponse -> ShowS
Prelude.Show, forall x. Rep FailuresResponse x -> FailuresResponse
forall x. FailuresResponse -> Rep FailuresResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailuresResponse x -> FailuresResponse
$cfrom :: forall x. FailuresResponse -> Rep FailuresResponse x
Prelude.Generic)

-- |
-- Create a value of 'FailuresResponse' 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:
--
-- 'failures', 'failuresResponse_failures' - List of all failures.
--
-- 'region', 'failuresResponse_region' - List of Amazon Web Services Regions where the failure occurred.
newFailuresResponse ::
  FailuresResponse
newFailuresResponse :: FailuresResponse
newFailuresResponse =
  FailuresResponse'
    { $sel:failures:FailuresResponse' :: Maybe [Failures]
failures = forall a. Maybe a
Prelude.Nothing,
      $sel:region:FailuresResponse' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing
    }

-- | List of all failures.
failuresResponse_failures :: Lens.Lens' FailuresResponse (Prelude.Maybe [Failures])
failuresResponse_failures :: Lens' FailuresResponse (Maybe [Failures])
failuresResponse_failures = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailuresResponse' {Maybe [Failures]
failures :: Maybe [Failures]
$sel:failures:FailuresResponse' :: FailuresResponse -> Maybe [Failures]
failures} -> Maybe [Failures]
failures) (\s :: FailuresResponse
s@FailuresResponse' {} Maybe [Failures]
a -> FailuresResponse
s {$sel:failures:FailuresResponse' :: Maybe [Failures]
failures = Maybe [Failures]
a} :: FailuresResponse) 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

-- | List of Amazon Web Services Regions where the failure occurred.
failuresResponse_region :: Lens.Lens' FailuresResponse (Prelude.Maybe Prelude.Text)
failuresResponse_region :: Lens' FailuresResponse (Maybe Text)
failuresResponse_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailuresResponse' {Maybe Text
region :: Maybe Text
$sel:region:FailuresResponse' :: FailuresResponse -> Maybe Text
region} -> Maybe Text
region) (\s :: FailuresResponse
s@FailuresResponse' {} Maybe Text
a -> FailuresResponse
s {$sel:region:FailuresResponse' :: Maybe Text
region = Maybe Text
a} :: FailuresResponse)

instance Data.FromJSON FailuresResponse where
  parseJSON :: Value -> Parser FailuresResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FailuresResponse"
      ( \Object
x ->
          Maybe [Failures] -> Maybe Text -> FailuresResponse
FailuresResponse'
            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
"failures" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"region")
      )

instance Prelude.Hashable FailuresResponse where
  hashWithSalt :: Int -> FailuresResponse -> Int
hashWithSalt Int
_salt FailuresResponse' {Maybe [Failures]
Maybe Text
region :: Maybe Text
failures :: Maybe [Failures]
$sel:region:FailuresResponse' :: FailuresResponse -> Maybe Text
$sel:failures:FailuresResponse' :: FailuresResponse -> Maybe [Failures]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Failures]
failures
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region

instance Prelude.NFData FailuresResponse where
  rnf :: FailuresResponse -> ()
rnf FailuresResponse' {Maybe [Failures]
Maybe Text
region :: Maybe Text
failures :: Maybe [Failures]
$sel:region:FailuresResponse' :: FailuresResponse -> Maybe Text
$sel:failures:FailuresResponse' :: FailuresResponse -> Maybe [Failures]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Failures]
failures
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region