{-# 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.CodeArtifact.Types.AssetSummary
-- 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.CodeArtifact.Types.AssetSummary where

import Amazonka.CodeArtifact.Types.HashAlgorithm
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains details about a package version asset.
--
-- /See:/ 'newAssetSummary' smart constructor.
data AssetSummary = AssetSummary'
  { -- | The size of the asset.
    AssetSummary -> Maybe Integer
size :: Prelude.Maybe Prelude.Integer,
    -- | The hashes of the asset.
    AssetSummary -> Maybe (HashMap HashAlgorithm Text)
hashes :: Prelude.Maybe (Prelude.HashMap HashAlgorithm Prelude.Text),
    -- | The name of the asset.
    AssetSummary -> Text
name :: Prelude.Text
  }
  deriving (AssetSummary -> AssetSummary -> Bool
(AssetSummary -> AssetSummary -> Bool)
-> (AssetSummary -> AssetSummary -> Bool) -> Eq AssetSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetSummary -> AssetSummary -> Bool
$c/= :: AssetSummary -> AssetSummary -> Bool
== :: AssetSummary -> AssetSummary -> Bool
$c== :: AssetSummary -> AssetSummary -> Bool
Prelude.Eq, ReadPrec [AssetSummary]
ReadPrec AssetSummary
Int -> ReadS AssetSummary
ReadS [AssetSummary]
(Int -> ReadS AssetSummary)
-> ReadS [AssetSummary]
-> ReadPrec AssetSummary
-> ReadPrec [AssetSummary]
-> Read AssetSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetSummary]
$creadListPrec :: ReadPrec [AssetSummary]
readPrec :: ReadPrec AssetSummary
$creadPrec :: ReadPrec AssetSummary
readList :: ReadS [AssetSummary]
$creadList :: ReadS [AssetSummary]
readsPrec :: Int -> ReadS AssetSummary
$creadsPrec :: Int -> ReadS AssetSummary
Prelude.Read, Int -> AssetSummary -> ShowS
[AssetSummary] -> ShowS
AssetSummary -> String
(Int -> AssetSummary -> ShowS)
-> (AssetSummary -> String)
-> ([AssetSummary] -> ShowS)
-> Show AssetSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetSummary] -> ShowS
$cshowList :: [AssetSummary] -> ShowS
show :: AssetSummary -> String
$cshow :: AssetSummary -> String
showsPrec :: Int -> AssetSummary -> ShowS
$cshowsPrec :: Int -> AssetSummary -> ShowS
Prelude.Show, (forall x. AssetSummary -> Rep AssetSummary x)
-> (forall x. Rep AssetSummary x -> AssetSummary)
-> Generic AssetSummary
forall x. Rep AssetSummary x -> AssetSummary
forall x. AssetSummary -> Rep AssetSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetSummary x -> AssetSummary
$cfrom :: forall x. AssetSummary -> Rep AssetSummary x
Prelude.Generic)

-- |
-- Create a value of 'AssetSummary' 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:
--
-- 'size', 'assetSummary_size' - The size of the asset.
--
-- 'hashes', 'assetSummary_hashes' - The hashes of the asset.
--
-- 'name', 'assetSummary_name' - The name of the asset.
newAssetSummary ::
  -- | 'name'
  Prelude.Text ->
  AssetSummary
newAssetSummary :: Text -> AssetSummary
newAssetSummary Text
pName_ =
  AssetSummary' :: Maybe Integer
-> Maybe (HashMap HashAlgorithm Text) -> Text -> AssetSummary
AssetSummary'
    { $sel:size:AssetSummary' :: Maybe Integer
size = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:hashes:AssetSummary' :: Maybe (HashMap HashAlgorithm Text)
hashes = Maybe (HashMap HashAlgorithm Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AssetSummary' :: Text
name = Text
pName_
    }

-- | The size of the asset.
assetSummary_size :: Lens.Lens' AssetSummary (Prelude.Maybe Prelude.Integer)
assetSummary_size :: (Maybe Integer -> f (Maybe Integer))
-> AssetSummary -> f AssetSummary
assetSummary_size = (AssetSummary -> Maybe Integer)
-> (AssetSummary -> Maybe Integer -> AssetSummary)
-> Lens AssetSummary AssetSummary (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetSummary' {Maybe Integer
size :: Maybe Integer
$sel:size:AssetSummary' :: AssetSummary -> Maybe Integer
size} -> Maybe Integer
size) (\s :: AssetSummary
s@AssetSummary' {} Maybe Integer
a -> AssetSummary
s {$sel:size:AssetSummary' :: Maybe Integer
size = Maybe Integer
a} :: AssetSummary)

-- | The hashes of the asset.
assetSummary_hashes :: Lens.Lens' AssetSummary (Prelude.Maybe (Prelude.HashMap HashAlgorithm Prelude.Text))
assetSummary_hashes :: (Maybe (HashMap HashAlgorithm Text)
 -> f (Maybe (HashMap HashAlgorithm Text)))
-> AssetSummary -> f AssetSummary
assetSummary_hashes = (AssetSummary -> Maybe (HashMap HashAlgorithm Text))
-> (AssetSummary
    -> Maybe (HashMap HashAlgorithm Text) -> AssetSummary)
-> Lens
     AssetSummary
     AssetSummary
     (Maybe (HashMap HashAlgorithm Text))
     (Maybe (HashMap HashAlgorithm Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetSummary' {Maybe (HashMap HashAlgorithm Text)
hashes :: Maybe (HashMap HashAlgorithm Text)
$sel:hashes:AssetSummary' :: AssetSummary -> Maybe (HashMap HashAlgorithm Text)
hashes} -> Maybe (HashMap HashAlgorithm Text)
hashes) (\s :: AssetSummary
s@AssetSummary' {} Maybe (HashMap HashAlgorithm Text)
a -> AssetSummary
s {$sel:hashes:AssetSummary' :: Maybe (HashMap HashAlgorithm Text)
hashes = Maybe (HashMap HashAlgorithm Text)
a} :: AssetSummary) ((Maybe (HashMap HashAlgorithm Text)
  -> f (Maybe (HashMap HashAlgorithm Text)))
 -> AssetSummary -> f AssetSummary)
-> ((Maybe (HashMap HashAlgorithm Text)
     -> f (Maybe (HashMap HashAlgorithm Text)))
    -> Maybe (HashMap HashAlgorithm Text)
    -> f (Maybe (HashMap HashAlgorithm Text)))
-> (Maybe (HashMap HashAlgorithm Text)
    -> f (Maybe (HashMap HashAlgorithm Text)))
-> AssetSummary
-> f AssetSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap HashAlgorithm Text)
  (HashMap HashAlgorithm Text)
  (HashMap HashAlgorithm Text)
  (HashMap HashAlgorithm Text)
-> Iso
     (Maybe (HashMap HashAlgorithm Text))
     (Maybe (HashMap HashAlgorithm Text))
     (Maybe (HashMap HashAlgorithm Text))
     (Maybe (HashMap HashAlgorithm Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap HashAlgorithm Text)
  (HashMap HashAlgorithm Text)
  (HashMap HashAlgorithm Text)
  (HashMap HashAlgorithm Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the asset.
assetSummary_name :: Lens.Lens' AssetSummary Prelude.Text
assetSummary_name :: (Text -> f Text) -> AssetSummary -> f AssetSummary
assetSummary_name = (AssetSummary -> Text)
-> (AssetSummary -> Text -> AssetSummary)
-> Lens AssetSummary AssetSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetSummary' {Text
name :: Text
$sel:name:AssetSummary' :: AssetSummary -> Text
name} -> Text
name) (\s :: AssetSummary
s@AssetSummary' {} Text
a -> AssetSummary
s {$sel:name:AssetSummary' :: Text
name = Text
a} :: AssetSummary)

instance Core.FromJSON AssetSummary where
  parseJSON :: Value -> Parser AssetSummary
parseJSON =
    String
-> (Object -> Parser AssetSummary) -> Value -> Parser AssetSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssetSummary"
      ( \Object
x ->
          Maybe Integer
-> Maybe (HashMap HashAlgorithm Text) -> Text -> AssetSummary
AssetSummary'
            (Maybe Integer
 -> Maybe (HashMap HashAlgorithm Text) -> Text -> AssetSummary)
-> Parser (Maybe Integer)
-> Parser
     (Maybe (HashMap HashAlgorithm Text) -> Text -> AssetSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"size")
            Parser (Maybe (HashMap HashAlgorithm Text) -> Text -> AssetSummary)
-> Parser (Maybe (HashMap HashAlgorithm Text))
-> Parser (Text -> AssetSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap HashAlgorithm Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"hashes" Parser (Maybe (Maybe (HashMap HashAlgorithm Text)))
-> Maybe (HashMap HashAlgorithm Text)
-> Parser (Maybe (HashMap HashAlgorithm Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap HashAlgorithm Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> AssetSummary) -> Parser Text -> Parser AssetSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
      )

instance Prelude.Hashable AssetSummary

instance Prelude.NFData AssetSummary