{-# 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.AggregateResourceIdentifier
-- 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.AggregateResourceIdentifier where

import Amazonka.Config.Types.ResourceType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details that identify a resource that is collected by Config
-- aggregator, including the resource type, ID, (if available) the custom
-- resource name, the source account, and source region.
--
-- /See:/ 'newAggregateResourceIdentifier' smart constructor.
data AggregateResourceIdentifier = AggregateResourceIdentifier'
  { -- | The name of the Amazon Web Services resource.
    AggregateResourceIdentifier -> Maybe Text
resourceName :: Prelude.Maybe Prelude.Text,
    -- | The 12-digit account ID of the source account.
    AggregateResourceIdentifier -> Text
sourceAccountId :: Prelude.Text,
    -- | The source region where data is aggregated.
    AggregateResourceIdentifier -> Text
sourceRegion :: Prelude.Text,
    -- | The ID of the Amazon Web Services resource.
    AggregateResourceIdentifier -> Text
resourceId :: Prelude.Text,
    -- | The type of the Amazon Web Services resource.
    AggregateResourceIdentifier -> ResourceType
resourceType :: ResourceType
  }
  deriving (AggregateResourceIdentifier -> AggregateResourceIdentifier -> Bool
(AggregateResourceIdentifier
 -> AggregateResourceIdentifier -> Bool)
-> (AggregateResourceIdentifier
    -> AggregateResourceIdentifier -> Bool)
-> Eq AggregateResourceIdentifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AggregateResourceIdentifier -> AggregateResourceIdentifier -> Bool
$c/= :: AggregateResourceIdentifier -> AggregateResourceIdentifier -> Bool
== :: AggregateResourceIdentifier -> AggregateResourceIdentifier -> Bool
$c== :: AggregateResourceIdentifier -> AggregateResourceIdentifier -> Bool
Prelude.Eq, ReadPrec [AggregateResourceIdentifier]
ReadPrec AggregateResourceIdentifier
Int -> ReadS AggregateResourceIdentifier
ReadS [AggregateResourceIdentifier]
(Int -> ReadS AggregateResourceIdentifier)
-> ReadS [AggregateResourceIdentifier]
-> ReadPrec AggregateResourceIdentifier
-> ReadPrec [AggregateResourceIdentifier]
-> Read AggregateResourceIdentifier
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AggregateResourceIdentifier]
$creadListPrec :: ReadPrec [AggregateResourceIdentifier]
readPrec :: ReadPrec AggregateResourceIdentifier
$creadPrec :: ReadPrec AggregateResourceIdentifier
readList :: ReadS [AggregateResourceIdentifier]
$creadList :: ReadS [AggregateResourceIdentifier]
readsPrec :: Int -> ReadS AggregateResourceIdentifier
$creadsPrec :: Int -> ReadS AggregateResourceIdentifier
Prelude.Read, Int -> AggregateResourceIdentifier -> ShowS
[AggregateResourceIdentifier] -> ShowS
AggregateResourceIdentifier -> String
(Int -> AggregateResourceIdentifier -> ShowS)
-> (AggregateResourceIdentifier -> String)
-> ([AggregateResourceIdentifier] -> ShowS)
-> Show AggregateResourceIdentifier
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AggregateResourceIdentifier] -> ShowS
$cshowList :: [AggregateResourceIdentifier] -> ShowS
show :: AggregateResourceIdentifier -> String
$cshow :: AggregateResourceIdentifier -> String
showsPrec :: Int -> AggregateResourceIdentifier -> ShowS
$cshowsPrec :: Int -> AggregateResourceIdentifier -> ShowS
Prelude.Show, (forall x.
 AggregateResourceIdentifier -> Rep AggregateResourceIdentifier x)
-> (forall x.
    Rep AggregateResourceIdentifier x -> AggregateResourceIdentifier)
-> Generic AggregateResourceIdentifier
forall x.
Rep AggregateResourceIdentifier x -> AggregateResourceIdentifier
forall x.
AggregateResourceIdentifier -> Rep AggregateResourceIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AggregateResourceIdentifier x -> AggregateResourceIdentifier
$cfrom :: forall x.
AggregateResourceIdentifier -> Rep AggregateResourceIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'AggregateResourceIdentifier' 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:
--
-- 'resourceName', 'aggregateResourceIdentifier_resourceName' - The name of the Amazon Web Services resource.
--
-- 'sourceAccountId', 'aggregateResourceIdentifier_sourceAccountId' - The 12-digit account ID of the source account.
--
-- 'sourceRegion', 'aggregateResourceIdentifier_sourceRegion' - The source region where data is aggregated.
--
-- 'resourceId', 'aggregateResourceIdentifier_resourceId' - The ID of the Amazon Web Services resource.
--
-- 'resourceType', 'aggregateResourceIdentifier_resourceType' - The type of the Amazon Web Services resource.
newAggregateResourceIdentifier ::
  -- | 'sourceAccountId'
  Prelude.Text ->
  -- | 'sourceRegion'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'resourceType'
  ResourceType ->
  AggregateResourceIdentifier
newAggregateResourceIdentifier :: Text -> Text -> Text -> ResourceType -> AggregateResourceIdentifier
newAggregateResourceIdentifier
  Text
pSourceAccountId_
  Text
pSourceRegion_
  Text
pResourceId_
  ResourceType
pResourceType_ =
    AggregateResourceIdentifier' :: Maybe Text
-> Text
-> Text
-> Text
-> ResourceType
-> AggregateResourceIdentifier
AggregateResourceIdentifier'
      { $sel:resourceName:AggregateResourceIdentifier' :: Maybe Text
resourceName =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:sourceAccountId:AggregateResourceIdentifier' :: Text
sourceAccountId = Text
pSourceAccountId_,
        $sel:sourceRegion:AggregateResourceIdentifier' :: Text
sourceRegion = Text
pSourceRegion_,
        $sel:resourceId:AggregateResourceIdentifier' :: Text
resourceId = Text
pResourceId_,
        $sel:resourceType:AggregateResourceIdentifier' :: ResourceType
resourceType = ResourceType
pResourceType_
      }

-- | The name of the Amazon Web Services resource.
aggregateResourceIdentifier_resourceName :: Lens.Lens' AggregateResourceIdentifier (Prelude.Maybe Prelude.Text)
aggregateResourceIdentifier_resourceName :: (Maybe Text -> f (Maybe Text))
-> AggregateResourceIdentifier -> f AggregateResourceIdentifier
aggregateResourceIdentifier_resourceName = (AggregateResourceIdentifier -> Maybe Text)
-> (AggregateResourceIdentifier
    -> Maybe Text -> AggregateResourceIdentifier)
-> Lens
     AggregateResourceIdentifier
     AggregateResourceIdentifier
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateResourceIdentifier' {Maybe Text
resourceName :: Maybe Text
$sel:resourceName:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> Maybe Text
resourceName} -> Maybe Text
resourceName) (\s :: AggregateResourceIdentifier
s@AggregateResourceIdentifier' {} Maybe Text
a -> AggregateResourceIdentifier
s {$sel:resourceName:AggregateResourceIdentifier' :: Maybe Text
resourceName = Maybe Text
a} :: AggregateResourceIdentifier)

-- | The 12-digit account ID of the source account.
aggregateResourceIdentifier_sourceAccountId :: Lens.Lens' AggregateResourceIdentifier Prelude.Text
aggregateResourceIdentifier_sourceAccountId :: (Text -> f Text)
-> AggregateResourceIdentifier -> f AggregateResourceIdentifier
aggregateResourceIdentifier_sourceAccountId = (AggregateResourceIdentifier -> Text)
-> (AggregateResourceIdentifier
    -> Text -> AggregateResourceIdentifier)
-> Lens
     AggregateResourceIdentifier AggregateResourceIdentifier Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateResourceIdentifier' {Text
sourceAccountId :: Text
$sel:sourceAccountId:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> Text
sourceAccountId} -> Text
sourceAccountId) (\s :: AggregateResourceIdentifier
s@AggregateResourceIdentifier' {} Text
a -> AggregateResourceIdentifier
s {$sel:sourceAccountId:AggregateResourceIdentifier' :: Text
sourceAccountId = Text
a} :: AggregateResourceIdentifier)

-- | The source region where data is aggregated.
aggregateResourceIdentifier_sourceRegion :: Lens.Lens' AggregateResourceIdentifier Prelude.Text
aggregateResourceIdentifier_sourceRegion :: (Text -> f Text)
-> AggregateResourceIdentifier -> f AggregateResourceIdentifier
aggregateResourceIdentifier_sourceRegion = (AggregateResourceIdentifier -> Text)
-> (AggregateResourceIdentifier
    -> Text -> AggregateResourceIdentifier)
-> Lens
     AggregateResourceIdentifier AggregateResourceIdentifier Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateResourceIdentifier' {Text
sourceRegion :: Text
$sel:sourceRegion:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> Text
sourceRegion} -> Text
sourceRegion) (\s :: AggregateResourceIdentifier
s@AggregateResourceIdentifier' {} Text
a -> AggregateResourceIdentifier
s {$sel:sourceRegion:AggregateResourceIdentifier' :: Text
sourceRegion = Text
a} :: AggregateResourceIdentifier)

-- | The ID of the Amazon Web Services resource.
aggregateResourceIdentifier_resourceId :: Lens.Lens' AggregateResourceIdentifier Prelude.Text
aggregateResourceIdentifier_resourceId :: (Text -> f Text)
-> AggregateResourceIdentifier -> f AggregateResourceIdentifier
aggregateResourceIdentifier_resourceId = (AggregateResourceIdentifier -> Text)
-> (AggregateResourceIdentifier
    -> Text -> AggregateResourceIdentifier)
-> Lens
     AggregateResourceIdentifier AggregateResourceIdentifier Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateResourceIdentifier' {Text
resourceId :: Text
$sel:resourceId:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> Text
resourceId} -> Text
resourceId) (\s :: AggregateResourceIdentifier
s@AggregateResourceIdentifier' {} Text
a -> AggregateResourceIdentifier
s {$sel:resourceId:AggregateResourceIdentifier' :: Text
resourceId = Text
a} :: AggregateResourceIdentifier)

-- | The type of the Amazon Web Services resource.
aggregateResourceIdentifier_resourceType :: Lens.Lens' AggregateResourceIdentifier ResourceType
aggregateResourceIdentifier_resourceType :: (ResourceType -> f ResourceType)
-> AggregateResourceIdentifier -> f AggregateResourceIdentifier
aggregateResourceIdentifier_resourceType = (AggregateResourceIdentifier -> ResourceType)
-> (AggregateResourceIdentifier
    -> ResourceType -> AggregateResourceIdentifier)
-> Lens
     AggregateResourceIdentifier
     AggregateResourceIdentifier
     ResourceType
     ResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateResourceIdentifier' {ResourceType
resourceType :: ResourceType
$sel:resourceType:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> ResourceType
resourceType} -> ResourceType
resourceType) (\s :: AggregateResourceIdentifier
s@AggregateResourceIdentifier' {} ResourceType
a -> AggregateResourceIdentifier
s {$sel:resourceType:AggregateResourceIdentifier' :: ResourceType
resourceType = ResourceType
a} :: AggregateResourceIdentifier)

instance Core.FromJSON AggregateResourceIdentifier where
  parseJSON :: Value -> Parser AggregateResourceIdentifier
parseJSON =
    String
-> (Object -> Parser AggregateResourceIdentifier)
-> Value
-> Parser AggregateResourceIdentifier
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AggregateResourceIdentifier"
      ( \Object
x ->
          Maybe Text
-> Text
-> Text
-> Text
-> ResourceType
-> AggregateResourceIdentifier
AggregateResourceIdentifier'
            (Maybe Text
 -> Text
 -> Text
 -> Text
 -> ResourceType
 -> AggregateResourceIdentifier)
-> Parser (Maybe Text)
-> Parser
     (Text
      -> Text -> Text -> ResourceType -> AggregateResourceIdentifier)
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
"ResourceName")
            Parser
  (Text
   -> Text -> Text -> ResourceType -> AggregateResourceIdentifier)
-> Parser Text
-> Parser
     (Text -> Text -> ResourceType -> AggregateResourceIdentifier)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SourceAccountId")
            Parser
  (Text -> Text -> ResourceType -> AggregateResourceIdentifier)
-> Parser Text
-> Parser (Text -> ResourceType -> AggregateResourceIdentifier)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SourceRegion")
            Parser (Text -> ResourceType -> AggregateResourceIdentifier)
-> Parser Text
-> Parser (ResourceType -> AggregateResourceIdentifier)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ResourceId")
            Parser (ResourceType -> AggregateResourceIdentifier)
-> Parser ResourceType -> Parser AggregateResourceIdentifier
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ResourceType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ResourceType")
      )

instance Prelude.Hashable AggregateResourceIdentifier

instance Prelude.NFData AggregateResourceIdentifier

instance Core.ToJSON AggregateResourceIdentifier where
  toJSON :: AggregateResourceIdentifier -> Value
toJSON AggregateResourceIdentifier' {Maybe Text
Text
ResourceType
resourceType :: ResourceType
resourceId :: Text
sourceRegion :: Text
sourceAccountId :: Text
resourceName :: Maybe Text
$sel:resourceType:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> ResourceType
$sel:resourceId:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> Text
$sel:sourceRegion:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> Text
$sel:sourceAccountId:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> Text
$sel:resourceName:AggregateResourceIdentifier' :: AggregateResourceIdentifier -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ResourceName" 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
resourceName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SourceAccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourceAccountId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SourceRegion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourceRegion),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceType" Text -> ResourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceType
resourceType)
          ]
      )