{-# 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.Greengrass.Types.BulkDeploymentMetrics
-- 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.Greengrass.Types.BulkDeploymentMetrics where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Relevant metrics on input records processed during bulk deployment.
--
-- /See:/ 'newBulkDeploymentMetrics' smart constructor.
data BulkDeploymentMetrics = BulkDeploymentMetrics'
  { -- | The total number of group records from the input file that have been
    -- processed so far, or attempted.
    BulkDeploymentMetrics -> Maybe Int
recordsProcessed :: Prelude.Maybe Prelude.Int,
    -- | The total number of deployment attempts that returned a retryable error.
    -- For example, a retry is triggered if the attempt to deploy a group
    -- returns a throttling error. \'\'StartBulkDeployment\'\' retries a group
    -- deployment up to five times.
    BulkDeploymentMetrics -> Maybe Int
retryAttempts :: Prelude.Maybe Prelude.Int,
    -- | The total number of records that returned a non-retryable error. For
    -- example, this can occur if a group record from the input file uses an
    -- invalid format or specifies a nonexistent group version, or if the
    -- execution role doesn\'t grant permission to deploy a group or group
    -- version.
    BulkDeploymentMetrics -> Maybe Int
invalidInputRecords :: Prelude.Maybe Prelude.Int
  }
  deriving (BulkDeploymentMetrics -> BulkDeploymentMetrics -> Bool
(BulkDeploymentMetrics -> BulkDeploymentMetrics -> Bool)
-> (BulkDeploymentMetrics -> BulkDeploymentMetrics -> Bool)
-> Eq BulkDeploymentMetrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BulkDeploymentMetrics -> BulkDeploymentMetrics -> Bool
$c/= :: BulkDeploymentMetrics -> BulkDeploymentMetrics -> Bool
== :: BulkDeploymentMetrics -> BulkDeploymentMetrics -> Bool
$c== :: BulkDeploymentMetrics -> BulkDeploymentMetrics -> Bool
Prelude.Eq, ReadPrec [BulkDeploymentMetrics]
ReadPrec BulkDeploymentMetrics
Int -> ReadS BulkDeploymentMetrics
ReadS [BulkDeploymentMetrics]
(Int -> ReadS BulkDeploymentMetrics)
-> ReadS [BulkDeploymentMetrics]
-> ReadPrec BulkDeploymentMetrics
-> ReadPrec [BulkDeploymentMetrics]
-> Read BulkDeploymentMetrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BulkDeploymentMetrics]
$creadListPrec :: ReadPrec [BulkDeploymentMetrics]
readPrec :: ReadPrec BulkDeploymentMetrics
$creadPrec :: ReadPrec BulkDeploymentMetrics
readList :: ReadS [BulkDeploymentMetrics]
$creadList :: ReadS [BulkDeploymentMetrics]
readsPrec :: Int -> ReadS BulkDeploymentMetrics
$creadsPrec :: Int -> ReadS BulkDeploymentMetrics
Prelude.Read, Int -> BulkDeploymentMetrics -> ShowS
[BulkDeploymentMetrics] -> ShowS
BulkDeploymentMetrics -> String
(Int -> BulkDeploymentMetrics -> ShowS)
-> (BulkDeploymentMetrics -> String)
-> ([BulkDeploymentMetrics] -> ShowS)
-> Show BulkDeploymentMetrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BulkDeploymentMetrics] -> ShowS
$cshowList :: [BulkDeploymentMetrics] -> ShowS
show :: BulkDeploymentMetrics -> String
$cshow :: BulkDeploymentMetrics -> String
showsPrec :: Int -> BulkDeploymentMetrics -> ShowS
$cshowsPrec :: Int -> BulkDeploymentMetrics -> ShowS
Prelude.Show, (forall x. BulkDeploymentMetrics -> Rep BulkDeploymentMetrics x)
-> (forall x. Rep BulkDeploymentMetrics x -> BulkDeploymentMetrics)
-> Generic BulkDeploymentMetrics
forall x. Rep BulkDeploymentMetrics x -> BulkDeploymentMetrics
forall x. BulkDeploymentMetrics -> Rep BulkDeploymentMetrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BulkDeploymentMetrics x -> BulkDeploymentMetrics
$cfrom :: forall x. BulkDeploymentMetrics -> Rep BulkDeploymentMetrics x
Prelude.Generic)

-- |
-- Create a value of 'BulkDeploymentMetrics' 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:
--
-- 'recordsProcessed', 'bulkDeploymentMetrics_recordsProcessed' - The total number of group records from the input file that have been
-- processed so far, or attempted.
--
-- 'retryAttempts', 'bulkDeploymentMetrics_retryAttempts' - The total number of deployment attempts that returned a retryable error.
-- For example, a retry is triggered if the attempt to deploy a group
-- returns a throttling error. \'\'StartBulkDeployment\'\' retries a group
-- deployment up to five times.
--
-- 'invalidInputRecords', 'bulkDeploymentMetrics_invalidInputRecords' - The total number of records that returned a non-retryable error. For
-- example, this can occur if a group record from the input file uses an
-- invalid format or specifies a nonexistent group version, or if the
-- execution role doesn\'t grant permission to deploy a group or group
-- version.
newBulkDeploymentMetrics ::
  BulkDeploymentMetrics
newBulkDeploymentMetrics :: BulkDeploymentMetrics
newBulkDeploymentMetrics =
  BulkDeploymentMetrics' :: Maybe Int -> Maybe Int -> Maybe Int -> BulkDeploymentMetrics
BulkDeploymentMetrics'
    { $sel:recordsProcessed:BulkDeploymentMetrics' :: Maybe Int
recordsProcessed =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:retryAttempts:BulkDeploymentMetrics' :: Maybe Int
retryAttempts = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:invalidInputRecords:BulkDeploymentMetrics' :: Maybe Int
invalidInputRecords = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The total number of group records from the input file that have been
-- processed so far, or attempted.
bulkDeploymentMetrics_recordsProcessed :: Lens.Lens' BulkDeploymentMetrics (Prelude.Maybe Prelude.Int)
bulkDeploymentMetrics_recordsProcessed :: (Maybe Int -> f (Maybe Int))
-> BulkDeploymentMetrics -> f BulkDeploymentMetrics
bulkDeploymentMetrics_recordsProcessed = (BulkDeploymentMetrics -> Maybe Int)
-> (BulkDeploymentMetrics -> Maybe Int -> BulkDeploymentMetrics)
-> Lens
     BulkDeploymentMetrics BulkDeploymentMetrics (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BulkDeploymentMetrics' {Maybe Int
recordsProcessed :: Maybe Int
$sel:recordsProcessed:BulkDeploymentMetrics' :: BulkDeploymentMetrics -> Maybe Int
recordsProcessed} -> Maybe Int
recordsProcessed) (\s :: BulkDeploymentMetrics
s@BulkDeploymentMetrics' {} Maybe Int
a -> BulkDeploymentMetrics
s {$sel:recordsProcessed:BulkDeploymentMetrics' :: Maybe Int
recordsProcessed = Maybe Int
a} :: BulkDeploymentMetrics)

-- | The total number of deployment attempts that returned a retryable error.
-- For example, a retry is triggered if the attempt to deploy a group
-- returns a throttling error. \'\'StartBulkDeployment\'\' retries a group
-- deployment up to five times.
bulkDeploymentMetrics_retryAttempts :: Lens.Lens' BulkDeploymentMetrics (Prelude.Maybe Prelude.Int)
bulkDeploymentMetrics_retryAttempts :: (Maybe Int -> f (Maybe Int))
-> BulkDeploymentMetrics -> f BulkDeploymentMetrics
bulkDeploymentMetrics_retryAttempts = (BulkDeploymentMetrics -> Maybe Int)
-> (BulkDeploymentMetrics -> Maybe Int -> BulkDeploymentMetrics)
-> Lens
     BulkDeploymentMetrics BulkDeploymentMetrics (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BulkDeploymentMetrics' {Maybe Int
retryAttempts :: Maybe Int
$sel:retryAttempts:BulkDeploymentMetrics' :: BulkDeploymentMetrics -> Maybe Int
retryAttempts} -> Maybe Int
retryAttempts) (\s :: BulkDeploymentMetrics
s@BulkDeploymentMetrics' {} Maybe Int
a -> BulkDeploymentMetrics
s {$sel:retryAttempts:BulkDeploymentMetrics' :: Maybe Int
retryAttempts = Maybe Int
a} :: BulkDeploymentMetrics)

-- | The total number of records that returned a non-retryable error. For
-- example, this can occur if a group record from the input file uses an
-- invalid format or specifies a nonexistent group version, or if the
-- execution role doesn\'t grant permission to deploy a group or group
-- version.
bulkDeploymentMetrics_invalidInputRecords :: Lens.Lens' BulkDeploymentMetrics (Prelude.Maybe Prelude.Int)
bulkDeploymentMetrics_invalidInputRecords :: (Maybe Int -> f (Maybe Int))
-> BulkDeploymentMetrics -> f BulkDeploymentMetrics
bulkDeploymentMetrics_invalidInputRecords = (BulkDeploymentMetrics -> Maybe Int)
-> (BulkDeploymentMetrics -> Maybe Int -> BulkDeploymentMetrics)
-> Lens
     BulkDeploymentMetrics BulkDeploymentMetrics (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BulkDeploymentMetrics' {Maybe Int
invalidInputRecords :: Maybe Int
$sel:invalidInputRecords:BulkDeploymentMetrics' :: BulkDeploymentMetrics -> Maybe Int
invalidInputRecords} -> Maybe Int
invalidInputRecords) (\s :: BulkDeploymentMetrics
s@BulkDeploymentMetrics' {} Maybe Int
a -> BulkDeploymentMetrics
s {$sel:invalidInputRecords:BulkDeploymentMetrics' :: Maybe Int
invalidInputRecords = Maybe Int
a} :: BulkDeploymentMetrics)

instance Core.FromJSON BulkDeploymentMetrics where
  parseJSON :: Value -> Parser BulkDeploymentMetrics
parseJSON =
    String
-> (Object -> Parser BulkDeploymentMetrics)
-> Value
-> Parser BulkDeploymentMetrics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BulkDeploymentMetrics"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> Maybe Int -> BulkDeploymentMetrics
BulkDeploymentMetrics'
            (Maybe Int -> Maybe Int -> Maybe Int -> BulkDeploymentMetrics)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> Maybe Int -> BulkDeploymentMetrics)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RecordsProcessed")
            Parser (Maybe Int -> Maybe Int -> BulkDeploymentMetrics)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> BulkDeploymentMetrics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RetryAttempts")
            Parser (Maybe Int -> BulkDeploymentMetrics)
-> Parser (Maybe Int) -> Parser BulkDeploymentMetrics
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InvalidInputRecords")
      )

instance Prelude.Hashable BulkDeploymentMetrics

instance Prelude.NFData BulkDeploymentMetrics