{-# 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.MacieV2.Types.UsageStatisticsFilter
-- 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.MacieV2.Types.UsageStatisticsFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types.UsageStatisticsFilterComparator
import Amazonka.MacieV2.Types.UsageStatisticsFilterKey
import qualified Amazonka.Prelude as Prelude

-- | Specifies a condition for filtering the results of a query for quota and
-- usage data for one or more Amazon Macie accounts.
--
-- /See:/ 'newUsageStatisticsFilter' smart constructor.
data UsageStatisticsFilter = UsageStatisticsFilter'
  { -- | The operator to use in the condition. If the value for the key property
    -- is accountId, this value must be CONTAINS. If the value for the key
    -- property is any other supported field, this value can be EQ, GT, GTE,
    -- LT, LTE, or NE.
    UsageStatisticsFilter -> Maybe UsageStatisticsFilterComparator
comparator :: Prelude.Maybe UsageStatisticsFilterComparator,
    -- | The field to use in the condition.
    UsageStatisticsFilter -> Maybe UsageStatisticsFilterKey
key :: Prelude.Maybe UsageStatisticsFilterKey,
    -- | An array that lists values to use in the condition, based on the value
    -- for the field specified by the key property. If the value for the key
    -- property is accountId, this array can specify multiple values.
    -- Otherwise, this array can specify only one value.
    --
    -- Valid values for each supported field are:
    --
    -- -   accountId - The unique identifier for an Amazon Web Services
    --     account.
    --
    -- -   freeTrialStartDate - The date and time, in UTC and extended ISO 8601
    --     format, when the Amazon Macie free trial started for an account.
    --
    -- -   serviceLimit - A Boolean (true or false) value that indicates
    --     whether an account has reached its monthly quota.
    --
    -- -   total - A string that represents the current estimated cost for an
    --     account.
    UsageStatisticsFilter -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (UsageStatisticsFilter -> UsageStatisticsFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsageStatisticsFilter -> UsageStatisticsFilter -> Bool
$c/= :: UsageStatisticsFilter -> UsageStatisticsFilter -> Bool
== :: UsageStatisticsFilter -> UsageStatisticsFilter -> Bool
$c== :: UsageStatisticsFilter -> UsageStatisticsFilter -> Bool
Prelude.Eq, ReadPrec [UsageStatisticsFilter]
ReadPrec UsageStatisticsFilter
Int -> ReadS UsageStatisticsFilter
ReadS [UsageStatisticsFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsageStatisticsFilter]
$creadListPrec :: ReadPrec [UsageStatisticsFilter]
readPrec :: ReadPrec UsageStatisticsFilter
$creadPrec :: ReadPrec UsageStatisticsFilter
readList :: ReadS [UsageStatisticsFilter]
$creadList :: ReadS [UsageStatisticsFilter]
readsPrec :: Int -> ReadS UsageStatisticsFilter
$creadsPrec :: Int -> ReadS UsageStatisticsFilter
Prelude.Read, Int -> UsageStatisticsFilter -> ShowS
[UsageStatisticsFilter] -> ShowS
UsageStatisticsFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsageStatisticsFilter] -> ShowS
$cshowList :: [UsageStatisticsFilter] -> ShowS
show :: UsageStatisticsFilter -> String
$cshow :: UsageStatisticsFilter -> String
showsPrec :: Int -> UsageStatisticsFilter -> ShowS
$cshowsPrec :: Int -> UsageStatisticsFilter -> ShowS
Prelude.Show, forall x. Rep UsageStatisticsFilter x -> UsageStatisticsFilter
forall x. UsageStatisticsFilter -> Rep UsageStatisticsFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsageStatisticsFilter x -> UsageStatisticsFilter
$cfrom :: forall x. UsageStatisticsFilter -> Rep UsageStatisticsFilter x
Prelude.Generic)

-- |
-- Create a value of 'UsageStatisticsFilter' 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:
--
-- 'comparator', 'usageStatisticsFilter_comparator' - The operator to use in the condition. If the value for the key property
-- is accountId, this value must be CONTAINS. If the value for the key
-- property is any other supported field, this value can be EQ, GT, GTE,
-- LT, LTE, or NE.
--
-- 'key', 'usageStatisticsFilter_key' - The field to use in the condition.
--
-- 'values', 'usageStatisticsFilter_values' - An array that lists values to use in the condition, based on the value
-- for the field specified by the key property. If the value for the key
-- property is accountId, this array can specify multiple values.
-- Otherwise, this array can specify only one value.
--
-- Valid values for each supported field are:
--
-- -   accountId - The unique identifier for an Amazon Web Services
--     account.
--
-- -   freeTrialStartDate - The date and time, in UTC and extended ISO 8601
--     format, when the Amazon Macie free trial started for an account.
--
-- -   serviceLimit - A Boolean (true or false) value that indicates
--     whether an account has reached its monthly quota.
--
-- -   total - A string that represents the current estimated cost for an
--     account.
newUsageStatisticsFilter ::
  UsageStatisticsFilter
newUsageStatisticsFilter :: UsageStatisticsFilter
newUsageStatisticsFilter =
  UsageStatisticsFilter'
    { $sel:comparator:UsageStatisticsFilter' :: Maybe UsageStatisticsFilterComparator
comparator =
        forall a. Maybe a
Prelude.Nothing,
      $sel:key:UsageStatisticsFilter' :: Maybe UsageStatisticsFilterKey
key = forall a. Maybe a
Prelude.Nothing,
      $sel:values:UsageStatisticsFilter' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The operator to use in the condition. If the value for the key property
-- is accountId, this value must be CONTAINS. If the value for the key
-- property is any other supported field, this value can be EQ, GT, GTE,
-- LT, LTE, or NE.
usageStatisticsFilter_comparator :: Lens.Lens' UsageStatisticsFilter (Prelude.Maybe UsageStatisticsFilterComparator)
usageStatisticsFilter_comparator :: Lens' UsageStatisticsFilter (Maybe UsageStatisticsFilterComparator)
usageStatisticsFilter_comparator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageStatisticsFilter' {Maybe UsageStatisticsFilterComparator
comparator :: Maybe UsageStatisticsFilterComparator
$sel:comparator:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe UsageStatisticsFilterComparator
comparator} -> Maybe UsageStatisticsFilterComparator
comparator) (\s :: UsageStatisticsFilter
s@UsageStatisticsFilter' {} Maybe UsageStatisticsFilterComparator
a -> UsageStatisticsFilter
s {$sel:comparator:UsageStatisticsFilter' :: Maybe UsageStatisticsFilterComparator
comparator = Maybe UsageStatisticsFilterComparator
a} :: UsageStatisticsFilter)

-- | The field to use in the condition.
usageStatisticsFilter_key :: Lens.Lens' UsageStatisticsFilter (Prelude.Maybe UsageStatisticsFilterKey)
usageStatisticsFilter_key :: Lens' UsageStatisticsFilter (Maybe UsageStatisticsFilterKey)
usageStatisticsFilter_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageStatisticsFilter' {Maybe UsageStatisticsFilterKey
key :: Maybe UsageStatisticsFilterKey
$sel:key:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe UsageStatisticsFilterKey
key} -> Maybe UsageStatisticsFilterKey
key) (\s :: UsageStatisticsFilter
s@UsageStatisticsFilter' {} Maybe UsageStatisticsFilterKey
a -> UsageStatisticsFilter
s {$sel:key:UsageStatisticsFilter' :: Maybe UsageStatisticsFilterKey
key = Maybe UsageStatisticsFilterKey
a} :: UsageStatisticsFilter)

-- | An array that lists values to use in the condition, based on the value
-- for the field specified by the key property. If the value for the key
-- property is accountId, this array can specify multiple values.
-- Otherwise, this array can specify only one value.
--
-- Valid values for each supported field are:
--
-- -   accountId - The unique identifier for an Amazon Web Services
--     account.
--
-- -   freeTrialStartDate - The date and time, in UTC and extended ISO 8601
--     format, when the Amazon Macie free trial started for an account.
--
-- -   serviceLimit - A Boolean (true or false) value that indicates
--     whether an account has reached its monthly quota.
--
-- -   total - A string that represents the current estimated cost for an
--     account.
usageStatisticsFilter_values :: Lens.Lens' UsageStatisticsFilter (Prelude.Maybe [Prelude.Text])
usageStatisticsFilter_values :: Lens' UsageStatisticsFilter (Maybe [Text])
usageStatisticsFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageStatisticsFilter' {Maybe [Text]
values :: Maybe [Text]
$sel:values:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: UsageStatisticsFilter
s@UsageStatisticsFilter' {} Maybe [Text]
a -> UsageStatisticsFilter
s {$sel:values:UsageStatisticsFilter' :: Maybe [Text]
values = Maybe [Text]
a} :: UsageStatisticsFilter) 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 UsageStatisticsFilter where
  hashWithSalt :: Int -> UsageStatisticsFilter -> Int
hashWithSalt Int
_salt UsageStatisticsFilter' {Maybe [Text]
Maybe UsageStatisticsFilterComparator
Maybe UsageStatisticsFilterKey
values :: Maybe [Text]
key :: Maybe UsageStatisticsFilterKey
comparator :: Maybe UsageStatisticsFilterComparator
$sel:values:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe [Text]
$sel:key:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe UsageStatisticsFilterKey
$sel:comparator:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe UsageStatisticsFilterComparator
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UsageStatisticsFilterComparator
comparator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UsageStatisticsFilterKey
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData UsageStatisticsFilter where
  rnf :: UsageStatisticsFilter -> ()
rnf UsageStatisticsFilter' {Maybe [Text]
Maybe UsageStatisticsFilterComparator
Maybe UsageStatisticsFilterKey
values :: Maybe [Text]
key :: Maybe UsageStatisticsFilterKey
comparator :: Maybe UsageStatisticsFilterComparator
$sel:values:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe [Text]
$sel:key:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe UsageStatisticsFilterKey
$sel:comparator:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe UsageStatisticsFilterComparator
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe UsageStatisticsFilterComparator
comparator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UsageStatisticsFilterKey
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values

instance Data.ToJSON UsageStatisticsFilter where
  toJSON :: UsageStatisticsFilter -> Value
toJSON UsageStatisticsFilter' {Maybe [Text]
Maybe UsageStatisticsFilterComparator
Maybe UsageStatisticsFilterKey
values :: Maybe [Text]
key :: Maybe UsageStatisticsFilterKey
comparator :: Maybe UsageStatisticsFilterComparator
$sel:values:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe [Text]
$sel:key:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe UsageStatisticsFilterKey
$sel:comparator:UsageStatisticsFilter' :: UsageStatisticsFilter -> Maybe UsageStatisticsFilterComparator
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"comparator" 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 UsageStatisticsFilterComparator
comparator,
            (Key
"key" 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 UsageStatisticsFilterKey
key,
            (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
          ]
      )