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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LicenseManager.Types.InventoryFilterCondition
import qualified Amazonka.Prelude as Prelude

-- | An inventory filter.
--
-- /See:/ 'newInventoryFilter' smart constructor.
data InventoryFilter = InventoryFilter'
  { -- | Value of the filter.
    InventoryFilter -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | Name of the filter.
    InventoryFilter -> Text
name :: Prelude.Text,
    -- | Condition of the filter.
    InventoryFilter -> InventoryFilterCondition
condition :: InventoryFilterCondition
  }
  deriving (InventoryFilter -> InventoryFilter -> Bool
(InventoryFilter -> InventoryFilter -> Bool)
-> (InventoryFilter -> InventoryFilter -> Bool)
-> Eq InventoryFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InventoryFilter -> InventoryFilter -> Bool
$c/= :: InventoryFilter -> InventoryFilter -> Bool
== :: InventoryFilter -> InventoryFilter -> Bool
$c== :: InventoryFilter -> InventoryFilter -> Bool
Prelude.Eq, ReadPrec [InventoryFilter]
ReadPrec InventoryFilter
Int -> ReadS InventoryFilter
ReadS [InventoryFilter]
(Int -> ReadS InventoryFilter)
-> ReadS [InventoryFilter]
-> ReadPrec InventoryFilter
-> ReadPrec [InventoryFilter]
-> Read InventoryFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InventoryFilter]
$creadListPrec :: ReadPrec [InventoryFilter]
readPrec :: ReadPrec InventoryFilter
$creadPrec :: ReadPrec InventoryFilter
readList :: ReadS [InventoryFilter]
$creadList :: ReadS [InventoryFilter]
readsPrec :: Int -> ReadS InventoryFilter
$creadsPrec :: Int -> ReadS InventoryFilter
Prelude.Read, Int -> InventoryFilter -> ShowS
[InventoryFilter] -> ShowS
InventoryFilter -> String
(Int -> InventoryFilter -> ShowS)
-> (InventoryFilter -> String)
-> ([InventoryFilter] -> ShowS)
-> Show InventoryFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InventoryFilter] -> ShowS
$cshowList :: [InventoryFilter] -> ShowS
show :: InventoryFilter -> String
$cshow :: InventoryFilter -> String
showsPrec :: Int -> InventoryFilter -> ShowS
$cshowsPrec :: Int -> InventoryFilter -> ShowS
Prelude.Show, (forall x. InventoryFilter -> Rep InventoryFilter x)
-> (forall x. Rep InventoryFilter x -> InventoryFilter)
-> Generic InventoryFilter
forall x. Rep InventoryFilter x -> InventoryFilter
forall x. InventoryFilter -> Rep InventoryFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InventoryFilter x -> InventoryFilter
$cfrom :: forall x. InventoryFilter -> Rep InventoryFilter x
Prelude.Generic)

-- |
-- Create a value of 'InventoryFilter' 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:
--
-- 'value', 'inventoryFilter_value' - Value of the filter.
--
-- 'name', 'inventoryFilter_name' - Name of the filter.
--
-- 'condition', 'inventoryFilter_condition' - Condition of the filter.
newInventoryFilter ::
  -- | 'name'
  Prelude.Text ->
  -- | 'condition'
  InventoryFilterCondition ->
  InventoryFilter
newInventoryFilter :: Text -> InventoryFilterCondition -> InventoryFilter
newInventoryFilter Text
pName_ InventoryFilterCondition
pCondition_ =
  InventoryFilter' :: Maybe Text -> Text -> InventoryFilterCondition -> InventoryFilter
InventoryFilter'
    { $sel:value:InventoryFilter' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:InventoryFilter' :: Text
name = Text
pName_,
      $sel:condition:InventoryFilter' :: InventoryFilterCondition
condition = InventoryFilterCondition
pCondition_
    }

-- | Value of the filter.
inventoryFilter_value :: Lens.Lens' InventoryFilter (Prelude.Maybe Prelude.Text)
inventoryFilter_value :: (Maybe Text -> f (Maybe Text))
-> InventoryFilter -> f InventoryFilter
inventoryFilter_value = (InventoryFilter -> Maybe Text)
-> (InventoryFilter -> Maybe Text -> InventoryFilter)
-> Lens InventoryFilter InventoryFilter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryFilter' {Maybe Text
value :: Maybe Text
$sel:value:InventoryFilter' :: InventoryFilter -> Maybe Text
value} -> Maybe Text
value) (\s :: InventoryFilter
s@InventoryFilter' {} Maybe Text
a -> InventoryFilter
s {$sel:value:InventoryFilter' :: Maybe Text
value = Maybe Text
a} :: InventoryFilter)

-- | Name of the filter.
inventoryFilter_name :: Lens.Lens' InventoryFilter Prelude.Text
inventoryFilter_name :: (Text -> f Text) -> InventoryFilter -> f InventoryFilter
inventoryFilter_name = (InventoryFilter -> Text)
-> (InventoryFilter -> Text -> InventoryFilter)
-> Lens InventoryFilter InventoryFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryFilter' {Text
name :: Text
$sel:name:InventoryFilter' :: InventoryFilter -> Text
name} -> Text
name) (\s :: InventoryFilter
s@InventoryFilter' {} Text
a -> InventoryFilter
s {$sel:name:InventoryFilter' :: Text
name = Text
a} :: InventoryFilter)

-- | Condition of the filter.
inventoryFilter_condition :: Lens.Lens' InventoryFilter InventoryFilterCondition
inventoryFilter_condition :: (InventoryFilterCondition -> f InventoryFilterCondition)
-> InventoryFilter -> f InventoryFilter
inventoryFilter_condition = (InventoryFilter -> InventoryFilterCondition)
-> (InventoryFilter -> InventoryFilterCondition -> InventoryFilter)
-> Lens
     InventoryFilter
     InventoryFilter
     InventoryFilterCondition
     InventoryFilterCondition
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryFilter' {InventoryFilterCondition
condition :: InventoryFilterCondition
$sel:condition:InventoryFilter' :: InventoryFilter -> InventoryFilterCondition
condition} -> InventoryFilterCondition
condition) (\s :: InventoryFilter
s@InventoryFilter' {} InventoryFilterCondition
a -> InventoryFilter
s {$sel:condition:InventoryFilter' :: InventoryFilterCondition
condition = InventoryFilterCondition
a} :: InventoryFilter)

instance Prelude.Hashable InventoryFilter

instance Prelude.NFData InventoryFilter

instance Core.ToJSON InventoryFilter where
  toJSON :: InventoryFilter -> Value
toJSON InventoryFilter' {Maybe Text
Text
InventoryFilterCondition
condition :: InventoryFilterCondition
name :: Text
value :: Maybe Text
$sel:condition:InventoryFilter' :: InventoryFilter -> InventoryFilterCondition
$sel:name:InventoryFilter' :: InventoryFilter -> Text
$sel:value:InventoryFilter' :: InventoryFilter -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Condition" Text -> InventoryFilterCondition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InventoryFilterCondition
condition)
          ]
      )