{-# 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.PackageSummary
-- 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.PackageSummary where

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

-- | Details about a package, including its format, namespace, and name. The
-- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_ListPackages.html ListPackages>
-- operation returns a list of @PackageSummary@ objects.
--
-- /See:/ 'newPackageSummary' smart constructor.
data PackageSummary = PackageSummary'
  { -- | The format of the package. Valid values are:
    --
    -- -   @npm@
    --
    -- -   @pypi@
    --
    -- -   @maven@
    PackageSummary -> Maybe PackageFormat
format :: Prelude.Maybe PackageFormat,
    -- | The namespace of the package. The package component that specifies its
    -- namespace depends on its type. For example:
    --
    -- -   The namespace of a Maven package is its @groupId@.
    --
    -- -   The namespace of an npm package is its @scope@.
    --
    -- -   A Python package does not contain a corresponding component, so
    --     Python packages do not have a namespace.
    PackageSummary -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | The name of the package.
    PackageSummary -> Maybe Text
package :: Prelude.Maybe Prelude.Text
  }
  deriving (PackageSummary -> PackageSummary -> Bool
(PackageSummary -> PackageSummary -> Bool)
-> (PackageSummary -> PackageSummary -> Bool) -> Eq PackageSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PackageSummary -> PackageSummary -> Bool
$c/= :: PackageSummary -> PackageSummary -> Bool
== :: PackageSummary -> PackageSummary -> Bool
$c== :: PackageSummary -> PackageSummary -> Bool
Prelude.Eq, ReadPrec [PackageSummary]
ReadPrec PackageSummary
Int -> ReadS PackageSummary
ReadS [PackageSummary]
(Int -> ReadS PackageSummary)
-> ReadS [PackageSummary]
-> ReadPrec PackageSummary
-> ReadPrec [PackageSummary]
-> Read PackageSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PackageSummary]
$creadListPrec :: ReadPrec [PackageSummary]
readPrec :: ReadPrec PackageSummary
$creadPrec :: ReadPrec PackageSummary
readList :: ReadS [PackageSummary]
$creadList :: ReadS [PackageSummary]
readsPrec :: Int -> ReadS PackageSummary
$creadsPrec :: Int -> ReadS PackageSummary
Prelude.Read, Int -> PackageSummary -> ShowS
[PackageSummary] -> ShowS
PackageSummary -> String
(Int -> PackageSummary -> ShowS)
-> (PackageSummary -> String)
-> ([PackageSummary] -> ShowS)
-> Show PackageSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PackageSummary] -> ShowS
$cshowList :: [PackageSummary] -> ShowS
show :: PackageSummary -> String
$cshow :: PackageSummary -> String
showsPrec :: Int -> PackageSummary -> ShowS
$cshowsPrec :: Int -> PackageSummary -> ShowS
Prelude.Show, (forall x. PackageSummary -> Rep PackageSummary x)
-> (forall x. Rep PackageSummary x -> PackageSummary)
-> Generic PackageSummary
forall x. Rep PackageSummary x -> PackageSummary
forall x. PackageSummary -> Rep PackageSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PackageSummary x -> PackageSummary
$cfrom :: forall x. PackageSummary -> Rep PackageSummary x
Prelude.Generic)

-- |
-- Create a value of 'PackageSummary' 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:
--
-- 'format', 'packageSummary_format' - The format of the package. Valid values are:
--
-- -   @npm@
--
-- -   @pypi@
--
-- -   @maven@
--
-- 'namespace', 'packageSummary_namespace' - The namespace of the package. The package component that specifies its
-- namespace depends on its type. For example:
--
-- -   The namespace of a Maven package is its @groupId@.
--
-- -   The namespace of an npm package is its @scope@.
--
-- -   A Python package does not contain a corresponding component, so
--     Python packages do not have a namespace.
--
-- 'package', 'packageSummary_package' - The name of the package.
newPackageSummary ::
  PackageSummary
newPackageSummary :: PackageSummary
newPackageSummary =
  PackageSummary' :: Maybe PackageFormat -> Maybe Text -> Maybe Text -> PackageSummary
PackageSummary'
    { $sel:format:PackageSummary' :: Maybe PackageFormat
format = Maybe PackageFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:PackageSummary' :: Maybe Text
namespace = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:package:PackageSummary' :: Maybe Text
package = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The format of the package. Valid values are:
--
-- -   @npm@
--
-- -   @pypi@
--
-- -   @maven@
packageSummary_format :: Lens.Lens' PackageSummary (Prelude.Maybe PackageFormat)
packageSummary_format :: (Maybe PackageFormat -> f (Maybe PackageFormat))
-> PackageSummary -> f PackageSummary
packageSummary_format = (PackageSummary -> Maybe PackageFormat)
-> (PackageSummary -> Maybe PackageFormat -> PackageSummary)
-> Lens
     PackageSummary
     PackageSummary
     (Maybe PackageFormat)
     (Maybe PackageFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageSummary' {Maybe PackageFormat
format :: Maybe PackageFormat
$sel:format:PackageSummary' :: PackageSummary -> Maybe PackageFormat
format} -> Maybe PackageFormat
format) (\s :: PackageSummary
s@PackageSummary' {} Maybe PackageFormat
a -> PackageSummary
s {$sel:format:PackageSummary' :: Maybe PackageFormat
format = Maybe PackageFormat
a} :: PackageSummary)

-- | The namespace of the package. The package component that specifies its
-- namespace depends on its type. For example:
--
-- -   The namespace of a Maven package is its @groupId@.
--
-- -   The namespace of an npm package is its @scope@.
--
-- -   A Python package does not contain a corresponding component, so
--     Python packages do not have a namespace.
packageSummary_namespace :: Lens.Lens' PackageSummary (Prelude.Maybe Prelude.Text)
packageSummary_namespace :: (Maybe Text -> f (Maybe Text))
-> PackageSummary -> f PackageSummary
packageSummary_namespace = (PackageSummary -> Maybe Text)
-> (PackageSummary -> Maybe Text -> PackageSummary)
-> Lens PackageSummary PackageSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageSummary' {Maybe Text
namespace :: Maybe Text
$sel:namespace:PackageSummary' :: PackageSummary -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: PackageSummary
s@PackageSummary' {} Maybe Text
a -> PackageSummary
s {$sel:namespace:PackageSummary' :: Maybe Text
namespace = Maybe Text
a} :: PackageSummary)

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

instance Core.FromJSON PackageSummary where
  parseJSON :: Value -> Parser PackageSummary
parseJSON =
    String
-> (Object -> Parser PackageSummary)
-> Value
-> Parser PackageSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PackageSummary"
      ( \Object
x ->
          Maybe PackageFormat -> Maybe Text -> Maybe Text -> PackageSummary
PackageSummary'
            (Maybe PackageFormat -> Maybe Text -> Maybe Text -> PackageSummary)
-> Parser (Maybe PackageFormat)
-> Parser (Maybe Text -> Maybe Text -> PackageSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PackageFormat)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"format")
            Parser (Maybe Text -> Maybe Text -> PackageSummary)
-> Parser (Maybe Text) -> Parser (Maybe Text -> PackageSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"namespace")
            Parser (Maybe Text -> PackageSummary)
-> Parser (Maybe Text) -> Parser PackageSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"package")
      )

instance Prelude.Hashable PackageSummary

instance Prelude.NFData PackageSummary