{-# 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.ImageBuilder.Types.ImageTestsConfiguration
-- 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.ImageBuilder.Types.ImageTestsConfiguration where

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

-- | Image tests configuration.
--
-- /See:/ 'newImageTestsConfiguration' smart constructor.
data ImageTestsConfiguration = ImageTestsConfiguration'
  { -- | The maximum time in minutes that tests are permitted to run.
    ImageTestsConfiguration -> Maybe Natural
timeoutMinutes :: Prelude.Maybe Prelude.Natural,
    -- | Defines if tests should be executed when building this image.
    ImageTestsConfiguration -> Maybe Bool
imageTestsEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (ImageTestsConfiguration -> ImageTestsConfiguration -> Bool
(ImageTestsConfiguration -> ImageTestsConfiguration -> Bool)
-> (ImageTestsConfiguration -> ImageTestsConfiguration -> Bool)
-> Eq ImageTestsConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageTestsConfiguration -> ImageTestsConfiguration -> Bool
$c/= :: ImageTestsConfiguration -> ImageTestsConfiguration -> Bool
== :: ImageTestsConfiguration -> ImageTestsConfiguration -> Bool
$c== :: ImageTestsConfiguration -> ImageTestsConfiguration -> Bool
Prelude.Eq, ReadPrec [ImageTestsConfiguration]
ReadPrec ImageTestsConfiguration
Int -> ReadS ImageTestsConfiguration
ReadS [ImageTestsConfiguration]
(Int -> ReadS ImageTestsConfiguration)
-> ReadS [ImageTestsConfiguration]
-> ReadPrec ImageTestsConfiguration
-> ReadPrec [ImageTestsConfiguration]
-> Read ImageTestsConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageTestsConfiguration]
$creadListPrec :: ReadPrec [ImageTestsConfiguration]
readPrec :: ReadPrec ImageTestsConfiguration
$creadPrec :: ReadPrec ImageTestsConfiguration
readList :: ReadS [ImageTestsConfiguration]
$creadList :: ReadS [ImageTestsConfiguration]
readsPrec :: Int -> ReadS ImageTestsConfiguration
$creadsPrec :: Int -> ReadS ImageTestsConfiguration
Prelude.Read, Int -> ImageTestsConfiguration -> ShowS
[ImageTestsConfiguration] -> ShowS
ImageTestsConfiguration -> String
(Int -> ImageTestsConfiguration -> ShowS)
-> (ImageTestsConfiguration -> String)
-> ([ImageTestsConfiguration] -> ShowS)
-> Show ImageTestsConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageTestsConfiguration] -> ShowS
$cshowList :: [ImageTestsConfiguration] -> ShowS
show :: ImageTestsConfiguration -> String
$cshow :: ImageTestsConfiguration -> String
showsPrec :: Int -> ImageTestsConfiguration -> ShowS
$cshowsPrec :: Int -> ImageTestsConfiguration -> ShowS
Prelude.Show, (forall x.
 ImageTestsConfiguration -> Rep ImageTestsConfiguration x)
-> (forall x.
    Rep ImageTestsConfiguration x -> ImageTestsConfiguration)
-> Generic ImageTestsConfiguration
forall x. Rep ImageTestsConfiguration x -> ImageTestsConfiguration
forall x. ImageTestsConfiguration -> Rep ImageTestsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageTestsConfiguration x -> ImageTestsConfiguration
$cfrom :: forall x. ImageTestsConfiguration -> Rep ImageTestsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ImageTestsConfiguration' 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:
--
-- 'timeoutMinutes', 'imageTestsConfiguration_timeoutMinutes' - The maximum time in minutes that tests are permitted to run.
--
-- 'imageTestsEnabled', 'imageTestsConfiguration_imageTestsEnabled' - Defines if tests should be executed when building this image.
newImageTestsConfiguration ::
  ImageTestsConfiguration
newImageTestsConfiguration :: ImageTestsConfiguration
newImageTestsConfiguration =
  ImageTestsConfiguration' :: Maybe Natural -> Maybe Bool -> ImageTestsConfiguration
ImageTestsConfiguration'
    { $sel:timeoutMinutes:ImageTestsConfiguration' :: Maybe Natural
timeoutMinutes =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:imageTestsEnabled:ImageTestsConfiguration' :: Maybe Bool
imageTestsEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum time in minutes that tests are permitted to run.
imageTestsConfiguration_timeoutMinutes :: Lens.Lens' ImageTestsConfiguration (Prelude.Maybe Prelude.Natural)
imageTestsConfiguration_timeoutMinutes :: (Maybe Natural -> f (Maybe Natural))
-> ImageTestsConfiguration -> f ImageTestsConfiguration
imageTestsConfiguration_timeoutMinutes = (ImageTestsConfiguration -> Maybe Natural)
-> (ImageTestsConfiguration
    -> Maybe Natural -> ImageTestsConfiguration)
-> Lens
     ImageTestsConfiguration
     ImageTestsConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageTestsConfiguration' {Maybe Natural
timeoutMinutes :: Maybe Natural
$sel:timeoutMinutes:ImageTestsConfiguration' :: ImageTestsConfiguration -> Maybe Natural
timeoutMinutes} -> Maybe Natural
timeoutMinutes) (\s :: ImageTestsConfiguration
s@ImageTestsConfiguration' {} Maybe Natural
a -> ImageTestsConfiguration
s {$sel:timeoutMinutes:ImageTestsConfiguration' :: Maybe Natural
timeoutMinutes = Maybe Natural
a} :: ImageTestsConfiguration)

-- | Defines if tests should be executed when building this image.
imageTestsConfiguration_imageTestsEnabled :: Lens.Lens' ImageTestsConfiguration (Prelude.Maybe Prelude.Bool)
imageTestsConfiguration_imageTestsEnabled :: (Maybe Bool -> f (Maybe Bool))
-> ImageTestsConfiguration -> f ImageTestsConfiguration
imageTestsConfiguration_imageTestsEnabled = (ImageTestsConfiguration -> Maybe Bool)
-> (ImageTestsConfiguration
    -> Maybe Bool -> ImageTestsConfiguration)
-> Lens
     ImageTestsConfiguration
     ImageTestsConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageTestsConfiguration' {Maybe Bool
imageTestsEnabled :: Maybe Bool
$sel:imageTestsEnabled:ImageTestsConfiguration' :: ImageTestsConfiguration -> Maybe Bool
imageTestsEnabled} -> Maybe Bool
imageTestsEnabled) (\s :: ImageTestsConfiguration
s@ImageTestsConfiguration' {} Maybe Bool
a -> ImageTestsConfiguration
s {$sel:imageTestsEnabled:ImageTestsConfiguration' :: Maybe Bool
imageTestsEnabled = Maybe Bool
a} :: ImageTestsConfiguration)

instance Core.FromJSON ImageTestsConfiguration where
  parseJSON :: Value -> Parser ImageTestsConfiguration
parseJSON =
    String
-> (Object -> Parser ImageTestsConfiguration)
-> Value
-> Parser ImageTestsConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageTestsConfiguration"
      ( \Object
x ->
          Maybe Natural -> Maybe Bool -> ImageTestsConfiguration
ImageTestsConfiguration'
            (Maybe Natural -> Maybe Bool -> ImageTestsConfiguration)
-> Parser (Maybe Natural)
-> Parser (Maybe Bool -> ImageTestsConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timeoutMinutes")
            Parser (Maybe Bool -> ImageTestsConfiguration)
-> Parser (Maybe Bool) -> Parser ImageTestsConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"imageTestsEnabled")
      )

instance Prelude.Hashable ImageTestsConfiguration

instance Prelude.NFData ImageTestsConfiguration

instance Core.ToJSON ImageTestsConfiguration where
  toJSON :: ImageTestsConfiguration -> Value
toJSON ImageTestsConfiguration' {Maybe Bool
Maybe Natural
imageTestsEnabled :: Maybe Bool
timeoutMinutes :: Maybe Natural
$sel:imageTestsEnabled:ImageTestsConfiguration' :: ImageTestsConfiguration -> Maybe Bool
$sel:timeoutMinutes:ImageTestsConfiguration' :: ImageTestsConfiguration -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"timeoutMinutes" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
timeoutMinutes,
            (Text
"imageTestsEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
imageTestsEnabled
          ]
      )