{-# 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-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.ComponentRunWith where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.SystemResourceLimits
import qualified Amazonka.Lens as Lens
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 (optional) group to use to run this component.
    -- 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.
    --
    -- 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
  }
  deriving (ComponentRunWith -> ComponentRunWith -> Bool
(ComponentRunWith -> ComponentRunWith -> Bool)
-> (ComponentRunWith -> ComponentRunWith -> Bool)
-> Eq ComponentRunWith
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]
(Int -> ReadS ComponentRunWith)
-> ReadS [ComponentRunWith]
-> ReadPrec ComponentRunWith
-> ReadPrec [ComponentRunWith]
-> Read 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
(Int -> ComponentRunWith -> ShowS)
-> (ComponentRunWith -> String)
-> ([ComponentRunWith] -> ShowS)
-> Show ComponentRunWith
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. ComponentRunWith -> Rep ComponentRunWith x)
-> (forall x. Rep ComponentRunWith x -> ComponentRunWith)
-> Generic ComponentRunWith
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 (optional) group to use to run this component.
-- 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.
--
-- 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>.
newComponentRunWith ::
  ComponentRunWith
newComponentRunWith :: ComponentRunWith
newComponentRunWith =
  ComponentRunWith' :: Maybe Text -> Maybe SystemResourceLimits -> ComponentRunWith
ComponentRunWith'
    { $sel:posixUser:ComponentRunWith' :: Maybe Text
posixUser = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:systemResourceLimits:ComponentRunWith' :: Maybe SystemResourceLimits
systemResourceLimits = Maybe SystemResourceLimits
forall a. Maybe a
Prelude.Nothing
    }

-- | The POSIX system user and (optional) group to use to run this component.
-- 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 :: (Maybe Text -> f (Maybe Text))
-> ComponentRunWith -> f ComponentRunWith
componentRunWith_posixUser = (ComponentRunWith -> Maybe Text)
-> (ComponentRunWith -> Maybe Text -> ComponentRunWith)
-> Lens ComponentRunWith ComponentRunWith (Maybe Text) (Maybe Text)
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.
--
-- 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 :: (Maybe SystemResourceLimits -> f (Maybe SystemResourceLimits))
-> ComponentRunWith -> f ComponentRunWith
componentRunWith_systemResourceLimits = (ComponentRunWith -> Maybe SystemResourceLimits)
-> (ComponentRunWith
    -> Maybe SystemResourceLimits -> ComponentRunWith)
-> Lens
     ComponentRunWith
     ComponentRunWith
     (Maybe SystemResourceLimits)
     (Maybe 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)

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

instance Prelude.Hashable ComponentRunWith

instance Prelude.NFData ComponentRunWith

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