{-# 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.GreengrassV2.Types.ComponentDeploymentSpecification
-- 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.GreengrassV2.Types.ComponentDeploymentSpecification where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.ComponentConfigurationUpdate
import Amazonka.GreengrassV2.Types.ComponentRunWith
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a component to deploy.
--
-- /See:/ 'newComponentDeploymentSpecification' smart constructor.
data ComponentDeploymentSpecification = ComponentDeploymentSpecification'
  { -- | The version of the component.
    ComponentDeploymentSpecification -> Maybe Text
componentVersion :: Prelude.Maybe Prelude.Text,
    -- | The system user and group that the IoT Greengrass Core software uses to
    -- run component processes on the core device. If you omit this parameter,
    -- the IoT Greengrass Core software uses the system user and group that you
    -- configure for the core device. For more information, see
    -- <https://docs.aws.amazon.com/greengrass/v2/developerguide/configure-greengrass-core-v2.html#configure-component-user Configure the user and group that run components>
    -- in the /IoT Greengrass V2 Developer Guide/.
    ComponentDeploymentSpecification -> Maybe ComponentRunWith
runWith :: Prelude.Maybe ComponentRunWith,
    -- | The configuration updates to deploy for the component. You can define
    -- /reset/ updates and /merge/ updates. A reset updates the keys that you
    -- specify to the default configuration for the component. A merge updates
    -- the core device\'s component configuration with the keys and values that
    -- you specify. The IoT Greengrass Core software applies reset updates
    -- before it applies merge updates. For more information, see
    -- <https://docs.aws.amazon.com/greengrass/v2/developerguide/update-component-configurations.html Update component configurations>
    -- in the /IoT Greengrass V2 Developer Guide/.
    ComponentDeploymentSpecification
-> Maybe ComponentConfigurationUpdate
configurationUpdate :: Prelude.Maybe ComponentConfigurationUpdate
  }
  deriving (ComponentDeploymentSpecification
-> ComponentDeploymentSpecification -> Bool
(ComponentDeploymentSpecification
 -> ComponentDeploymentSpecification -> Bool)
-> (ComponentDeploymentSpecification
    -> ComponentDeploymentSpecification -> Bool)
-> Eq ComponentDeploymentSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentDeploymentSpecification
-> ComponentDeploymentSpecification -> Bool
$c/= :: ComponentDeploymentSpecification
-> ComponentDeploymentSpecification -> Bool
== :: ComponentDeploymentSpecification
-> ComponentDeploymentSpecification -> Bool
$c== :: ComponentDeploymentSpecification
-> ComponentDeploymentSpecification -> Bool
Prelude.Eq, ReadPrec [ComponentDeploymentSpecification]
ReadPrec ComponentDeploymentSpecification
Int -> ReadS ComponentDeploymentSpecification
ReadS [ComponentDeploymentSpecification]
(Int -> ReadS ComponentDeploymentSpecification)
-> ReadS [ComponentDeploymentSpecification]
-> ReadPrec ComponentDeploymentSpecification
-> ReadPrec [ComponentDeploymentSpecification]
-> Read ComponentDeploymentSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentDeploymentSpecification]
$creadListPrec :: ReadPrec [ComponentDeploymentSpecification]
readPrec :: ReadPrec ComponentDeploymentSpecification
$creadPrec :: ReadPrec ComponentDeploymentSpecification
readList :: ReadS [ComponentDeploymentSpecification]
$creadList :: ReadS [ComponentDeploymentSpecification]
readsPrec :: Int -> ReadS ComponentDeploymentSpecification
$creadsPrec :: Int -> ReadS ComponentDeploymentSpecification
Prelude.Read, Int -> ComponentDeploymentSpecification -> ShowS
[ComponentDeploymentSpecification] -> ShowS
ComponentDeploymentSpecification -> String
(Int -> ComponentDeploymentSpecification -> ShowS)
-> (ComponentDeploymentSpecification -> String)
-> ([ComponentDeploymentSpecification] -> ShowS)
-> Show ComponentDeploymentSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentDeploymentSpecification] -> ShowS
$cshowList :: [ComponentDeploymentSpecification] -> ShowS
show :: ComponentDeploymentSpecification -> String
$cshow :: ComponentDeploymentSpecification -> String
showsPrec :: Int -> ComponentDeploymentSpecification -> ShowS
$cshowsPrec :: Int -> ComponentDeploymentSpecification -> ShowS
Prelude.Show, (forall x.
 ComponentDeploymentSpecification
 -> Rep ComponentDeploymentSpecification x)
-> (forall x.
    Rep ComponentDeploymentSpecification x
    -> ComponentDeploymentSpecification)
-> Generic ComponentDeploymentSpecification
forall x.
Rep ComponentDeploymentSpecification x
-> ComponentDeploymentSpecification
forall x.
ComponentDeploymentSpecification
-> Rep ComponentDeploymentSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ComponentDeploymentSpecification x
-> ComponentDeploymentSpecification
$cfrom :: forall x.
ComponentDeploymentSpecification
-> Rep ComponentDeploymentSpecification x
Prelude.Generic)

-- |
-- Create a value of 'ComponentDeploymentSpecification' 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:
--
-- 'componentVersion', 'componentDeploymentSpecification_componentVersion' - The version of the component.
--
-- 'runWith', 'componentDeploymentSpecification_runWith' - The system user and group that the IoT Greengrass Core software uses to
-- run component processes on the core device. If you omit this parameter,
-- the IoT Greengrass Core software uses the system user and group that you
-- configure for the core device. For more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/configure-greengrass-core-v2.html#configure-component-user Configure the user and group that run components>
-- in the /IoT Greengrass V2 Developer Guide/.
--
-- 'configurationUpdate', 'componentDeploymentSpecification_configurationUpdate' - The configuration updates to deploy for the component. You can define
-- /reset/ updates and /merge/ updates. A reset updates the keys that you
-- specify to the default configuration for the component. A merge updates
-- the core device\'s component configuration with the keys and values that
-- you specify. The IoT Greengrass Core software applies reset updates
-- before it applies merge updates. For more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/update-component-configurations.html Update component configurations>
-- in the /IoT Greengrass V2 Developer Guide/.
newComponentDeploymentSpecification ::
  ComponentDeploymentSpecification
newComponentDeploymentSpecification :: ComponentDeploymentSpecification
newComponentDeploymentSpecification =
  ComponentDeploymentSpecification' :: Maybe Text
-> Maybe ComponentRunWith
-> Maybe ComponentConfigurationUpdate
-> ComponentDeploymentSpecification
ComponentDeploymentSpecification'
    { $sel:componentVersion:ComponentDeploymentSpecification' :: Maybe Text
componentVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:runWith:ComponentDeploymentSpecification' :: Maybe ComponentRunWith
runWith = Maybe ComponentRunWith
forall a. Maybe a
Prelude.Nothing,
      $sel:configurationUpdate:ComponentDeploymentSpecification' :: Maybe ComponentConfigurationUpdate
configurationUpdate = Maybe ComponentConfigurationUpdate
forall a. Maybe a
Prelude.Nothing
    }

-- | The version of the component.
componentDeploymentSpecification_componentVersion :: Lens.Lens' ComponentDeploymentSpecification (Prelude.Maybe Prelude.Text)
componentDeploymentSpecification_componentVersion :: (Maybe Text -> f (Maybe Text))
-> ComponentDeploymentSpecification
-> f ComponentDeploymentSpecification
componentDeploymentSpecification_componentVersion = (ComponentDeploymentSpecification -> Maybe Text)
-> (ComponentDeploymentSpecification
    -> Maybe Text -> ComponentDeploymentSpecification)
-> Lens
     ComponentDeploymentSpecification
     ComponentDeploymentSpecification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentDeploymentSpecification' {Maybe Text
componentVersion :: Maybe Text
$sel:componentVersion:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification -> Maybe Text
componentVersion} -> Maybe Text
componentVersion) (\s :: ComponentDeploymentSpecification
s@ComponentDeploymentSpecification' {} Maybe Text
a -> ComponentDeploymentSpecification
s {$sel:componentVersion:ComponentDeploymentSpecification' :: Maybe Text
componentVersion = Maybe Text
a} :: ComponentDeploymentSpecification)

-- | The system user and group that the IoT Greengrass Core software uses to
-- run component processes on the core device. If you omit this parameter,
-- the IoT Greengrass Core software uses the system user and group that you
-- configure for the core device. For more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/configure-greengrass-core-v2.html#configure-component-user Configure the user and group that run components>
-- in the /IoT Greengrass V2 Developer Guide/.
componentDeploymentSpecification_runWith :: Lens.Lens' ComponentDeploymentSpecification (Prelude.Maybe ComponentRunWith)
componentDeploymentSpecification_runWith :: (Maybe ComponentRunWith -> f (Maybe ComponentRunWith))
-> ComponentDeploymentSpecification
-> f ComponentDeploymentSpecification
componentDeploymentSpecification_runWith = (ComponentDeploymentSpecification -> Maybe ComponentRunWith)
-> (ComponentDeploymentSpecification
    -> Maybe ComponentRunWith -> ComponentDeploymentSpecification)
-> Lens
     ComponentDeploymentSpecification
     ComponentDeploymentSpecification
     (Maybe ComponentRunWith)
     (Maybe ComponentRunWith)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentDeploymentSpecification' {Maybe ComponentRunWith
runWith :: Maybe ComponentRunWith
$sel:runWith:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification -> Maybe ComponentRunWith
runWith} -> Maybe ComponentRunWith
runWith) (\s :: ComponentDeploymentSpecification
s@ComponentDeploymentSpecification' {} Maybe ComponentRunWith
a -> ComponentDeploymentSpecification
s {$sel:runWith:ComponentDeploymentSpecification' :: Maybe ComponentRunWith
runWith = Maybe ComponentRunWith
a} :: ComponentDeploymentSpecification)

-- | The configuration updates to deploy for the component. You can define
-- /reset/ updates and /merge/ updates. A reset updates the keys that you
-- specify to the default configuration for the component. A merge updates
-- the core device\'s component configuration with the keys and values that
-- you specify. The IoT Greengrass Core software applies reset updates
-- before it applies merge updates. For more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/update-component-configurations.html Update component configurations>
-- in the /IoT Greengrass V2 Developer Guide/.
componentDeploymentSpecification_configurationUpdate :: Lens.Lens' ComponentDeploymentSpecification (Prelude.Maybe ComponentConfigurationUpdate)
componentDeploymentSpecification_configurationUpdate :: (Maybe ComponentConfigurationUpdate
 -> f (Maybe ComponentConfigurationUpdate))
-> ComponentDeploymentSpecification
-> f ComponentDeploymentSpecification
componentDeploymentSpecification_configurationUpdate = (ComponentDeploymentSpecification
 -> Maybe ComponentConfigurationUpdate)
-> (ComponentDeploymentSpecification
    -> Maybe ComponentConfigurationUpdate
    -> ComponentDeploymentSpecification)
-> Lens
     ComponentDeploymentSpecification
     ComponentDeploymentSpecification
     (Maybe ComponentConfigurationUpdate)
     (Maybe ComponentConfigurationUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentDeploymentSpecification' {Maybe ComponentConfigurationUpdate
configurationUpdate :: Maybe ComponentConfigurationUpdate
$sel:configurationUpdate:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification
-> Maybe ComponentConfigurationUpdate
configurationUpdate} -> Maybe ComponentConfigurationUpdate
configurationUpdate) (\s :: ComponentDeploymentSpecification
s@ComponentDeploymentSpecification' {} Maybe ComponentConfigurationUpdate
a -> ComponentDeploymentSpecification
s {$sel:configurationUpdate:ComponentDeploymentSpecification' :: Maybe ComponentConfigurationUpdate
configurationUpdate = Maybe ComponentConfigurationUpdate
a} :: ComponentDeploymentSpecification)

instance
  Core.FromJSON
    ComponentDeploymentSpecification
  where
  parseJSON :: Value -> Parser ComponentDeploymentSpecification
parseJSON =
    String
-> (Object -> Parser ComponentDeploymentSpecification)
-> Value
-> Parser ComponentDeploymentSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ComponentDeploymentSpecification"
      ( \Object
x ->
          Maybe Text
-> Maybe ComponentRunWith
-> Maybe ComponentConfigurationUpdate
-> ComponentDeploymentSpecification
ComponentDeploymentSpecification'
            (Maybe Text
 -> Maybe ComponentRunWith
 -> Maybe ComponentConfigurationUpdate
 -> ComponentDeploymentSpecification)
-> Parser (Maybe Text)
-> Parser
     (Maybe ComponentRunWith
      -> Maybe ComponentConfigurationUpdate
      -> ComponentDeploymentSpecification)
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
"componentVersion")
            Parser
  (Maybe ComponentRunWith
   -> Maybe ComponentConfigurationUpdate
   -> ComponentDeploymentSpecification)
-> Parser (Maybe ComponentRunWith)
-> Parser
     (Maybe ComponentConfigurationUpdate
      -> ComponentDeploymentSpecification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ComponentRunWith)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"runWith")
            Parser
  (Maybe ComponentConfigurationUpdate
   -> ComponentDeploymentSpecification)
-> Parser (Maybe ComponentConfigurationUpdate)
-> Parser ComponentDeploymentSpecification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ComponentConfigurationUpdate)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"configurationUpdate")
      )

instance
  Prelude.Hashable
    ComponentDeploymentSpecification

instance
  Prelude.NFData
    ComponentDeploymentSpecification

instance Core.ToJSON ComponentDeploymentSpecification where
  toJSON :: ComponentDeploymentSpecification -> Value
toJSON ComponentDeploymentSpecification' {Maybe Text
Maybe ComponentConfigurationUpdate
Maybe ComponentRunWith
configurationUpdate :: Maybe ComponentConfigurationUpdate
runWith :: Maybe ComponentRunWith
componentVersion :: Maybe Text
$sel:configurationUpdate:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification
-> Maybe ComponentConfigurationUpdate
$sel:runWith:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification -> Maybe ComponentRunWith
$sel:componentVersion:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"componentVersion" 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
componentVersion,
            (Text
"runWith" Text -> ComponentRunWith -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ComponentRunWith -> Pair) -> Maybe ComponentRunWith -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComponentRunWith
runWith,
            (Text
"configurationUpdate" Text -> ComponentConfigurationUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ComponentConfigurationUpdate -> Pair)
-> Maybe ComponentConfigurationUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComponentConfigurationUpdate
configurationUpdate
          ]
      )