{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EKS.Types.FargateProfileSelector where

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

-- | An object representing an Fargate profile selector.
--
-- /See:/ 'newFargateProfileSelector' smart constructor.
data FargateProfileSelector = 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 -> Maybe (HashMap Text Text)
labels :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The Kubernetes namespace that the selector should match.
    FargateProfileSelector -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text
  }
  deriving (FargateProfileSelector -> FargateProfileSelector -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'namespace', 'fargateProfileSelector_namespace' - The Kubernetes namespace that the selector should match.
newFargateProfileSelector ::
  FargateProfileSelector
newFargateProfileSelector :: FargateProfileSelector
newFargateProfileSelector =
  FargateProfileSelector'
    { $sel:labels:FargateProfileSelector' :: Maybe (HashMap Text Text)
labels = forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:FargateProfileSelector' :: Maybe Text
namespace = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' FargateProfileSelector (Maybe (HashMap Text Text))
fargateProfileSelector_labels = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Kubernetes namespace that the selector should match.
fargateProfileSelector_namespace :: Lens.Lens' FargateProfileSelector (Prelude.Maybe Prelude.Text)
fargateProfileSelector_namespace :: Lens' FargateProfileSelector (Maybe Text)
fargateProfileSelector_namespace = 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)

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

instance Prelude.Hashable FargateProfileSelector where
  hashWithSalt :: Int -> FargateProfileSelector -> Int
hashWithSalt Int
_salt FargateProfileSelector' {Maybe Text
Maybe (HashMap Text Text)
namespace :: Maybe Text
labels :: Maybe (HashMap Text Text)
$sel:namespace:FargateProfileSelector' :: FargateProfileSelector -> Maybe Text
$sel:labels:FargateProfileSelector' :: FargateProfileSelector -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
labels
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
namespace

instance Prelude.NFData FargateProfileSelector where
  rnf :: FargateProfileSelector -> ()
rnf FargateProfileSelector' {Maybe Text
Maybe (HashMap Text Text)
namespace :: Maybe Text
labels :: Maybe (HashMap Text Text)
$sel:namespace:FargateProfileSelector' :: FargateProfileSelector -> Maybe Text
$sel:labels:FargateProfileSelector' :: FargateProfileSelector -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
labels
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
namespace

instance Data.ToJSON FargateProfileSelector where
  toJSON :: FargateProfileSelector -> Value
toJSON FargateProfileSelector' {Maybe Text
Maybe (HashMap Text Text)
namespace :: Maybe Text
labels :: Maybe (HashMap Text Text)
$sel:namespace:FargateProfileSelector' :: FargateProfileSelector -> Maybe Text
$sel:labels:FargateProfileSelector' :: FargateProfileSelector -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"labels" 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 (HashMap Text Text)
labels,
            (Key
"namespace" 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 Text
namespace
          ]
      )