{-# 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.MarketplaceCatalog.Types.Filter
-- 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.MarketplaceCatalog.Types.Filter where

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

-- | A filter object, used to optionally filter results from calls to the
-- @ListEntities@ and @ListChangeSets@ actions.
--
-- /See:/ 'newFilter' smart constructor.
data Filter = Filter'
  { -- | @ListEntities@ - This is a list of unique @EntityId@s.
    --
    -- @ListChangeSets@ - The supported filter names and associated
    -- @ValueList@s is as follows:
    --
    -- -   @ChangeSetName@ - The supported @ValueList@ is a list of non-unique
    --     @ChangeSetName@s. These are defined when you call the
    --     @StartChangeSet@ action.
    --
    -- -   @Status@ - The supported @ValueList@ is a list of statuses for all
    --     change set requests.
    --
    -- -   @EntityId@ - The supported @ValueList@ is a list of unique
    --     @EntityId@s.
    --
    -- -   @BeforeStartTime@ - The supported @ValueList@ is a list of all
    --     change sets that started before the filter value.
    --
    -- -   @AfterStartTime@ - The supported @ValueList@ is a list of all change
    --     sets that started after the filter value.
    --
    -- -   @BeforeEndTime@ - The supported @ValueList@ is a list of all change
    --     sets that ended before the filter value.
    --
    -- -   @AfterEndTime@ - The supported @ValueList@ is a list of all change
    --     sets that ended after the filter value.
    Filter -> Maybe (NonEmpty Text)
valueList :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | For @ListEntities@, the supported value for this is an @EntityId@.
    --
    -- For @ListChangeSets@, the supported values are as follows:
    Filter -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Filter -> Filter -> Bool
(Filter -> Filter -> Bool)
-> (Filter -> Filter -> Bool) -> Eq Filter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Filter -> Filter -> Bool
$c/= :: Filter -> Filter -> Bool
== :: Filter -> Filter -> Bool
$c== :: Filter -> Filter -> Bool
Prelude.Eq, ReadPrec [Filter]
ReadPrec Filter
Int -> ReadS Filter
ReadS [Filter]
(Int -> ReadS Filter)
-> ReadS [Filter]
-> ReadPrec Filter
-> ReadPrec [Filter]
-> Read Filter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Filter]
$creadListPrec :: ReadPrec [Filter]
readPrec :: ReadPrec Filter
$creadPrec :: ReadPrec Filter
readList :: ReadS [Filter]
$creadList :: ReadS [Filter]
readsPrec :: Int -> ReadS Filter
$creadsPrec :: Int -> ReadS Filter
Prelude.Read, Int -> Filter -> ShowS
[Filter] -> ShowS
Filter -> String
(Int -> Filter -> ShowS)
-> (Filter -> String) -> ([Filter] -> ShowS) -> Show Filter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Filter] -> ShowS
$cshowList :: [Filter] -> ShowS
show :: Filter -> String
$cshow :: Filter -> String
showsPrec :: Int -> Filter -> ShowS
$cshowsPrec :: Int -> Filter -> ShowS
Prelude.Show, (forall x. Filter -> Rep Filter x)
-> (forall x. Rep Filter x -> Filter) -> Generic Filter
forall x. Rep Filter x -> Filter
forall x. Filter -> Rep Filter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Filter x -> Filter
$cfrom :: forall x. Filter -> Rep Filter x
Prelude.Generic)

-- |
-- Create a value of 'Filter' 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:
--
-- 'valueList', 'filter_valueList' - @ListEntities@ - This is a list of unique @EntityId@s.
--
-- @ListChangeSets@ - The supported filter names and associated
-- @ValueList@s is as follows:
--
-- -   @ChangeSetName@ - The supported @ValueList@ is a list of non-unique
--     @ChangeSetName@s. These are defined when you call the
--     @StartChangeSet@ action.
--
-- -   @Status@ - The supported @ValueList@ is a list of statuses for all
--     change set requests.
--
-- -   @EntityId@ - The supported @ValueList@ is a list of unique
--     @EntityId@s.
--
-- -   @BeforeStartTime@ - The supported @ValueList@ is a list of all
--     change sets that started before the filter value.
--
-- -   @AfterStartTime@ - The supported @ValueList@ is a list of all change
--     sets that started after the filter value.
--
-- -   @BeforeEndTime@ - The supported @ValueList@ is a list of all change
--     sets that ended before the filter value.
--
-- -   @AfterEndTime@ - The supported @ValueList@ is a list of all change
--     sets that ended after the filter value.
--
-- 'name', 'filter_name' - For @ListEntities@, the supported value for this is an @EntityId@.
--
-- For @ListChangeSets@, the supported values are as follows:
newFilter ::
  Filter
newFilter :: Filter
newFilter =
  Filter' :: Maybe (NonEmpty Text) -> Maybe Text -> Filter
Filter'
    { $sel:valueList:Filter' :: Maybe (NonEmpty Text)
valueList = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Filter' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | @ListEntities@ - This is a list of unique @EntityId@s.
--
-- @ListChangeSets@ - The supported filter names and associated
-- @ValueList@s is as follows:
--
-- -   @ChangeSetName@ - The supported @ValueList@ is a list of non-unique
--     @ChangeSetName@s. These are defined when you call the
--     @StartChangeSet@ action.
--
-- -   @Status@ - The supported @ValueList@ is a list of statuses for all
--     change set requests.
--
-- -   @EntityId@ - The supported @ValueList@ is a list of unique
--     @EntityId@s.
--
-- -   @BeforeStartTime@ - The supported @ValueList@ is a list of all
--     change sets that started before the filter value.
--
-- -   @AfterStartTime@ - The supported @ValueList@ is a list of all change
--     sets that started after the filter value.
--
-- -   @BeforeEndTime@ - The supported @ValueList@ is a list of all change
--     sets that ended before the filter value.
--
-- -   @AfterEndTime@ - The supported @ValueList@ is a list of all change
--     sets that ended after the filter value.
filter_valueList :: Lens.Lens' Filter (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
filter_valueList :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Filter -> f Filter
filter_valueList = (Filter -> Maybe (NonEmpty Text))
-> (Filter -> Maybe (NonEmpty Text) -> Filter)
-> Lens
     Filter Filter (Maybe (NonEmpty Text)) (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe (NonEmpty Text)
valueList :: Maybe (NonEmpty Text)
$sel:valueList:Filter' :: Filter -> Maybe (NonEmpty Text)
valueList} -> Maybe (NonEmpty Text)
valueList) (\s :: Filter
s@Filter' {} Maybe (NonEmpty Text)
a -> Filter
s {$sel:valueList:Filter' :: Maybe (NonEmpty Text)
valueList = Maybe (NonEmpty Text)
a} :: Filter) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> Filter -> f Filter)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Filter
-> f Filter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty 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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | For @ListEntities@, the supported value for this is an @EntityId@.
--
-- For @ListChangeSets@, the supported values are as follows:
filter_name :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_name :: (Maybe Text -> f (Maybe Text)) -> Filter -> f Filter
filter_name = (Filter -> Maybe Text)
-> (Filter -> Maybe Text -> Filter)
-> Lens Filter Filter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
name :: Maybe Text
$sel:name:Filter' :: Filter -> Maybe Text
name} -> Maybe Text
name) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:name:Filter' :: Maybe Text
name = Maybe Text
a} :: Filter)

instance Prelude.Hashable Filter

instance Prelude.NFData Filter

instance Core.ToJSON Filter where
  toJSON :: Filter -> Value
toJSON Filter' {Maybe (NonEmpty Text)
Maybe Text
name :: Maybe Text
valueList :: Maybe (NonEmpty Text)
$sel:name:Filter' :: Filter -> Maybe Text
$sel:valueList:Filter' :: Filter -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ValueList" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
valueList,
            (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
          ]
      )