{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GreengrassV2.Types.ComponentDeploymentSpecification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GreengrassV2.Types.ComponentConfigurationUpdate
import Amazonka.GreengrassV2.Types.ComponentRunWith
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 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,
    -- | 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
  }
  deriving (ComponentDeploymentSpecification
-> ComponentDeploymentSpecification -> Bool
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]
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
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.
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.
--
-- '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/.
--
-- '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/.
newComponentDeploymentSpecification ::
  ComponentDeploymentSpecification
newComponentDeploymentSpecification :: ComponentDeploymentSpecification
newComponentDeploymentSpecification =
  ComponentDeploymentSpecification'
    { $sel:componentVersion:ComponentDeploymentSpecification' :: Maybe Text
componentVersion =
        forall a. Maybe a
Prelude.Nothing,
      $sel:configurationUpdate:ComponentDeploymentSpecification' :: Maybe ComponentConfigurationUpdate
configurationUpdate = forall a. Maybe a
Prelude.Nothing,
      $sel:runWith:ComponentDeploymentSpecification' :: Maybe ComponentRunWith
runWith = forall a. Maybe a
Prelude.Nothing
    }

-- | The version of the component.
componentDeploymentSpecification_componentVersion :: Lens.Lens' ComponentDeploymentSpecification (Prelude.Maybe Prelude.Text)
componentDeploymentSpecification_componentVersion :: Lens' ComponentDeploymentSpecification (Maybe Text)
componentDeploymentSpecification_componentVersion = 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 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 :: Lens'
  ComponentDeploymentSpecification
  (Maybe ComponentConfigurationUpdate)
componentDeploymentSpecification_configurationUpdate = 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)

-- | 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 :: Lens' ComponentDeploymentSpecification (Maybe ComponentRunWith)
componentDeploymentSpecification_runWith = 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)

instance
  Data.FromJSON
    ComponentDeploymentSpecification
  where
  parseJSON :: Value -> Parser ComponentDeploymentSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ComponentDeploymentSpecification"
      ( \Object
x ->
          Maybe Text
-> Maybe ComponentConfigurationUpdate
-> Maybe ComponentRunWith
-> ComponentDeploymentSpecification
ComponentDeploymentSpecification'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"componentVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"configurationUpdate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"runWith")
      )

instance
  Prelude.Hashable
    ComponentDeploymentSpecification
  where
  hashWithSalt :: Int -> ComponentDeploymentSpecification -> Int
hashWithSalt
    Int
_salt
    ComponentDeploymentSpecification' {Maybe Text
Maybe ComponentConfigurationUpdate
Maybe ComponentRunWith
runWith :: Maybe ComponentRunWith
configurationUpdate :: Maybe ComponentConfigurationUpdate
componentVersion :: Maybe Text
$sel:runWith:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification -> Maybe ComponentRunWith
$sel:configurationUpdate:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification
-> Maybe ComponentConfigurationUpdate
$sel:componentVersion:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
componentVersion
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ComponentConfigurationUpdate
configurationUpdate
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ComponentRunWith
runWith

instance
  Prelude.NFData
    ComponentDeploymentSpecification
  where
  rnf :: ComponentDeploymentSpecification -> ()
rnf ComponentDeploymentSpecification' {Maybe Text
Maybe ComponentConfigurationUpdate
Maybe ComponentRunWith
runWith :: Maybe ComponentRunWith
configurationUpdate :: Maybe ComponentConfigurationUpdate
componentVersion :: Maybe Text
$sel:runWith:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification -> Maybe ComponentRunWith
$sel:configurationUpdate:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification
-> Maybe ComponentConfigurationUpdate
$sel:componentVersion:ComponentDeploymentSpecification' :: ComponentDeploymentSpecification -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
componentVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ComponentConfigurationUpdate
configurationUpdate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ComponentRunWith
runWith

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