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

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

-- | An object representing a Kubernetes label change for a managed node
-- group.
--
-- /See:/ 'newUpdateLabelsPayload' smart constructor.
data UpdateLabelsPayload = UpdateLabelsPayload'
  { -- | Kubernetes labels to be removed.
    UpdateLabelsPayload -> Maybe [Text]
removeLabels :: Prelude.Maybe [Prelude.Text],
    -- | Kubernetes labels to be added or updated.
    UpdateLabelsPayload -> Maybe (HashMap Text Text)
addOrUpdateLabels :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (UpdateLabelsPayload -> UpdateLabelsPayload -> Bool
(UpdateLabelsPayload -> UpdateLabelsPayload -> Bool)
-> (UpdateLabelsPayload -> UpdateLabelsPayload -> Bool)
-> Eq UpdateLabelsPayload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLabelsPayload -> UpdateLabelsPayload -> Bool
$c/= :: UpdateLabelsPayload -> UpdateLabelsPayload -> Bool
== :: UpdateLabelsPayload -> UpdateLabelsPayload -> Bool
$c== :: UpdateLabelsPayload -> UpdateLabelsPayload -> Bool
Prelude.Eq, ReadPrec [UpdateLabelsPayload]
ReadPrec UpdateLabelsPayload
Int -> ReadS UpdateLabelsPayload
ReadS [UpdateLabelsPayload]
(Int -> ReadS UpdateLabelsPayload)
-> ReadS [UpdateLabelsPayload]
-> ReadPrec UpdateLabelsPayload
-> ReadPrec [UpdateLabelsPayload]
-> Read UpdateLabelsPayload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateLabelsPayload]
$creadListPrec :: ReadPrec [UpdateLabelsPayload]
readPrec :: ReadPrec UpdateLabelsPayload
$creadPrec :: ReadPrec UpdateLabelsPayload
readList :: ReadS [UpdateLabelsPayload]
$creadList :: ReadS [UpdateLabelsPayload]
readsPrec :: Int -> ReadS UpdateLabelsPayload
$creadsPrec :: Int -> ReadS UpdateLabelsPayload
Prelude.Read, Int -> UpdateLabelsPayload -> ShowS
[UpdateLabelsPayload] -> ShowS
UpdateLabelsPayload -> String
(Int -> UpdateLabelsPayload -> ShowS)
-> (UpdateLabelsPayload -> String)
-> ([UpdateLabelsPayload] -> ShowS)
-> Show UpdateLabelsPayload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLabelsPayload] -> ShowS
$cshowList :: [UpdateLabelsPayload] -> ShowS
show :: UpdateLabelsPayload -> String
$cshow :: UpdateLabelsPayload -> String
showsPrec :: Int -> UpdateLabelsPayload -> ShowS
$cshowsPrec :: Int -> UpdateLabelsPayload -> ShowS
Prelude.Show, (forall x. UpdateLabelsPayload -> Rep UpdateLabelsPayload x)
-> (forall x. Rep UpdateLabelsPayload x -> UpdateLabelsPayload)
-> Generic UpdateLabelsPayload
forall x. Rep UpdateLabelsPayload x -> UpdateLabelsPayload
forall x. UpdateLabelsPayload -> Rep UpdateLabelsPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateLabelsPayload x -> UpdateLabelsPayload
$cfrom :: forall x. UpdateLabelsPayload -> Rep UpdateLabelsPayload x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLabelsPayload' 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:
--
-- 'removeLabels', 'updateLabelsPayload_removeLabels' - Kubernetes labels to be removed.
--
-- 'addOrUpdateLabels', 'updateLabelsPayload_addOrUpdateLabels' - Kubernetes labels to be added or updated.
newUpdateLabelsPayload ::
  UpdateLabelsPayload
newUpdateLabelsPayload :: UpdateLabelsPayload
newUpdateLabelsPayload =
  UpdateLabelsPayload' :: Maybe [Text] -> Maybe (HashMap Text Text) -> UpdateLabelsPayload
UpdateLabelsPayload'
    { $sel:removeLabels:UpdateLabelsPayload' :: Maybe [Text]
removeLabels =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:addOrUpdateLabels:UpdateLabelsPayload' :: Maybe (HashMap Text Text)
addOrUpdateLabels = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | Kubernetes labels to be removed.
updateLabelsPayload_removeLabels :: Lens.Lens' UpdateLabelsPayload (Prelude.Maybe [Prelude.Text])
updateLabelsPayload_removeLabels :: (Maybe [Text] -> f (Maybe [Text]))
-> UpdateLabelsPayload -> f UpdateLabelsPayload
updateLabelsPayload_removeLabels = (UpdateLabelsPayload -> Maybe [Text])
-> (UpdateLabelsPayload -> Maybe [Text] -> UpdateLabelsPayload)
-> Lens
     UpdateLabelsPayload
     UpdateLabelsPayload
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLabelsPayload' {Maybe [Text]
removeLabels :: Maybe [Text]
$sel:removeLabels:UpdateLabelsPayload' :: UpdateLabelsPayload -> Maybe [Text]
removeLabels} -> Maybe [Text]
removeLabels) (\s :: UpdateLabelsPayload
s@UpdateLabelsPayload' {} Maybe [Text]
a -> UpdateLabelsPayload
s {$sel:removeLabels:UpdateLabelsPayload' :: Maybe [Text]
removeLabels = Maybe [Text]
a} :: UpdateLabelsPayload) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpdateLabelsPayload -> f UpdateLabelsPayload)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpdateLabelsPayload
-> f UpdateLabelsPayload
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Kubernetes labels to be added or updated.
updateLabelsPayload_addOrUpdateLabels :: Lens.Lens' UpdateLabelsPayload (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
updateLabelsPayload_addOrUpdateLabels :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> UpdateLabelsPayload -> f UpdateLabelsPayload
updateLabelsPayload_addOrUpdateLabels = (UpdateLabelsPayload -> Maybe (HashMap Text Text))
-> (UpdateLabelsPayload
    -> Maybe (HashMap Text Text) -> UpdateLabelsPayload)
-> Lens
     UpdateLabelsPayload
     UpdateLabelsPayload
     (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 (\UpdateLabelsPayload' {Maybe (HashMap Text Text)
addOrUpdateLabels :: Maybe (HashMap Text Text)
$sel:addOrUpdateLabels:UpdateLabelsPayload' :: UpdateLabelsPayload -> Maybe (HashMap Text Text)
addOrUpdateLabels} -> Maybe (HashMap Text Text)
addOrUpdateLabels) (\s :: UpdateLabelsPayload
s@UpdateLabelsPayload' {} Maybe (HashMap Text Text)
a -> UpdateLabelsPayload
s {$sel:addOrUpdateLabels:UpdateLabelsPayload' :: Maybe (HashMap Text Text)
addOrUpdateLabels = Maybe (HashMap Text Text)
a} :: UpdateLabelsPayload) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> UpdateLabelsPayload -> f UpdateLabelsPayload)
-> ((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)))
-> UpdateLabelsPayload
-> f UpdateLabelsPayload
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 Prelude.Hashable UpdateLabelsPayload

instance Prelude.NFData UpdateLabelsPayload

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