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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector2.Types.FilterAction
import Amazonka.Inspector2.Types.FilterCriteria
import qualified Amazonka.Prelude as Prelude

-- | Details about a filter.
--
-- /See:/ 'newFilter' smart constructor.
data Filter = Filter'
  { -- | A description of the filter.
    Filter -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The reason for the filter.
    Filter -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The tags attached to the filter.
    Filter -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The action that is to be applied to the findings that match the filter.
    Filter -> FilterAction
action :: FilterAction,
    -- | The Amazon Resource Number (ARN) associated with this filter.
    Filter -> Text
arn :: Prelude.Text,
    -- | The date and time this filter was created at.
    Filter -> POSIX
createdAt :: Data.POSIX,
    -- | Details on the filter criteria associated with this filter.
    Filter -> FilterCriteria
criteria :: FilterCriteria,
    -- | The name of the filter.
    Filter -> Text
name :: Prelude.Text,
    -- | The Amazon Web Services account ID of the account that created the
    -- filter.
    Filter -> Text
ownerId :: Prelude.Text,
    -- | The date and time the filter was last updated at.
    Filter -> POSIX
updatedAt :: Data.POSIX
  }
  deriving (Filter -> Filter -> Bool
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]
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
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. 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:
--
-- 'description', 'filter_description' - A description of the filter.
--
-- 'reason', 'filter_reason' - The reason for the filter.
--
-- 'tags', 'filter_tags' - The tags attached to the filter.
--
-- 'action', 'filter_action' - The action that is to be applied to the findings that match the filter.
--
-- 'arn', 'filter_arn' - The Amazon Resource Number (ARN) associated with this filter.
--
-- 'createdAt', 'filter_createdAt' - The date and time this filter was created at.
--
-- 'criteria', 'filter_criteria' - Details on the filter criteria associated with this filter.
--
-- 'name', 'filter_name' - The name of the filter.
--
-- 'ownerId', 'filter_ownerId' - The Amazon Web Services account ID of the account that created the
-- filter.
--
-- 'updatedAt', 'filter_updatedAt' - The date and time the filter was last updated at.
newFilter ::
  -- | 'action'
  FilterAction ->
  -- | 'arn'
  Prelude.Text ->
  -- | 'createdAt'
  Prelude.UTCTime ->
  -- | 'criteria'
  FilterCriteria ->
  -- | 'name'
  Prelude.Text ->
  -- | 'ownerId'
  Prelude.Text ->
  -- | 'updatedAt'
  Prelude.UTCTime ->
  Filter
newFilter :: FilterAction
-> Text
-> UTCTime
-> FilterCriteria
-> Text
-> Text
-> UTCTime
-> Filter
newFilter
  FilterAction
pAction_
  Text
pArn_
  UTCTime
pCreatedAt_
  FilterCriteria
pCriteria_
  Text
pName_
  Text
pOwnerId_
  UTCTime
pUpdatedAt_ =
    Filter'
      { $sel:description:Filter' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
        $sel:reason:Filter' :: Maybe Text
reason = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:Filter' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:action:Filter' :: FilterAction
action = FilterAction
pAction_,
        $sel:arn:Filter' :: Text
arn = Text
pArn_,
        $sel:createdAt:Filter' :: POSIX
createdAt = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreatedAt_,
        $sel:criteria:Filter' :: FilterCriteria
criteria = FilterCriteria
pCriteria_,
        $sel:name:Filter' :: Text
name = Text
pName_,
        $sel:ownerId:Filter' :: Text
ownerId = Text
pOwnerId_,
        $sel:updatedAt:Filter' :: POSIX
updatedAt = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pUpdatedAt_
      }

-- | A description of the filter.
filter_description :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_description :: Lens' Filter (Maybe Text)
filter_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
description :: Maybe Text
$sel:description:Filter' :: Filter -> Maybe Text
description} -> Maybe Text
description) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:description:Filter' :: Maybe Text
description = Maybe Text
a} :: Filter)

-- | The reason for the filter.
filter_reason :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_reason :: Lens' Filter (Maybe Text)
filter_reason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
reason :: Maybe Text
$sel:reason:Filter' :: Filter -> Maybe Text
reason} -> Maybe Text
reason) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:reason:Filter' :: Maybe Text
reason = Maybe Text
a} :: Filter)

-- | The tags attached to the filter.
filter_tags :: Lens.Lens' Filter (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
filter_tags :: Lens' Filter (Maybe (HashMap Text Text))
filter_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:Filter' :: Filter -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: Filter
s@Filter' {} Maybe (HashMap Text Text)
a -> Filter
s {$sel:tags:Filter' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: Filter) 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

-- | The action that is to be applied to the findings that match the filter.
filter_action :: Lens.Lens' Filter FilterAction
filter_action :: Lens' Filter FilterAction
filter_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {FilterAction
action :: FilterAction
$sel:action:Filter' :: Filter -> FilterAction
action} -> FilterAction
action) (\s :: Filter
s@Filter' {} FilterAction
a -> Filter
s {$sel:action:Filter' :: FilterAction
action = FilterAction
a} :: Filter)

-- | The Amazon Resource Number (ARN) associated with this filter.
filter_arn :: Lens.Lens' Filter Prelude.Text
filter_arn :: Lens' Filter Text
filter_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Text
arn :: Text
$sel:arn:Filter' :: Filter -> Text
arn} -> Text
arn) (\s :: Filter
s@Filter' {} Text
a -> Filter
s {$sel:arn:Filter' :: Text
arn = Text
a} :: Filter)

-- | The date and time this filter was created at.
filter_createdAt :: Lens.Lens' Filter Prelude.UTCTime
filter_createdAt :: Lens' Filter UTCTime
filter_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {POSIX
createdAt :: POSIX
$sel:createdAt:Filter' :: Filter -> POSIX
createdAt} -> POSIX
createdAt) (\s :: Filter
s@Filter' {} POSIX
a -> Filter
s {$sel:createdAt:Filter' :: POSIX
createdAt = POSIX
a} :: Filter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Details on the filter criteria associated with this filter.
filter_criteria :: Lens.Lens' Filter FilterCriteria
filter_criteria :: Lens' Filter FilterCriteria
filter_criteria = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {FilterCriteria
criteria :: FilterCriteria
$sel:criteria:Filter' :: Filter -> FilterCriteria
criteria} -> FilterCriteria
criteria) (\s :: Filter
s@Filter' {} FilterCriteria
a -> Filter
s {$sel:criteria:Filter' :: FilterCriteria
criteria = FilterCriteria
a} :: Filter)

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

-- | The Amazon Web Services account ID of the account that created the
-- filter.
filter_ownerId :: Lens.Lens' Filter Prelude.Text
filter_ownerId :: Lens' Filter Text
filter_ownerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Text
ownerId :: Text
$sel:ownerId:Filter' :: Filter -> Text
ownerId} -> Text
ownerId) (\s :: Filter
s@Filter' {} Text
a -> Filter
s {$sel:ownerId:Filter' :: Text
ownerId = Text
a} :: Filter)

-- | The date and time the filter was last updated at.
filter_updatedAt :: Lens.Lens' Filter Prelude.UTCTime
filter_updatedAt :: Lens' Filter UTCTime
filter_updatedAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {POSIX
updatedAt :: POSIX
$sel:updatedAt:Filter' :: Filter -> POSIX
updatedAt} -> POSIX
updatedAt) (\s :: Filter
s@Filter' {} POSIX
a -> Filter
s {$sel:updatedAt:Filter' :: POSIX
updatedAt = POSIX
a} :: Filter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON Filter where
  parseJSON :: Value -> Parser Filter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Filter"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> FilterAction
-> Text
-> POSIX
-> FilterCriteria
-> Text
-> Text
-> POSIX
-> Filter
Filter'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"reason")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"action")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"createdAt")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"criteria")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ownerId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"updatedAt")
      )

instance Prelude.Hashable Filter where
  hashWithSalt :: Int -> Filter -> Int
hashWithSalt Int
_salt Filter' {Maybe Text
Maybe (HashMap Text Text)
Text
POSIX
FilterAction
FilterCriteria
updatedAt :: POSIX
ownerId :: Text
name :: Text
criteria :: FilterCriteria
createdAt :: POSIX
arn :: Text
action :: FilterAction
tags :: Maybe (HashMap Text Text)
reason :: Maybe Text
description :: Maybe Text
$sel:updatedAt:Filter' :: Filter -> POSIX
$sel:ownerId:Filter' :: Filter -> Text
$sel:name:Filter' :: Filter -> Text
$sel:criteria:Filter' :: Filter -> FilterCriteria
$sel:createdAt:Filter' :: Filter -> POSIX
$sel:arn:Filter' :: Filter -> Text
$sel:action:Filter' :: Filter -> FilterAction
$sel:tags:Filter' :: Filter -> Maybe (HashMap Text Text)
$sel:reason:Filter' :: Filter -> Maybe Text
$sel:description:Filter' :: Filter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FilterAction
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FilterCriteria
criteria
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ownerId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
updatedAt

instance Prelude.NFData Filter where
  rnf :: Filter -> ()
rnf Filter' {Maybe Text
Maybe (HashMap Text Text)
Text
POSIX
FilterAction
FilterCriteria
updatedAt :: POSIX
ownerId :: Text
name :: Text
criteria :: FilterCriteria
createdAt :: POSIX
arn :: Text
action :: FilterAction
tags :: Maybe (HashMap Text Text)
reason :: Maybe Text
description :: Maybe Text
$sel:updatedAt:Filter' :: Filter -> POSIX
$sel:ownerId:Filter' :: Filter -> Text
$sel:name:Filter' :: Filter -> Text
$sel:criteria:Filter' :: Filter -> FilterCriteria
$sel:createdAt:Filter' :: Filter -> POSIX
$sel:arn:Filter' :: Filter -> Text
$sel:action:Filter' :: Filter -> FilterAction
$sel:tags:Filter' :: Filter -> Maybe (HashMap Text Text)
$sel:reason:Filter' :: Filter -> Maybe Text
$sel:description:Filter' :: Filter -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf FilterAction
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf FilterCriteria
criteria
      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 Text
ownerId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
updatedAt