{-# 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.ECR.Types.ImageScanningConfiguration
-- 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.ECR.Types.ImageScanningConfiguration where

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

-- | The image scanning configuration for a repository.
--
-- /See:/ 'newImageScanningConfiguration' smart constructor.
data ImageScanningConfiguration = ImageScanningConfiguration'
  { -- | The setting that determines whether images are scanned after being
    -- pushed to a repository. If set to @true@, images will be scanned after
    -- being pushed. If this parameter is not specified, it will default to
    -- @false@ and images will not be scanned unless a scan is manually started
    -- with the
    -- <https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_StartImageScan.html API_StartImageScan>
    -- API.
    ImageScanningConfiguration -> Maybe Bool
scanOnPush :: Prelude.Maybe Prelude.Bool
  }
  deriving (ImageScanningConfiguration -> ImageScanningConfiguration -> Bool
(ImageScanningConfiguration -> ImageScanningConfiguration -> Bool)
-> (ImageScanningConfiguration
    -> ImageScanningConfiguration -> Bool)
-> Eq ImageScanningConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageScanningConfiguration -> ImageScanningConfiguration -> Bool
$c/= :: ImageScanningConfiguration -> ImageScanningConfiguration -> Bool
== :: ImageScanningConfiguration -> ImageScanningConfiguration -> Bool
$c== :: ImageScanningConfiguration -> ImageScanningConfiguration -> Bool
Prelude.Eq, ReadPrec [ImageScanningConfiguration]
ReadPrec ImageScanningConfiguration
Int -> ReadS ImageScanningConfiguration
ReadS [ImageScanningConfiguration]
(Int -> ReadS ImageScanningConfiguration)
-> ReadS [ImageScanningConfiguration]
-> ReadPrec ImageScanningConfiguration
-> ReadPrec [ImageScanningConfiguration]
-> Read ImageScanningConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageScanningConfiguration]
$creadListPrec :: ReadPrec [ImageScanningConfiguration]
readPrec :: ReadPrec ImageScanningConfiguration
$creadPrec :: ReadPrec ImageScanningConfiguration
readList :: ReadS [ImageScanningConfiguration]
$creadList :: ReadS [ImageScanningConfiguration]
readsPrec :: Int -> ReadS ImageScanningConfiguration
$creadsPrec :: Int -> ReadS ImageScanningConfiguration
Prelude.Read, Int -> ImageScanningConfiguration -> ShowS
[ImageScanningConfiguration] -> ShowS
ImageScanningConfiguration -> String
(Int -> ImageScanningConfiguration -> ShowS)
-> (ImageScanningConfiguration -> String)
-> ([ImageScanningConfiguration] -> ShowS)
-> Show ImageScanningConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageScanningConfiguration] -> ShowS
$cshowList :: [ImageScanningConfiguration] -> ShowS
show :: ImageScanningConfiguration -> String
$cshow :: ImageScanningConfiguration -> String
showsPrec :: Int -> ImageScanningConfiguration -> ShowS
$cshowsPrec :: Int -> ImageScanningConfiguration -> ShowS
Prelude.Show, (forall x.
 ImageScanningConfiguration -> Rep ImageScanningConfiguration x)
-> (forall x.
    Rep ImageScanningConfiguration x -> ImageScanningConfiguration)
-> Generic ImageScanningConfiguration
forall x.
Rep ImageScanningConfiguration x -> ImageScanningConfiguration
forall x.
ImageScanningConfiguration -> Rep ImageScanningConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ImageScanningConfiguration x -> ImageScanningConfiguration
$cfrom :: forall x.
ImageScanningConfiguration -> Rep ImageScanningConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ImageScanningConfiguration' 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:
--
-- 'scanOnPush', 'imageScanningConfiguration_scanOnPush' - The setting that determines whether images are scanned after being
-- pushed to a repository. If set to @true@, images will be scanned after
-- being pushed. If this parameter is not specified, it will default to
-- @false@ and images will not be scanned unless a scan is manually started
-- with the
-- <https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_StartImageScan.html API_StartImageScan>
-- API.
newImageScanningConfiguration ::
  ImageScanningConfiguration
newImageScanningConfiguration :: ImageScanningConfiguration
newImageScanningConfiguration =
  ImageScanningConfiguration' :: Maybe Bool -> ImageScanningConfiguration
ImageScanningConfiguration'
    { $sel:scanOnPush:ImageScanningConfiguration' :: Maybe Bool
scanOnPush =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The setting that determines whether images are scanned after being
-- pushed to a repository. If set to @true@, images will be scanned after
-- being pushed. If this parameter is not specified, it will default to
-- @false@ and images will not be scanned unless a scan is manually started
-- with the
-- <https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_StartImageScan.html API_StartImageScan>
-- API.
imageScanningConfiguration_scanOnPush :: Lens.Lens' ImageScanningConfiguration (Prelude.Maybe Prelude.Bool)
imageScanningConfiguration_scanOnPush :: (Maybe Bool -> f (Maybe Bool))
-> ImageScanningConfiguration -> f ImageScanningConfiguration
imageScanningConfiguration_scanOnPush = (ImageScanningConfiguration -> Maybe Bool)
-> (ImageScanningConfiguration
    -> Maybe Bool -> ImageScanningConfiguration)
-> Lens
     ImageScanningConfiguration
     ImageScanningConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanningConfiguration' {Maybe Bool
scanOnPush :: Maybe Bool
$sel:scanOnPush:ImageScanningConfiguration' :: ImageScanningConfiguration -> Maybe Bool
scanOnPush} -> Maybe Bool
scanOnPush) (\s :: ImageScanningConfiguration
s@ImageScanningConfiguration' {} Maybe Bool
a -> ImageScanningConfiguration
s {$sel:scanOnPush:ImageScanningConfiguration' :: Maybe Bool
scanOnPush = Maybe Bool
a} :: ImageScanningConfiguration)

instance Core.FromJSON ImageScanningConfiguration where
  parseJSON :: Value -> Parser ImageScanningConfiguration
parseJSON =
    String
-> (Object -> Parser ImageScanningConfiguration)
-> Value
-> Parser ImageScanningConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageScanningConfiguration"
      ( \Object
x ->
          Maybe Bool -> ImageScanningConfiguration
ImageScanningConfiguration'
            (Maybe Bool -> ImageScanningConfiguration)
-> Parser (Maybe Bool) -> Parser ImageScanningConfiguration
forall (f :: * -> *) a b. Functor 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
"scanOnPush")
      )

instance Prelude.Hashable ImageScanningConfiguration

instance Prelude.NFData ImageScanningConfiguration

instance Core.ToJSON ImageScanningConfiguration where
  toJSON :: ImageScanningConfiguration -> Value
toJSON ImageScanningConfiguration' {Maybe Bool
scanOnPush :: Maybe Bool
$sel:scanOnPush:ImageScanningConfiguration' :: ImageScanningConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"scanOnPush" 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
scanOnPush]
      )