{-# 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.DataRepositoryTaskFilter
-- 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.DataRepositoryTaskFilter 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.DataRepositoryTaskFilterName
import qualified Amazonka.Prelude as Prelude

-- | (Optional) An array of filter objects you can use to filter the response
-- of data repository tasks you will see in the the response. You can
-- filter the tasks returned in the response by one or more file system
-- IDs, task lifecycles, and by task type. A filter object consists of a
-- filter @Name@, and one or more @Values@ for the filter.
--
-- /See:/ 'newDataRepositoryTaskFilter' smart constructor.
data DataRepositoryTaskFilter = DataRepositoryTaskFilter'
  { -- | Name of the task property to use in filtering the tasks returned in the
    -- response.
    --
    -- -   Use @file-system-id@ to retrieve data repository tasks for specific
    --     file systems.
    --
    -- -   Use @task-lifecycle@ to retrieve data repository tasks with one or
    --     more specific lifecycle states, as follows: CANCELED, EXECUTING,
    --     FAILED, PENDING, and SUCCEEDED.
    DataRepositoryTaskFilter -> Maybe DataRepositoryTaskFilterName
name :: Prelude.Maybe DataRepositoryTaskFilterName,
    -- | Use Values to include the specific file system IDs and task lifecycle
    -- states for the filters you are using.
    DataRepositoryTaskFilter -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DataRepositoryTaskFilter -> DataRepositoryTaskFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataRepositoryTaskFilter -> DataRepositoryTaskFilter -> Bool
$c/= :: DataRepositoryTaskFilter -> DataRepositoryTaskFilter -> Bool
== :: DataRepositoryTaskFilter -> DataRepositoryTaskFilter -> Bool
$c== :: DataRepositoryTaskFilter -> DataRepositoryTaskFilter -> Bool
Prelude.Eq, ReadPrec [DataRepositoryTaskFilter]
ReadPrec DataRepositoryTaskFilter
Int -> ReadS DataRepositoryTaskFilter
ReadS [DataRepositoryTaskFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataRepositoryTaskFilter]
$creadListPrec :: ReadPrec [DataRepositoryTaskFilter]
readPrec :: ReadPrec DataRepositoryTaskFilter
$creadPrec :: ReadPrec DataRepositoryTaskFilter
readList :: ReadS [DataRepositoryTaskFilter]
$creadList :: ReadS [DataRepositoryTaskFilter]
readsPrec :: Int -> ReadS DataRepositoryTaskFilter
$creadsPrec :: Int -> ReadS DataRepositoryTaskFilter
Prelude.Read, Int -> DataRepositoryTaskFilter -> ShowS
[DataRepositoryTaskFilter] -> ShowS
DataRepositoryTaskFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataRepositoryTaskFilter] -> ShowS
$cshowList :: [DataRepositoryTaskFilter] -> ShowS
show :: DataRepositoryTaskFilter -> String
$cshow :: DataRepositoryTaskFilter -> String
showsPrec :: Int -> DataRepositoryTaskFilter -> ShowS
$cshowsPrec :: Int -> DataRepositoryTaskFilter -> ShowS
Prelude.Show, forall x.
Rep DataRepositoryTaskFilter x -> DataRepositoryTaskFilter
forall x.
DataRepositoryTaskFilter -> Rep DataRepositoryTaskFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DataRepositoryTaskFilter x -> DataRepositoryTaskFilter
$cfrom :: forall x.
DataRepositoryTaskFilter -> Rep DataRepositoryTaskFilter x
Prelude.Generic)

-- |
-- Create a value of 'DataRepositoryTaskFilter' 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', 'dataRepositoryTaskFilter_name' - Name of the task property to use in filtering the tasks returned in the
-- response.
--
-- -   Use @file-system-id@ to retrieve data repository tasks for specific
--     file systems.
--
-- -   Use @task-lifecycle@ to retrieve data repository tasks with one or
--     more specific lifecycle states, as follows: CANCELED, EXECUTING,
--     FAILED, PENDING, and SUCCEEDED.
--
-- 'values', 'dataRepositoryTaskFilter_values' - Use Values to include the specific file system IDs and task lifecycle
-- states for the filters you are using.
newDataRepositoryTaskFilter ::
  DataRepositoryTaskFilter
newDataRepositoryTaskFilter :: DataRepositoryTaskFilter
newDataRepositoryTaskFilter =
  DataRepositoryTaskFilter'
    { $sel:name:DataRepositoryTaskFilter' :: Maybe DataRepositoryTaskFilterName
name = forall a. Maybe a
Prelude.Nothing,
      $sel:values:DataRepositoryTaskFilter' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | Name of the task property to use in filtering the tasks returned in the
-- response.
--
-- -   Use @file-system-id@ to retrieve data repository tasks for specific
--     file systems.
--
-- -   Use @task-lifecycle@ to retrieve data repository tasks with one or
--     more specific lifecycle states, as follows: CANCELED, EXECUTING,
--     FAILED, PENDING, and SUCCEEDED.
dataRepositoryTaskFilter_name :: Lens.Lens' DataRepositoryTaskFilter (Prelude.Maybe DataRepositoryTaskFilterName)
dataRepositoryTaskFilter_name :: Lens' DataRepositoryTaskFilter (Maybe DataRepositoryTaskFilterName)
dataRepositoryTaskFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataRepositoryTaskFilter' {Maybe DataRepositoryTaskFilterName
name :: Maybe DataRepositoryTaskFilterName
$sel:name:DataRepositoryTaskFilter' :: DataRepositoryTaskFilter -> Maybe DataRepositoryTaskFilterName
name} -> Maybe DataRepositoryTaskFilterName
name) (\s :: DataRepositoryTaskFilter
s@DataRepositoryTaskFilter' {} Maybe DataRepositoryTaskFilterName
a -> DataRepositoryTaskFilter
s {$sel:name:DataRepositoryTaskFilter' :: Maybe DataRepositoryTaskFilterName
name = Maybe DataRepositoryTaskFilterName
a} :: DataRepositoryTaskFilter)

-- | Use Values to include the specific file system IDs and task lifecycle
-- states for the filters you are using.
dataRepositoryTaskFilter_values :: Lens.Lens' DataRepositoryTaskFilter (Prelude.Maybe [Prelude.Text])
dataRepositoryTaskFilter_values :: Lens' DataRepositoryTaskFilter (Maybe [Text])
dataRepositoryTaskFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataRepositoryTaskFilter' {Maybe [Text]
values :: Maybe [Text]
$sel:values:DataRepositoryTaskFilter' :: DataRepositoryTaskFilter -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: DataRepositoryTaskFilter
s@DataRepositoryTaskFilter' {} Maybe [Text]
a -> DataRepositoryTaskFilter
s {$sel:values:DataRepositoryTaskFilter' :: Maybe [Text]
values = Maybe [Text]
a} :: DataRepositoryTaskFilter) 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 DataRepositoryTaskFilter where
  hashWithSalt :: Int -> DataRepositoryTaskFilter -> Int
hashWithSalt Int
_salt DataRepositoryTaskFilter' {Maybe [Text]
Maybe DataRepositoryTaskFilterName
values :: Maybe [Text]
name :: Maybe DataRepositoryTaskFilterName
$sel:values:DataRepositoryTaskFilter' :: DataRepositoryTaskFilter -> Maybe [Text]
$sel:name:DataRepositoryTaskFilter' :: DataRepositoryTaskFilter -> Maybe DataRepositoryTaskFilterName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DataRepositoryTaskFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

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

instance Data.ToJSON DataRepositoryTaskFilter where
  toJSON :: DataRepositoryTaskFilter -> Value
toJSON DataRepositoryTaskFilter' {Maybe [Text]
Maybe DataRepositoryTaskFilterName
values :: Maybe [Text]
name :: Maybe DataRepositoryTaskFilterName
$sel:values:DataRepositoryTaskFilter' :: DataRepositoryTaskFilter -> Maybe [Text]
$sel:name:DataRepositoryTaskFilter' :: DataRepositoryTaskFilter -> Maybe DataRepositoryTaskFilterName
..} =
    [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 DataRepositoryTaskFilterName
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
          ]
      )