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

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

-- | Details about a package version, including its status, version, and
-- revision. The
-- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_ListPackageVersions.html ListPackageVersions>
-- operation returns a list of @PackageVersionSummary@ objects.
--
-- /See:/ 'newPackageVersionSummary' smart constructor.
data PackageVersionSummary = PackageVersionSummary'
  { -- | The revision associated with a package version.
    PackageVersionSummary -> Maybe Text
revision :: Prelude.Maybe Prelude.Text,
    -- | Information about a package version.
    PackageVersionSummary -> Text
version :: Prelude.Text,
    -- | A string that contains the status of the package version. It can be one
    -- of the following:
    --
    -- -   @Published@
    --
    -- -   @Unfinished@
    --
    -- -   @Unlisted@
    --
    -- -   @Archived@
    --
    -- -   @Disposed@
    PackageVersionSummary -> PackageVersionStatus
status :: PackageVersionStatus
  }
  deriving (PackageVersionSummary -> PackageVersionSummary -> Bool
(PackageVersionSummary -> PackageVersionSummary -> Bool)
-> (PackageVersionSummary -> PackageVersionSummary -> Bool)
-> Eq PackageVersionSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PackageVersionSummary -> PackageVersionSummary -> Bool
$c/= :: PackageVersionSummary -> PackageVersionSummary -> Bool
== :: PackageVersionSummary -> PackageVersionSummary -> Bool
$c== :: PackageVersionSummary -> PackageVersionSummary -> Bool
Prelude.Eq, ReadPrec [PackageVersionSummary]
ReadPrec PackageVersionSummary
Int -> ReadS PackageVersionSummary
ReadS [PackageVersionSummary]
(Int -> ReadS PackageVersionSummary)
-> ReadS [PackageVersionSummary]
-> ReadPrec PackageVersionSummary
-> ReadPrec [PackageVersionSummary]
-> Read PackageVersionSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PackageVersionSummary]
$creadListPrec :: ReadPrec [PackageVersionSummary]
readPrec :: ReadPrec PackageVersionSummary
$creadPrec :: ReadPrec PackageVersionSummary
readList :: ReadS [PackageVersionSummary]
$creadList :: ReadS [PackageVersionSummary]
readsPrec :: Int -> ReadS PackageVersionSummary
$creadsPrec :: Int -> ReadS PackageVersionSummary
Prelude.Read, Int -> PackageVersionSummary -> ShowS
[PackageVersionSummary] -> ShowS
PackageVersionSummary -> String
(Int -> PackageVersionSummary -> ShowS)
-> (PackageVersionSummary -> String)
-> ([PackageVersionSummary] -> ShowS)
-> Show PackageVersionSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PackageVersionSummary] -> ShowS
$cshowList :: [PackageVersionSummary] -> ShowS
show :: PackageVersionSummary -> String
$cshow :: PackageVersionSummary -> String
showsPrec :: Int -> PackageVersionSummary -> ShowS
$cshowsPrec :: Int -> PackageVersionSummary -> ShowS
Prelude.Show, (forall x. PackageVersionSummary -> Rep PackageVersionSummary x)
-> (forall x. Rep PackageVersionSummary x -> PackageVersionSummary)
-> Generic PackageVersionSummary
forall x. Rep PackageVersionSummary x -> PackageVersionSummary
forall x. PackageVersionSummary -> Rep PackageVersionSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PackageVersionSummary x -> PackageVersionSummary
$cfrom :: forall x. PackageVersionSummary -> Rep PackageVersionSummary x
Prelude.Generic)

-- |
-- Create a value of 'PackageVersionSummary' 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:
--
-- 'revision', 'packageVersionSummary_revision' - The revision associated with a package version.
--
-- 'version', 'packageVersionSummary_version' - Information about a package version.
--
-- 'status', 'packageVersionSummary_status' - A string that contains the status of the package version. It can be one
-- of the following:
--
-- -   @Published@
--
-- -   @Unfinished@
--
-- -   @Unlisted@
--
-- -   @Archived@
--
-- -   @Disposed@
newPackageVersionSummary ::
  -- | 'version'
  Prelude.Text ->
  -- | 'status'
  PackageVersionStatus ->
  PackageVersionSummary
newPackageVersionSummary :: Text -> PackageVersionStatus -> PackageVersionSummary
newPackageVersionSummary Text
pVersion_ PackageVersionStatus
pStatus_ =
  PackageVersionSummary' :: Maybe Text -> Text -> PackageVersionStatus -> PackageVersionSummary
PackageVersionSummary'
    { $sel:revision:PackageVersionSummary' :: Maybe Text
revision = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:version:PackageVersionSummary' :: Text
version = Text
pVersion_,
      $sel:status:PackageVersionSummary' :: PackageVersionStatus
status = PackageVersionStatus
pStatus_
    }

-- | The revision associated with a package version.
packageVersionSummary_revision :: Lens.Lens' PackageVersionSummary (Prelude.Maybe Prelude.Text)
packageVersionSummary_revision :: (Maybe Text -> f (Maybe Text))
-> PackageVersionSummary -> f PackageVersionSummary
packageVersionSummary_revision = (PackageVersionSummary -> Maybe Text)
-> (PackageVersionSummary -> Maybe Text -> PackageVersionSummary)
-> Lens
     PackageVersionSummary
     PackageVersionSummary
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageVersionSummary' {Maybe Text
revision :: Maybe Text
$sel:revision:PackageVersionSummary' :: PackageVersionSummary -> Maybe Text
revision} -> Maybe Text
revision) (\s :: PackageVersionSummary
s@PackageVersionSummary' {} Maybe Text
a -> PackageVersionSummary
s {$sel:revision:PackageVersionSummary' :: Maybe Text
revision = Maybe Text
a} :: PackageVersionSummary)

-- | Information about a package version.
packageVersionSummary_version :: Lens.Lens' PackageVersionSummary Prelude.Text
packageVersionSummary_version :: (Text -> f Text)
-> PackageVersionSummary -> f PackageVersionSummary
packageVersionSummary_version = (PackageVersionSummary -> Text)
-> (PackageVersionSummary -> Text -> PackageVersionSummary)
-> Lens PackageVersionSummary PackageVersionSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageVersionSummary' {Text
version :: Text
$sel:version:PackageVersionSummary' :: PackageVersionSummary -> Text
version} -> Text
version) (\s :: PackageVersionSummary
s@PackageVersionSummary' {} Text
a -> PackageVersionSummary
s {$sel:version:PackageVersionSummary' :: Text
version = Text
a} :: PackageVersionSummary)

-- | A string that contains the status of the package version. It can be one
-- of the following:
--
-- -   @Published@
--
-- -   @Unfinished@
--
-- -   @Unlisted@
--
-- -   @Archived@
--
-- -   @Disposed@
packageVersionSummary_status :: Lens.Lens' PackageVersionSummary PackageVersionStatus
packageVersionSummary_status :: (PackageVersionStatus -> f PackageVersionStatus)
-> PackageVersionSummary -> f PackageVersionSummary
packageVersionSummary_status = (PackageVersionSummary -> PackageVersionStatus)
-> (PackageVersionSummary
    -> PackageVersionStatus -> PackageVersionSummary)
-> Lens
     PackageVersionSummary
     PackageVersionSummary
     PackageVersionStatus
     PackageVersionStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageVersionSummary' {PackageVersionStatus
status :: PackageVersionStatus
$sel:status:PackageVersionSummary' :: PackageVersionSummary -> PackageVersionStatus
status} -> PackageVersionStatus
status) (\s :: PackageVersionSummary
s@PackageVersionSummary' {} PackageVersionStatus
a -> PackageVersionSummary
s {$sel:status:PackageVersionSummary' :: PackageVersionStatus
status = PackageVersionStatus
a} :: PackageVersionSummary)

instance Core.FromJSON PackageVersionSummary where
  parseJSON :: Value -> Parser PackageVersionSummary
parseJSON =
    String
-> (Object -> Parser PackageVersionSummary)
-> Value
-> Parser PackageVersionSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PackageVersionSummary"
      ( \Object
x ->
          Maybe Text -> Text -> PackageVersionStatus -> PackageVersionSummary
PackageVersionSummary'
            (Maybe Text
 -> Text -> PackageVersionStatus -> PackageVersionSummary)
-> Parser (Maybe Text)
-> Parser (Text -> PackageVersionStatus -> PackageVersionSummary)
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
"revision")
            Parser (Text -> PackageVersionStatus -> PackageVersionSummary)
-> Parser Text
-> Parser (PackageVersionStatus -> PackageVersionSummary)
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
"version")
            Parser (PackageVersionStatus -> PackageVersionSummary)
-> Parser PackageVersionStatus -> Parser PackageVersionSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PackageVersionStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"status")
      )

instance Prelude.Hashable PackageVersionSummary

instance Prelude.NFData PackageVersionSummary