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

import qualified Amazonka.Core as Core
import Amazonka.EKS.Types.TaintEffect
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A property that allows a node to repel a set of pods.
--
-- /See:/ 'newTaint' smart constructor.
data Taint = Taint'
  { -- | The effect of the taint.
    Taint -> Maybe TaintEffect
effect :: Prelude.Maybe TaintEffect,
    -- | The value of the taint.
    Taint -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The key of the taint.
    Taint -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (Taint -> Taint -> Bool
(Taint -> Taint -> Bool) -> (Taint -> Taint -> Bool) -> Eq Taint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Taint -> Taint -> Bool
$c/= :: Taint -> Taint -> Bool
== :: Taint -> Taint -> Bool
$c== :: Taint -> Taint -> Bool
Prelude.Eq, ReadPrec [Taint]
ReadPrec Taint
Int -> ReadS Taint
ReadS [Taint]
(Int -> ReadS Taint)
-> ReadS [Taint]
-> ReadPrec Taint
-> ReadPrec [Taint]
-> Read Taint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Taint]
$creadListPrec :: ReadPrec [Taint]
readPrec :: ReadPrec Taint
$creadPrec :: ReadPrec Taint
readList :: ReadS [Taint]
$creadList :: ReadS [Taint]
readsPrec :: Int -> ReadS Taint
$creadsPrec :: Int -> ReadS Taint
Prelude.Read, Int -> Taint -> ShowS
[Taint] -> ShowS
Taint -> String
(Int -> Taint -> ShowS)
-> (Taint -> String) -> ([Taint] -> ShowS) -> Show Taint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Taint] -> ShowS
$cshowList :: [Taint] -> ShowS
show :: Taint -> String
$cshow :: Taint -> String
showsPrec :: Int -> Taint -> ShowS
$cshowsPrec :: Int -> Taint -> ShowS
Prelude.Show, (forall x. Taint -> Rep Taint x)
-> (forall x. Rep Taint x -> Taint) -> Generic Taint
forall x. Rep Taint x -> Taint
forall x. Taint -> Rep Taint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Taint x -> Taint
$cfrom :: forall x. Taint -> Rep Taint x
Prelude.Generic)

-- |
-- Create a value of 'Taint' 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:
--
-- 'effect', 'taint_effect' - The effect of the taint.
--
-- 'value', 'taint_value' - The value of the taint.
--
-- 'key', 'taint_key' - The key of the taint.
newTaint ::
  Taint
newTaint :: Taint
newTaint =
  Taint' :: Maybe TaintEffect -> Maybe Text -> Maybe Text -> Taint
Taint'
    { $sel:effect:Taint' :: Maybe TaintEffect
effect = Maybe TaintEffect
forall a. Maybe a
Prelude.Nothing,
      $sel:value:Taint' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:Taint' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The effect of the taint.
taint_effect :: Lens.Lens' Taint (Prelude.Maybe TaintEffect)
taint_effect :: (Maybe TaintEffect -> f (Maybe TaintEffect)) -> Taint -> f Taint
taint_effect = (Taint -> Maybe TaintEffect)
-> (Taint -> Maybe TaintEffect -> Taint)
-> Lens Taint Taint (Maybe TaintEffect) (Maybe TaintEffect)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Taint' {Maybe TaintEffect
effect :: Maybe TaintEffect
$sel:effect:Taint' :: Taint -> Maybe TaintEffect
effect} -> Maybe TaintEffect
effect) (\s :: Taint
s@Taint' {} Maybe TaintEffect
a -> Taint
s {$sel:effect:Taint' :: Maybe TaintEffect
effect = Maybe TaintEffect
a} :: Taint)

-- | The value of the taint.
taint_value :: Lens.Lens' Taint (Prelude.Maybe Prelude.Text)
taint_value :: (Maybe Text -> f (Maybe Text)) -> Taint -> f Taint
taint_value = (Taint -> Maybe Text)
-> (Taint -> Maybe Text -> Taint)
-> Lens Taint Taint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Taint' {Maybe Text
value :: Maybe Text
$sel:value:Taint' :: Taint -> Maybe Text
value} -> Maybe Text
value) (\s :: Taint
s@Taint' {} Maybe Text
a -> Taint
s {$sel:value:Taint' :: Maybe Text
value = Maybe Text
a} :: Taint)

-- | The key of the taint.
taint_key :: Lens.Lens' Taint (Prelude.Maybe Prelude.Text)
taint_key :: (Maybe Text -> f (Maybe Text)) -> Taint -> f Taint
taint_key = (Taint -> Maybe Text)
-> (Taint -> Maybe Text -> Taint)
-> Lens Taint Taint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Taint' {Maybe Text
key :: Maybe Text
$sel:key:Taint' :: Taint -> Maybe Text
key} -> Maybe Text
key) (\s :: Taint
s@Taint' {} Maybe Text
a -> Taint
s {$sel:key:Taint' :: Maybe Text
key = Maybe Text
a} :: Taint)

instance Core.FromJSON Taint where
  parseJSON :: Value -> Parser Taint
parseJSON =
    String -> (Object -> Parser Taint) -> Value -> Parser Taint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Taint"
      ( \Object
x ->
          Maybe TaintEffect -> Maybe Text -> Maybe Text -> Taint
Taint'
            (Maybe TaintEffect -> Maybe Text -> Maybe Text -> Taint)
-> Parser (Maybe TaintEffect)
-> Parser (Maybe Text -> Maybe Text -> Taint)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TaintEffect)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"effect")
            Parser (Maybe Text -> Maybe Text -> Taint)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Taint)
forall (f :: * -> *) a b. Applicative f => 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
"value")
            Parser (Maybe Text -> Taint) -> Parser (Maybe Text) -> Parser Taint
forall (f :: * -> *) a b. Applicative f => 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
"key")
      )

instance Prelude.Hashable Taint

instance Prelude.NFData Taint

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