{-# 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.ServiceCatalog.Types.ShareError
-- 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.ServiceCatalog.Types.ShareError 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

-- | Errors that occurred during the portfolio share operation.
--
-- /See:/ 'newShareError' smart constructor.
data ShareError = ShareError'
  { -- | List of accounts impacted by the error.
    ShareError -> Maybe [Text]
accounts :: Prelude.Maybe [Prelude.Text],
    -- | Error type that happened when processing the operation.
    ShareError -> Maybe Text
error :: Prelude.Maybe Prelude.Text,
    -- | Information about the error.
    ShareError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (ShareError -> ShareError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShareError -> ShareError -> Bool
$c/= :: ShareError -> ShareError -> Bool
== :: ShareError -> ShareError -> Bool
$c== :: ShareError -> ShareError -> Bool
Prelude.Eq, ReadPrec [ShareError]
ReadPrec ShareError
Int -> ReadS ShareError
ReadS [ShareError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShareError]
$creadListPrec :: ReadPrec [ShareError]
readPrec :: ReadPrec ShareError
$creadPrec :: ReadPrec ShareError
readList :: ReadS [ShareError]
$creadList :: ReadS [ShareError]
readsPrec :: Int -> ReadS ShareError
$creadsPrec :: Int -> ReadS ShareError
Prelude.Read, Int -> ShareError -> ShowS
[ShareError] -> ShowS
ShareError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShareError] -> ShowS
$cshowList :: [ShareError] -> ShowS
show :: ShareError -> String
$cshow :: ShareError -> String
showsPrec :: Int -> ShareError -> ShowS
$cshowsPrec :: Int -> ShareError -> ShowS
Prelude.Show, forall x. Rep ShareError x -> ShareError
forall x. ShareError -> Rep ShareError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShareError x -> ShareError
$cfrom :: forall x. ShareError -> Rep ShareError x
Prelude.Generic)

-- |
-- Create a value of 'ShareError' 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:
--
-- 'accounts', 'shareError_accounts' - List of accounts impacted by the error.
--
-- 'error', 'shareError_error' - Error type that happened when processing the operation.
--
-- 'message', 'shareError_message' - Information about the error.
newShareError ::
  ShareError
newShareError :: ShareError
newShareError =
  ShareError'
    { $sel:accounts:ShareError' :: Maybe [Text]
accounts = forall a. Maybe a
Prelude.Nothing,
      $sel:error:ShareError' :: Maybe Text
error = forall a. Maybe a
Prelude.Nothing,
      $sel:message:ShareError' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | List of accounts impacted by the error.
shareError_accounts :: Lens.Lens' ShareError (Prelude.Maybe [Prelude.Text])
shareError_accounts :: Lens' ShareError (Maybe [Text])
shareError_accounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShareError' {Maybe [Text]
accounts :: Maybe [Text]
$sel:accounts:ShareError' :: ShareError -> Maybe [Text]
accounts} -> Maybe [Text]
accounts) (\s :: ShareError
s@ShareError' {} Maybe [Text]
a -> ShareError
s {$sel:accounts:ShareError' :: Maybe [Text]
accounts = Maybe [Text]
a} :: ShareError) 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

-- | Error type that happened when processing the operation.
shareError_error :: Lens.Lens' ShareError (Prelude.Maybe Prelude.Text)
shareError_error :: Lens' ShareError (Maybe Text)
shareError_error = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShareError' {Maybe Text
error :: Maybe Text
$sel:error:ShareError' :: ShareError -> Maybe Text
error} -> Maybe Text
error) (\s :: ShareError
s@ShareError' {} Maybe Text
a -> ShareError
s {$sel:error:ShareError' :: Maybe Text
error = Maybe Text
a} :: ShareError)

-- | Information about the error.
shareError_message :: Lens.Lens' ShareError (Prelude.Maybe Prelude.Text)
shareError_message :: Lens' ShareError (Maybe Text)
shareError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShareError' {Maybe Text
message :: Maybe Text
$sel:message:ShareError' :: ShareError -> Maybe Text
message} -> Maybe Text
message) (\s :: ShareError
s@ShareError' {} Maybe Text
a -> ShareError
s {$sel:message:ShareError' :: Maybe Text
message = Maybe Text
a} :: ShareError)

instance Data.FromJSON ShareError where
  parseJSON :: Value -> Parser ShareError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ShareError"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> Maybe Text -> ShareError
ShareError'
            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
"Accounts" 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
"Error")
            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
"Message")
      )

instance Prelude.Hashable ShareError where
  hashWithSalt :: Int -> ShareError -> Int
hashWithSalt Int
_salt ShareError' {Maybe [Text]
Maybe Text
message :: Maybe Text
error :: Maybe Text
accounts :: Maybe [Text]
$sel:message:ShareError' :: ShareError -> Maybe Text
$sel:error:ShareError' :: ShareError -> Maybe Text
$sel:accounts:ShareError' :: ShareError -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
accounts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
error
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData ShareError where
  rnf :: ShareError -> ()
rnf ShareError' {Maybe [Text]
Maybe Text
message :: Maybe Text
error :: Maybe Text
accounts :: Maybe [Text]
$sel:message:ShareError' :: ShareError -> Maybe Text
$sel:error:ShareError' :: ShareError -> Maybe Text
$sel:accounts:ShareError' :: ShareError -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
accounts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
error
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message