{-# 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.Config.Types.AggregationAuthorization
-- 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.Config.Types.AggregationAuthorization where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the authorizations granted to aggregator
-- accounts and regions.
--
-- /See:/ 'newAggregationAuthorization' smart constructor.
data AggregationAuthorization = AggregationAuthorization'
  { -- | The Amazon Resource Name (ARN) of the aggregation object.
    AggregationAuthorization -> Maybe Text
aggregationAuthorizationArn :: Prelude.Maybe Prelude.Text,
    -- | The 12-digit account ID of the account authorized to aggregate data.
    AggregationAuthorization -> Maybe Text
authorizedAccountId :: Prelude.Maybe Prelude.Text,
    -- | The region authorized to collect aggregated data.
    AggregationAuthorization -> Maybe Text
authorizedAwsRegion :: Prelude.Maybe Prelude.Text,
    -- | The time stamp when the aggregation authorization was created.
    AggregationAuthorization -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX
  }
  deriving (AggregationAuthorization -> AggregationAuthorization -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AggregationAuthorization -> AggregationAuthorization -> Bool
$c/= :: AggregationAuthorization -> AggregationAuthorization -> Bool
== :: AggregationAuthorization -> AggregationAuthorization -> Bool
$c== :: AggregationAuthorization -> AggregationAuthorization -> Bool
Prelude.Eq, ReadPrec [AggregationAuthorization]
ReadPrec AggregationAuthorization
Int -> ReadS AggregationAuthorization
ReadS [AggregationAuthorization]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AggregationAuthorization]
$creadListPrec :: ReadPrec [AggregationAuthorization]
readPrec :: ReadPrec AggregationAuthorization
$creadPrec :: ReadPrec AggregationAuthorization
readList :: ReadS [AggregationAuthorization]
$creadList :: ReadS [AggregationAuthorization]
readsPrec :: Int -> ReadS AggregationAuthorization
$creadsPrec :: Int -> ReadS AggregationAuthorization
Prelude.Read, Int -> AggregationAuthorization -> ShowS
[AggregationAuthorization] -> ShowS
AggregationAuthorization -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AggregationAuthorization] -> ShowS
$cshowList :: [AggregationAuthorization] -> ShowS
show :: AggregationAuthorization -> String
$cshow :: AggregationAuthorization -> String
showsPrec :: Int -> AggregationAuthorization -> ShowS
$cshowsPrec :: Int -> AggregationAuthorization -> ShowS
Prelude.Show, forall x.
Rep AggregationAuthorization x -> AggregationAuthorization
forall x.
AggregationAuthorization -> Rep AggregationAuthorization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AggregationAuthorization x -> AggregationAuthorization
$cfrom :: forall x.
AggregationAuthorization -> Rep AggregationAuthorization x
Prelude.Generic)

-- |
-- Create a value of 'AggregationAuthorization' 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:
--
-- 'aggregationAuthorizationArn', 'aggregationAuthorization_aggregationAuthorizationArn' - The Amazon Resource Name (ARN) of the aggregation object.
--
-- 'authorizedAccountId', 'aggregationAuthorization_authorizedAccountId' - The 12-digit account ID of the account authorized to aggregate data.
--
-- 'authorizedAwsRegion', 'aggregationAuthorization_authorizedAwsRegion' - The region authorized to collect aggregated data.
--
-- 'creationTime', 'aggregationAuthorization_creationTime' - The time stamp when the aggregation authorization was created.
newAggregationAuthorization ::
  AggregationAuthorization
newAggregationAuthorization :: AggregationAuthorization
newAggregationAuthorization =
  AggregationAuthorization'
    { $sel:aggregationAuthorizationArn:AggregationAuthorization' :: Maybe Text
aggregationAuthorizationArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:authorizedAccountId:AggregationAuthorization' :: Maybe Text
authorizedAccountId = forall a. Maybe a
Prelude.Nothing,
      $sel:authorizedAwsRegion:AggregationAuthorization' :: Maybe Text
authorizedAwsRegion = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:AggregationAuthorization' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the aggregation object.
aggregationAuthorization_aggregationAuthorizationArn :: Lens.Lens' AggregationAuthorization (Prelude.Maybe Prelude.Text)
aggregationAuthorization_aggregationAuthorizationArn :: Lens' AggregationAuthorization (Maybe Text)
aggregationAuthorization_aggregationAuthorizationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregationAuthorization' {Maybe Text
aggregationAuthorizationArn :: Maybe Text
$sel:aggregationAuthorizationArn:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
aggregationAuthorizationArn} -> Maybe Text
aggregationAuthorizationArn) (\s :: AggregationAuthorization
s@AggregationAuthorization' {} Maybe Text
a -> AggregationAuthorization
s {$sel:aggregationAuthorizationArn:AggregationAuthorization' :: Maybe Text
aggregationAuthorizationArn = Maybe Text
a} :: AggregationAuthorization)

-- | The 12-digit account ID of the account authorized to aggregate data.
aggregationAuthorization_authorizedAccountId :: Lens.Lens' AggregationAuthorization (Prelude.Maybe Prelude.Text)
aggregationAuthorization_authorizedAccountId :: Lens' AggregationAuthorization (Maybe Text)
aggregationAuthorization_authorizedAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregationAuthorization' {Maybe Text
authorizedAccountId :: Maybe Text
$sel:authorizedAccountId:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
authorizedAccountId} -> Maybe Text
authorizedAccountId) (\s :: AggregationAuthorization
s@AggregationAuthorization' {} Maybe Text
a -> AggregationAuthorization
s {$sel:authorizedAccountId:AggregationAuthorization' :: Maybe Text
authorizedAccountId = Maybe Text
a} :: AggregationAuthorization)

-- | The region authorized to collect aggregated data.
aggregationAuthorization_authorizedAwsRegion :: Lens.Lens' AggregationAuthorization (Prelude.Maybe Prelude.Text)
aggregationAuthorization_authorizedAwsRegion :: Lens' AggregationAuthorization (Maybe Text)
aggregationAuthorization_authorizedAwsRegion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregationAuthorization' {Maybe Text
authorizedAwsRegion :: Maybe Text
$sel:authorizedAwsRegion:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
authorizedAwsRegion} -> Maybe Text
authorizedAwsRegion) (\s :: AggregationAuthorization
s@AggregationAuthorization' {} Maybe Text
a -> AggregationAuthorization
s {$sel:authorizedAwsRegion:AggregationAuthorization' :: Maybe Text
authorizedAwsRegion = Maybe Text
a} :: AggregationAuthorization)

-- | The time stamp when the aggregation authorization was created.
aggregationAuthorization_creationTime :: Lens.Lens' AggregationAuthorization (Prelude.Maybe Prelude.UTCTime)
aggregationAuthorization_creationTime :: Lens' AggregationAuthorization (Maybe UTCTime)
aggregationAuthorization_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregationAuthorization' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:AggregationAuthorization' :: AggregationAuthorization -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: AggregationAuthorization
s@AggregationAuthorization' {} Maybe POSIX
a -> AggregationAuthorization
s {$sel:creationTime:AggregationAuthorization' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: AggregationAuthorization) 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

instance Data.FromJSON AggregationAuthorization where
  parseJSON :: Value -> Parser AggregationAuthorization
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AggregationAuthorization"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> AggregationAuthorization
AggregationAuthorization'
            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
"AggregationAuthorizationArn")
            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
"AuthorizedAccountId")
            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
"AuthorizedAwsRegion")
            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
"CreationTime")
      )

instance Prelude.Hashable AggregationAuthorization where
  hashWithSalt :: Int -> AggregationAuthorization -> Int
hashWithSalt Int
_salt AggregationAuthorization' {Maybe Text
Maybe POSIX
creationTime :: Maybe POSIX
authorizedAwsRegion :: Maybe Text
authorizedAccountId :: Maybe Text
aggregationAuthorizationArn :: Maybe Text
$sel:creationTime:AggregationAuthorization' :: AggregationAuthorization -> Maybe POSIX
$sel:authorizedAwsRegion:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
$sel:authorizedAccountId:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
$sel:aggregationAuthorizationArn:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
aggregationAuthorizationArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
authorizedAccountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
authorizedAwsRegion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime

instance Prelude.NFData AggregationAuthorization where
  rnf :: AggregationAuthorization -> ()
rnf AggregationAuthorization' {Maybe Text
Maybe POSIX
creationTime :: Maybe POSIX
authorizedAwsRegion :: Maybe Text
authorizedAccountId :: Maybe Text
aggregationAuthorizationArn :: Maybe Text
$sel:creationTime:AggregationAuthorization' :: AggregationAuthorization -> Maybe POSIX
$sel:authorizedAwsRegion:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
$sel:authorizedAccountId:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
$sel:aggregationAuthorizationArn:AggregationAuthorization' :: AggregationAuthorization -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
aggregationAuthorizationArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
authorizedAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
authorizedAwsRegion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime