{-# 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.FSx.Types.SnapshotFilter
-- 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.FSx.Types.SnapshotFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FSx.Types.SnapshotFilterName
import qualified Amazonka.Prelude as Prelude

-- | A filter used to restrict the results of @DescribeSnapshots@ calls. You
-- can use multiple filters to return results that meet all applied filter
-- requirements.
--
-- /See:/ 'newSnapshotFilter' smart constructor.
data SnapshotFilter = SnapshotFilter'
  { -- | The name of the filter to use. You can filter by the @file-system-id@ or
    -- by @volume-id@.
    SnapshotFilter -> Maybe SnapshotFilterName
name :: Prelude.Maybe SnapshotFilterName,
    -- | The @file-system-id@ or @volume-id@ that you are filtering for.
    SnapshotFilter -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (SnapshotFilter -> SnapshotFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnapshotFilter -> SnapshotFilter -> Bool
$c/= :: SnapshotFilter -> SnapshotFilter -> Bool
== :: SnapshotFilter -> SnapshotFilter -> Bool
$c== :: SnapshotFilter -> SnapshotFilter -> Bool
Prelude.Eq, ReadPrec [SnapshotFilter]
ReadPrec SnapshotFilter
Int -> ReadS SnapshotFilter
ReadS [SnapshotFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnapshotFilter]
$creadListPrec :: ReadPrec [SnapshotFilter]
readPrec :: ReadPrec SnapshotFilter
$creadPrec :: ReadPrec SnapshotFilter
readList :: ReadS [SnapshotFilter]
$creadList :: ReadS [SnapshotFilter]
readsPrec :: Int -> ReadS SnapshotFilter
$creadsPrec :: Int -> ReadS SnapshotFilter
Prelude.Read, Int -> SnapshotFilter -> ShowS
[SnapshotFilter] -> ShowS
SnapshotFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnapshotFilter] -> ShowS
$cshowList :: [SnapshotFilter] -> ShowS
show :: SnapshotFilter -> String
$cshow :: SnapshotFilter -> String
showsPrec :: Int -> SnapshotFilter -> ShowS
$cshowsPrec :: Int -> SnapshotFilter -> ShowS
Prelude.Show, forall x. Rep SnapshotFilter x -> SnapshotFilter
forall x. SnapshotFilter -> Rep SnapshotFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnapshotFilter x -> SnapshotFilter
$cfrom :: forall x. SnapshotFilter -> Rep SnapshotFilter x
Prelude.Generic)

-- |
-- Create a value of 'SnapshotFilter' 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:
--
-- 'name', 'snapshotFilter_name' - The name of the filter to use. You can filter by the @file-system-id@ or
-- by @volume-id@.
--
-- 'values', 'snapshotFilter_values' - The @file-system-id@ or @volume-id@ that you are filtering for.
newSnapshotFilter ::
  SnapshotFilter
newSnapshotFilter :: SnapshotFilter
newSnapshotFilter =
  SnapshotFilter'
    { $sel:name:SnapshotFilter' :: Maybe SnapshotFilterName
name = forall a. Maybe a
Prelude.Nothing,
      $sel:values:SnapshotFilter' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the filter to use. You can filter by the @file-system-id@ or
-- by @volume-id@.
snapshotFilter_name :: Lens.Lens' SnapshotFilter (Prelude.Maybe SnapshotFilterName)
snapshotFilter_name :: Lens' SnapshotFilter (Maybe SnapshotFilterName)
snapshotFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotFilter' {Maybe SnapshotFilterName
name :: Maybe SnapshotFilterName
$sel:name:SnapshotFilter' :: SnapshotFilter -> Maybe SnapshotFilterName
name} -> Maybe SnapshotFilterName
name) (\s :: SnapshotFilter
s@SnapshotFilter' {} Maybe SnapshotFilterName
a -> SnapshotFilter
s {$sel:name:SnapshotFilter' :: Maybe SnapshotFilterName
name = Maybe SnapshotFilterName
a} :: SnapshotFilter)

-- | The @file-system-id@ or @volume-id@ that you are filtering for.
snapshotFilter_values :: Lens.Lens' SnapshotFilter (Prelude.Maybe [Prelude.Text])
snapshotFilter_values :: Lens' SnapshotFilter (Maybe [Text])
snapshotFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotFilter' {Maybe [Text]
values :: Maybe [Text]
$sel:values:SnapshotFilter' :: SnapshotFilter -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: SnapshotFilter
s@SnapshotFilter' {} Maybe [Text]
a -> SnapshotFilter
s {$sel:values:SnapshotFilter' :: Maybe [Text]
values = Maybe [Text]
a} :: SnapshotFilter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable SnapshotFilter where
  hashWithSalt :: Int -> SnapshotFilter -> Int
hashWithSalt Int
_salt SnapshotFilter' {Maybe [Text]
Maybe SnapshotFilterName
values :: Maybe [Text]
name :: Maybe SnapshotFilterName
$sel:values:SnapshotFilter' :: SnapshotFilter -> Maybe [Text]
$sel:name:SnapshotFilter' :: SnapshotFilter -> Maybe SnapshotFilterName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SnapshotFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData SnapshotFilter where
  rnf :: SnapshotFilter -> ()
rnf SnapshotFilter' {Maybe [Text]
Maybe SnapshotFilterName
values :: Maybe [Text]
name :: Maybe SnapshotFilterName
$sel:values:SnapshotFilter' :: SnapshotFilter -> Maybe [Text]
$sel:name:SnapshotFilter' :: SnapshotFilter -> Maybe SnapshotFilterName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SnapshotFilterName
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values

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