{-# 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.FMS.Types.Resource
-- 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.FMS.Types.Resource 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

-- | Details of a resource that is associated to an Firewall Manager resource
-- set.
--
-- /See:/ 'newResource' smart constructor.
data Resource = Resource'
  { -- | The Amazon Web Services account ID that the associated resource belongs
    -- to.
    Resource -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The resource\'s universal resource indicator (URI).
    Resource -> Text
uri :: Prelude.Text
  }
  deriving (Resource -> Resource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Resource -> Resource -> Bool
$c/= :: Resource -> Resource -> Bool
== :: Resource -> Resource -> Bool
$c== :: Resource -> Resource -> Bool
Prelude.Eq, ReadPrec [Resource]
ReadPrec Resource
Int -> ReadS Resource
ReadS [Resource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Resource]
$creadListPrec :: ReadPrec [Resource]
readPrec :: ReadPrec Resource
$creadPrec :: ReadPrec Resource
readList :: ReadS [Resource]
$creadList :: ReadS [Resource]
readsPrec :: Int -> ReadS Resource
$creadsPrec :: Int -> ReadS Resource
Prelude.Read, Int -> Resource -> ShowS
[Resource] -> ShowS
Resource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Resource] -> ShowS
$cshowList :: [Resource] -> ShowS
show :: Resource -> String
$cshow :: Resource -> String
showsPrec :: Int -> Resource -> ShowS
$cshowsPrec :: Int -> Resource -> ShowS
Prelude.Show, forall x. Rep Resource x -> Resource
forall x. Resource -> Rep Resource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Resource x -> Resource
$cfrom :: forall x. Resource -> Rep Resource x
Prelude.Generic)

-- |
-- Create a value of 'Resource' 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', 'resource_accountId' - The Amazon Web Services account ID that the associated resource belongs
-- to.
--
-- 'uri', 'resource_uri' - The resource\'s universal resource indicator (URI).
newResource ::
  -- | 'uri'
  Prelude.Text ->
  Resource
newResource :: Text -> Resource
newResource Text
pURI_ =
  Resource' {$sel:accountId:Resource' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing, $sel:uri:Resource' :: Text
uri = Text
pURI_}

-- | The Amazon Web Services account ID that the associated resource belongs
-- to.
resource_accountId :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_accountId :: Lens' Resource (Maybe Text)
resource_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
accountId :: Maybe Text
$sel:accountId:Resource' :: Resource -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:accountId:Resource' :: Maybe Text
accountId = Maybe Text
a} :: Resource)

-- | The resource\'s universal resource indicator (URI).
resource_uri :: Lens.Lens' Resource Prelude.Text
resource_uri :: Lens' Resource Text
resource_uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Text
uri :: Text
$sel:uri:Resource' :: Resource -> Text
uri} -> Text
uri) (\s :: Resource
s@Resource' {} Text
a -> Resource
s {$sel:uri:Resource' :: Text
uri = Text
a} :: Resource)

instance Data.FromJSON Resource where
  parseJSON :: Value -> Parser Resource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Resource"
      ( \Object
x ->
          Maybe Text -> Text -> Resource
Resource'
            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 a
Data..: Key
"URI")
      )

instance Prelude.Hashable Resource where
  hashWithSalt :: Int -> Resource -> Int
hashWithSalt Int
_salt Resource' {Maybe Text
Text
uri :: Text
accountId :: Maybe Text
$sel:uri:Resource' :: Resource -> Text
$sel:accountId:Resource' :: Resource -> 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` Text
uri

instance Prelude.NFData Resource where
  rnf :: Resource -> ()
rnf Resource' {Maybe Text
Text
uri :: Text
accountId :: Maybe Text
$sel:uri:Resource' :: Resource -> Text
$sel:accountId:Resource' :: Resource -> 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 Text
uri