{-# 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.Panorama.Types.PackageVersionOutputConfig
-- 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.Panorama.Types.PackageVersionOutputConfig where

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

-- | A package version output configuration.
--
-- /See:/ 'newPackageVersionOutputConfig' smart constructor.
data PackageVersionOutputConfig = PackageVersionOutputConfig'
  { -- | Indicates that the version is recommended for all users.
    PackageVersionOutputConfig -> Maybe Bool
markLatest :: Prelude.Maybe Prelude.Bool,
    -- | The output\'s package name.
    PackageVersionOutputConfig -> Text
packageName :: Prelude.Text,
    -- | The output\'s package version.
    PackageVersionOutputConfig -> Text
packageVersion :: Prelude.Text
  }
  deriving (PackageVersionOutputConfig -> PackageVersionOutputConfig -> Bool
(PackageVersionOutputConfig -> PackageVersionOutputConfig -> Bool)
-> (PackageVersionOutputConfig
    -> PackageVersionOutputConfig -> Bool)
-> Eq PackageVersionOutputConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PackageVersionOutputConfig -> PackageVersionOutputConfig -> Bool
$c/= :: PackageVersionOutputConfig -> PackageVersionOutputConfig -> Bool
== :: PackageVersionOutputConfig -> PackageVersionOutputConfig -> Bool
$c== :: PackageVersionOutputConfig -> PackageVersionOutputConfig -> Bool
Prelude.Eq, ReadPrec [PackageVersionOutputConfig]
ReadPrec PackageVersionOutputConfig
Int -> ReadS PackageVersionOutputConfig
ReadS [PackageVersionOutputConfig]
(Int -> ReadS PackageVersionOutputConfig)
-> ReadS [PackageVersionOutputConfig]
-> ReadPrec PackageVersionOutputConfig
-> ReadPrec [PackageVersionOutputConfig]
-> Read PackageVersionOutputConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PackageVersionOutputConfig]
$creadListPrec :: ReadPrec [PackageVersionOutputConfig]
readPrec :: ReadPrec PackageVersionOutputConfig
$creadPrec :: ReadPrec PackageVersionOutputConfig
readList :: ReadS [PackageVersionOutputConfig]
$creadList :: ReadS [PackageVersionOutputConfig]
readsPrec :: Int -> ReadS PackageVersionOutputConfig
$creadsPrec :: Int -> ReadS PackageVersionOutputConfig
Prelude.Read, Int -> PackageVersionOutputConfig -> ShowS
[PackageVersionOutputConfig] -> ShowS
PackageVersionOutputConfig -> String
(Int -> PackageVersionOutputConfig -> ShowS)
-> (PackageVersionOutputConfig -> String)
-> ([PackageVersionOutputConfig] -> ShowS)
-> Show PackageVersionOutputConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PackageVersionOutputConfig] -> ShowS
$cshowList :: [PackageVersionOutputConfig] -> ShowS
show :: PackageVersionOutputConfig -> String
$cshow :: PackageVersionOutputConfig -> String
showsPrec :: Int -> PackageVersionOutputConfig -> ShowS
$cshowsPrec :: Int -> PackageVersionOutputConfig -> ShowS
Prelude.Show, (forall x.
 PackageVersionOutputConfig -> Rep PackageVersionOutputConfig x)
-> (forall x.
    Rep PackageVersionOutputConfig x -> PackageVersionOutputConfig)
-> Generic PackageVersionOutputConfig
forall x.
Rep PackageVersionOutputConfig x -> PackageVersionOutputConfig
forall x.
PackageVersionOutputConfig -> Rep PackageVersionOutputConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PackageVersionOutputConfig x -> PackageVersionOutputConfig
$cfrom :: forall x.
PackageVersionOutputConfig -> Rep PackageVersionOutputConfig x
Prelude.Generic)

-- |
-- Create a value of 'PackageVersionOutputConfig' 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:
--
-- 'markLatest', 'packageVersionOutputConfig_markLatest' - Indicates that the version is recommended for all users.
--
-- 'packageName', 'packageVersionOutputConfig_packageName' - The output\'s package name.
--
-- 'packageVersion', 'packageVersionOutputConfig_packageVersion' - The output\'s package version.
newPackageVersionOutputConfig ::
  -- | 'packageName'
  Prelude.Text ->
  -- | 'packageVersion'
  Prelude.Text ->
  PackageVersionOutputConfig
newPackageVersionOutputConfig :: Text -> Text -> PackageVersionOutputConfig
newPackageVersionOutputConfig
  Text
pPackageName_
  Text
pPackageVersion_ =
    PackageVersionOutputConfig' :: Maybe Bool -> Text -> Text -> PackageVersionOutputConfig
PackageVersionOutputConfig'
      { $sel:markLatest:PackageVersionOutputConfig' :: Maybe Bool
markLatest =
          Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:packageName:PackageVersionOutputConfig' :: Text
packageName = Text
pPackageName_,
        $sel:packageVersion:PackageVersionOutputConfig' :: Text
packageVersion = Text
pPackageVersion_
      }

-- | Indicates that the version is recommended for all users.
packageVersionOutputConfig_markLatest :: Lens.Lens' PackageVersionOutputConfig (Prelude.Maybe Prelude.Bool)
packageVersionOutputConfig_markLatest :: (Maybe Bool -> f (Maybe Bool))
-> PackageVersionOutputConfig -> f PackageVersionOutputConfig
packageVersionOutputConfig_markLatest = (PackageVersionOutputConfig -> Maybe Bool)
-> (PackageVersionOutputConfig
    -> Maybe Bool -> PackageVersionOutputConfig)
-> Lens
     PackageVersionOutputConfig
     PackageVersionOutputConfig
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageVersionOutputConfig' {Maybe Bool
markLatest :: Maybe Bool
$sel:markLatest:PackageVersionOutputConfig' :: PackageVersionOutputConfig -> Maybe Bool
markLatest} -> Maybe Bool
markLatest) (\s :: PackageVersionOutputConfig
s@PackageVersionOutputConfig' {} Maybe Bool
a -> PackageVersionOutputConfig
s {$sel:markLatest:PackageVersionOutputConfig' :: Maybe Bool
markLatest = Maybe Bool
a} :: PackageVersionOutputConfig)

-- | The output\'s package name.
packageVersionOutputConfig_packageName :: Lens.Lens' PackageVersionOutputConfig Prelude.Text
packageVersionOutputConfig_packageName :: (Text -> f Text)
-> PackageVersionOutputConfig -> f PackageVersionOutputConfig
packageVersionOutputConfig_packageName = (PackageVersionOutputConfig -> Text)
-> (PackageVersionOutputConfig
    -> Text -> PackageVersionOutputConfig)
-> Lens
     PackageVersionOutputConfig PackageVersionOutputConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageVersionOutputConfig' {Text
packageName :: Text
$sel:packageName:PackageVersionOutputConfig' :: PackageVersionOutputConfig -> Text
packageName} -> Text
packageName) (\s :: PackageVersionOutputConfig
s@PackageVersionOutputConfig' {} Text
a -> PackageVersionOutputConfig
s {$sel:packageName:PackageVersionOutputConfig' :: Text
packageName = Text
a} :: PackageVersionOutputConfig)

-- | The output\'s package version.
packageVersionOutputConfig_packageVersion :: Lens.Lens' PackageVersionOutputConfig Prelude.Text
packageVersionOutputConfig_packageVersion :: (Text -> f Text)
-> PackageVersionOutputConfig -> f PackageVersionOutputConfig
packageVersionOutputConfig_packageVersion = (PackageVersionOutputConfig -> Text)
-> (PackageVersionOutputConfig
    -> Text -> PackageVersionOutputConfig)
-> Lens
     PackageVersionOutputConfig PackageVersionOutputConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageVersionOutputConfig' {Text
packageVersion :: Text
$sel:packageVersion:PackageVersionOutputConfig' :: PackageVersionOutputConfig -> Text
packageVersion} -> Text
packageVersion) (\s :: PackageVersionOutputConfig
s@PackageVersionOutputConfig' {} Text
a -> PackageVersionOutputConfig
s {$sel:packageVersion:PackageVersionOutputConfig' :: Text
packageVersion = Text
a} :: PackageVersionOutputConfig)

instance Core.FromJSON PackageVersionOutputConfig where
  parseJSON :: Value -> Parser PackageVersionOutputConfig
parseJSON =
    String
-> (Object -> Parser PackageVersionOutputConfig)
-> Value
-> Parser PackageVersionOutputConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PackageVersionOutputConfig"
      ( \Object
x ->
          Maybe Bool -> Text -> Text -> PackageVersionOutputConfig
PackageVersionOutputConfig'
            (Maybe Bool -> Text -> Text -> PackageVersionOutputConfig)
-> Parser (Maybe Bool)
-> Parser (Text -> Text -> PackageVersionOutputConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MarkLatest")
            Parser (Text -> Text -> PackageVersionOutputConfig)
-> Parser Text -> Parser (Text -> PackageVersionOutputConfig)
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
"PackageName")
            Parser (Text -> PackageVersionOutputConfig)
-> Parser Text -> Parser PackageVersionOutputConfig
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
"PackageVersion")
      )

instance Prelude.Hashable PackageVersionOutputConfig

instance Prelude.NFData PackageVersionOutputConfig

instance Core.ToJSON PackageVersionOutputConfig where
  toJSON :: PackageVersionOutputConfig -> Value
toJSON PackageVersionOutputConfig' {Maybe Bool
Text
packageVersion :: Text
packageName :: Text
markLatest :: Maybe Bool
$sel:packageVersion:PackageVersionOutputConfig' :: PackageVersionOutputConfig -> Text
$sel:packageName:PackageVersionOutputConfig' :: PackageVersionOutputConfig -> Text
$sel:markLatest:PackageVersionOutputConfig' :: PackageVersionOutputConfig -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MarkLatest" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
markLatest,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PackageName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
packageName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"PackageVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
packageVersion)
          ]
      )