{-# 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.SecurityHub.Types.SoftwarePackage
-- 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.SecurityHub.Types.SoftwarePackage where

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

-- | Information about a software package.
--
-- /See:/ 'newSoftwarePackage' smart constructor.
data SoftwarePackage = SoftwarePackage'
  { -- | The file system path to the package manager inventory file.
    SoftwarePackage -> Maybe Text
filePath :: Prelude.Maybe Prelude.Text,
    -- | The release of the software package.
    SoftwarePackage -> Maybe Text
release :: Prelude.Maybe Prelude.Text,
    -- | The name of the software package.
    SoftwarePackage -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The version of the software package.
    SoftwarePackage -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The architecture used for the software package.
    SoftwarePackage -> Maybe Text
architecture :: Prelude.Maybe Prelude.Text,
    -- | The source of the package.
    SoftwarePackage -> Maybe Text
packageManager :: Prelude.Maybe Prelude.Text,
    -- | The epoch of the software package.
    SoftwarePackage -> Maybe Text
epoch :: Prelude.Maybe Prelude.Text
  }
  deriving (SoftwarePackage -> SoftwarePackage -> Bool
(SoftwarePackage -> SoftwarePackage -> Bool)
-> (SoftwarePackage -> SoftwarePackage -> Bool)
-> Eq SoftwarePackage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SoftwarePackage -> SoftwarePackage -> Bool
$c/= :: SoftwarePackage -> SoftwarePackage -> Bool
== :: SoftwarePackage -> SoftwarePackage -> Bool
$c== :: SoftwarePackage -> SoftwarePackage -> Bool
Prelude.Eq, ReadPrec [SoftwarePackage]
ReadPrec SoftwarePackage
Int -> ReadS SoftwarePackage
ReadS [SoftwarePackage]
(Int -> ReadS SoftwarePackage)
-> ReadS [SoftwarePackage]
-> ReadPrec SoftwarePackage
-> ReadPrec [SoftwarePackage]
-> Read SoftwarePackage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SoftwarePackage]
$creadListPrec :: ReadPrec [SoftwarePackage]
readPrec :: ReadPrec SoftwarePackage
$creadPrec :: ReadPrec SoftwarePackage
readList :: ReadS [SoftwarePackage]
$creadList :: ReadS [SoftwarePackage]
readsPrec :: Int -> ReadS SoftwarePackage
$creadsPrec :: Int -> ReadS SoftwarePackage
Prelude.Read, Int -> SoftwarePackage -> ShowS
[SoftwarePackage] -> ShowS
SoftwarePackage -> String
(Int -> SoftwarePackage -> ShowS)
-> (SoftwarePackage -> String)
-> ([SoftwarePackage] -> ShowS)
-> Show SoftwarePackage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SoftwarePackage] -> ShowS
$cshowList :: [SoftwarePackage] -> ShowS
show :: SoftwarePackage -> String
$cshow :: SoftwarePackage -> String
showsPrec :: Int -> SoftwarePackage -> ShowS
$cshowsPrec :: Int -> SoftwarePackage -> ShowS
Prelude.Show, (forall x. SoftwarePackage -> Rep SoftwarePackage x)
-> (forall x. Rep SoftwarePackage x -> SoftwarePackage)
-> Generic SoftwarePackage
forall x. Rep SoftwarePackage x -> SoftwarePackage
forall x. SoftwarePackage -> Rep SoftwarePackage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SoftwarePackage x -> SoftwarePackage
$cfrom :: forall x. SoftwarePackage -> Rep SoftwarePackage x
Prelude.Generic)

-- |
-- Create a value of 'SoftwarePackage' 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:
--
-- 'filePath', 'softwarePackage_filePath' - The file system path to the package manager inventory file.
--
-- 'release', 'softwarePackage_release' - The release of the software package.
--
-- 'name', 'softwarePackage_name' - The name of the software package.
--
-- 'version', 'softwarePackage_version' - The version of the software package.
--
-- 'architecture', 'softwarePackage_architecture' - The architecture used for the software package.
--
-- 'packageManager', 'softwarePackage_packageManager' - The source of the package.
--
-- 'epoch', 'softwarePackage_epoch' - The epoch of the software package.
newSoftwarePackage ::
  SoftwarePackage
newSoftwarePackage :: SoftwarePackage
newSoftwarePackage =
  SoftwarePackage' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SoftwarePackage
SoftwarePackage'
    { $sel:filePath:SoftwarePackage' :: Maybe Text
filePath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:release:SoftwarePackage' :: Maybe Text
release = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:SoftwarePackage' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:version:SoftwarePackage' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:architecture:SoftwarePackage' :: Maybe Text
architecture = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:packageManager:SoftwarePackage' :: Maybe Text
packageManager = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:epoch:SoftwarePackage' :: Maybe Text
epoch = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The file system path to the package manager inventory file.
softwarePackage_filePath :: Lens.Lens' SoftwarePackage (Prelude.Maybe Prelude.Text)
softwarePackage_filePath :: (Maybe Text -> f (Maybe Text))
-> SoftwarePackage -> f SoftwarePackage
softwarePackage_filePath = (SoftwarePackage -> Maybe Text)
-> (SoftwarePackage -> Maybe Text -> SoftwarePackage)
-> Lens SoftwarePackage SoftwarePackage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SoftwarePackage' {Maybe Text
filePath :: Maybe Text
$sel:filePath:SoftwarePackage' :: SoftwarePackage -> Maybe Text
filePath} -> Maybe Text
filePath) (\s :: SoftwarePackage
s@SoftwarePackage' {} Maybe Text
a -> SoftwarePackage
s {$sel:filePath:SoftwarePackage' :: Maybe Text
filePath = Maybe Text
a} :: SoftwarePackage)

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

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

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

-- | The architecture used for the software package.
softwarePackage_architecture :: Lens.Lens' SoftwarePackage (Prelude.Maybe Prelude.Text)
softwarePackage_architecture :: (Maybe Text -> f (Maybe Text))
-> SoftwarePackage -> f SoftwarePackage
softwarePackage_architecture = (SoftwarePackage -> Maybe Text)
-> (SoftwarePackage -> Maybe Text -> SoftwarePackage)
-> Lens SoftwarePackage SoftwarePackage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SoftwarePackage' {Maybe Text
architecture :: Maybe Text
$sel:architecture:SoftwarePackage' :: SoftwarePackage -> Maybe Text
architecture} -> Maybe Text
architecture) (\s :: SoftwarePackage
s@SoftwarePackage' {} Maybe Text
a -> SoftwarePackage
s {$sel:architecture:SoftwarePackage' :: Maybe Text
architecture = Maybe Text
a} :: SoftwarePackage)

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

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

instance Core.FromJSON SoftwarePackage where
  parseJSON :: Value -> Parser SoftwarePackage
parseJSON =
    String
-> (Object -> Parser SoftwarePackage)
-> Value
-> Parser SoftwarePackage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SoftwarePackage"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SoftwarePackage
SoftwarePackage'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> SoftwarePackage)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SoftwarePackage)
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
"FilePath")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> SoftwarePackage)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SoftwarePackage)
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
"Release")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> SoftwarePackage)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> SoftwarePackage)
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
"Name")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> SoftwarePackage)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> SoftwarePackage)
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
"Version")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> SoftwarePackage)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> SoftwarePackage)
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
"Architecture")
            Parser (Maybe Text -> Maybe Text -> SoftwarePackage)
-> Parser (Maybe Text) -> Parser (Maybe Text -> SoftwarePackage)
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
"PackageManager")
            Parser (Maybe Text -> SoftwarePackage)
-> Parser (Maybe Text) -> Parser SoftwarePackage
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
"Epoch")
      )

instance Prelude.Hashable SoftwarePackage

instance Prelude.NFData SoftwarePackage

instance Core.ToJSON SoftwarePackage where
  toJSON :: SoftwarePackage -> Value
toJSON SoftwarePackage' {Maybe Text
epoch :: Maybe Text
packageManager :: Maybe Text
architecture :: Maybe Text
version :: Maybe Text
name :: Maybe Text
release :: Maybe Text
filePath :: Maybe Text
$sel:epoch:SoftwarePackage' :: SoftwarePackage -> Maybe Text
$sel:packageManager:SoftwarePackage' :: SoftwarePackage -> Maybe Text
$sel:architecture:SoftwarePackage' :: SoftwarePackage -> Maybe Text
$sel:version:SoftwarePackage' :: SoftwarePackage -> Maybe Text
$sel:name:SoftwarePackage' :: SoftwarePackage -> Maybe Text
$sel:release:SoftwarePackage' :: SoftwarePackage -> Maybe Text
$sel:filePath:SoftwarePackage' :: SoftwarePackage -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FilePath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
filePath,
            (Text
"Release" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
release,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"Version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
version,
            (Text
"Architecture" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
architecture,
            (Text
"PackageManager" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
packageManager,
            (Text
"Epoch" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
epoch
          ]
      )