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

import qualified Amazonka.Core as Core
import Amazonka.EMRContainers.Types.ContainerInfo
import Amazonka.EMRContainers.Types.ContainerProviderType
import qualified Amazonka.Lens as Lens
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
(ContainerProvider -> ContainerProvider -> Bool)
-> (ContainerProvider -> ContainerProvider -> Bool)
-> Eq ContainerProvider
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]
(Int -> ReadS ContainerProvider)
-> ReadS [ContainerProvider]
-> ReadPrec ContainerProvider
-> ReadPrec [ContainerProvider]
-> Read 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
(Int -> ContainerProvider -> ShowS)
-> (ContainerProvider -> String)
-> ([ContainerProvider] -> ShowS)
-> Show ContainerProvider
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. ContainerProvider -> Rep ContainerProvider x)
-> (forall x. Rep ContainerProvider x -> ContainerProvider)
-> Generic ContainerProvider
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' :: Maybe ContainerInfo
-> ContainerProviderType -> Text -> ContainerProvider
ContainerProvider'
    { $sel:info:ContainerProvider' :: Maybe ContainerInfo
info = Maybe ContainerInfo
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 :: (Maybe ContainerInfo -> f (Maybe ContainerInfo))
-> ContainerProvider -> f ContainerProvider
containerProvider_info = (ContainerProvider -> Maybe ContainerInfo)
-> (ContainerProvider -> Maybe ContainerInfo -> ContainerProvider)
-> Lens
     ContainerProvider
     ContainerProvider
     (Maybe ContainerInfo)
     (Maybe ContainerInfo)
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 :: (ContainerProviderType -> f ContainerProviderType)
-> ContainerProvider -> f ContainerProvider
containerProvider_type = (ContainerProvider -> ContainerProviderType)
-> (ContainerProvider
    -> ContainerProviderType -> ContainerProvider)
-> Lens
     ContainerProvider
     ContainerProvider
     ContainerProviderType
     ContainerProviderType
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 :: (Text -> f Text) -> ContainerProvider -> f ContainerProvider
containerProvider_id = (ContainerProvider -> Text)
-> (ContainerProvider -> Text -> ContainerProvider)
-> Lens ContainerProvider ContainerProvider Text Text
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 Core.FromJSON ContainerProvider where
  parseJSON :: Value -> Parser ContainerProvider
parseJSON =
    String
-> (Object -> Parser ContainerProvider)
-> Value
-> Parser ContainerProvider
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContainerProvider"
      ( \Object
x ->
          Maybe ContainerInfo
-> ContainerProviderType -> Text -> ContainerProvider
ContainerProvider'
            (Maybe ContainerInfo
 -> ContainerProviderType -> Text -> ContainerProvider)
-> Parser (Maybe ContainerInfo)
-> Parser (ContainerProviderType -> Text -> ContainerProvider)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ContainerInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"info")
            Parser (ContainerProviderType -> Text -> ContainerProvider)
-> Parser ContainerProviderType
-> Parser (Text -> ContainerProvider)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ContainerProviderType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
            Parser (Text -> ContainerProvider)
-> Parser Text -> Parser ContainerProvider
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"id")
      )

instance Prelude.Hashable ContainerProvider

instance Prelude.NFData ContainerProvider

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"info" Text -> ContainerInfo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ContainerInfo -> Pair) -> Maybe ContainerInfo -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ContainerInfo
info,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> ContainerProviderType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContainerProviderType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )