{-# 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.ResourceGroups.Types.ResourceIdentifier
-- 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.ResourceGroups.Types.ResourceIdentifier where

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

-- | A structure that contains the ARN of a resource and its resource type.
--
-- /See:/ 'newResourceIdentifier' smart constructor.
data ResourceIdentifier = ResourceIdentifier'
  { -- | The resource type of a resource, such as @AWS::EC2::Instance@.
    ResourceIdentifier -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The ARN of a resource.
    ResourceIdentifier -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceIdentifier -> ResourceIdentifier -> Bool
(ResourceIdentifier -> ResourceIdentifier -> Bool)
-> (ResourceIdentifier -> ResourceIdentifier -> Bool)
-> Eq ResourceIdentifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceIdentifier -> ResourceIdentifier -> Bool
$c/= :: ResourceIdentifier -> ResourceIdentifier -> Bool
== :: ResourceIdentifier -> ResourceIdentifier -> Bool
$c== :: ResourceIdentifier -> ResourceIdentifier -> Bool
Prelude.Eq, ReadPrec [ResourceIdentifier]
ReadPrec ResourceIdentifier
Int -> ReadS ResourceIdentifier
ReadS [ResourceIdentifier]
(Int -> ReadS ResourceIdentifier)
-> ReadS [ResourceIdentifier]
-> ReadPrec ResourceIdentifier
-> ReadPrec [ResourceIdentifier]
-> Read ResourceIdentifier
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceIdentifier]
$creadListPrec :: ReadPrec [ResourceIdentifier]
readPrec :: ReadPrec ResourceIdentifier
$creadPrec :: ReadPrec ResourceIdentifier
readList :: ReadS [ResourceIdentifier]
$creadList :: ReadS [ResourceIdentifier]
readsPrec :: Int -> ReadS ResourceIdentifier
$creadsPrec :: Int -> ReadS ResourceIdentifier
Prelude.Read, Int -> ResourceIdentifier -> ShowS
[ResourceIdentifier] -> ShowS
ResourceIdentifier -> String
(Int -> ResourceIdentifier -> ShowS)
-> (ResourceIdentifier -> String)
-> ([ResourceIdentifier] -> ShowS)
-> Show ResourceIdentifier
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceIdentifier] -> ShowS
$cshowList :: [ResourceIdentifier] -> ShowS
show :: ResourceIdentifier -> String
$cshow :: ResourceIdentifier -> String
showsPrec :: Int -> ResourceIdentifier -> ShowS
$cshowsPrec :: Int -> ResourceIdentifier -> ShowS
Prelude.Show, (forall x. ResourceIdentifier -> Rep ResourceIdentifier x)
-> (forall x. Rep ResourceIdentifier x -> ResourceIdentifier)
-> Generic ResourceIdentifier
forall x. Rep ResourceIdentifier x -> ResourceIdentifier
forall x. ResourceIdentifier -> Rep ResourceIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceIdentifier x -> ResourceIdentifier
$cfrom :: forall x. ResourceIdentifier -> Rep ResourceIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'ResourceIdentifier' 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:
--
-- 'resourceType', 'resourceIdentifier_resourceType' - The resource type of a resource, such as @AWS::EC2::Instance@.
--
-- 'resourceArn', 'resourceIdentifier_resourceArn' - The ARN of a resource.
newResourceIdentifier ::
  ResourceIdentifier
newResourceIdentifier :: ResourceIdentifier
newResourceIdentifier =
  ResourceIdentifier' :: Maybe Text -> Maybe Text -> ResourceIdentifier
ResourceIdentifier'
    { $sel:resourceType:ResourceIdentifier' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:ResourceIdentifier' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The resource type of a resource, such as @AWS::EC2::Instance@.
resourceIdentifier_resourceType :: Lens.Lens' ResourceIdentifier (Prelude.Maybe Prelude.Text)
resourceIdentifier_resourceType :: (Maybe Text -> f (Maybe Text))
-> ResourceIdentifier -> f ResourceIdentifier
resourceIdentifier_resourceType = (ResourceIdentifier -> Maybe Text)
-> (ResourceIdentifier -> Maybe Text -> ResourceIdentifier)
-> Lens
     ResourceIdentifier ResourceIdentifier (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceIdentifier' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:ResourceIdentifier' :: ResourceIdentifier -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: ResourceIdentifier
s@ResourceIdentifier' {} Maybe Text
a -> ResourceIdentifier
s {$sel:resourceType:ResourceIdentifier' :: Maybe Text
resourceType = Maybe Text
a} :: ResourceIdentifier)

-- | The ARN of a resource.
resourceIdentifier_resourceArn :: Lens.Lens' ResourceIdentifier (Prelude.Maybe Prelude.Text)
resourceIdentifier_resourceArn :: (Maybe Text -> f (Maybe Text))
-> ResourceIdentifier -> f ResourceIdentifier
resourceIdentifier_resourceArn = (ResourceIdentifier -> Maybe Text)
-> (ResourceIdentifier -> Maybe Text -> ResourceIdentifier)
-> Lens
     ResourceIdentifier ResourceIdentifier (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceIdentifier' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:ResourceIdentifier' :: ResourceIdentifier -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: ResourceIdentifier
s@ResourceIdentifier' {} Maybe Text
a -> ResourceIdentifier
s {$sel:resourceArn:ResourceIdentifier' :: Maybe Text
resourceArn = Maybe Text
a} :: ResourceIdentifier)

instance Core.FromJSON ResourceIdentifier where
  parseJSON :: Value -> Parser ResourceIdentifier
parseJSON =
    String
-> (Object -> Parser ResourceIdentifier)
-> Value
-> Parser ResourceIdentifier
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceIdentifier"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ResourceIdentifier
ResourceIdentifier'
            (Maybe Text -> Maybe Text -> ResourceIdentifier)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ResourceIdentifier)
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
"ResourceType")
            Parser (Maybe Text -> ResourceIdentifier)
-> Parser (Maybe Text) -> Parser ResourceIdentifier
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
"ResourceArn")
      )

instance Prelude.Hashable ResourceIdentifier

instance Prelude.NFData ResourceIdentifier