{-# 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.SecurityHub.Types.StringFilter -- 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.SecurityHub.Types.StringFilter where import qualified Amazonka.Core as Core import qualified Amazonka.Lens as Lens import qualified Amazonka.Prelude as Prelude import Amazonka.SecurityHub.Types.StringFilterComparison -- | A string filter for querying findings. -- -- /See:/ 'newStringFilter' smart constructor. data StringFilter = StringFilter' { -- | The string filter value. Filter values are case sensitive. For example, -- the product name for control-based findings is @Security Hub@. If you -- provide @security hub@ as the filter text, then there is no match. StringFilter -> Maybe Text value :: Prelude.Maybe Prelude.Text, -- | The condition to apply to a string value when querying for findings. To -- search for values that contain the filter criteria value, use one of the -- following comparison operators: -- -- - To search for values that exactly match the filter value, use -- @EQUALS@. -- -- For example, the filter @ResourceType EQUALS AwsEc2SecurityGroup@ -- only matches findings that have a resource type of -- @AwsEc2SecurityGroup@. -- -- - To search for values that start with the filter value, use @PREFIX@. -- -- For example, the filter @ResourceType PREFIX AwsIam@ matches -- findings that have a resource type that starts with @AwsIam@. -- Findings with a resource type of @AwsIamPolicy@, @AwsIamRole@, or -- @AwsIamUser@ would all match. -- -- @EQUALS@ and @PREFIX@ filters on the same field are joined by @OR@. A -- finding matches if it matches any one of those filters. -- -- To search for values that do not contain the filter criteria value, use -- one of the following comparison operators: -- -- - To search for values that do not exactly match the filter value, use -- @NOT_EQUALS@. -- -- For example, the filter @ResourceType NOT_EQUALS AwsIamPolicy@ -- matches findings that have a resource type other than -- @AwsIamPolicy@. -- -- - To search for values that do not start with the filter value, use -- @PREFIX_NOT_EQUALS@. -- -- For example, the filter @ResourceType PREFIX_NOT_EQUALS AwsIam@ -- matches findings that have a resource type that does not start with -- @AwsIam@. Findings with a resource type of @AwsIamPolicy@, -- @AwsIamRole@, or @AwsIamUser@ would all be excluded from the -- results. -- -- @NOT_EQUALS@ and @PREFIX_NOT_EQUALS@ filters on the same field are -- joined by @AND@. A finding matches only if it matches all of those -- filters. -- -- For filters on the same field, you cannot provide both an @EQUALS@ -- filter and a @NOT_EQUALS@ or @PREFIX_NOT_EQUALS@ filter. Combining -- filters in this way always returns an error, even if the provided filter -- values would return valid results. -- -- You can combine @PREFIX@ filters with @NOT_EQUALS@ or -- @PREFIX_NOT_EQUALS@ filters for the same field. Security Hub first -- processes the @PREFIX@ filters, then the @NOT_EQUALS@ or -- @PREFIX_NOT_EQUALS@ filters. -- -- For example, for the following filter, Security Hub first identifies -- findings that have resource types that start with either @AwsIAM@ or -- @AwsEc2@. It then excludes findings that have a resource type of -- @AwsIamPolicy@ and findings that have a resource type of -- @AwsEc2NetworkInterface@. -- -- - @ResourceType PREFIX AwsIam@ -- -- - @ResourceType PREFIX AwsEc2@ -- -- - @ResourceType NOT_EQUALS AwsIamPolicy@ -- -- - @ResourceType NOT_EQUALS AwsEc2NetworkInterface@ StringFilter -> Maybe StringFilterComparison comparison :: Prelude.Maybe StringFilterComparison } deriving (StringFilter -> StringFilter -> Bool (StringFilter -> StringFilter -> Bool) -> (StringFilter -> StringFilter -> Bool) -> Eq StringFilter forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: StringFilter -> StringFilter -> Bool $c/= :: StringFilter -> StringFilter -> Bool == :: StringFilter -> StringFilter -> Bool $c== :: StringFilter -> StringFilter -> Bool Prelude.Eq, ReadPrec [StringFilter] ReadPrec StringFilter Int -> ReadS StringFilter ReadS [StringFilter] (Int -> ReadS StringFilter) -> ReadS [StringFilter] -> ReadPrec StringFilter -> ReadPrec [StringFilter] -> Read StringFilter forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a readListPrec :: ReadPrec [StringFilter] $creadListPrec :: ReadPrec [StringFilter] readPrec :: ReadPrec StringFilter $creadPrec :: ReadPrec StringFilter readList :: ReadS [StringFilter] $creadList :: ReadS [StringFilter] readsPrec :: Int -> ReadS StringFilter $creadsPrec :: Int -> ReadS StringFilter Prelude.Read, Int -> StringFilter -> ShowS [StringFilter] -> ShowS StringFilter -> String (Int -> StringFilter -> ShowS) -> (StringFilter -> String) -> ([StringFilter] -> ShowS) -> Show StringFilter forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [StringFilter] -> ShowS $cshowList :: [StringFilter] -> ShowS show :: StringFilter -> String $cshow :: StringFilter -> String showsPrec :: Int -> StringFilter -> ShowS $cshowsPrec :: Int -> StringFilter -> ShowS Prelude.Show, (forall x. StringFilter -> Rep StringFilter x) -> (forall x. Rep StringFilter x -> StringFilter) -> Generic StringFilter forall x. Rep StringFilter x -> StringFilter forall x. StringFilter -> Rep StringFilter x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cto :: forall x. Rep StringFilter x -> StringFilter $cfrom :: forall x. StringFilter -> Rep StringFilter x Prelude.Generic) -- | -- Create a value of 'StringFilter' 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', 'stringFilter_value' - The string filter value. Filter values are case sensitive. For example, -- the product name for control-based findings is @Security Hub@. If you -- provide @security hub@ as the filter text, then there is no match. -- -- 'comparison', 'stringFilter_comparison' - The condition to apply to a string value when querying for findings. To -- search for values that contain the filter criteria value, use one of the -- following comparison operators: -- -- - To search for values that exactly match the filter value, use -- @EQUALS@. -- -- For example, the filter @ResourceType EQUALS AwsEc2SecurityGroup@ -- only matches findings that have a resource type of -- @AwsEc2SecurityGroup@. -- -- - To search for values that start with the filter value, use @PREFIX@. -- -- For example, the filter @ResourceType PREFIX AwsIam@ matches -- findings that have a resource type that starts with @AwsIam@. -- Findings with a resource type of @AwsIamPolicy@, @AwsIamRole@, or -- @AwsIamUser@ would all match. -- -- @EQUALS@ and @PREFIX@ filters on the same field are joined by @OR@. A -- finding matches if it matches any one of those filters. -- -- To search for values that do not contain the filter criteria value, use -- one of the following comparison operators: -- -- - To search for values that do not exactly match the filter value, use -- @NOT_EQUALS@. -- -- For example, the filter @ResourceType NOT_EQUALS AwsIamPolicy@ -- matches findings that have a resource type other than -- @AwsIamPolicy@. -- -- - To search for values that do not start with the filter value, use -- @PREFIX_NOT_EQUALS@. -- -- For example, the filter @ResourceType PREFIX_NOT_EQUALS AwsIam@ -- matches findings that have a resource type that does not start with -- @AwsIam@. Findings with a resource type of @AwsIamPolicy@, -- @AwsIamRole@, or @AwsIamUser@ would all be excluded from the -- results. -- -- @NOT_EQUALS@ and @PREFIX_NOT_EQUALS@ filters on the same field are -- joined by @AND@. A finding matches only if it matches all of those -- filters. -- -- For filters on the same field, you cannot provide both an @EQUALS@ -- filter and a @NOT_EQUALS@ or @PREFIX_NOT_EQUALS@ filter. Combining -- filters in this way always returns an error, even if the provided filter -- values would return valid results. -- -- You can combine @PREFIX@ filters with @NOT_EQUALS@ or -- @PREFIX_NOT_EQUALS@ filters for the same field. Security Hub first -- processes the @PREFIX@ filters, then the @NOT_EQUALS@ or -- @PREFIX_NOT_EQUALS@ filters. -- -- For example, for the following filter, Security Hub first identifies -- findings that have resource types that start with either @AwsIAM@ or -- @AwsEc2@. It then excludes findings that have a resource type of -- @AwsIamPolicy@ and findings that have a resource type of -- @AwsEc2NetworkInterface@. -- -- - @ResourceType PREFIX AwsIam@ -- -- - @ResourceType PREFIX AwsEc2@ -- -- - @ResourceType NOT_EQUALS AwsIamPolicy@ -- -- - @ResourceType NOT_EQUALS AwsEc2NetworkInterface@ newStringFilter :: StringFilter newStringFilter :: StringFilter newStringFilter = StringFilter' :: Maybe Text -> Maybe StringFilterComparison -> StringFilter StringFilter' { $sel:value:StringFilter' :: Maybe Text value = Maybe Text forall a. Maybe a Prelude.Nothing, $sel:comparison:StringFilter' :: Maybe StringFilterComparison comparison = Maybe StringFilterComparison forall a. Maybe a Prelude.Nothing } -- | The string filter value. Filter values are case sensitive. For example, -- the product name for control-based findings is @Security Hub@. If you -- provide @security hub@ as the filter text, then there is no match. stringFilter_value :: Lens.Lens' StringFilter (Prelude.Maybe Prelude.Text) stringFilter_value :: (Maybe Text -> f (Maybe Text)) -> StringFilter -> f StringFilter stringFilter_value = (StringFilter -> Maybe Text) -> (StringFilter -> Maybe Text -> StringFilter) -> Lens StringFilter StringFilter (Maybe Text) (Maybe Text) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\StringFilter' {Maybe Text value :: Maybe Text $sel:value:StringFilter' :: StringFilter -> Maybe Text value} -> Maybe Text value) (\s :: StringFilter s@StringFilter' {} Maybe Text a -> StringFilter s {$sel:value:StringFilter' :: Maybe Text value = Maybe Text a} :: StringFilter) -- | The condition to apply to a string value when querying for findings. To -- search for values that contain the filter criteria value, use one of the -- following comparison operators: -- -- - To search for values that exactly match the filter value, use -- @EQUALS@. -- -- For example, the filter @ResourceType EQUALS AwsEc2SecurityGroup@ -- only matches findings that have a resource type of -- @AwsEc2SecurityGroup@. -- -- - To search for values that start with the filter value, use @PREFIX@. -- -- For example, the filter @ResourceType PREFIX AwsIam@ matches -- findings that have a resource type that starts with @AwsIam@. -- Findings with a resource type of @AwsIamPolicy@, @AwsIamRole@, or -- @AwsIamUser@ would all match. -- -- @EQUALS@ and @PREFIX@ filters on the same field are joined by @OR@. A -- finding matches if it matches any one of those filters. -- -- To search for values that do not contain the filter criteria value, use -- one of the following comparison operators: -- -- - To search for values that do not exactly match the filter value, use -- @NOT_EQUALS@. -- -- For example, the filter @ResourceType NOT_EQUALS AwsIamPolicy@ -- matches findings that have a resource type other than -- @AwsIamPolicy@. -- -- - To search for values that do not start with the filter value, use -- @PREFIX_NOT_EQUALS@. -- -- For example, the filter @ResourceType PREFIX_NOT_EQUALS AwsIam@ -- matches findings that have a resource type that does not start with -- @AwsIam@. Findings with a resource type of @AwsIamPolicy@, -- @AwsIamRole@, or @AwsIamUser@ would all be excluded from the -- results. -- -- @NOT_EQUALS@ and @PREFIX_NOT_EQUALS@ filters on the same field are -- joined by @AND@. A finding matches only if it matches all of those -- filters. -- -- For filters on the same field, you cannot provide both an @EQUALS@ -- filter and a @NOT_EQUALS@ or @PREFIX_NOT_EQUALS@ filter. Combining -- filters in this way always returns an error, even if the provided filter -- values would return valid results. -- -- You can combine @PREFIX@ filters with @NOT_EQUALS@ or -- @PREFIX_NOT_EQUALS@ filters for the same field. Security Hub first -- processes the @PREFIX@ filters, then the @NOT_EQUALS@ or -- @PREFIX_NOT_EQUALS@ filters. -- -- For example, for the following filter, Security Hub first identifies -- findings that have resource types that start with either @AwsIAM@ or -- @AwsEc2@. It then excludes findings that have a resource type of -- @AwsIamPolicy@ and findings that have a resource type of -- @AwsEc2NetworkInterface@. -- -- - @ResourceType PREFIX AwsIam@ -- -- - @ResourceType PREFIX AwsEc2@ -- -- - @ResourceType NOT_EQUALS AwsIamPolicy@ -- -- - @ResourceType NOT_EQUALS AwsEc2NetworkInterface@ stringFilter_comparison :: Lens.Lens' StringFilter (Prelude.Maybe StringFilterComparison) stringFilter_comparison :: (Maybe StringFilterComparison -> f (Maybe StringFilterComparison)) -> StringFilter -> f StringFilter stringFilter_comparison = (StringFilter -> Maybe StringFilterComparison) -> (StringFilter -> Maybe StringFilterComparison -> StringFilter) -> Lens StringFilter StringFilter (Maybe StringFilterComparison) (Maybe StringFilterComparison) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\StringFilter' {Maybe StringFilterComparison comparison :: Maybe StringFilterComparison $sel:comparison:StringFilter' :: StringFilter -> Maybe StringFilterComparison comparison} -> Maybe StringFilterComparison comparison) (\s :: StringFilter s@StringFilter' {} Maybe StringFilterComparison a -> StringFilter s {$sel:comparison:StringFilter' :: Maybe StringFilterComparison comparison = Maybe StringFilterComparison a} :: StringFilter) instance Core.FromJSON StringFilter where parseJSON :: Value -> Parser StringFilter parseJSON = String -> (Object -> Parser StringFilter) -> Value -> Parser StringFilter forall a. String -> (Object -> Parser a) -> Value -> Parser a Core.withObject String "StringFilter" ( \Object x -> Maybe Text -> Maybe StringFilterComparison -> StringFilter StringFilter' (Maybe Text -> Maybe StringFilterComparison -> StringFilter) -> Parser (Maybe Text) -> Parser (Maybe StringFilterComparison -> StringFilter) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> (Object x Object -> Text -> Parser (Maybe Text) forall a. FromJSON a => Object -> Text -> Parser (Maybe a) Core..:? Text "Value") Parser (Maybe StringFilterComparison -> StringFilter) -> Parser (Maybe StringFilterComparison) -> Parser StringFilter forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b Prelude.<*> (Object x Object -> Text -> Parser (Maybe StringFilterComparison) forall a. FromJSON a => Object -> Text -> Parser (Maybe a) Core..:? Text "Comparison") ) instance Prelude.Hashable StringFilter instance Prelude.NFData StringFilter instance Core.ToJSON StringFilter where toJSON :: StringFilter -> Value toJSON StringFilter' {Maybe Text Maybe StringFilterComparison comparison :: Maybe StringFilterComparison value :: Maybe Text $sel:comparison:StringFilter' :: StringFilter -> Maybe StringFilterComparison $sel:value:StringFilter' :: StringFilter -> Maybe Text ..} = [Pair] -> Value Core.object ( [Maybe Pair] -> [Pair] forall a. [Maybe a] -> [a] Prelude.catMaybes [ (Text "Value" 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 value, (Text "Comparison" Text -> StringFilterComparison -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv Core..=) (StringFilterComparison -> Pair) -> Maybe StringFilterComparison -> Maybe Pair forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> Maybe StringFilterComparison comparison ] )