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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 time stamp when the aggregation authorization was created.
    AggregationAuthorization -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | The region authorized to collect aggregated data.
    AggregationAuthorization -> Maybe Text
authorizedAwsRegion :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (AggregationAuthorization -> AggregationAuthorization -> Bool
(AggregationAuthorization -> AggregationAuthorization -> Bool)
-> (AggregationAuthorization -> AggregationAuthorization -> Bool)
-> Eq AggregationAuthorization
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]
(Int -> ReadS AggregationAuthorization)
-> ReadS [AggregationAuthorization]
-> ReadPrec AggregationAuthorization
-> ReadPrec [AggregationAuthorization]
-> Read 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
(Int -> AggregationAuthorization -> ShowS)
-> (AggregationAuthorization -> String)
-> ([AggregationAuthorization] -> ShowS)
-> Show AggregationAuthorization
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.
 AggregationAuthorization -> Rep AggregationAuthorization x)
-> (forall x.
    Rep AggregationAuthorization x -> AggregationAuthorization)
-> Generic AggregationAuthorization
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:
--
-- 'creationTime', 'aggregationAuthorization_creationTime' - The time stamp when the aggregation authorization was created.
--
-- 'authorizedAwsRegion', 'aggregationAuthorization_authorizedAwsRegion' - The region authorized to collect aggregated data.
--
-- '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.
newAggregationAuthorization ::
  AggregationAuthorization
newAggregationAuthorization :: AggregationAuthorization
newAggregationAuthorization =
  AggregationAuthorization' :: Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AggregationAuthorization
AggregationAuthorization'
    { $sel:creationTime:AggregationAuthorization' :: Maybe POSIX
creationTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:authorizedAwsRegion:AggregationAuthorization' :: Maybe Text
authorizedAwsRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aggregationAuthorizationArn:AggregationAuthorization' :: Maybe Text
aggregationAuthorizationArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authorizedAccountId:AggregationAuthorization' :: Maybe Text
authorizedAccountId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The time stamp when the aggregation authorization was created.
aggregationAuthorization_creationTime :: Lens.Lens' AggregationAuthorization (Prelude.Maybe Prelude.UTCTime)
aggregationAuthorization_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AggregationAuthorization -> f AggregationAuthorization
aggregationAuthorization_creationTime = (AggregationAuthorization -> Maybe POSIX)
-> (AggregationAuthorization
    -> Maybe POSIX -> AggregationAuthorization)
-> Lens
     AggregationAuthorization
     AggregationAuthorization
     (Maybe POSIX)
     (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> AggregationAuthorization -> f AggregationAuthorization)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AggregationAuthorization
-> f AggregationAuthorization
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The region authorized to collect aggregated data.
aggregationAuthorization_authorizedAwsRegion :: Lens.Lens' AggregationAuthorization (Prelude.Maybe Prelude.Text)
aggregationAuthorization_authorizedAwsRegion :: (Maybe Text -> f (Maybe Text))
-> AggregationAuthorization -> f AggregationAuthorization
aggregationAuthorization_authorizedAwsRegion = (AggregationAuthorization -> Maybe Text)
-> (AggregationAuthorization
    -> Maybe Text -> AggregationAuthorization)
-> Lens
     AggregationAuthorization
     AggregationAuthorization
     (Maybe Text)
     (Maybe Text)
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 Amazon Resource Name (ARN) of the aggregation object.
aggregationAuthorization_aggregationAuthorizationArn :: Lens.Lens' AggregationAuthorization (Prelude.Maybe Prelude.Text)
aggregationAuthorization_aggregationAuthorizationArn :: (Maybe Text -> f (Maybe Text))
-> AggregationAuthorization -> f AggregationAuthorization
aggregationAuthorization_aggregationAuthorizationArn = (AggregationAuthorization -> Maybe Text)
-> (AggregationAuthorization
    -> Maybe Text -> AggregationAuthorization)
-> Lens
     AggregationAuthorization
     AggregationAuthorization
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> AggregationAuthorization -> f AggregationAuthorization
aggregationAuthorization_authorizedAccountId = (AggregationAuthorization -> Maybe Text)
-> (AggregationAuthorization
    -> Maybe Text -> AggregationAuthorization)
-> Lens
     AggregationAuthorization
     AggregationAuthorization
     (Maybe Text)
     (Maybe Text)
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)

instance Core.FromJSON AggregationAuthorization where
  parseJSON :: Value -> Parser AggregationAuthorization
parseJSON =
    String
-> (Object -> Parser AggregationAuthorization)
-> Value
-> Parser AggregationAuthorization
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AggregationAuthorization"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AggregationAuthorization
AggregationAuthorization'
            (Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> AggregationAuthorization)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> AggregationAuthorization)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationTime")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> AggregationAuthorization)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> AggregationAuthorization)
forall (f :: * -> *) a b. Applicative f => 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
"AuthorizedAwsRegion")
            Parser (Maybe Text -> Maybe Text -> AggregationAuthorization)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AggregationAuthorization)
forall (f :: * -> *) a b. Applicative f => 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
"AggregationAuthorizationArn")
            Parser (Maybe Text -> AggregationAuthorization)
-> Parser (Maybe Text) -> Parser AggregationAuthorization
forall (f :: * -> *) a b. Applicative f => 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
"AuthorizedAccountId")
      )

instance Prelude.Hashable AggregationAuthorization

instance Prelude.NFData AggregationAuthorization