{-# 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.CodePipeline.Types.ArtifactDetails
-- 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.CodePipeline.Types.ArtifactDetails where

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

-- | Returns information about the details of an artifact.
--
-- /See:/ 'newArtifactDetails' smart constructor.
data ArtifactDetails = ArtifactDetails'
  { -- | The minimum number of artifacts allowed for the action type.
    ArtifactDetails -> Natural
minimumCount :: Prelude.Natural,
    -- | The maximum number of artifacts allowed for the action type.
    ArtifactDetails -> Natural
maximumCount :: Prelude.Natural
  }
  deriving (ArtifactDetails -> ArtifactDetails -> Bool
(ArtifactDetails -> ArtifactDetails -> Bool)
-> (ArtifactDetails -> ArtifactDetails -> Bool)
-> Eq ArtifactDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArtifactDetails -> ArtifactDetails -> Bool
$c/= :: ArtifactDetails -> ArtifactDetails -> Bool
== :: ArtifactDetails -> ArtifactDetails -> Bool
$c== :: ArtifactDetails -> ArtifactDetails -> Bool
Prelude.Eq, ReadPrec [ArtifactDetails]
ReadPrec ArtifactDetails
Int -> ReadS ArtifactDetails
ReadS [ArtifactDetails]
(Int -> ReadS ArtifactDetails)
-> ReadS [ArtifactDetails]
-> ReadPrec ArtifactDetails
-> ReadPrec [ArtifactDetails]
-> Read ArtifactDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArtifactDetails]
$creadListPrec :: ReadPrec [ArtifactDetails]
readPrec :: ReadPrec ArtifactDetails
$creadPrec :: ReadPrec ArtifactDetails
readList :: ReadS [ArtifactDetails]
$creadList :: ReadS [ArtifactDetails]
readsPrec :: Int -> ReadS ArtifactDetails
$creadsPrec :: Int -> ReadS ArtifactDetails
Prelude.Read, Int -> ArtifactDetails -> ShowS
[ArtifactDetails] -> ShowS
ArtifactDetails -> String
(Int -> ArtifactDetails -> ShowS)
-> (ArtifactDetails -> String)
-> ([ArtifactDetails] -> ShowS)
-> Show ArtifactDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArtifactDetails] -> ShowS
$cshowList :: [ArtifactDetails] -> ShowS
show :: ArtifactDetails -> String
$cshow :: ArtifactDetails -> String
showsPrec :: Int -> ArtifactDetails -> ShowS
$cshowsPrec :: Int -> ArtifactDetails -> ShowS
Prelude.Show, (forall x. ArtifactDetails -> Rep ArtifactDetails x)
-> (forall x. Rep ArtifactDetails x -> ArtifactDetails)
-> Generic ArtifactDetails
forall x. Rep ArtifactDetails x -> ArtifactDetails
forall x. ArtifactDetails -> Rep ArtifactDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArtifactDetails x -> ArtifactDetails
$cfrom :: forall x. ArtifactDetails -> Rep ArtifactDetails x
Prelude.Generic)

-- |
-- Create a value of 'ArtifactDetails' 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:
--
-- 'minimumCount', 'artifactDetails_minimumCount' - The minimum number of artifacts allowed for the action type.
--
-- 'maximumCount', 'artifactDetails_maximumCount' - The maximum number of artifacts allowed for the action type.
newArtifactDetails ::
  -- | 'minimumCount'
  Prelude.Natural ->
  -- | 'maximumCount'
  Prelude.Natural ->
  ArtifactDetails
newArtifactDetails :: Natural -> Natural -> ArtifactDetails
newArtifactDetails Natural
pMinimumCount_ Natural
pMaximumCount_ =
  ArtifactDetails' :: Natural -> Natural -> ArtifactDetails
ArtifactDetails'
    { $sel:minimumCount:ArtifactDetails' :: Natural
minimumCount = Natural
pMinimumCount_,
      $sel:maximumCount:ArtifactDetails' :: Natural
maximumCount = Natural
pMaximumCount_
    }

-- | The minimum number of artifacts allowed for the action type.
artifactDetails_minimumCount :: Lens.Lens' ArtifactDetails Prelude.Natural
artifactDetails_minimumCount :: (Natural -> f Natural) -> ArtifactDetails -> f ArtifactDetails
artifactDetails_minimumCount = (ArtifactDetails -> Natural)
-> (ArtifactDetails -> Natural -> ArtifactDetails)
-> Lens ArtifactDetails ArtifactDetails Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactDetails' {Natural
minimumCount :: Natural
$sel:minimumCount:ArtifactDetails' :: ArtifactDetails -> Natural
minimumCount} -> Natural
minimumCount) (\s :: ArtifactDetails
s@ArtifactDetails' {} Natural
a -> ArtifactDetails
s {$sel:minimumCount:ArtifactDetails' :: Natural
minimumCount = Natural
a} :: ArtifactDetails)

-- | The maximum number of artifacts allowed for the action type.
artifactDetails_maximumCount :: Lens.Lens' ArtifactDetails Prelude.Natural
artifactDetails_maximumCount :: (Natural -> f Natural) -> ArtifactDetails -> f ArtifactDetails
artifactDetails_maximumCount = (ArtifactDetails -> Natural)
-> (ArtifactDetails -> Natural -> ArtifactDetails)
-> Lens ArtifactDetails ArtifactDetails Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactDetails' {Natural
maximumCount :: Natural
$sel:maximumCount:ArtifactDetails' :: ArtifactDetails -> Natural
maximumCount} -> Natural
maximumCount) (\s :: ArtifactDetails
s@ArtifactDetails' {} Natural
a -> ArtifactDetails
s {$sel:maximumCount:ArtifactDetails' :: Natural
maximumCount = Natural
a} :: ArtifactDetails)

instance Core.FromJSON ArtifactDetails where
  parseJSON :: Value -> Parser ArtifactDetails
parseJSON =
    String
-> (Object -> Parser ArtifactDetails)
-> Value
-> Parser ArtifactDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ArtifactDetails"
      ( \Object
x ->
          Natural -> Natural -> ArtifactDetails
ArtifactDetails'
            (Natural -> Natural -> ArtifactDetails)
-> Parser Natural -> Parser (Natural -> ArtifactDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"minimumCount")
            Parser (Natural -> ArtifactDetails)
-> Parser Natural -> Parser ArtifactDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"maximumCount")
      )

instance Prelude.Hashable ArtifactDetails

instance Prelude.NFData ArtifactDetails

instance Core.ToJSON ArtifactDetails where
  toJSON :: ArtifactDetails -> Value
toJSON ArtifactDetails' {Natural
maximumCount :: Natural
minimumCount :: Natural
$sel:maximumCount:ArtifactDetails' :: ArtifactDetails -> Natural
$sel:minimumCount:ArtifactDetails' :: ArtifactDetails -> Natural
..} =
    [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
"minimumCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
minimumCount),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"maximumCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maximumCount)
          ]
      )