{-# 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.LicenseManager.Types.ProductInformationFilter
-- 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.LicenseManager.Types.ProductInformationFilter where

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

-- | Describes product information filters.
--
-- /See:/ 'newProductInformationFilter' smart constructor.
data ProductInformationFilter = ProductInformationFilter'
  { -- | Filter value.
    ProductInformationFilter -> Maybe [Text]
productInformationFilterValue :: Prelude.Maybe [Prelude.Text],
    -- | Filter name.
    ProductInformationFilter -> Text
productInformationFilterName :: Prelude.Text,
    -- | Logical operator.
    ProductInformationFilter -> Text
productInformationFilterComparator :: Prelude.Text
  }
  deriving (ProductInformationFilter -> ProductInformationFilter -> Bool
(ProductInformationFilter -> ProductInformationFilter -> Bool)
-> (ProductInformationFilter -> ProductInformationFilter -> Bool)
-> Eq ProductInformationFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProductInformationFilter -> ProductInformationFilter -> Bool
$c/= :: ProductInformationFilter -> ProductInformationFilter -> Bool
== :: ProductInformationFilter -> ProductInformationFilter -> Bool
$c== :: ProductInformationFilter -> ProductInformationFilter -> Bool
Prelude.Eq, ReadPrec [ProductInformationFilter]
ReadPrec ProductInformationFilter
Int -> ReadS ProductInformationFilter
ReadS [ProductInformationFilter]
(Int -> ReadS ProductInformationFilter)
-> ReadS [ProductInformationFilter]
-> ReadPrec ProductInformationFilter
-> ReadPrec [ProductInformationFilter]
-> Read ProductInformationFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProductInformationFilter]
$creadListPrec :: ReadPrec [ProductInformationFilter]
readPrec :: ReadPrec ProductInformationFilter
$creadPrec :: ReadPrec ProductInformationFilter
readList :: ReadS [ProductInformationFilter]
$creadList :: ReadS [ProductInformationFilter]
readsPrec :: Int -> ReadS ProductInformationFilter
$creadsPrec :: Int -> ReadS ProductInformationFilter
Prelude.Read, Int -> ProductInformationFilter -> ShowS
[ProductInformationFilter] -> ShowS
ProductInformationFilter -> String
(Int -> ProductInformationFilter -> ShowS)
-> (ProductInformationFilter -> String)
-> ([ProductInformationFilter] -> ShowS)
-> Show ProductInformationFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProductInformationFilter] -> ShowS
$cshowList :: [ProductInformationFilter] -> ShowS
show :: ProductInformationFilter -> String
$cshow :: ProductInformationFilter -> String
showsPrec :: Int -> ProductInformationFilter -> ShowS
$cshowsPrec :: Int -> ProductInformationFilter -> ShowS
Prelude.Show, (forall x.
 ProductInformationFilter -> Rep ProductInformationFilter x)
-> (forall x.
    Rep ProductInformationFilter x -> ProductInformationFilter)
-> Generic ProductInformationFilter
forall x.
Rep ProductInformationFilter x -> ProductInformationFilter
forall x.
ProductInformationFilter -> Rep ProductInformationFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ProductInformationFilter x -> ProductInformationFilter
$cfrom :: forall x.
ProductInformationFilter -> Rep ProductInformationFilter x
Prelude.Generic)

-- |
-- Create a value of 'ProductInformationFilter' 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:
--
-- 'productInformationFilterValue', 'productInformationFilter_productInformationFilterValue' - Filter value.
--
-- 'productInformationFilterName', 'productInformationFilter_productInformationFilterName' - Filter name.
--
-- 'productInformationFilterComparator', 'productInformationFilter_productInformationFilterComparator' - Logical operator.
newProductInformationFilter ::
  -- | 'productInformationFilterName'
  Prelude.Text ->
  -- | 'productInformationFilterComparator'
  Prelude.Text ->
  ProductInformationFilter
newProductInformationFilter :: Text -> Text -> ProductInformationFilter
newProductInformationFilter
  Text
pProductInformationFilterName_
  Text
pProductInformationFilterComparator_ =
    ProductInformationFilter' :: Maybe [Text] -> Text -> Text -> ProductInformationFilter
ProductInformationFilter'
      { $sel:productInformationFilterValue:ProductInformationFilter' :: Maybe [Text]
productInformationFilterValue =
          Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:productInformationFilterName:ProductInformationFilter' :: Text
productInformationFilterName =
          Text
pProductInformationFilterName_,
        $sel:productInformationFilterComparator:ProductInformationFilter' :: Text
productInformationFilterComparator =
          Text
pProductInformationFilterComparator_
      }

-- | Filter value.
productInformationFilter_productInformationFilterValue :: Lens.Lens' ProductInformationFilter (Prelude.Maybe [Prelude.Text])
productInformationFilter_productInformationFilterValue :: (Maybe [Text] -> f (Maybe [Text]))
-> ProductInformationFilter -> f ProductInformationFilter
productInformationFilter_productInformationFilterValue = (ProductInformationFilter -> Maybe [Text])
-> (ProductInformationFilter
    -> Maybe [Text] -> ProductInformationFilter)
-> Lens
     ProductInformationFilter
     ProductInformationFilter
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductInformationFilter' {Maybe [Text]
productInformationFilterValue :: Maybe [Text]
$sel:productInformationFilterValue:ProductInformationFilter' :: ProductInformationFilter -> Maybe [Text]
productInformationFilterValue} -> Maybe [Text]
productInformationFilterValue) (\s :: ProductInformationFilter
s@ProductInformationFilter' {} Maybe [Text]
a -> ProductInformationFilter
s {$sel:productInformationFilterValue:ProductInformationFilter' :: Maybe [Text]
productInformationFilterValue = Maybe [Text]
a} :: ProductInformationFilter) ((Maybe [Text] -> f (Maybe [Text]))
 -> ProductInformationFilter -> f ProductInformationFilter)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ProductInformationFilter
-> f ProductInformationFilter
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

-- | Filter name.
productInformationFilter_productInformationFilterName :: Lens.Lens' ProductInformationFilter Prelude.Text
productInformationFilter_productInformationFilterName :: (Text -> f Text)
-> ProductInformationFilter -> f ProductInformationFilter
productInformationFilter_productInformationFilterName = (ProductInformationFilter -> Text)
-> (ProductInformationFilter -> Text -> ProductInformationFilter)
-> Lens ProductInformationFilter ProductInformationFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductInformationFilter' {Text
productInformationFilterName :: Text
$sel:productInformationFilterName:ProductInformationFilter' :: ProductInformationFilter -> Text
productInformationFilterName} -> Text
productInformationFilterName) (\s :: ProductInformationFilter
s@ProductInformationFilter' {} Text
a -> ProductInformationFilter
s {$sel:productInformationFilterName:ProductInformationFilter' :: Text
productInformationFilterName = Text
a} :: ProductInformationFilter)

-- | Logical operator.
productInformationFilter_productInformationFilterComparator :: Lens.Lens' ProductInformationFilter Prelude.Text
productInformationFilter_productInformationFilterComparator :: (Text -> f Text)
-> ProductInformationFilter -> f ProductInformationFilter
productInformationFilter_productInformationFilterComparator = (ProductInformationFilter -> Text)
-> (ProductInformationFilter -> Text -> ProductInformationFilter)
-> Lens ProductInformationFilter ProductInformationFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductInformationFilter' {Text
productInformationFilterComparator :: Text
$sel:productInformationFilterComparator:ProductInformationFilter' :: ProductInformationFilter -> Text
productInformationFilterComparator} -> Text
productInformationFilterComparator) (\s :: ProductInformationFilter
s@ProductInformationFilter' {} Text
a -> ProductInformationFilter
s {$sel:productInformationFilterComparator:ProductInformationFilter' :: Text
productInformationFilterComparator = Text
a} :: ProductInformationFilter)

instance Core.FromJSON ProductInformationFilter where
  parseJSON :: Value -> Parser ProductInformationFilter
parseJSON =
    String
-> (Object -> Parser ProductInformationFilter)
-> Value
-> Parser ProductInformationFilter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProductInformationFilter"
      ( \Object
x ->
          Maybe [Text] -> Text -> Text -> ProductInformationFilter
ProductInformationFilter'
            (Maybe [Text] -> Text -> Text -> ProductInformationFilter)
-> Parser (Maybe [Text])
-> Parser (Text -> Text -> ProductInformationFilter)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProductInformationFilterValue"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Text -> Text -> ProductInformationFilter)
-> Parser Text -> Parser (Text -> ProductInformationFilter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ProductInformationFilterName")
            Parser (Text -> ProductInformationFilter)
-> Parser Text -> Parser ProductInformationFilter
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ProductInformationFilterComparator")
      )

instance Prelude.Hashable ProductInformationFilter

instance Prelude.NFData ProductInformationFilter

instance Core.ToJSON ProductInformationFilter where
  toJSON :: ProductInformationFilter -> Value
toJSON ProductInformationFilter' {Maybe [Text]
Text
productInformationFilterComparator :: Text
productInformationFilterName :: Text
productInformationFilterValue :: Maybe [Text]
$sel:productInformationFilterComparator:ProductInformationFilter' :: ProductInformationFilter -> Text
$sel:productInformationFilterName:ProductInformationFilter' :: ProductInformationFilter -> Text
$sel:productInformationFilterValue:ProductInformationFilter' :: ProductInformationFilter -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ProductInformationFilterValue" 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]
productInformationFilterValue,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ProductInformationFilterName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productInformationFilterName
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ProductInformationFilterComparator"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productInformationFilterComparator
              )
          ]
      )