{-# 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.EMRContainers.Types.ContainerInfo
-- 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.EMRContainers.Types.ContainerInfo where

import qualified Amazonka.Core as Core
import Amazonka.EMRContainers.Types.EksInfo
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The information about the container used for a job run or a managed
-- endpoint.
--
-- /See:/ 'newContainerInfo' smart constructor.
data ContainerInfo = ContainerInfo'
  { -- | The information about the EKS cluster.
    ContainerInfo -> Maybe EksInfo
eksInfo :: Prelude.Maybe EksInfo
  }
  deriving (ContainerInfo -> ContainerInfo -> Bool
(ContainerInfo -> ContainerInfo -> Bool)
-> (ContainerInfo -> ContainerInfo -> Bool) -> Eq ContainerInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerInfo -> ContainerInfo -> Bool
$c/= :: ContainerInfo -> ContainerInfo -> Bool
== :: ContainerInfo -> ContainerInfo -> Bool
$c== :: ContainerInfo -> ContainerInfo -> Bool
Prelude.Eq, ReadPrec [ContainerInfo]
ReadPrec ContainerInfo
Int -> ReadS ContainerInfo
ReadS [ContainerInfo]
(Int -> ReadS ContainerInfo)
-> ReadS [ContainerInfo]
-> ReadPrec ContainerInfo
-> ReadPrec [ContainerInfo]
-> Read ContainerInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerInfo]
$creadListPrec :: ReadPrec [ContainerInfo]
readPrec :: ReadPrec ContainerInfo
$creadPrec :: ReadPrec ContainerInfo
readList :: ReadS [ContainerInfo]
$creadList :: ReadS [ContainerInfo]
readsPrec :: Int -> ReadS ContainerInfo
$creadsPrec :: Int -> ReadS ContainerInfo
Prelude.Read, Int -> ContainerInfo -> ShowS
[ContainerInfo] -> ShowS
ContainerInfo -> String
(Int -> ContainerInfo -> ShowS)
-> (ContainerInfo -> String)
-> ([ContainerInfo] -> ShowS)
-> Show ContainerInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerInfo] -> ShowS
$cshowList :: [ContainerInfo] -> ShowS
show :: ContainerInfo -> String
$cshow :: ContainerInfo -> String
showsPrec :: Int -> ContainerInfo -> ShowS
$cshowsPrec :: Int -> ContainerInfo -> ShowS
Prelude.Show, (forall x. ContainerInfo -> Rep ContainerInfo x)
-> (forall x. Rep ContainerInfo x -> ContainerInfo)
-> Generic ContainerInfo
forall x. Rep ContainerInfo x -> ContainerInfo
forall x. ContainerInfo -> Rep ContainerInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContainerInfo x -> ContainerInfo
$cfrom :: forall x. ContainerInfo -> Rep ContainerInfo x
Prelude.Generic)

-- |
-- Create a value of 'ContainerInfo' 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:
--
-- 'eksInfo', 'containerInfo_eksInfo' - The information about the EKS cluster.
newContainerInfo ::
  ContainerInfo
newContainerInfo :: ContainerInfo
newContainerInfo =
  ContainerInfo' :: Maybe EksInfo -> ContainerInfo
ContainerInfo' {$sel:eksInfo:ContainerInfo' :: Maybe EksInfo
eksInfo = Maybe EksInfo
forall a. Maybe a
Prelude.Nothing}

-- | The information about the EKS cluster.
containerInfo_eksInfo :: Lens.Lens' ContainerInfo (Prelude.Maybe EksInfo)
containerInfo_eksInfo :: (Maybe EksInfo -> f (Maybe EksInfo))
-> ContainerInfo -> f ContainerInfo
containerInfo_eksInfo = (ContainerInfo -> Maybe EksInfo)
-> (ContainerInfo -> Maybe EksInfo -> ContainerInfo)
-> Lens ContainerInfo ContainerInfo (Maybe EksInfo) (Maybe EksInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerInfo' {Maybe EksInfo
eksInfo :: Maybe EksInfo
$sel:eksInfo:ContainerInfo' :: ContainerInfo -> Maybe EksInfo
eksInfo} -> Maybe EksInfo
eksInfo) (\s :: ContainerInfo
s@ContainerInfo' {} Maybe EksInfo
a -> ContainerInfo
s {$sel:eksInfo:ContainerInfo' :: Maybe EksInfo
eksInfo = Maybe EksInfo
a} :: ContainerInfo)

instance Core.FromJSON ContainerInfo where
  parseJSON :: Value -> Parser ContainerInfo
parseJSON =
    String
-> (Object -> Parser ContainerInfo)
-> Value
-> Parser ContainerInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContainerInfo"
      ( \Object
x ->
          Maybe EksInfo -> ContainerInfo
ContainerInfo' (Maybe EksInfo -> ContainerInfo)
-> Parser (Maybe EksInfo) -> Parser ContainerInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EksInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eksInfo")
      )

instance Prelude.Hashable ContainerInfo

instance Prelude.NFData ContainerInfo

instance Core.ToJSON ContainerInfo where
  toJSON :: ContainerInfo -> Value
toJSON ContainerInfo' {Maybe EksInfo
eksInfo :: Maybe EksInfo
$sel:eksInfo:ContainerInfo' :: ContainerInfo -> Maybe EksInfo
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"eksInfo" Text -> EksInfo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EksInfo -> Pair) -> Maybe EksInfo -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EksInfo
eksInfo]
      )