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

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

-- | Details about a package dependency.
--
-- /See:/ 'newPackageDependency' smart constructor.
data PackageDependency = PackageDependency'
  { -- | The type of a package dependency. The possible values depend on the
    -- package type. Example types are @compile@, @runtime@, and @test@ for
    -- Maven packages, and @dev@, @prod@, and @optional@ for npm packages.
    PackageDependency -> Maybe Text
dependencyType :: Prelude.Maybe Prelude.Text,
    -- | 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.
    PackageDependency -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | The name of the package that this package depends on.
    PackageDependency -> Maybe Text
package :: Prelude.Maybe Prelude.Text,
    -- | The required version, or version range, of the package that this package
    -- depends on. The version format is specific to the package type. For
    -- example, the following are possible valid required versions: @1.2.3@,
    -- @^2.3.4@, or @4.x@.
    PackageDependency -> Maybe Text
versionRequirement :: Prelude.Maybe Prelude.Text
  }
  deriving (PackageDependency -> PackageDependency -> Bool
(PackageDependency -> PackageDependency -> Bool)
-> (PackageDependency -> PackageDependency -> Bool)
-> Eq PackageDependency
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PackageDependency -> PackageDependency -> Bool
$c/= :: PackageDependency -> PackageDependency -> Bool
== :: PackageDependency -> PackageDependency -> Bool
$c== :: PackageDependency -> PackageDependency -> Bool
Prelude.Eq, ReadPrec [PackageDependency]
ReadPrec PackageDependency
Int -> ReadS PackageDependency
ReadS [PackageDependency]
(Int -> ReadS PackageDependency)
-> ReadS [PackageDependency]
-> ReadPrec PackageDependency
-> ReadPrec [PackageDependency]
-> Read PackageDependency
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PackageDependency]
$creadListPrec :: ReadPrec [PackageDependency]
readPrec :: ReadPrec PackageDependency
$creadPrec :: ReadPrec PackageDependency
readList :: ReadS [PackageDependency]
$creadList :: ReadS [PackageDependency]
readsPrec :: Int -> ReadS PackageDependency
$creadsPrec :: Int -> ReadS PackageDependency
Prelude.Read, Int -> PackageDependency -> ShowS
[PackageDependency] -> ShowS
PackageDependency -> String
(Int -> PackageDependency -> ShowS)
-> (PackageDependency -> String)
-> ([PackageDependency] -> ShowS)
-> Show PackageDependency
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PackageDependency] -> ShowS
$cshowList :: [PackageDependency] -> ShowS
show :: PackageDependency -> String
$cshow :: PackageDependency -> String
showsPrec :: Int -> PackageDependency -> ShowS
$cshowsPrec :: Int -> PackageDependency -> ShowS
Prelude.Show, (forall x. PackageDependency -> Rep PackageDependency x)
-> (forall x. Rep PackageDependency x -> PackageDependency)
-> Generic PackageDependency
forall x. Rep PackageDependency x -> PackageDependency
forall x. PackageDependency -> Rep PackageDependency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PackageDependency x -> PackageDependency
$cfrom :: forall x. PackageDependency -> Rep PackageDependency x
Prelude.Generic)

-- |
-- Create a value of 'PackageDependency' 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:
--
-- 'dependencyType', 'packageDependency_dependencyType' - The type of a package dependency. The possible values depend on the
-- package type. Example types are @compile@, @runtime@, and @test@ for
-- Maven packages, and @dev@, @prod@, and @optional@ for npm packages.
--
-- 'namespace', 'packageDependency_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', 'packageDependency_package' - The name of the package that this package depends on.
--
-- 'versionRequirement', 'packageDependency_versionRequirement' - The required version, or version range, of the package that this package
-- depends on. The version format is specific to the package type. For
-- example, the following are possible valid required versions: @1.2.3@,
-- @^2.3.4@, or @4.x@.
newPackageDependency ::
  PackageDependency
newPackageDependency :: PackageDependency
newPackageDependency =
  PackageDependency' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> PackageDependency
PackageDependency'
    { $sel:dependencyType:PackageDependency' :: Maybe Text
dependencyType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:PackageDependency' :: Maybe Text
namespace = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:package:PackageDependency' :: Maybe Text
package = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:versionRequirement:PackageDependency' :: Maybe Text
versionRequirement = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of a package dependency. The possible values depend on the
-- package type. Example types are @compile@, @runtime@, and @test@ for
-- Maven packages, and @dev@, @prod@, and @optional@ for npm packages.
packageDependency_dependencyType :: Lens.Lens' PackageDependency (Prelude.Maybe Prelude.Text)
packageDependency_dependencyType :: (Maybe Text -> f (Maybe Text))
-> PackageDependency -> f PackageDependency
packageDependency_dependencyType = (PackageDependency -> Maybe Text)
-> (PackageDependency -> Maybe Text -> PackageDependency)
-> Lens
     PackageDependency PackageDependency (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageDependency' {Maybe Text
dependencyType :: Maybe Text
$sel:dependencyType:PackageDependency' :: PackageDependency -> Maybe Text
dependencyType} -> Maybe Text
dependencyType) (\s :: PackageDependency
s@PackageDependency' {} Maybe Text
a -> PackageDependency
s {$sel:dependencyType:PackageDependency' :: Maybe Text
dependencyType = Maybe Text
a} :: PackageDependency)

-- | 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.
packageDependency_namespace :: Lens.Lens' PackageDependency (Prelude.Maybe Prelude.Text)
packageDependency_namespace :: (Maybe Text -> f (Maybe Text))
-> PackageDependency -> f PackageDependency
packageDependency_namespace = (PackageDependency -> Maybe Text)
-> (PackageDependency -> Maybe Text -> PackageDependency)
-> Lens
     PackageDependency PackageDependency (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageDependency' {Maybe Text
namespace :: Maybe Text
$sel:namespace:PackageDependency' :: PackageDependency -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: PackageDependency
s@PackageDependency' {} Maybe Text
a -> PackageDependency
s {$sel:namespace:PackageDependency' :: Maybe Text
namespace = Maybe Text
a} :: PackageDependency)

-- | The name of the package that this package depends on.
packageDependency_package :: Lens.Lens' PackageDependency (Prelude.Maybe Prelude.Text)
packageDependency_package :: (Maybe Text -> f (Maybe Text))
-> PackageDependency -> f PackageDependency
packageDependency_package = (PackageDependency -> Maybe Text)
-> (PackageDependency -> Maybe Text -> PackageDependency)
-> Lens
     PackageDependency PackageDependency (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageDependency' {Maybe Text
package :: Maybe Text
$sel:package:PackageDependency' :: PackageDependency -> Maybe Text
package} -> Maybe Text
package) (\s :: PackageDependency
s@PackageDependency' {} Maybe Text
a -> PackageDependency
s {$sel:package:PackageDependency' :: Maybe Text
package = Maybe Text
a} :: PackageDependency)

-- | The required version, or version range, of the package that this package
-- depends on. The version format is specific to the package type. For
-- example, the following are possible valid required versions: @1.2.3@,
-- @^2.3.4@, or @4.x@.
packageDependency_versionRequirement :: Lens.Lens' PackageDependency (Prelude.Maybe Prelude.Text)
packageDependency_versionRequirement :: (Maybe Text -> f (Maybe Text))
-> PackageDependency -> f PackageDependency
packageDependency_versionRequirement = (PackageDependency -> Maybe Text)
-> (PackageDependency -> Maybe Text -> PackageDependency)
-> Lens
     PackageDependency PackageDependency (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageDependency' {Maybe Text
versionRequirement :: Maybe Text
$sel:versionRequirement:PackageDependency' :: PackageDependency -> Maybe Text
versionRequirement} -> Maybe Text
versionRequirement) (\s :: PackageDependency
s@PackageDependency' {} Maybe Text
a -> PackageDependency
s {$sel:versionRequirement:PackageDependency' :: Maybe Text
versionRequirement = Maybe Text
a} :: PackageDependency)

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

instance Prelude.Hashable PackageDependency

instance Prelude.NFData PackageDependency