{-# 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.SSM.Types.PatchSource
-- 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.SSM.Types.PatchSource where

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

-- | Information about the patches to use to update the instances, including
-- target operating systems and source repository. Applies to Linux
-- instances only.
--
-- /See:/ 'newPatchSource' smart constructor.
data PatchSource = PatchSource'
  { -- | The name specified to identify the patch source.
    PatchSource -> Text
name :: Prelude.Text,
    -- | The specific operating system versions a patch repository applies to,
    -- such as \"Ubuntu16.04\", \"AmazonLinux2016.09\",
    -- \"RedhatEnterpriseLinux7.2\" or \"Suse12.7\". For lists of supported
    -- product values, see PatchFilter.
    PatchSource -> NonEmpty Text
products :: Prelude.NonEmpty Prelude.Text,
    -- | The value of the yum repo configuration. For example:
    --
    -- @[main]@
    --
    -- @name=MyCustomRepository@
    --
    -- @baseurl=https:\/\/my-custom-repository@
    --
    -- @enabled=1@
    --
    -- For information about other options available for your yum repository
    -- configuration, see
    -- <https://man7.org/linux/man-pages/man5/dnf.conf.5.html dnf.conf(5)>.
    PatchSource -> Sensitive Text
configuration :: Core.Sensitive Prelude.Text
  }
  deriving (PatchSource -> PatchSource -> Bool
(PatchSource -> PatchSource -> Bool)
-> (PatchSource -> PatchSource -> Bool) -> Eq PatchSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PatchSource -> PatchSource -> Bool
$c/= :: PatchSource -> PatchSource -> Bool
== :: PatchSource -> PatchSource -> Bool
$c== :: PatchSource -> PatchSource -> Bool
Prelude.Eq, Int -> PatchSource -> ShowS
[PatchSource] -> ShowS
PatchSource -> String
(Int -> PatchSource -> ShowS)
-> (PatchSource -> String)
-> ([PatchSource] -> ShowS)
-> Show PatchSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PatchSource] -> ShowS
$cshowList :: [PatchSource] -> ShowS
show :: PatchSource -> String
$cshow :: PatchSource -> String
showsPrec :: Int -> PatchSource -> ShowS
$cshowsPrec :: Int -> PatchSource -> ShowS
Prelude.Show, (forall x. PatchSource -> Rep PatchSource x)
-> (forall x. Rep PatchSource x -> PatchSource)
-> Generic PatchSource
forall x. Rep PatchSource x -> PatchSource
forall x. PatchSource -> Rep PatchSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PatchSource x -> PatchSource
$cfrom :: forall x. PatchSource -> Rep PatchSource x
Prelude.Generic)

-- |
-- Create a value of 'PatchSource' 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:
--
-- 'name', 'patchSource_name' - The name specified to identify the patch source.
--
-- 'products', 'patchSource_products' - The specific operating system versions a patch repository applies to,
-- such as \"Ubuntu16.04\", \"AmazonLinux2016.09\",
-- \"RedhatEnterpriseLinux7.2\" or \"Suse12.7\". For lists of supported
-- product values, see PatchFilter.
--
-- 'configuration', 'patchSource_configuration' - The value of the yum repo configuration. For example:
--
-- @[main]@
--
-- @name=MyCustomRepository@
--
-- @baseurl=https:\/\/my-custom-repository@
--
-- @enabled=1@
--
-- For information about other options available for your yum repository
-- configuration, see
-- <https://man7.org/linux/man-pages/man5/dnf.conf.5.html dnf.conf(5)>.
newPatchSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'products'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'configuration'
  Prelude.Text ->
  PatchSource
newPatchSource :: Text -> NonEmpty Text -> Text -> PatchSource
newPatchSource Text
pName_ NonEmpty Text
pProducts_ Text
pConfiguration_ =
  PatchSource' :: Text -> NonEmpty Text -> Sensitive Text -> PatchSource
PatchSource'
    { $sel:name:PatchSource' :: Text
name = Text
pName_,
      $sel:products:PatchSource' :: NonEmpty Text
products = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pProducts_,
      $sel:configuration:PatchSource' :: Sensitive Text
configuration =
        Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pConfiguration_
    }

-- | The name specified to identify the patch source.
patchSource_name :: Lens.Lens' PatchSource Prelude.Text
patchSource_name :: (Text -> f Text) -> PatchSource -> f PatchSource
patchSource_name = (PatchSource -> Text)
-> (PatchSource -> Text -> PatchSource)
-> Lens PatchSource PatchSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PatchSource' {Text
name :: Text
$sel:name:PatchSource' :: PatchSource -> Text
name} -> Text
name) (\s :: PatchSource
s@PatchSource' {} Text
a -> PatchSource
s {$sel:name:PatchSource' :: Text
name = Text
a} :: PatchSource)

-- | The specific operating system versions a patch repository applies to,
-- such as \"Ubuntu16.04\", \"AmazonLinux2016.09\",
-- \"RedhatEnterpriseLinux7.2\" or \"Suse12.7\". For lists of supported
-- product values, see PatchFilter.
patchSource_products :: Lens.Lens' PatchSource (Prelude.NonEmpty Prelude.Text)
patchSource_products :: (NonEmpty Text -> f (NonEmpty Text))
-> PatchSource -> f PatchSource
patchSource_products = (PatchSource -> NonEmpty Text)
-> (PatchSource -> NonEmpty Text -> PatchSource)
-> Lens PatchSource PatchSource (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PatchSource' {NonEmpty Text
products :: NonEmpty Text
$sel:products:PatchSource' :: PatchSource -> NonEmpty Text
products} -> NonEmpty Text
products) (\s :: PatchSource
s@PatchSource' {} NonEmpty Text
a -> PatchSource
s {$sel:products:PatchSource' :: NonEmpty Text
products = NonEmpty Text
a} :: PatchSource) ((NonEmpty Text -> f (NonEmpty Text))
 -> PatchSource -> f PatchSource)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> PatchSource
-> f PatchSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The value of the yum repo configuration. For example:
--
-- @[main]@
--
-- @name=MyCustomRepository@
--
-- @baseurl=https:\/\/my-custom-repository@
--
-- @enabled=1@
--
-- For information about other options available for your yum repository
-- configuration, see
-- <https://man7.org/linux/man-pages/man5/dnf.conf.5.html dnf.conf(5)>.
patchSource_configuration :: Lens.Lens' PatchSource Prelude.Text
patchSource_configuration :: (Text -> f Text) -> PatchSource -> f PatchSource
patchSource_configuration = (PatchSource -> Sensitive Text)
-> (PatchSource -> Sensitive Text -> PatchSource)
-> Lens PatchSource PatchSource (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PatchSource' {Sensitive Text
configuration :: Sensitive Text
$sel:configuration:PatchSource' :: PatchSource -> Sensitive Text
configuration} -> Sensitive Text
configuration) (\s :: PatchSource
s@PatchSource' {} Sensitive Text
a -> PatchSource
s {$sel:configuration:PatchSource' :: Sensitive Text
configuration = Sensitive Text
a} :: PatchSource) ((Sensitive Text -> f (Sensitive Text))
 -> PatchSource -> f PatchSource)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> PatchSource
-> f PatchSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.FromJSON PatchSource where
  parseJSON :: Value -> Parser PatchSource
parseJSON =
    String
-> (Object -> Parser PatchSource) -> Value -> Parser PatchSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PatchSource"
      ( \Object
x ->
          Text -> NonEmpty Text -> Sensitive Text -> PatchSource
PatchSource'
            (Text -> NonEmpty Text -> Sensitive Text -> PatchSource)
-> Parser Text
-> Parser (NonEmpty Text -> Sensitive Text -> PatchSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser (NonEmpty Text -> Sensitive Text -> PatchSource)
-> Parser (NonEmpty Text) -> Parser (Sensitive Text -> PatchSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Products")
            Parser (Sensitive Text -> PatchSource)
-> Parser (Sensitive Text) -> Parser PatchSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Configuration")
      )

instance Prelude.Hashable PatchSource

instance Prelude.NFData PatchSource

instance Core.ToJSON PatchSource where
  toJSON :: PatchSource -> Value
toJSON PatchSource' {NonEmpty Text
Text
Sensitive Text
configuration :: Sensitive Text
products :: NonEmpty Text
name :: Text
$sel:configuration:PatchSource' :: PatchSource -> Sensitive Text
$sel:products:PatchSource' :: PatchSource -> NonEmpty Text
$sel:name:PatchSource' :: PatchSource -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Products" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
products),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"Configuration" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
configuration)
          ]
      )