{-# 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.SESV2.Types.MetricDataError
-- 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.SESV2.Types.MetricDataError 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.SESV2.Types.QueryErrorCode

-- | An error corresponding to the unsuccessful processing of a single metric
-- data query.
--
-- /See:/ 'newMetricDataError' smart constructor.
data MetricDataError = MetricDataError'
  { -- | The query error code. Can be one of:
    --
    -- -   @INTERNAL_FAILURE@ – Amazon SES has failed to process one of the
    --     queries.
    --
    -- -   @ACCESS_DENIED@ – You have insufficient access to retrieve metrics
    --     based on the given query.
    MetricDataError -> Maybe QueryErrorCode
code :: Prelude.Maybe QueryErrorCode,
    -- | The query identifier.
    MetricDataError -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The error message associated with the current query error.
    MetricDataError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (MetricDataError -> MetricDataError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDataError -> MetricDataError -> Bool
$c/= :: MetricDataError -> MetricDataError -> Bool
== :: MetricDataError -> MetricDataError -> Bool
$c== :: MetricDataError -> MetricDataError -> Bool
Prelude.Eq, ReadPrec [MetricDataError]
ReadPrec MetricDataError
Int -> ReadS MetricDataError
ReadS [MetricDataError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDataError]
$creadListPrec :: ReadPrec [MetricDataError]
readPrec :: ReadPrec MetricDataError
$creadPrec :: ReadPrec MetricDataError
readList :: ReadS [MetricDataError]
$creadList :: ReadS [MetricDataError]
readsPrec :: Int -> ReadS MetricDataError
$creadsPrec :: Int -> ReadS MetricDataError
Prelude.Read, Int -> MetricDataError -> ShowS
[MetricDataError] -> ShowS
MetricDataError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDataError] -> ShowS
$cshowList :: [MetricDataError] -> ShowS
show :: MetricDataError -> String
$cshow :: MetricDataError -> String
showsPrec :: Int -> MetricDataError -> ShowS
$cshowsPrec :: Int -> MetricDataError -> ShowS
Prelude.Show, forall x. Rep MetricDataError x -> MetricDataError
forall x. MetricDataError -> Rep MetricDataError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricDataError x -> MetricDataError
$cfrom :: forall x. MetricDataError -> Rep MetricDataError x
Prelude.Generic)

-- |
-- Create a value of 'MetricDataError' 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:
--
-- 'code', 'metricDataError_code' - The query error code. Can be one of:
--
-- -   @INTERNAL_FAILURE@ – Amazon SES has failed to process one of the
--     queries.
--
-- -   @ACCESS_DENIED@ – You have insufficient access to retrieve metrics
--     based on the given query.
--
-- 'id', 'metricDataError_id' - The query identifier.
--
-- 'message', 'metricDataError_message' - The error message associated with the current query error.
newMetricDataError ::
  MetricDataError
newMetricDataError :: MetricDataError
newMetricDataError =
  MetricDataError'
    { $sel:code:MetricDataError' :: Maybe QueryErrorCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:id:MetricDataError' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:message:MetricDataError' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The query error code. Can be one of:
--
-- -   @INTERNAL_FAILURE@ – Amazon SES has failed to process one of the
--     queries.
--
-- -   @ACCESS_DENIED@ – You have insufficient access to retrieve metrics
--     based on the given query.
metricDataError_code :: Lens.Lens' MetricDataError (Prelude.Maybe QueryErrorCode)
metricDataError_code :: Lens' MetricDataError (Maybe QueryErrorCode)
metricDataError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDataError' {Maybe QueryErrorCode
code :: Maybe QueryErrorCode
$sel:code:MetricDataError' :: MetricDataError -> Maybe QueryErrorCode
code} -> Maybe QueryErrorCode
code) (\s :: MetricDataError
s@MetricDataError' {} Maybe QueryErrorCode
a -> MetricDataError
s {$sel:code:MetricDataError' :: Maybe QueryErrorCode
code = Maybe QueryErrorCode
a} :: MetricDataError)

-- | The query identifier.
metricDataError_id :: Lens.Lens' MetricDataError (Prelude.Maybe Prelude.Text)
metricDataError_id :: Lens' MetricDataError (Maybe Text)
metricDataError_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDataError' {Maybe Text
id :: Maybe Text
$sel:id:MetricDataError' :: MetricDataError -> Maybe Text
id} -> Maybe Text
id) (\s :: MetricDataError
s@MetricDataError' {} Maybe Text
a -> MetricDataError
s {$sel:id:MetricDataError' :: Maybe Text
id = Maybe Text
a} :: MetricDataError)

-- | The error message associated with the current query error.
metricDataError_message :: Lens.Lens' MetricDataError (Prelude.Maybe Prelude.Text)
metricDataError_message :: Lens' MetricDataError (Maybe Text)
metricDataError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDataError' {Maybe Text
message :: Maybe Text
$sel:message:MetricDataError' :: MetricDataError -> Maybe Text
message} -> Maybe Text
message) (\s :: MetricDataError
s@MetricDataError' {} Maybe Text
a -> MetricDataError
s {$sel:message:MetricDataError' :: Maybe Text
message = Maybe Text
a} :: MetricDataError)

instance Data.FromJSON MetricDataError where
  parseJSON :: Value -> Parser MetricDataError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MetricDataError"
      ( \Object
x ->
          Maybe QueryErrorCode -> Maybe Text -> Maybe Text -> MetricDataError
MetricDataError'
            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
"Code")
            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
"Id")
            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 MetricDataError where
  hashWithSalt :: Int -> MetricDataError -> Int
hashWithSalt Int
_salt MetricDataError' {Maybe Text
Maybe QueryErrorCode
message :: Maybe Text
id :: Maybe Text
code :: Maybe QueryErrorCode
$sel:message:MetricDataError' :: MetricDataError -> Maybe Text
$sel:id:MetricDataError' :: MetricDataError -> Maybe Text
$sel:code:MetricDataError' :: MetricDataError -> Maybe QueryErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QueryErrorCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData MetricDataError where
  rnf :: MetricDataError -> ()
rnf MetricDataError' {Maybe Text
Maybe QueryErrorCode
message :: Maybe Text
id :: Maybe Text
code :: Maybe QueryErrorCode
$sel:message:MetricDataError' :: MetricDataError -> Maybe Text
$sel:id:MetricDataError' :: MetricDataError -> Maybe Text
$sel:code:MetricDataError' :: MetricDataError -> Maybe QueryErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe QueryErrorCode
code
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message