{-# 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.Batch.Types.KeyValuesPair
-- 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.Batch.Types.KeyValuesPair where

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

-- | A filter name and value pair that\'s used to return a more specific list
-- of results from a @ListJobs@ API operation.
--
-- /See:/ 'newKeyValuesPair' smart constructor.
data KeyValuesPair = KeyValuesPair'
  { -- | The filter values.
    KeyValuesPair -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | The name of the filter. Filter names are case sensitive.
    KeyValuesPair -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (KeyValuesPair -> KeyValuesPair -> Bool
(KeyValuesPair -> KeyValuesPair -> Bool)
-> (KeyValuesPair -> KeyValuesPair -> Bool) -> Eq KeyValuesPair
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyValuesPair -> KeyValuesPair -> Bool
$c/= :: KeyValuesPair -> KeyValuesPair -> Bool
== :: KeyValuesPair -> KeyValuesPair -> Bool
$c== :: KeyValuesPair -> KeyValuesPair -> Bool
Prelude.Eq, ReadPrec [KeyValuesPair]
ReadPrec KeyValuesPair
Int -> ReadS KeyValuesPair
ReadS [KeyValuesPair]
(Int -> ReadS KeyValuesPair)
-> ReadS [KeyValuesPair]
-> ReadPrec KeyValuesPair
-> ReadPrec [KeyValuesPair]
-> Read KeyValuesPair
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeyValuesPair]
$creadListPrec :: ReadPrec [KeyValuesPair]
readPrec :: ReadPrec KeyValuesPair
$creadPrec :: ReadPrec KeyValuesPair
readList :: ReadS [KeyValuesPair]
$creadList :: ReadS [KeyValuesPair]
readsPrec :: Int -> ReadS KeyValuesPair
$creadsPrec :: Int -> ReadS KeyValuesPair
Prelude.Read, Int -> KeyValuesPair -> ShowS
[KeyValuesPair] -> ShowS
KeyValuesPair -> String
(Int -> KeyValuesPair -> ShowS)
-> (KeyValuesPair -> String)
-> ([KeyValuesPair] -> ShowS)
-> Show KeyValuesPair
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyValuesPair] -> ShowS
$cshowList :: [KeyValuesPair] -> ShowS
show :: KeyValuesPair -> String
$cshow :: KeyValuesPair -> String
showsPrec :: Int -> KeyValuesPair -> ShowS
$cshowsPrec :: Int -> KeyValuesPair -> ShowS
Prelude.Show, (forall x. KeyValuesPair -> Rep KeyValuesPair x)
-> (forall x. Rep KeyValuesPair x -> KeyValuesPair)
-> Generic KeyValuesPair
forall x. Rep KeyValuesPair x -> KeyValuesPair
forall x. KeyValuesPair -> Rep KeyValuesPair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeyValuesPair x -> KeyValuesPair
$cfrom :: forall x. KeyValuesPair -> Rep KeyValuesPair x
Prelude.Generic)

-- |
-- Create a value of 'KeyValuesPair' 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:
--
-- 'values', 'keyValuesPair_values' - The filter values.
--
-- 'name', 'keyValuesPair_name' - The name of the filter. Filter names are case sensitive.
newKeyValuesPair ::
  KeyValuesPair
newKeyValuesPair :: KeyValuesPair
newKeyValuesPair =
  KeyValuesPair' :: Maybe [Text] -> Maybe Text -> KeyValuesPair
KeyValuesPair'
    { $sel:values:KeyValuesPair' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:KeyValuesPair' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The filter values.
keyValuesPair_values :: Lens.Lens' KeyValuesPair (Prelude.Maybe [Prelude.Text])
keyValuesPair_values :: (Maybe [Text] -> f (Maybe [Text]))
-> KeyValuesPair -> f KeyValuesPair
keyValuesPair_values = (KeyValuesPair -> Maybe [Text])
-> (KeyValuesPair -> Maybe [Text] -> KeyValuesPair)
-> Lens KeyValuesPair KeyValuesPair (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyValuesPair' {Maybe [Text]
values :: Maybe [Text]
$sel:values:KeyValuesPair' :: KeyValuesPair -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: KeyValuesPair
s@KeyValuesPair' {} Maybe [Text]
a -> KeyValuesPair
s {$sel:values:KeyValuesPair' :: Maybe [Text]
values = Maybe [Text]
a} :: KeyValuesPair) ((Maybe [Text] -> f (Maybe [Text]))
 -> KeyValuesPair -> f KeyValuesPair)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> KeyValuesPair
-> f KeyValuesPair
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

-- | The name of the filter. Filter names are case sensitive.
keyValuesPair_name :: Lens.Lens' KeyValuesPair (Prelude.Maybe Prelude.Text)
keyValuesPair_name :: (Maybe Text -> f (Maybe Text)) -> KeyValuesPair -> f KeyValuesPair
keyValuesPair_name = (KeyValuesPair -> Maybe Text)
-> (KeyValuesPair -> Maybe Text -> KeyValuesPair)
-> Lens KeyValuesPair KeyValuesPair (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyValuesPair' {Maybe Text
name :: Maybe Text
$sel:name:KeyValuesPair' :: KeyValuesPair -> Maybe Text
name} -> Maybe Text
name) (\s :: KeyValuesPair
s@KeyValuesPair' {} Maybe Text
a -> KeyValuesPair
s {$sel:name:KeyValuesPair' :: Maybe Text
name = Maybe Text
a} :: KeyValuesPair)

instance Prelude.Hashable KeyValuesPair

instance Prelude.NFData KeyValuesPair

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