{-# 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.ImageBuilder.Types.ImagePackage
-- 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.ImageBuilder.Types.ImagePackage where

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

-- | Represents a package installed on an Image Builder image.
--
-- /See:/ 'newImagePackage' smart constructor.
data ImagePackage = ImagePackage'
  { -- | The name of the package as reported to the operating system package
    -- manager.
    ImagePackage -> Maybe Text
packageName :: Prelude.Maybe Prelude.Text,
    -- | The version of the package as reported to the operating system package
    -- manager.
    ImagePackage -> Maybe Text
packageVersion :: Prelude.Maybe Prelude.Text
  }
  deriving (ImagePackage -> ImagePackage -> Bool
(ImagePackage -> ImagePackage -> Bool)
-> (ImagePackage -> ImagePackage -> Bool) -> Eq ImagePackage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImagePackage -> ImagePackage -> Bool
$c/= :: ImagePackage -> ImagePackage -> Bool
== :: ImagePackage -> ImagePackage -> Bool
$c== :: ImagePackage -> ImagePackage -> Bool
Prelude.Eq, ReadPrec [ImagePackage]
ReadPrec ImagePackage
Int -> ReadS ImagePackage
ReadS [ImagePackage]
(Int -> ReadS ImagePackage)
-> ReadS [ImagePackage]
-> ReadPrec ImagePackage
-> ReadPrec [ImagePackage]
-> Read ImagePackage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImagePackage]
$creadListPrec :: ReadPrec [ImagePackage]
readPrec :: ReadPrec ImagePackage
$creadPrec :: ReadPrec ImagePackage
readList :: ReadS [ImagePackage]
$creadList :: ReadS [ImagePackage]
readsPrec :: Int -> ReadS ImagePackage
$creadsPrec :: Int -> ReadS ImagePackage
Prelude.Read, Int -> ImagePackage -> ShowS
[ImagePackage] -> ShowS
ImagePackage -> String
(Int -> ImagePackage -> ShowS)
-> (ImagePackage -> String)
-> ([ImagePackage] -> ShowS)
-> Show ImagePackage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImagePackage] -> ShowS
$cshowList :: [ImagePackage] -> ShowS
show :: ImagePackage -> String
$cshow :: ImagePackage -> String
showsPrec :: Int -> ImagePackage -> ShowS
$cshowsPrec :: Int -> ImagePackage -> ShowS
Prelude.Show, (forall x. ImagePackage -> Rep ImagePackage x)
-> (forall x. Rep ImagePackage x -> ImagePackage)
-> Generic ImagePackage
forall x. Rep ImagePackage x -> ImagePackage
forall x. ImagePackage -> Rep ImagePackage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImagePackage x -> ImagePackage
$cfrom :: forall x. ImagePackage -> Rep ImagePackage x
Prelude.Generic)

-- |
-- Create a value of 'ImagePackage' 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:
--
-- 'packageName', 'imagePackage_packageName' - The name of the package as reported to the operating system package
-- manager.
--
-- 'packageVersion', 'imagePackage_packageVersion' - The version of the package as reported to the operating system package
-- manager.
newImagePackage ::
  ImagePackage
newImagePackage :: ImagePackage
newImagePackage =
  ImagePackage' :: Maybe Text -> Maybe Text -> ImagePackage
ImagePackage'
    { $sel:packageName:ImagePackage' :: Maybe Text
packageName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:packageVersion:ImagePackage' :: Maybe Text
packageVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the package as reported to the operating system package
-- manager.
imagePackage_packageName :: Lens.Lens' ImagePackage (Prelude.Maybe Prelude.Text)
imagePackage_packageName :: (Maybe Text -> f (Maybe Text)) -> ImagePackage -> f ImagePackage
imagePackage_packageName = (ImagePackage -> Maybe Text)
-> (ImagePackage -> Maybe Text -> ImagePackage)
-> Lens ImagePackage ImagePackage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImagePackage' {Maybe Text
packageName :: Maybe Text
$sel:packageName:ImagePackage' :: ImagePackage -> Maybe Text
packageName} -> Maybe Text
packageName) (\s :: ImagePackage
s@ImagePackage' {} Maybe Text
a -> ImagePackage
s {$sel:packageName:ImagePackage' :: Maybe Text
packageName = Maybe Text
a} :: ImagePackage)

-- | The version of the package as reported to the operating system package
-- manager.
imagePackage_packageVersion :: Lens.Lens' ImagePackage (Prelude.Maybe Prelude.Text)
imagePackage_packageVersion :: (Maybe Text -> f (Maybe Text)) -> ImagePackage -> f ImagePackage
imagePackage_packageVersion = (ImagePackage -> Maybe Text)
-> (ImagePackage -> Maybe Text -> ImagePackage)
-> Lens ImagePackage ImagePackage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImagePackage' {Maybe Text
packageVersion :: Maybe Text
$sel:packageVersion:ImagePackage' :: ImagePackage -> Maybe Text
packageVersion} -> Maybe Text
packageVersion) (\s :: ImagePackage
s@ImagePackage' {} Maybe Text
a -> ImagePackage
s {$sel:packageVersion:ImagePackage' :: Maybe Text
packageVersion = Maybe Text
a} :: ImagePackage)

instance Core.FromJSON ImagePackage where
  parseJSON :: Value -> Parser ImagePackage
parseJSON =
    String
-> (Object -> Parser ImagePackage) -> Value -> Parser ImagePackage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImagePackage"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ImagePackage
ImagePackage'
            (Maybe Text -> Maybe Text -> ImagePackage)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ImagePackage)
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
"packageName")
            Parser (Maybe Text -> ImagePackage)
-> Parser (Maybe Text) -> Parser ImagePackage
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
"packageVersion")
      )

instance Prelude.Hashable ImagePackage

instance Prelude.NFData ImagePackage