{-# 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.ECS.Types.SystemControl
-- 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.ECS.Types.SystemControl where

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

-- | A list of namespaced kernel parameters to set in the container. This
-- parameter maps to @Sysctls@ in the
-- <https://docs.docker.com/engine/api/v1.35/#operation/ContainerCreate Create a container>
-- section of the
-- <https://docs.docker.com/engine/api/v1.35/ Docker Remote API> and the
-- @--sysctl@ option to
-- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>.
--
-- We don\'t recommend that you specify network-related @systemControls@
-- parameters for multiple containers in a single task. This task also uses
-- either the @awsvpc@ or @host@ network mode. It does it for the following
-- reasons.
--
-- -   For tasks that use the @awsvpc@ network mode, if you set
--     @systemControls@ for any container, it applies to all containers in
--     the task. If you set different @systemControls@ for multiple
--     containers in a single task, the container that\'s started last
--     determines which @systemControls@ take effect.
--
-- -   For tasks that use the @host@ network mode, the @systemControls@
--     parameter applies to the container instance\'s kernel parameter and
--     that of all containers of any tasks running on that container
--     instance.
--
-- /See:/ 'newSystemControl' smart constructor.
data SystemControl = SystemControl'
  { -- | The namespaced kernel parameter to set a @value@ for.
    SystemControl -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | The value for the namespaced kernel parameter that\'s specified in
    -- @namespace@.
    SystemControl -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (SystemControl -> SystemControl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SystemControl -> SystemControl -> Bool
$c/= :: SystemControl -> SystemControl -> Bool
== :: SystemControl -> SystemControl -> Bool
$c== :: SystemControl -> SystemControl -> Bool
Prelude.Eq, ReadPrec [SystemControl]
ReadPrec SystemControl
Int -> ReadS SystemControl
ReadS [SystemControl]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SystemControl]
$creadListPrec :: ReadPrec [SystemControl]
readPrec :: ReadPrec SystemControl
$creadPrec :: ReadPrec SystemControl
readList :: ReadS [SystemControl]
$creadList :: ReadS [SystemControl]
readsPrec :: Int -> ReadS SystemControl
$creadsPrec :: Int -> ReadS SystemControl
Prelude.Read, Int -> SystemControl -> ShowS
[SystemControl] -> ShowS
SystemControl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SystemControl] -> ShowS
$cshowList :: [SystemControl] -> ShowS
show :: SystemControl -> String
$cshow :: SystemControl -> String
showsPrec :: Int -> SystemControl -> ShowS
$cshowsPrec :: Int -> SystemControl -> ShowS
Prelude.Show, forall x. Rep SystemControl x -> SystemControl
forall x. SystemControl -> Rep SystemControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SystemControl x -> SystemControl
$cfrom :: forall x. SystemControl -> Rep SystemControl x
Prelude.Generic)

-- |
-- Create a value of 'SystemControl' 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:
--
-- 'namespace', 'systemControl_namespace' - The namespaced kernel parameter to set a @value@ for.
--
-- 'value', 'systemControl_value' - The value for the namespaced kernel parameter that\'s specified in
-- @namespace@.
newSystemControl ::
  SystemControl
newSystemControl :: SystemControl
newSystemControl =
  SystemControl'
    { $sel:namespace:SystemControl' :: Maybe Text
namespace = forall a. Maybe a
Prelude.Nothing,
      $sel:value:SystemControl' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The namespaced kernel parameter to set a @value@ for.
systemControl_namespace :: Lens.Lens' SystemControl (Prelude.Maybe Prelude.Text)
systemControl_namespace :: Lens' SystemControl (Maybe Text)
systemControl_namespace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SystemControl' {Maybe Text
namespace :: Maybe Text
$sel:namespace:SystemControl' :: SystemControl -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: SystemControl
s@SystemControl' {} Maybe Text
a -> SystemControl
s {$sel:namespace:SystemControl' :: Maybe Text
namespace = Maybe Text
a} :: SystemControl)

-- | The value for the namespaced kernel parameter that\'s specified in
-- @namespace@.
systemControl_value :: Lens.Lens' SystemControl (Prelude.Maybe Prelude.Text)
systemControl_value :: Lens' SystemControl (Maybe Text)
systemControl_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SystemControl' {Maybe Text
value :: Maybe Text
$sel:value:SystemControl' :: SystemControl -> Maybe Text
value} -> Maybe Text
value) (\s :: SystemControl
s@SystemControl' {} Maybe Text
a -> SystemControl
s {$sel:value:SystemControl' :: Maybe Text
value = Maybe Text
a} :: SystemControl)

instance Data.FromJSON SystemControl where
  parseJSON :: Value -> Parser SystemControl
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SystemControl"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SystemControl
SystemControl'
            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
"namespace")
            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
"value")
      )

instance Prelude.Hashable SystemControl where
  hashWithSalt :: Int -> SystemControl -> Int
hashWithSalt Int
_salt SystemControl' {Maybe Text
value :: Maybe Text
namespace :: Maybe Text
$sel:value:SystemControl' :: SystemControl -> Maybe Text
$sel:namespace:SystemControl' :: SystemControl -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
namespace
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData SystemControl where
  rnf :: SystemControl -> ()
rnf SystemControl' {Maybe Text
value :: Maybe Text
namespace :: Maybe Text
$sel:value:SystemControl' :: SystemControl -> Maybe Text
$sel:namespace:SystemControl' :: SystemControl -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
namespace
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

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