{-# 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.EKS.Types.FargateProfileSelector
-- 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.EKS.Types.FargateProfileSelector where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing an Fargate profile selector.
--
-- /See:/ 'newFargateProfileSelector' smart constructor.
data FargateProfileSelector = FargateProfileSelector'
  { -- | The Kubernetes namespace that the selector should match.
    FargateProfileSelector -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | The Kubernetes labels that the selector should match. A pod must contain
    -- all of the labels that are specified in the selector for it to be
    -- considered a match.
    FargateProfileSelector -> Maybe (HashMap Text Text)
labels :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (FargateProfileSelector -> FargateProfileSelector -> Bool
(FargateProfileSelector -> FargateProfileSelector -> Bool)
-> (FargateProfileSelector -> FargateProfileSelector -> Bool)
-> Eq FargateProfileSelector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FargateProfileSelector -> FargateProfileSelector -> Bool
$c/= :: FargateProfileSelector -> FargateProfileSelector -> Bool
== :: FargateProfileSelector -> FargateProfileSelector -> Bool
$c== :: FargateProfileSelector -> FargateProfileSelector -> Bool
Prelude.Eq, ReadPrec [FargateProfileSelector]
ReadPrec FargateProfileSelector
Int -> ReadS FargateProfileSelector
ReadS [FargateProfileSelector]
(Int -> ReadS FargateProfileSelector)
-> ReadS [FargateProfileSelector]
-> ReadPrec FargateProfileSelector
-> ReadPrec [FargateProfileSelector]
-> Read FargateProfileSelector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FargateProfileSelector]
$creadListPrec :: ReadPrec [FargateProfileSelector]
readPrec :: ReadPrec FargateProfileSelector
$creadPrec :: ReadPrec FargateProfileSelector
readList :: ReadS [FargateProfileSelector]
$creadList :: ReadS [FargateProfileSelector]
readsPrec :: Int -> ReadS FargateProfileSelector
$creadsPrec :: Int -> ReadS FargateProfileSelector
Prelude.Read, Int -> FargateProfileSelector -> ShowS
[FargateProfileSelector] -> ShowS
FargateProfileSelector -> String
(Int -> FargateProfileSelector -> ShowS)
-> (FargateProfileSelector -> String)
-> ([FargateProfileSelector] -> ShowS)
-> Show FargateProfileSelector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FargateProfileSelector] -> ShowS
$cshowList :: [FargateProfileSelector] -> ShowS
show :: FargateProfileSelector -> String
$cshow :: FargateProfileSelector -> String
showsPrec :: Int -> FargateProfileSelector -> ShowS
$cshowsPrec :: Int -> FargateProfileSelector -> ShowS
Prelude.Show, (forall x. FargateProfileSelector -> Rep FargateProfileSelector x)
-> (forall x.
    Rep FargateProfileSelector x -> FargateProfileSelector)
-> Generic FargateProfileSelector
forall x. Rep FargateProfileSelector x -> FargateProfileSelector
forall x. FargateProfileSelector -> Rep FargateProfileSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FargateProfileSelector x -> FargateProfileSelector
$cfrom :: forall x. FargateProfileSelector -> Rep FargateProfileSelector x
Prelude.Generic)

-- |
-- Create a value of 'FargateProfileSelector' 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:
--
-- 'namespace', 'fargateProfileSelector_namespace' - The Kubernetes namespace that the selector should match.
--
-- 'labels', 'fargateProfileSelector_labels' - The Kubernetes labels that the selector should match. A pod must contain
-- all of the labels that are specified in the selector for it to be
-- considered a match.
newFargateProfileSelector ::
  FargateProfileSelector
newFargateProfileSelector :: FargateProfileSelector
newFargateProfileSelector =
  FargateProfileSelector' :: Maybe Text -> Maybe (HashMap Text Text) -> FargateProfileSelector
FargateProfileSelector'
    { $sel:namespace:FargateProfileSelector' :: Maybe Text
namespace =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:labels:FargateProfileSelector' :: Maybe (HashMap Text Text)
labels = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The Kubernetes namespace that the selector should match.
fargateProfileSelector_namespace :: Lens.Lens' FargateProfileSelector (Prelude.Maybe Prelude.Text)
fargateProfileSelector_namespace :: (Maybe Text -> f (Maybe Text))
-> FargateProfileSelector -> f FargateProfileSelector
fargateProfileSelector_namespace = (FargateProfileSelector -> Maybe Text)
-> (FargateProfileSelector -> Maybe Text -> FargateProfileSelector)
-> Lens
     FargateProfileSelector
     FargateProfileSelector
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FargateProfileSelector' {Maybe Text
namespace :: Maybe Text
$sel:namespace:FargateProfileSelector' :: FargateProfileSelector -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: FargateProfileSelector
s@FargateProfileSelector' {} Maybe Text
a -> FargateProfileSelector
s {$sel:namespace:FargateProfileSelector' :: Maybe Text
namespace = Maybe Text
a} :: FargateProfileSelector)

-- | The Kubernetes labels that the selector should match. A pod must contain
-- all of the labels that are specified in the selector for it to be
-- considered a match.
fargateProfileSelector_labels :: Lens.Lens' FargateProfileSelector (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
fargateProfileSelector_labels :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> FargateProfileSelector -> f FargateProfileSelector
fargateProfileSelector_labels = (FargateProfileSelector -> Maybe (HashMap Text Text))
-> (FargateProfileSelector
    -> Maybe (HashMap Text Text) -> FargateProfileSelector)
-> Lens
     FargateProfileSelector
     FargateProfileSelector
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FargateProfileSelector' {Maybe (HashMap Text Text)
labels :: Maybe (HashMap Text Text)
$sel:labels:FargateProfileSelector' :: FargateProfileSelector -> Maybe (HashMap Text Text)
labels} -> Maybe (HashMap Text Text)
labels) (\s :: FargateProfileSelector
s@FargateProfileSelector' {} Maybe (HashMap Text Text)
a -> FargateProfileSelector
s {$sel:labels:FargateProfileSelector' :: Maybe (HashMap Text Text)
labels = Maybe (HashMap Text Text)
a} :: FargateProfileSelector) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> FargateProfileSelector -> f FargateProfileSelector)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> FargateProfileSelector
-> f FargateProfileSelector
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON FargateProfileSelector where
  parseJSON :: Value -> Parser FargateProfileSelector
parseJSON =
    String
-> (Object -> Parser FargateProfileSelector)
-> Value
-> Parser FargateProfileSelector
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FargateProfileSelector"
      ( \Object
x ->
          Maybe Text -> Maybe (HashMap Text Text) -> FargateProfileSelector
FargateProfileSelector'
            (Maybe Text -> Maybe (HashMap Text Text) -> FargateProfileSelector)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> FargateProfileSelector)
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
"namespace")
            Parser (Maybe (HashMap Text Text) -> FargateProfileSelector)
-> Parser (Maybe (HashMap Text Text))
-> Parser FargateProfileSelector
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"labels" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable FargateProfileSelector

instance Prelude.NFData FargateProfileSelector

instance Core.ToJSON FargateProfileSelector where
  toJSON :: FargateProfileSelector -> Value
toJSON FargateProfileSelector' {Maybe Text
Maybe (HashMap Text Text)
labels :: Maybe (HashMap Text Text)
namespace :: Maybe Text
$sel:labels:FargateProfileSelector' :: FargateProfileSelector -> Maybe (HashMap Text Text)
$sel:namespace:FargateProfileSelector' :: FargateProfileSelector -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            (Text
"labels" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
labels
          ]
      )