{-# 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.ComponentRunWith
-- 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.ComponentRunWith 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.SystemResourceLimits
import qualified Amazonka.Prelude as Prelude

-- | Contains information system user and group that the IoT Greengrass Core
-- software uses to run component processes on 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/.
--
-- /See:/ 'newComponentRunWith' smart constructor.
data ComponentRunWith = ComponentRunWith'
  { -- | The POSIX system user and, optionally, group to use to run this
    -- component on Linux core devices. The user, and group if specified, must
    -- exist on each Linux core device. Specify the user and group separated by
    -- a colon (@:@) in the following format: @user:group@. The group is
    -- optional. If you don\'t specify a group, the IoT Greengrass Core
    -- software uses the primary user for the group.
    --
    -- If you omit this parameter, the IoT Greengrass Core software uses the
    -- default system user and group that you configure on the Greengrass
    -- nucleus component. 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>.
    ComponentRunWith -> Maybe Text
posixUser :: Prelude.Maybe Prelude.Text,
    -- | The system resource limits to apply to this component\'s process on the
    -- core device. IoT Greengrass currently supports this feature on only
    -- Linux core devices.
    --
    -- If you omit this parameter, the IoT Greengrass Core software uses the
    -- default system resource limits that you configure on the Greengrass
    -- nucleus component. For more information, see
    -- <https://docs.aws.amazon.com/greengrass/v2/developerguide/configure-greengrass-core-v2.html#configure-component-system-resource-limits Configure system resource limits for components>.
    ComponentRunWith -> Maybe SystemResourceLimits
systemResourceLimits :: Prelude.Maybe SystemResourceLimits,
    -- | The Windows user to use to run this component on Windows core devices.
    -- The user must exist on each Windows core device, and its name and
    -- password must be in the LocalSystem account\'s Credentials Manager
    -- instance.
    --
    -- If you omit this parameter, the IoT Greengrass Core software uses the
    -- default Windows user that you configure on the Greengrass nucleus
    -- component. 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>.
    ComponentRunWith -> Maybe Text
windowsUser :: Prelude.Maybe Prelude.Text
  }
  deriving (ComponentRunWith -> ComponentRunWith -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentRunWith -> ComponentRunWith -> Bool
$c/= :: ComponentRunWith -> ComponentRunWith -> Bool
== :: ComponentRunWith -> ComponentRunWith -> Bool
$c== :: ComponentRunWith -> ComponentRunWith -> Bool
Prelude.Eq, ReadPrec [ComponentRunWith]
ReadPrec ComponentRunWith
Int -> ReadS ComponentRunWith
ReadS [ComponentRunWith]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentRunWith]
$creadListPrec :: ReadPrec [ComponentRunWith]
readPrec :: ReadPrec ComponentRunWith
$creadPrec :: ReadPrec ComponentRunWith
readList :: ReadS [ComponentRunWith]
$creadList :: ReadS [ComponentRunWith]
readsPrec :: Int -> ReadS ComponentRunWith
$creadsPrec :: Int -> ReadS ComponentRunWith
Prelude.Read, Int -> ComponentRunWith -> ShowS
[ComponentRunWith] -> ShowS
ComponentRunWith -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentRunWith] -> ShowS
$cshowList :: [ComponentRunWith] -> ShowS
show :: ComponentRunWith -> String
$cshow :: ComponentRunWith -> String
showsPrec :: Int -> ComponentRunWith -> ShowS
$cshowsPrec :: Int -> ComponentRunWith -> ShowS
Prelude.Show, forall x. Rep ComponentRunWith x -> ComponentRunWith
forall x. ComponentRunWith -> Rep ComponentRunWith x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComponentRunWith x -> ComponentRunWith
$cfrom :: forall x. ComponentRunWith -> Rep ComponentRunWith x
Prelude.Generic)

-- |
-- Create a value of 'ComponentRunWith' 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:
--
-- 'posixUser', 'componentRunWith_posixUser' - The POSIX system user and, optionally, group to use to run this
-- component on Linux core devices. The user, and group if specified, must
-- exist on each Linux core device. Specify the user and group separated by
-- a colon (@:@) in the following format: @user:group@. The group is
-- optional. If you don\'t specify a group, the IoT Greengrass Core
-- software uses the primary user for the group.
--
-- If you omit this parameter, the IoT Greengrass Core software uses the
-- default system user and group that you configure on the Greengrass
-- nucleus component. 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>.
--
-- 'systemResourceLimits', 'componentRunWith_systemResourceLimits' - The system resource limits to apply to this component\'s process on the
-- core device. IoT Greengrass currently supports this feature on only
-- Linux core devices.
--
-- If you omit this parameter, the IoT Greengrass Core software uses the
-- default system resource limits that you configure on the Greengrass
-- nucleus component. For more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/configure-greengrass-core-v2.html#configure-component-system-resource-limits Configure system resource limits for components>.
--
-- 'windowsUser', 'componentRunWith_windowsUser' - The Windows user to use to run this component on Windows core devices.
-- The user must exist on each Windows core device, and its name and
-- password must be in the LocalSystem account\'s Credentials Manager
-- instance.
--
-- If you omit this parameter, the IoT Greengrass Core software uses the
-- default Windows user that you configure on the Greengrass nucleus
-- component. 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>.
newComponentRunWith ::
  ComponentRunWith
newComponentRunWith :: ComponentRunWith
newComponentRunWith =
  ComponentRunWith'
    { $sel:posixUser:ComponentRunWith' :: Maybe Text
posixUser = forall a. Maybe a
Prelude.Nothing,
      $sel:systemResourceLimits:ComponentRunWith' :: Maybe SystemResourceLimits
systemResourceLimits = forall a. Maybe a
Prelude.Nothing,
      $sel:windowsUser:ComponentRunWith' :: Maybe Text
windowsUser = forall a. Maybe a
Prelude.Nothing
    }

-- | The POSIX system user and, optionally, group to use to run this
-- component on Linux core devices. The user, and group if specified, must
-- exist on each Linux core device. Specify the user and group separated by
-- a colon (@:@) in the following format: @user:group@. The group is
-- optional. If you don\'t specify a group, the IoT Greengrass Core
-- software uses the primary user for the group.
--
-- If you omit this parameter, the IoT Greengrass Core software uses the
-- default system user and group that you configure on the Greengrass
-- nucleus component. 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>.
componentRunWith_posixUser :: Lens.Lens' ComponentRunWith (Prelude.Maybe Prelude.Text)
componentRunWith_posixUser :: Lens' ComponentRunWith (Maybe Text)
componentRunWith_posixUser = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentRunWith' {Maybe Text
posixUser :: Maybe Text
$sel:posixUser:ComponentRunWith' :: ComponentRunWith -> Maybe Text
posixUser} -> Maybe Text
posixUser) (\s :: ComponentRunWith
s@ComponentRunWith' {} Maybe Text
a -> ComponentRunWith
s {$sel:posixUser:ComponentRunWith' :: Maybe Text
posixUser = Maybe Text
a} :: ComponentRunWith)

-- | The system resource limits to apply to this component\'s process on the
-- core device. IoT Greengrass currently supports this feature on only
-- Linux core devices.
--
-- If you omit this parameter, the IoT Greengrass Core software uses the
-- default system resource limits that you configure on the Greengrass
-- nucleus component. For more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/configure-greengrass-core-v2.html#configure-component-system-resource-limits Configure system resource limits for components>.
componentRunWith_systemResourceLimits :: Lens.Lens' ComponentRunWith (Prelude.Maybe SystemResourceLimits)
componentRunWith_systemResourceLimits :: Lens' ComponentRunWith (Maybe SystemResourceLimits)
componentRunWith_systemResourceLimits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentRunWith' {Maybe SystemResourceLimits
systemResourceLimits :: Maybe SystemResourceLimits
$sel:systemResourceLimits:ComponentRunWith' :: ComponentRunWith -> Maybe SystemResourceLimits
systemResourceLimits} -> Maybe SystemResourceLimits
systemResourceLimits) (\s :: ComponentRunWith
s@ComponentRunWith' {} Maybe SystemResourceLimits
a -> ComponentRunWith
s {$sel:systemResourceLimits:ComponentRunWith' :: Maybe SystemResourceLimits
systemResourceLimits = Maybe SystemResourceLimits
a} :: ComponentRunWith)

-- | The Windows user to use to run this component on Windows core devices.
-- The user must exist on each Windows core device, and its name and
-- password must be in the LocalSystem account\'s Credentials Manager
-- instance.
--
-- If you omit this parameter, the IoT Greengrass Core software uses the
-- default Windows user that you configure on the Greengrass nucleus
-- component. 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>.
componentRunWith_windowsUser :: Lens.Lens' ComponentRunWith (Prelude.Maybe Prelude.Text)
componentRunWith_windowsUser :: Lens' ComponentRunWith (Maybe Text)
componentRunWith_windowsUser = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentRunWith' {Maybe Text
windowsUser :: Maybe Text
$sel:windowsUser:ComponentRunWith' :: ComponentRunWith -> Maybe Text
windowsUser} -> Maybe Text
windowsUser) (\s :: ComponentRunWith
s@ComponentRunWith' {} Maybe Text
a -> ComponentRunWith
s {$sel:windowsUser:ComponentRunWith' :: Maybe Text
windowsUser = Maybe Text
a} :: ComponentRunWith)

instance Data.FromJSON ComponentRunWith where
  parseJSON :: Value -> Parser ComponentRunWith
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ComponentRunWith"
      ( \Object
x ->
          Maybe Text
-> Maybe SystemResourceLimits -> Maybe Text -> ComponentRunWith
ComponentRunWith'
            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
"posixUser")
            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
"systemResourceLimits")
            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
"windowsUser")
      )

instance Prelude.Hashable ComponentRunWith where
  hashWithSalt :: Int -> ComponentRunWith -> Int
hashWithSalt Int
_salt ComponentRunWith' {Maybe Text
Maybe SystemResourceLimits
windowsUser :: Maybe Text
systemResourceLimits :: Maybe SystemResourceLimits
posixUser :: Maybe Text
$sel:windowsUser:ComponentRunWith' :: ComponentRunWith -> Maybe Text
$sel:systemResourceLimits:ComponentRunWith' :: ComponentRunWith -> Maybe SystemResourceLimits
$sel:posixUser:ComponentRunWith' :: ComponentRunWith -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
posixUser
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SystemResourceLimits
systemResourceLimits
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
windowsUser

instance Prelude.NFData ComponentRunWith where
  rnf :: ComponentRunWith -> ()
rnf ComponentRunWith' {Maybe Text
Maybe SystemResourceLimits
windowsUser :: Maybe Text
systemResourceLimits :: Maybe SystemResourceLimits
posixUser :: Maybe Text
$sel:windowsUser:ComponentRunWith' :: ComponentRunWith -> Maybe Text
$sel:systemResourceLimits:ComponentRunWith' :: ComponentRunWith -> Maybe SystemResourceLimits
$sel:posixUser:ComponentRunWith' :: ComponentRunWith -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
posixUser
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SystemResourceLimits
systemResourceLimits
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
windowsUser

instance Data.ToJSON ComponentRunWith where
  toJSON :: ComponentRunWith -> Value
toJSON ComponentRunWith' {Maybe Text
Maybe SystemResourceLimits
windowsUser :: Maybe Text
systemResourceLimits :: Maybe SystemResourceLimits
posixUser :: Maybe Text
$sel:windowsUser:ComponentRunWith' :: ComponentRunWith -> Maybe Text
$sel:systemResourceLimits:ComponentRunWith' :: ComponentRunWith -> Maybe SystemResourceLimits
$sel:posixUser:ComponentRunWith' :: ComponentRunWith -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"posixUser" 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
posixUser,
            (Key
"systemResourceLimits" 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 SystemResourceLimits
systemResourceLimits,
            (Key
"windowsUser" 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
windowsUser
          ]
      )