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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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>.
--
-- It is not recommended that you specify network-related @systemControls@
-- parameters for multiple containers in a single task that also uses
-- either the @awsvpc@ or @host@ network mode 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 is 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 as
--     well as that of all containers of any tasks running on that
--     container instance.
--
-- /See:/ 'newSystemControl' smart constructor.
data SystemControl = SystemControl'
  { -- | The value for the namespaced kernel parameter specified in @namespace@.
    SystemControl -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The namespaced kernel parameter for which to set a @value@.
    SystemControl -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text
  }
  deriving (SystemControl -> SystemControl -> Bool
(SystemControl -> SystemControl -> Bool)
-> (SystemControl -> SystemControl -> Bool) -> Eq SystemControl
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]
(Int -> ReadS SystemControl)
-> ReadS [SystemControl]
-> ReadPrec SystemControl
-> ReadPrec [SystemControl]
-> Read 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
(Int -> SystemControl -> ShowS)
-> (SystemControl -> String)
-> ([SystemControl] -> ShowS)
-> Show SystemControl
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. SystemControl -> Rep SystemControl x)
-> (forall x. Rep SystemControl x -> SystemControl)
-> Generic SystemControl
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:
--
-- 'value', 'systemControl_value' - The value for the namespaced kernel parameter specified in @namespace@.
--
-- 'namespace', 'systemControl_namespace' - The namespaced kernel parameter for which to set a @value@.
newSystemControl ::
  SystemControl
newSystemControl :: SystemControl
newSystemControl =
  SystemControl' :: Maybe Text -> Maybe Text -> SystemControl
SystemControl'
    { $sel:value:SystemControl' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:SystemControl' :: Maybe Text
namespace = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value for the namespaced kernel parameter specified in @namespace@.
systemControl_value :: Lens.Lens' SystemControl (Prelude.Maybe Prelude.Text)
systemControl_value :: (Maybe Text -> f (Maybe Text)) -> SystemControl -> f SystemControl
systemControl_value = (SystemControl -> Maybe Text)
-> (SystemControl -> Maybe Text -> SystemControl)
-> Lens SystemControl SystemControl (Maybe Text) (Maybe Text)
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)

-- | The namespaced kernel parameter for which to set a @value@.
systemControl_namespace :: Lens.Lens' SystemControl (Prelude.Maybe Prelude.Text)
systemControl_namespace :: (Maybe Text -> f (Maybe Text)) -> SystemControl -> f SystemControl
systemControl_namespace = (SystemControl -> Maybe Text)
-> (SystemControl -> Maybe Text -> SystemControl)
-> Lens SystemControl SystemControl (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable SystemControl

instance Prelude.NFData SystemControl

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