{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LicenseManager.Types.InventoryFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:value:InventoryFilter' :: Maybe Text
value = 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 :: Lens' InventoryFilter (Maybe Text)
inventoryFilter_value = 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 :: Lens' InventoryFilter Text
inventoryFilter_name = 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 :: Lens' InventoryFilter InventoryFilterCondition
inventoryFilter_condition = 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 where
  hashWithSalt :: Int -> InventoryFilter -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InventoryFilterCondition
condition

instance Prelude.NFData InventoryFilter where
  rnf :: InventoryFilter -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf InventoryFilterCondition
condition

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
value,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Condition" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= InventoryFilterCondition
condition)
          ]
      )