{-# 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.GreengrassV2.Types.IoTJobAbortConfig
-- 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.GreengrassV2.Types.IoTJobAbortConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GreengrassV2.Types.IoTJobAbortCriteria
import qualified Amazonka.Prelude as Prelude

-- | Contains a list of criteria that define when and how to cancel a
-- configuration deployment.
--
-- /See:/ 'newIoTJobAbortConfig' smart constructor.
data IoTJobAbortConfig = IoTJobAbortConfig'
  { -- | The list of criteria that define when and how to cancel the
    -- configuration deployment.
    IoTJobAbortConfig -> NonEmpty IoTJobAbortCriteria
criteriaList :: Prelude.NonEmpty IoTJobAbortCriteria
  }
  deriving (IoTJobAbortConfig -> IoTJobAbortConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IoTJobAbortConfig -> IoTJobAbortConfig -> Bool
$c/= :: IoTJobAbortConfig -> IoTJobAbortConfig -> Bool
== :: IoTJobAbortConfig -> IoTJobAbortConfig -> Bool
$c== :: IoTJobAbortConfig -> IoTJobAbortConfig -> Bool
Prelude.Eq, ReadPrec [IoTJobAbortConfig]
ReadPrec IoTJobAbortConfig
Int -> ReadS IoTJobAbortConfig
ReadS [IoTJobAbortConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IoTJobAbortConfig]
$creadListPrec :: ReadPrec [IoTJobAbortConfig]
readPrec :: ReadPrec IoTJobAbortConfig
$creadPrec :: ReadPrec IoTJobAbortConfig
readList :: ReadS [IoTJobAbortConfig]
$creadList :: ReadS [IoTJobAbortConfig]
readsPrec :: Int -> ReadS IoTJobAbortConfig
$creadsPrec :: Int -> ReadS IoTJobAbortConfig
Prelude.Read, Int -> IoTJobAbortConfig -> ShowS
[IoTJobAbortConfig] -> ShowS
IoTJobAbortConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IoTJobAbortConfig] -> ShowS
$cshowList :: [IoTJobAbortConfig] -> ShowS
show :: IoTJobAbortConfig -> String
$cshow :: IoTJobAbortConfig -> String
showsPrec :: Int -> IoTJobAbortConfig -> ShowS
$cshowsPrec :: Int -> IoTJobAbortConfig -> ShowS
Prelude.Show, forall x. Rep IoTJobAbortConfig x -> IoTJobAbortConfig
forall x. IoTJobAbortConfig -> Rep IoTJobAbortConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IoTJobAbortConfig x -> IoTJobAbortConfig
$cfrom :: forall x. IoTJobAbortConfig -> Rep IoTJobAbortConfig x
Prelude.Generic)

-- |
-- Create a value of 'IoTJobAbortConfig' 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:
--
-- 'criteriaList', 'ioTJobAbortConfig_criteriaList' - The list of criteria that define when and how to cancel the
-- configuration deployment.
newIoTJobAbortConfig ::
  -- | 'criteriaList'
  Prelude.NonEmpty IoTJobAbortCriteria ->
  IoTJobAbortConfig
newIoTJobAbortConfig :: NonEmpty IoTJobAbortCriteria -> IoTJobAbortConfig
newIoTJobAbortConfig NonEmpty IoTJobAbortCriteria
pCriteriaList_ =
  IoTJobAbortConfig'
    { $sel:criteriaList:IoTJobAbortConfig' :: NonEmpty IoTJobAbortCriteria
criteriaList =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty IoTJobAbortCriteria
pCriteriaList_
    }

-- | The list of criteria that define when and how to cancel the
-- configuration deployment.
ioTJobAbortConfig_criteriaList :: Lens.Lens' IoTJobAbortConfig (Prelude.NonEmpty IoTJobAbortCriteria)
ioTJobAbortConfig_criteriaList :: Lens' IoTJobAbortConfig (NonEmpty IoTJobAbortCriteria)
ioTJobAbortConfig_criteriaList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobAbortConfig' {NonEmpty IoTJobAbortCriteria
criteriaList :: NonEmpty IoTJobAbortCriteria
$sel:criteriaList:IoTJobAbortConfig' :: IoTJobAbortConfig -> NonEmpty IoTJobAbortCriteria
criteriaList} -> NonEmpty IoTJobAbortCriteria
criteriaList) (\s :: IoTJobAbortConfig
s@IoTJobAbortConfig' {} NonEmpty IoTJobAbortCriteria
a -> IoTJobAbortConfig
s {$sel:criteriaList:IoTJobAbortConfig' :: NonEmpty IoTJobAbortCriteria
criteriaList = NonEmpty IoTJobAbortCriteria
a} :: IoTJobAbortConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON IoTJobAbortConfig where
  parseJSON :: Value -> Parser IoTJobAbortConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IoTJobAbortConfig"
      ( \Object
x ->
          NonEmpty IoTJobAbortCriteria -> IoTJobAbortConfig
IoTJobAbortConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"criteriaList")
      )

instance Prelude.Hashable IoTJobAbortConfig where
  hashWithSalt :: Int -> IoTJobAbortConfig -> Int
hashWithSalt Int
_salt IoTJobAbortConfig' {NonEmpty IoTJobAbortCriteria
criteriaList :: NonEmpty IoTJobAbortCriteria
$sel:criteriaList:IoTJobAbortConfig' :: IoTJobAbortConfig -> NonEmpty IoTJobAbortCriteria
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty IoTJobAbortCriteria
criteriaList

instance Prelude.NFData IoTJobAbortConfig where
  rnf :: IoTJobAbortConfig -> ()
rnf IoTJobAbortConfig' {NonEmpty IoTJobAbortCriteria
criteriaList :: NonEmpty IoTJobAbortCriteria
$sel:criteriaList:IoTJobAbortConfig' :: IoTJobAbortConfig -> NonEmpty IoTJobAbortCriteria
..} = forall a. NFData a => a -> ()
Prelude.rnf NonEmpty IoTJobAbortCriteria
criteriaList

instance Data.ToJSON IoTJobAbortConfig where
  toJSON :: IoTJobAbortConfig -> Value
toJSON IoTJobAbortConfig' {NonEmpty IoTJobAbortCriteria
criteriaList :: NonEmpty IoTJobAbortCriteria
$sel:criteriaList:IoTJobAbortConfig' :: IoTJobAbortConfig -> NonEmpty IoTJobAbortCriteria
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"criteriaList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty IoTJobAbortCriteria
criteriaList)]
      )