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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(PortalResource -> PortalResource -> Bool)
-> (PortalResource -> PortalResource -> Bool) -> Eq PortalResource
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]
(Int -> ReadS PortalResource)
-> ReadS [PortalResource]
-> ReadPrec PortalResource
-> ReadPrec [PortalResource]
-> Read 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
(Int -> PortalResource -> ShowS)
-> (PortalResource -> String)
-> ([PortalResource] -> ShowS)
-> Show PortalResource
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. PortalResource -> Rep PortalResource x)
-> (forall x. Rep PortalResource x -> PortalResource)
-> Generic PortalResource
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' :: Text -> PortalResource
PortalResource' {$sel:id:PortalResource' :: Text
id = Text
pId_}

-- | The ID of the portal.
portalResource_id :: Lens.Lens' PortalResource Prelude.Text
portalResource_id :: (Text -> f Text) -> PortalResource -> f PortalResource
portalResource_id = (PortalResource -> Text)
-> (PortalResource -> Text -> PortalResource)
-> Lens PortalResource PortalResource Text Text
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 Core.FromJSON PortalResource where
  parseJSON :: Value -> Parser PortalResource
parseJSON =
    String
-> (Object -> Parser PortalResource)
-> Value
-> Parser PortalResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PortalResource"
      (\Object
x -> Text -> PortalResource
PortalResource' (Text -> PortalResource) -> Parser Text -> Parser PortalResource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"id"))

instance Prelude.Hashable PortalResource

instance Prelude.NFData PortalResource

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