{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECR.Types.ImageScanningConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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'
    { $sel:scanOnPush:ImageScanningConfiguration' :: Maybe Bool
scanOnPush =
        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 :: Lens' ImageScanningConfiguration (Maybe Bool)
imageScanningConfiguration_scanOnPush = 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 Data.FromJSON ImageScanningConfiguration where
  parseJSON :: Value -> Parser ImageScanningConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImageScanningConfiguration"
      ( \Object
x ->
          Maybe Bool -> ImageScanningConfiguration
ImageScanningConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"scanOnPush")
      )

instance Prelude.Hashable ImageScanningConfiguration where
  hashWithSalt :: Int -> ImageScanningConfiguration -> Int
hashWithSalt Int
_salt ImageScanningConfiguration' {Maybe Bool
scanOnPush :: Maybe Bool
$sel:scanOnPush:ImageScanningConfiguration' :: ImageScanningConfiguration -> Maybe Bool
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
scanOnPush

instance Prelude.NFData ImageScanningConfiguration where
  rnf :: ImageScanningConfiguration -> ()
rnf ImageScanningConfiguration' {Maybe Bool
scanOnPush :: Maybe Bool
$sel:scanOnPush:ImageScanningConfiguration' :: ImageScanningConfiguration -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
scanOnPush

instance Data.ToJSON ImageScanningConfiguration where
  toJSON :: ImageScanningConfiguration -> Value
toJSON ImageScanningConfiguration' {Maybe Bool
scanOnPush :: Maybe Bool
$sel:scanOnPush:ImageScanningConfiguration' :: ImageScanningConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"scanOnPush" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
scanOnPush]
      )