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

-- | Provides quota and aggregated usage data for an Amazon Macie account.
--
-- /See:/ 'newUsageRecord' smart constructor.
data UsageRecord = UsageRecord'
  { -- | The unique identifier for the Amazon Web Services account that the data
    -- applies to.
    UsageRecord -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The date and time, in UTC and extended ISO 8601 format, when the free
    -- trial of automated sensitive data discovery started for the account. If
    -- the account is a member account in an organization, this value is the
    -- same as the value for the organization\'s Amazon Macie administrator
    -- account.
    UsageRecord -> Maybe ISO8601
automatedDiscoveryFreeTrialStartDate :: Prelude.Maybe Data.ISO8601,
    -- | The date and time, in UTC and extended ISO 8601 format, when the Amazon
    -- Macie free trial started for the account.
    UsageRecord -> Maybe ISO8601
freeTrialStartDate :: Prelude.Maybe Data.ISO8601,
    -- | An array of objects that contains usage data and quotas for the account.
    -- Each object contains the data for a specific usage metric and the
    -- corresponding quota.
    UsageRecord -> Maybe [UsageByAccount]
usage :: Prelude.Maybe [UsageByAccount]
  }
  deriving (UsageRecord -> UsageRecord -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsageRecord -> UsageRecord -> Bool
$c/= :: UsageRecord -> UsageRecord -> Bool
== :: UsageRecord -> UsageRecord -> Bool
$c== :: UsageRecord -> UsageRecord -> Bool
Prelude.Eq, ReadPrec [UsageRecord]
ReadPrec UsageRecord
Int -> ReadS UsageRecord
ReadS [UsageRecord]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsageRecord]
$creadListPrec :: ReadPrec [UsageRecord]
readPrec :: ReadPrec UsageRecord
$creadPrec :: ReadPrec UsageRecord
readList :: ReadS [UsageRecord]
$creadList :: ReadS [UsageRecord]
readsPrec :: Int -> ReadS UsageRecord
$creadsPrec :: Int -> ReadS UsageRecord
Prelude.Read, Int -> UsageRecord -> ShowS
[UsageRecord] -> ShowS
UsageRecord -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsageRecord] -> ShowS
$cshowList :: [UsageRecord] -> ShowS
show :: UsageRecord -> String
$cshow :: UsageRecord -> String
showsPrec :: Int -> UsageRecord -> ShowS
$cshowsPrec :: Int -> UsageRecord -> ShowS
Prelude.Show, forall x. Rep UsageRecord x -> UsageRecord
forall x. UsageRecord -> Rep UsageRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsageRecord x -> UsageRecord
$cfrom :: forall x. UsageRecord -> Rep UsageRecord x
Prelude.Generic)

-- |
-- Create a value of 'UsageRecord' 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:
--
-- 'accountId', 'usageRecord_accountId' - The unique identifier for the Amazon Web Services account that the data
-- applies to.
--
-- 'automatedDiscoveryFreeTrialStartDate', 'usageRecord_automatedDiscoveryFreeTrialStartDate' - The date and time, in UTC and extended ISO 8601 format, when the free
-- trial of automated sensitive data discovery started for the account. If
-- the account is a member account in an organization, this value is the
-- same as the value for the organization\'s Amazon Macie administrator
-- account.
--
-- 'freeTrialStartDate', 'usageRecord_freeTrialStartDate' - The date and time, in UTC and extended ISO 8601 format, when the Amazon
-- Macie free trial started for the account.
--
-- 'usage', 'usageRecord_usage' - An array of objects that contains usage data and quotas for the account.
-- Each object contains the data for a specific usage metric and the
-- corresponding quota.
newUsageRecord ::
  UsageRecord
newUsageRecord :: UsageRecord
newUsageRecord =
  UsageRecord'
    { $sel:accountId:UsageRecord' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:automatedDiscoveryFreeTrialStartDate:UsageRecord' :: Maybe ISO8601
automatedDiscoveryFreeTrialStartDate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:freeTrialStartDate:UsageRecord' :: Maybe ISO8601
freeTrialStartDate = forall a. Maybe a
Prelude.Nothing,
      $sel:usage:UsageRecord' :: Maybe [UsageByAccount]
usage = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the Amazon Web Services account that the data
-- applies to.
usageRecord_accountId :: Lens.Lens' UsageRecord (Prelude.Maybe Prelude.Text)
usageRecord_accountId :: Lens' UsageRecord (Maybe Text)
usageRecord_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {Maybe Text
accountId :: Maybe Text
$sel:accountId:UsageRecord' :: UsageRecord -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: UsageRecord
s@UsageRecord' {} Maybe Text
a -> UsageRecord
s {$sel:accountId:UsageRecord' :: Maybe Text
accountId = Maybe Text
a} :: UsageRecord)

-- | The date and time, in UTC and extended ISO 8601 format, when the free
-- trial of automated sensitive data discovery started for the account. If
-- the account is a member account in an organization, this value is the
-- same as the value for the organization\'s Amazon Macie administrator
-- account.
usageRecord_automatedDiscoveryFreeTrialStartDate :: Lens.Lens' UsageRecord (Prelude.Maybe Prelude.UTCTime)
usageRecord_automatedDiscoveryFreeTrialStartDate :: Lens' UsageRecord (Maybe UTCTime)
usageRecord_automatedDiscoveryFreeTrialStartDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {Maybe ISO8601
automatedDiscoveryFreeTrialStartDate :: Maybe ISO8601
$sel:automatedDiscoveryFreeTrialStartDate:UsageRecord' :: UsageRecord -> Maybe ISO8601
automatedDiscoveryFreeTrialStartDate} -> Maybe ISO8601
automatedDiscoveryFreeTrialStartDate) (\s :: UsageRecord
s@UsageRecord' {} Maybe ISO8601
a -> UsageRecord
s {$sel:automatedDiscoveryFreeTrialStartDate:UsageRecord' :: Maybe ISO8601
automatedDiscoveryFreeTrialStartDate = Maybe ISO8601
a} :: UsageRecord) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The date and time, in UTC and extended ISO 8601 format, when the Amazon
-- Macie free trial started for the account.
usageRecord_freeTrialStartDate :: Lens.Lens' UsageRecord (Prelude.Maybe Prelude.UTCTime)
usageRecord_freeTrialStartDate :: Lens' UsageRecord (Maybe UTCTime)
usageRecord_freeTrialStartDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {Maybe ISO8601
freeTrialStartDate :: Maybe ISO8601
$sel:freeTrialStartDate:UsageRecord' :: UsageRecord -> Maybe ISO8601
freeTrialStartDate} -> Maybe ISO8601
freeTrialStartDate) (\s :: UsageRecord
s@UsageRecord' {} Maybe ISO8601
a -> UsageRecord
s {$sel:freeTrialStartDate:UsageRecord' :: Maybe ISO8601
freeTrialStartDate = Maybe ISO8601
a} :: UsageRecord) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | An array of objects that contains usage data and quotas for the account.
-- Each object contains the data for a specific usage metric and the
-- corresponding quota.
usageRecord_usage :: Lens.Lens' UsageRecord (Prelude.Maybe [UsageByAccount])
usageRecord_usage :: Lens' UsageRecord (Maybe [UsageByAccount])
usageRecord_usage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {Maybe [UsageByAccount]
usage :: Maybe [UsageByAccount]
$sel:usage:UsageRecord' :: UsageRecord -> Maybe [UsageByAccount]
usage} -> Maybe [UsageByAccount]
usage) (\s :: UsageRecord
s@UsageRecord' {} Maybe [UsageByAccount]
a -> UsageRecord
s {$sel:usage:UsageRecord' :: Maybe [UsageByAccount]
usage = Maybe [UsageByAccount]
a} :: UsageRecord) 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 Data.FromJSON UsageRecord where
  parseJSON :: Value -> Parser UsageRecord
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UsageRecord"
      ( \Object
x ->
          Maybe Text
-> Maybe ISO8601
-> Maybe ISO8601
-> Maybe [UsageByAccount]
-> UsageRecord
UsageRecord'
            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
"accountId")
            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
"automatedDiscoveryFreeTrialStartDate")
            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
"freeTrialStartDate")
            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
"usage" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable UsageRecord where
  hashWithSalt :: Int -> UsageRecord -> Int
hashWithSalt Int
_salt UsageRecord' {Maybe [UsageByAccount]
Maybe Text
Maybe ISO8601
usage :: Maybe [UsageByAccount]
freeTrialStartDate :: Maybe ISO8601
automatedDiscoveryFreeTrialStartDate :: Maybe ISO8601
accountId :: Maybe Text
$sel:usage:UsageRecord' :: UsageRecord -> Maybe [UsageByAccount]
$sel:freeTrialStartDate:UsageRecord' :: UsageRecord -> Maybe ISO8601
$sel:automatedDiscoveryFreeTrialStartDate:UsageRecord' :: UsageRecord -> Maybe ISO8601
$sel:accountId:UsageRecord' :: UsageRecord -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
automatedDiscoveryFreeTrialStartDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
freeTrialStartDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [UsageByAccount]
usage

instance Prelude.NFData UsageRecord where
  rnf :: UsageRecord -> ()
rnf UsageRecord' {Maybe [UsageByAccount]
Maybe Text
Maybe ISO8601
usage :: Maybe [UsageByAccount]
freeTrialStartDate :: Maybe ISO8601
automatedDiscoveryFreeTrialStartDate :: Maybe ISO8601
accountId :: Maybe Text
$sel:usage:UsageRecord' :: UsageRecord -> Maybe [UsageByAccount]
$sel:freeTrialStartDate:UsageRecord' :: UsageRecord -> Maybe ISO8601
$sel:automatedDiscoveryFreeTrialStartDate:UsageRecord' :: UsageRecord -> Maybe ISO8601
$sel:accountId:UsageRecord' :: UsageRecord -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
automatedDiscoveryFreeTrialStartDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
freeTrialStartDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [UsageByAccount]
usage