{-# 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.IoT.Types.AwsJobAbortConfig
-- 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.IoT.Types.AwsJobAbortConfig where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.AwsJobAbortCriteria
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The criteria that determine when and how a job abort takes place.
--
-- /See:/ 'newAwsJobAbortConfig' smart constructor.
data AwsJobAbortConfig = AwsJobAbortConfig'
  { -- | The list of criteria that determine when and how to abort the job.
    AwsJobAbortConfig -> NonEmpty AwsJobAbortCriteria
abortCriteriaList :: Prelude.NonEmpty AwsJobAbortCriteria
  }
  deriving (AwsJobAbortConfig -> AwsJobAbortConfig -> Bool
(AwsJobAbortConfig -> AwsJobAbortConfig -> Bool)
-> (AwsJobAbortConfig -> AwsJobAbortConfig -> Bool)
-> Eq AwsJobAbortConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsJobAbortConfig -> AwsJobAbortConfig -> Bool
$c/= :: AwsJobAbortConfig -> AwsJobAbortConfig -> Bool
== :: AwsJobAbortConfig -> AwsJobAbortConfig -> Bool
$c== :: AwsJobAbortConfig -> AwsJobAbortConfig -> Bool
Prelude.Eq, ReadPrec [AwsJobAbortConfig]
ReadPrec AwsJobAbortConfig
Int -> ReadS AwsJobAbortConfig
ReadS [AwsJobAbortConfig]
(Int -> ReadS AwsJobAbortConfig)
-> ReadS [AwsJobAbortConfig]
-> ReadPrec AwsJobAbortConfig
-> ReadPrec [AwsJobAbortConfig]
-> Read AwsJobAbortConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsJobAbortConfig]
$creadListPrec :: ReadPrec [AwsJobAbortConfig]
readPrec :: ReadPrec AwsJobAbortConfig
$creadPrec :: ReadPrec AwsJobAbortConfig
readList :: ReadS [AwsJobAbortConfig]
$creadList :: ReadS [AwsJobAbortConfig]
readsPrec :: Int -> ReadS AwsJobAbortConfig
$creadsPrec :: Int -> ReadS AwsJobAbortConfig
Prelude.Read, Int -> AwsJobAbortConfig -> ShowS
[AwsJobAbortConfig] -> ShowS
AwsJobAbortConfig -> String
(Int -> AwsJobAbortConfig -> ShowS)
-> (AwsJobAbortConfig -> String)
-> ([AwsJobAbortConfig] -> ShowS)
-> Show AwsJobAbortConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsJobAbortConfig] -> ShowS
$cshowList :: [AwsJobAbortConfig] -> ShowS
show :: AwsJobAbortConfig -> String
$cshow :: AwsJobAbortConfig -> String
showsPrec :: Int -> AwsJobAbortConfig -> ShowS
$cshowsPrec :: Int -> AwsJobAbortConfig -> ShowS
Prelude.Show, (forall x. AwsJobAbortConfig -> Rep AwsJobAbortConfig x)
-> (forall x. Rep AwsJobAbortConfig x -> AwsJobAbortConfig)
-> Generic AwsJobAbortConfig
forall x. Rep AwsJobAbortConfig x -> AwsJobAbortConfig
forall x. AwsJobAbortConfig -> Rep AwsJobAbortConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsJobAbortConfig x -> AwsJobAbortConfig
$cfrom :: forall x. AwsJobAbortConfig -> Rep AwsJobAbortConfig x
Prelude.Generic)

-- |
-- Create a value of 'AwsJobAbortConfig' 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:
--
-- 'abortCriteriaList', 'awsJobAbortConfig_abortCriteriaList' - The list of criteria that determine when and how to abort the job.
newAwsJobAbortConfig ::
  -- | 'abortCriteriaList'
  Prelude.NonEmpty AwsJobAbortCriteria ->
  AwsJobAbortConfig
newAwsJobAbortConfig :: NonEmpty AwsJobAbortCriteria -> AwsJobAbortConfig
newAwsJobAbortConfig NonEmpty AwsJobAbortCriteria
pAbortCriteriaList_ =
  AwsJobAbortConfig' :: NonEmpty AwsJobAbortCriteria -> AwsJobAbortConfig
AwsJobAbortConfig'
    { $sel:abortCriteriaList:AwsJobAbortConfig' :: NonEmpty AwsJobAbortCriteria
abortCriteriaList =
        Tagged
  (NonEmpty AwsJobAbortCriteria)
  (Identity (NonEmpty AwsJobAbortCriteria))
-> Tagged
     (NonEmpty AwsJobAbortCriteria)
     (Identity (NonEmpty AwsJobAbortCriteria))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty AwsJobAbortCriteria)
   (Identity (NonEmpty AwsJobAbortCriteria))
 -> Tagged
      (NonEmpty AwsJobAbortCriteria)
      (Identity (NonEmpty AwsJobAbortCriteria)))
-> NonEmpty AwsJobAbortCriteria -> NonEmpty AwsJobAbortCriteria
forall t b. AReview t b -> b -> t
Lens.# NonEmpty AwsJobAbortCriteria
pAbortCriteriaList_
    }

-- | The list of criteria that determine when and how to abort the job.
awsJobAbortConfig_abortCriteriaList :: Lens.Lens' AwsJobAbortConfig (Prelude.NonEmpty AwsJobAbortCriteria)
awsJobAbortConfig_abortCriteriaList :: (NonEmpty AwsJobAbortCriteria -> f (NonEmpty AwsJobAbortCriteria))
-> AwsJobAbortConfig -> f AwsJobAbortConfig
awsJobAbortConfig_abortCriteriaList = (AwsJobAbortConfig -> NonEmpty AwsJobAbortCriteria)
-> (AwsJobAbortConfig
    -> NonEmpty AwsJobAbortCriteria -> AwsJobAbortConfig)
-> Lens
     AwsJobAbortConfig
     AwsJobAbortConfig
     (NonEmpty AwsJobAbortCriteria)
     (NonEmpty AwsJobAbortCriteria)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobAbortConfig' {NonEmpty AwsJobAbortCriteria
abortCriteriaList :: NonEmpty AwsJobAbortCriteria
$sel:abortCriteriaList:AwsJobAbortConfig' :: AwsJobAbortConfig -> NonEmpty AwsJobAbortCriteria
abortCriteriaList} -> NonEmpty AwsJobAbortCriteria
abortCriteriaList) (\s :: AwsJobAbortConfig
s@AwsJobAbortConfig' {} NonEmpty AwsJobAbortCriteria
a -> AwsJobAbortConfig
s {$sel:abortCriteriaList:AwsJobAbortConfig' :: NonEmpty AwsJobAbortCriteria
abortCriteriaList = NonEmpty AwsJobAbortCriteria
a} :: AwsJobAbortConfig) ((NonEmpty AwsJobAbortCriteria -> f (NonEmpty AwsJobAbortCriteria))
 -> AwsJobAbortConfig -> f AwsJobAbortConfig)
-> ((NonEmpty AwsJobAbortCriteria
     -> f (NonEmpty AwsJobAbortCriteria))
    -> NonEmpty AwsJobAbortCriteria
    -> f (NonEmpty AwsJobAbortCriteria))
-> (NonEmpty AwsJobAbortCriteria
    -> f (NonEmpty AwsJobAbortCriteria))
-> AwsJobAbortConfig
-> f AwsJobAbortConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AwsJobAbortCriteria -> f (NonEmpty AwsJobAbortCriteria))
-> NonEmpty AwsJobAbortCriteria -> f (NonEmpty AwsJobAbortCriteria)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable AwsJobAbortConfig

instance Prelude.NFData AwsJobAbortConfig

instance Core.ToJSON AwsJobAbortConfig where
  toJSON :: AwsJobAbortConfig -> Value
toJSON AwsJobAbortConfig' {NonEmpty AwsJobAbortCriteria
abortCriteriaList :: NonEmpty AwsJobAbortCriteria
$sel:abortCriteriaList:AwsJobAbortConfig' :: AwsJobAbortConfig -> NonEmpty AwsJobAbortCriteria
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"abortCriteriaList" Text -> NonEmpty AwsJobAbortCriteria -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty AwsJobAbortCriteria
abortCriteriaList)
          ]
      )