{-# 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.IoTSiteWise.Types.PortalResource
-- 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.IoTSiteWise.Types.PortalResource 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

-- | Identifies an IoT SiteWise Monitor portal.
--
-- /See:/ 'newPortalResource' smart constructor.
data PortalResource = PortalResource'
  { -- | The ID of the portal.
    PortalResource -> Text
id :: Prelude.Text
  }
  deriving (PortalResource -> PortalResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortalResource -> PortalResource -> Bool
$c/= :: PortalResource -> PortalResource -> Bool
== :: PortalResource -> PortalResource -> Bool
$c== :: PortalResource -> PortalResource -> Bool
Prelude.Eq, ReadPrec [PortalResource]
ReadPrec PortalResource
Int -> ReadS PortalResource
ReadS [PortalResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortalResource]
$creadListPrec :: ReadPrec [PortalResource]
readPrec :: ReadPrec PortalResource
$creadPrec :: ReadPrec PortalResource
readList :: ReadS [PortalResource]
$creadList :: ReadS [PortalResource]
readsPrec :: Int -> ReadS PortalResource
$creadsPrec :: Int -> ReadS PortalResource
Prelude.Read, Int -> PortalResource -> ShowS
[PortalResource] -> ShowS
PortalResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortalResource] -> ShowS
$cshowList :: [PortalResource] -> ShowS
show :: PortalResource -> String
$cshow :: PortalResource -> String
showsPrec :: Int -> PortalResource -> ShowS
$cshowsPrec :: Int -> PortalResource -> ShowS
Prelude.Show, forall x. Rep PortalResource x -> PortalResource
forall x. PortalResource -> Rep PortalResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortalResource x -> PortalResource
$cfrom :: forall x. PortalResource -> Rep PortalResource x
Prelude.Generic)

-- |
-- Create a value of 'PortalResource' 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:
--
-- 'id', 'portalResource_id' - The ID of the portal.
newPortalResource ::
  -- | 'id'
  Prelude.Text ->
  PortalResource
newPortalResource :: Text -> PortalResource
newPortalResource Text
pId_ = PortalResource' {$sel:id:PortalResource' :: Text
id = Text
pId_}

-- | The ID of the portal.
portalResource_id :: Lens.Lens' PortalResource Prelude.Text
portalResource_id :: Lens' PortalResource Text
portalResource_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortalResource' {Text
id :: Text
$sel:id:PortalResource' :: PortalResource -> Text
id} -> Text
id) (\s :: PortalResource
s@PortalResource' {} Text
a -> PortalResource
s {$sel:id:PortalResource' :: Text
id = Text
a} :: PortalResource)

instance Data.FromJSON PortalResource where
  parseJSON :: Value -> Parser PortalResource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PortalResource"
      (\Object
x -> Text -> PortalResource
PortalResource' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"id"))

instance Prelude.Hashable PortalResource where
  hashWithSalt :: Int -> PortalResource -> Int
hashWithSalt Int
_salt PortalResource' {Text
id :: Text
$sel:id:PortalResource' :: PortalResource -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData PortalResource where
  rnf :: PortalResource -> ()
rnf PortalResource' {Text
id :: Text
$sel:id:PortalResource' :: PortalResource -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToJSON PortalResource where
  toJSON :: PortalResource -> Value
toJSON PortalResource' {Text
id :: Text
$sel:id:PortalResource' :: PortalResource -> Text
..} =
    [Pair] -> Value
Data.object
      (forall a. [Maybe a] -> [a]
Prelude.catMaybes [forall a. a -> Maybe a
Prelude.Just (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)])