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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types.CPUArchitecture
import Amazonka.ECS.Types.OSFamily
import qualified Amazonka.Prelude as Prelude

-- | Information about the platform for the Amazon ECS service or task.
--
-- For more information about @RuntimePlatform@, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#runtime-platform RuntimePlatform>
-- in the /Amazon Elastic Container Service Developer Guide/.
--
-- /See:/ 'newRuntimePlatform' smart constructor.
data RuntimePlatform = RuntimePlatform'
  { -- | The CPU architecture.
    --
    -- You can run your Linux tasks on an ARM-based platform by setting the
    -- value to @ARM64@. This option is available for tasks that run on Linux
    -- Amazon EC2 instance or Linux containers on Fargate.
    RuntimePlatform -> Maybe CPUArchitecture
cpuArchitecture :: Prelude.Maybe CPUArchitecture,
    -- | The operating system.
    RuntimePlatform -> Maybe OSFamily
operatingSystemFamily :: Prelude.Maybe OSFamily
  }
  deriving (RuntimePlatform -> RuntimePlatform -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuntimePlatform -> RuntimePlatform -> Bool
$c/= :: RuntimePlatform -> RuntimePlatform -> Bool
== :: RuntimePlatform -> RuntimePlatform -> Bool
$c== :: RuntimePlatform -> RuntimePlatform -> Bool
Prelude.Eq, ReadPrec [RuntimePlatform]
ReadPrec RuntimePlatform
Int -> ReadS RuntimePlatform
ReadS [RuntimePlatform]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuntimePlatform]
$creadListPrec :: ReadPrec [RuntimePlatform]
readPrec :: ReadPrec RuntimePlatform
$creadPrec :: ReadPrec RuntimePlatform
readList :: ReadS [RuntimePlatform]
$creadList :: ReadS [RuntimePlatform]
readsPrec :: Int -> ReadS RuntimePlatform
$creadsPrec :: Int -> ReadS RuntimePlatform
Prelude.Read, Int -> RuntimePlatform -> ShowS
[RuntimePlatform] -> ShowS
RuntimePlatform -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuntimePlatform] -> ShowS
$cshowList :: [RuntimePlatform] -> ShowS
show :: RuntimePlatform -> String
$cshow :: RuntimePlatform -> String
showsPrec :: Int -> RuntimePlatform -> ShowS
$cshowsPrec :: Int -> RuntimePlatform -> ShowS
Prelude.Show, forall x. Rep RuntimePlatform x -> RuntimePlatform
forall x. RuntimePlatform -> Rep RuntimePlatform x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuntimePlatform x -> RuntimePlatform
$cfrom :: forall x. RuntimePlatform -> Rep RuntimePlatform x
Prelude.Generic)

-- |
-- Create a value of 'RuntimePlatform' 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:
--
-- 'cpuArchitecture', 'runtimePlatform_cpuArchitecture' - The CPU architecture.
--
-- You can run your Linux tasks on an ARM-based platform by setting the
-- value to @ARM64@. This option is available for tasks that run on Linux
-- Amazon EC2 instance or Linux containers on Fargate.
--
-- 'operatingSystemFamily', 'runtimePlatform_operatingSystemFamily' - The operating system.
newRuntimePlatform ::
  RuntimePlatform
newRuntimePlatform :: RuntimePlatform
newRuntimePlatform =
  RuntimePlatform'
    { $sel:cpuArchitecture:RuntimePlatform' :: Maybe CPUArchitecture
cpuArchitecture = forall a. Maybe a
Prelude.Nothing,
      $sel:operatingSystemFamily:RuntimePlatform' :: Maybe OSFamily
operatingSystemFamily = forall a. Maybe a
Prelude.Nothing
    }

-- | The CPU architecture.
--
-- You can run your Linux tasks on an ARM-based platform by setting the
-- value to @ARM64@. This option is available for tasks that run on Linux
-- Amazon EC2 instance or Linux containers on Fargate.
runtimePlatform_cpuArchitecture :: Lens.Lens' RuntimePlatform (Prelude.Maybe CPUArchitecture)
runtimePlatform_cpuArchitecture :: Lens' RuntimePlatform (Maybe CPUArchitecture)
runtimePlatform_cpuArchitecture = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuntimePlatform' {Maybe CPUArchitecture
cpuArchitecture :: Maybe CPUArchitecture
$sel:cpuArchitecture:RuntimePlatform' :: RuntimePlatform -> Maybe CPUArchitecture
cpuArchitecture} -> Maybe CPUArchitecture
cpuArchitecture) (\s :: RuntimePlatform
s@RuntimePlatform' {} Maybe CPUArchitecture
a -> RuntimePlatform
s {$sel:cpuArchitecture:RuntimePlatform' :: Maybe CPUArchitecture
cpuArchitecture = Maybe CPUArchitecture
a} :: RuntimePlatform)

-- | The operating system.
runtimePlatform_operatingSystemFamily :: Lens.Lens' RuntimePlatform (Prelude.Maybe OSFamily)
runtimePlatform_operatingSystemFamily :: Lens' RuntimePlatform (Maybe OSFamily)
runtimePlatform_operatingSystemFamily = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuntimePlatform' {Maybe OSFamily
operatingSystemFamily :: Maybe OSFamily
$sel:operatingSystemFamily:RuntimePlatform' :: RuntimePlatform -> Maybe OSFamily
operatingSystemFamily} -> Maybe OSFamily
operatingSystemFamily) (\s :: RuntimePlatform
s@RuntimePlatform' {} Maybe OSFamily
a -> RuntimePlatform
s {$sel:operatingSystemFamily:RuntimePlatform' :: Maybe OSFamily
operatingSystemFamily = Maybe OSFamily
a} :: RuntimePlatform)

instance Data.FromJSON RuntimePlatform where
  parseJSON :: Value -> Parser RuntimePlatform
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RuntimePlatform"
      ( \Object
x ->
          Maybe CPUArchitecture -> Maybe OSFamily -> RuntimePlatform
RuntimePlatform'
            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
"cpuArchitecture")
            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
"operatingSystemFamily")
      )

instance Prelude.Hashable RuntimePlatform where
  hashWithSalt :: Int -> RuntimePlatform -> Int
hashWithSalt Int
_salt RuntimePlatform' {Maybe CPUArchitecture
Maybe OSFamily
operatingSystemFamily :: Maybe OSFamily
cpuArchitecture :: Maybe CPUArchitecture
$sel:operatingSystemFamily:RuntimePlatform' :: RuntimePlatform -> Maybe OSFamily
$sel:cpuArchitecture:RuntimePlatform' :: RuntimePlatform -> Maybe CPUArchitecture
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CPUArchitecture
cpuArchitecture
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OSFamily
operatingSystemFamily

instance Prelude.NFData RuntimePlatform where
  rnf :: RuntimePlatform -> ()
rnf RuntimePlatform' {Maybe CPUArchitecture
Maybe OSFamily
operatingSystemFamily :: Maybe OSFamily
cpuArchitecture :: Maybe CPUArchitecture
$sel:operatingSystemFamily:RuntimePlatform' :: RuntimePlatform -> Maybe OSFamily
$sel:cpuArchitecture:RuntimePlatform' :: RuntimePlatform -> Maybe CPUArchitecture
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CPUArchitecture
cpuArchitecture
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OSFamily
operatingSystemFamily

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