{-# 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.SageMakerMetrics.Types.BatchPutMetricsError
-- 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.SageMakerMetrics.Types.BatchPutMetricsError 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.SageMakerMetrics.Types.PutMetricsErrorCode

-- | An error that occured when putting the metric data.
--
-- /See:/ 'newBatchPutMetricsError' smart constructor.
data BatchPutMetricsError = BatchPutMetricsError'
  { -- | The error code of an error that occured when attempting to put metrics.
    --
    -- -   @METRIC_LIMIT_EXCEEDED@: The maximum amount of metrics per resource
    --     is exceeded.
    --
    -- -   @INTERNAL_ERROR@: An internal error occured.
    --
    -- -   @VALIDATION_ERROR@: The metric data failed validation.
    --
    -- -   @CONFLICT_ERROR@: Multiple requests attempted to modify the same
    --     data simultaneously.
    BatchPutMetricsError -> Maybe PutMetricsErrorCode
code :: Prelude.Maybe PutMetricsErrorCode,
    -- | An index that corresponds to the metric in the request.
    BatchPutMetricsError -> Maybe Int
metricIndex :: Prelude.Maybe Prelude.Int
  }
  deriving (BatchPutMetricsError -> BatchPutMetricsError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchPutMetricsError -> BatchPutMetricsError -> Bool
$c/= :: BatchPutMetricsError -> BatchPutMetricsError -> Bool
== :: BatchPutMetricsError -> BatchPutMetricsError -> Bool
$c== :: BatchPutMetricsError -> BatchPutMetricsError -> Bool
Prelude.Eq, ReadPrec [BatchPutMetricsError]
ReadPrec BatchPutMetricsError
Int -> ReadS BatchPutMetricsError
ReadS [BatchPutMetricsError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchPutMetricsError]
$creadListPrec :: ReadPrec [BatchPutMetricsError]
readPrec :: ReadPrec BatchPutMetricsError
$creadPrec :: ReadPrec BatchPutMetricsError
readList :: ReadS [BatchPutMetricsError]
$creadList :: ReadS [BatchPutMetricsError]
readsPrec :: Int -> ReadS BatchPutMetricsError
$creadsPrec :: Int -> ReadS BatchPutMetricsError
Prelude.Read, Int -> BatchPutMetricsError -> ShowS
[BatchPutMetricsError] -> ShowS
BatchPutMetricsError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchPutMetricsError] -> ShowS
$cshowList :: [BatchPutMetricsError] -> ShowS
show :: BatchPutMetricsError -> String
$cshow :: BatchPutMetricsError -> String
showsPrec :: Int -> BatchPutMetricsError -> ShowS
$cshowsPrec :: Int -> BatchPutMetricsError -> ShowS
Prelude.Show, forall x. Rep BatchPutMetricsError x -> BatchPutMetricsError
forall x. BatchPutMetricsError -> Rep BatchPutMetricsError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchPutMetricsError x -> BatchPutMetricsError
$cfrom :: forall x. BatchPutMetricsError -> Rep BatchPutMetricsError x
Prelude.Generic)

-- |
-- Create a value of 'BatchPutMetricsError' 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', 'batchPutMetricsError_code' - The error code of an error that occured when attempting to put metrics.
--
-- -   @METRIC_LIMIT_EXCEEDED@: The maximum amount of metrics per resource
--     is exceeded.
--
-- -   @INTERNAL_ERROR@: An internal error occured.
--
-- -   @VALIDATION_ERROR@: The metric data failed validation.
--
-- -   @CONFLICT_ERROR@: Multiple requests attempted to modify the same
--     data simultaneously.
--
-- 'metricIndex', 'batchPutMetricsError_metricIndex' - An index that corresponds to the metric in the request.
newBatchPutMetricsError ::
  BatchPutMetricsError
newBatchPutMetricsError :: BatchPutMetricsError
newBatchPutMetricsError =
  BatchPutMetricsError'
    { $sel:code:BatchPutMetricsError' :: Maybe PutMetricsErrorCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:metricIndex:BatchPutMetricsError' :: Maybe Int
metricIndex = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code of an error that occured when attempting to put metrics.
--
-- -   @METRIC_LIMIT_EXCEEDED@: The maximum amount of metrics per resource
--     is exceeded.
--
-- -   @INTERNAL_ERROR@: An internal error occured.
--
-- -   @VALIDATION_ERROR@: The metric data failed validation.
--
-- -   @CONFLICT_ERROR@: Multiple requests attempted to modify the same
--     data simultaneously.
batchPutMetricsError_code :: Lens.Lens' BatchPutMetricsError (Prelude.Maybe PutMetricsErrorCode)
batchPutMetricsError_code :: Lens' BatchPutMetricsError (Maybe PutMetricsErrorCode)
batchPutMetricsError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMetricsError' {Maybe PutMetricsErrorCode
code :: Maybe PutMetricsErrorCode
$sel:code:BatchPutMetricsError' :: BatchPutMetricsError -> Maybe PutMetricsErrorCode
code} -> Maybe PutMetricsErrorCode
code) (\s :: BatchPutMetricsError
s@BatchPutMetricsError' {} Maybe PutMetricsErrorCode
a -> BatchPutMetricsError
s {$sel:code:BatchPutMetricsError' :: Maybe PutMetricsErrorCode
code = Maybe PutMetricsErrorCode
a} :: BatchPutMetricsError)

-- | An index that corresponds to the metric in the request.
batchPutMetricsError_metricIndex :: Lens.Lens' BatchPutMetricsError (Prelude.Maybe Prelude.Int)
batchPutMetricsError_metricIndex :: Lens' BatchPutMetricsError (Maybe Int)
batchPutMetricsError_metricIndex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMetricsError' {Maybe Int
metricIndex :: Maybe Int
$sel:metricIndex:BatchPutMetricsError' :: BatchPutMetricsError -> Maybe Int
metricIndex} -> Maybe Int
metricIndex) (\s :: BatchPutMetricsError
s@BatchPutMetricsError' {} Maybe Int
a -> BatchPutMetricsError
s {$sel:metricIndex:BatchPutMetricsError' :: Maybe Int
metricIndex = Maybe Int
a} :: BatchPutMetricsError)

instance Data.FromJSON BatchPutMetricsError where
  parseJSON :: Value -> Parser BatchPutMetricsError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchPutMetricsError"
      ( \Object
x ->
          Maybe PutMetricsErrorCode -> Maybe Int -> BatchPutMetricsError
BatchPutMetricsError'
            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
"MetricIndex")
      )

instance Prelude.Hashable BatchPutMetricsError where
  hashWithSalt :: Int -> BatchPutMetricsError -> Int
hashWithSalt Int
_salt BatchPutMetricsError' {Maybe Int
Maybe PutMetricsErrorCode
metricIndex :: Maybe Int
code :: Maybe PutMetricsErrorCode
$sel:metricIndex:BatchPutMetricsError' :: BatchPutMetricsError -> Maybe Int
$sel:code:BatchPutMetricsError' :: BatchPutMetricsError -> Maybe PutMetricsErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PutMetricsErrorCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
metricIndex

instance Prelude.NFData BatchPutMetricsError where
  rnf :: BatchPutMetricsError -> ()
rnf BatchPutMetricsError' {Maybe Int
Maybe PutMetricsErrorCode
metricIndex :: Maybe Int
code :: Maybe PutMetricsErrorCode
$sel:metricIndex:BatchPutMetricsError' :: BatchPutMetricsError -> Maybe Int
$sel:code:BatchPutMetricsError' :: BatchPutMetricsError -> Maybe PutMetricsErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe PutMetricsErrorCode
code
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
metricIndex