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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EMRContainers.Types.ContainerInfo
import Amazonka.EMRContainers.Types.ContainerProviderType
import qualified Amazonka.Prelude as Prelude

-- | The information about the container provider.
--
-- /See:/ 'newContainerProvider' smart constructor.
data ContainerProvider = ContainerProvider'
  { -- | The information about the container cluster.
    ContainerProvider -> Maybe ContainerInfo
info :: Prelude.Maybe ContainerInfo,
    -- | The type of the container provider. EKS is the only supported type as of
    -- now.
    ContainerProvider -> ContainerProviderType
type' :: ContainerProviderType,
    -- | The ID of the container cluster.
    ContainerProvider -> Text
id :: Prelude.Text
  }
  deriving (ContainerProvider -> ContainerProvider -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerProvider -> ContainerProvider -> Bool
$c/= :: ContainerProvider -> ContainerProvider -> Bool
== :: ContainerProvider -> ContainerProvider -> Bool
$c== :: ContainerProvider -> ContainerProvider -> Bool
Prelude.Eq, ReadPrec [ContainerProvider]
ReadPrec ContainerProvider
Int -> ReadS ContainerProvider
ReadS [ContainerProvider]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerProvider]
$creadListPrec :: ReadPrec [ContainerProvider]
readPrec :: ReadPrec ContainerProvider
$creadPrec :: ReadPrec ContainerProvider
readList :: ReadS [ContainerProvider]
$creadList :: ReadS [ContainerProvider]
readsPrec :: Int -> ReadS ContainerProvider
$creadsPrec :: Int -> ReadS ContainerProvider
Prelude.Read, Int -> ContainerProvider -> ShowS
[ContainerProvider] -> ShowS
ContainerProvider -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerProvider] -> ShowS
$cshowList :: [ContainerProvider] -> ShowS
show :: ContainerProvider -> String
$cshow :: ContainerProvider -> String
showsPrec :: Int -> ContainerProvider -> ShowS
$cshowsPrec :: Int -> ContainerProvider -> ShowS
Prelude.Show, forall x. Rep ContainerProvider x -> ContainerProvider
forall x. ContainerProvider -> Rep ContainerProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContainerProvider x -> ContainerProvider
$cfrom :: forall x. ContainerProvider -> Rep ContainerProvider x
Prelude.Generic)

-- |
-- Create a value of 'ContainerProvider' 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:
--
-- 'info', 'containerProvider_info' - The information about the container cluster.
--
-- 'type'', 'containerProvider_type' - The type of the container provider. EKS is the only supported type as of
-- now.
--
-- 'id', 'containerProvider_id' - The ID of the container cluster.
newContainerProvider ::
  -- | 'type''
  ContainerProviderType ->
  -- | 'id'
  Prelude.Text ->
  ContainerProvider
newContainerProvider :: ContainerProviderType -> Text -> ContainerProvider
newContainerProvider ContainerProviderType
pType_ Text
pId_ =
  ContainerProvider'
    { $sel:info:ContainerProvider' :: Maybe ContainerInfo
info = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ContainerProvider' :: ContainerProviderType
type' = ContainerProviderType
pType_,
      $sel:id:ContainerProvider' :: Text
id = Text
pId_
    }

-- | The information about the container cluster.
containerProvider_info :: Lens.Lens' ContainerProvider (Prelude.Maybe ContainerInfo)
containerProvider_info :: Lens' ContainerProvider (Maybe ContainerInfo)
containerProvider_info = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerProvider' {Maybe ContainerInfo
info :: Maybe ContainerInfo
$sel:info:ContainerProvider' :: ContainerProvider -> Maybe ContainerInfo
info} -> Maybe ContainerInfo
info) (\s :: ContainerProvider
s@ContainerProvider' {} Maybe ContainerInfo
a -> ContainerProvider
s {$sel:info:ContainerProvider' :: Maybe ContainerInfo
info = Maybe ContainerInfo
a} :: ContainerProvider)

-- | The type of the container provider. EKS is the only supported type as of
-- now.
containerProvider_type :: Lens.Lens' ContainerProvider ContainerProviderType
containerProvider_type :: Lens' ContainerProvider ContainerProviderType
containerProvider_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerProvider' {ContainerProviderType
type' :: ContainerProviderType
$sel:type':ContainerProvider' :: ContainerProvider -> ContainerProviderType
type'} -> ContainerProviderType
type') (\s :: ContainerProvider
s@ContainerProvider' {} ContainerProviderType
a -> ContainerProvider
s {$sel:type':ContainerProvider' :: ContainerProviderType
type' = ContainerProviderType
a} :: ContainerProvider)

-- | The ID of the container cluster.
containerProvider_id :: Lens.Lens' ContainerProvider Prelude.Text
containerProvider_id :: Lens' ContainerProvider Text
containerProvider_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerProvider' {Text
id :: Text
$sel:id:ContainerProvider' :: ContainerProvider -> Text
id} -> Text
id) (\s :: ContainerProvider
s@ContainerProvider' {} Text
a -> ContainerProvider
s {$sel:id:ContainerProvider' :: Text
id = Text
a} :: ContainerProvider)

instance Data.FromJSON ContainerProvider where
  parseJSON :: Value -> Parser ContainerProvider
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContainerProvider"
      ( \Object
x ->
          Maybe ContainerInfo
-> ContainerProviderType -> Text -> ContainerProvider
ContainerProvider'
            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
"info")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"id")
      )

instance Prelude.Hashable ContainerProvider where
  hashWithSalt :: Int -> ContainerProvider -> Int
hashWithSalt Int
_salt ContainerProvider' {Maybe ContainerInfo
Text
ContainerProviderType
id :: Text
type' :: ContainerProviderType
info :: Maybe ContainerInfo
$sel:id:ContainerProvider' :: ContainerProvider -> Text
$sel:type':ContainerProvider' :: ContainerProvider -> ContainerProviderType
$sel:info:ContainerProvider' :: ContainerProvider -> Maybe ContainerInfo
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ContainerInfo
info
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ContainerProviderType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData ContainerProvider where
  rnf :: ContainerProvider -> ()
rnf ContainerProvider' {Maybe ContainerInfo
Text
ContainerProviderType
id :: Text
type' :: ContainerProviderType
info :: Maybe ContainerInfo
$sel:id:ContainerProvider' :: ContainerProvider -> Text
$sel:type':ContainerProvider' :: ContainerProvider -> ContainerProviderType
$sel:info:ContainerProvider' :: ContainerProvider -> Maybe ContainerInfo
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ContainerInfo
info
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ContainerProviderType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToJSON ContainerProvider where
  toJSON :: ContainerProvider -> Value
toJSON ContainerProvider' {Maybe ContainerInfo
Text
ContainerProviderType
id :: Text
type' :: ContainerProviderType
info :: Maybe ContainerInfo
$sel:id:ContainerProvider' :: ContainerProvider -> Text
$sel:type':ContainerProvider' :: ContainerProvider -> ContainerProviderType
$sel:info:ContainerProvider' :: ContainerProvider -> Maybe ContainerInfo
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"info" 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 ContainerInfo
info,
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ContainerProviderType
type'),
            forall a. a -> Maybe a
Prelude.Just (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
          ]
      )