{-# 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.IoT.Types.RelatedResource
-- 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.IoT.Types.RelatedResource where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.ResourceIdentifier
import Amazonka.IoT.Types.ResourceType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a related resource.
--
-- /See:/ 'newRelatedResource' smart constructor.
data RelatedResource = RelatedResource'
  { -- | Other information about the resource.
    RelatedResource -> Maybe (HashMap Text Text)
additionalInfo :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The type of resource.
    RelatedResource -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | Information that identifies the resource.
    RelatedResource -> Maybe ResourceIdentifier
resourceIdentifier :: Prelude.Maybe ResourceIdentifier
  }
  deriving (RelatedResource -> RelatedResource -> Bool
(RelatedResource -> RelatedResource -> Bool)
-> (RelatedResource -> RelatedResource -> Bool)
-> Eq RelatedResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelatedResource -> RelatedResource -> Bool
$c/= :: RelatedResource -> RelatedResource -> Bool
== :: RelatedResource -> RelatedResource -> Bool
$c== :: RelatedResource -> RelatedResource -> Bool
Prelude.Eq, ReadPrec [RelatedResource]
ReadPrec RelatedResource
Int -> ReadS RelatedResource
ReadS [RelatedResource]
(Int -> ReadS RelatedResource)
-> ReadS [RelatedResource]
-> ReadPrec RelatedResource
-> ReadPrec [RelatedResource]
-> Read RelatedResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelatedResource]
$creadListPrec :: ReadPrec [RelatedResource]
readPrec :: ReadPrec RelatedResource
$creadPrec :: ReadPrec RelatedResource
readList :: ReadS [RelatedResource]
$creadList :: ReadS [RelatedResource]
readsPrec :: Int -> ReadS RelatedResource
$creadsPrec :: Int -> ReadS RelatedResource
Prelude.Read, Int -> RelatedResource -> ShowS
[RelatedResource] -> ShowS
RelatedResource -> String
(Int -> RelatedResource -> ShowS)
-> (RelatedResource -> String)
-> ([RelatedResource] -> ShowS)
-> Show RelatedResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelatedResource] -> ShowS
$cshowList :: [RelatedResource] -> ShowS
show :: RelatedResource -> String
$cshow :: RelatedResource -> String
showsPrec :: Int -> RelatedResource -> ShowS
$cshowsPrec :: Int -> RelatedResource -> ShowS
Prelude.Show, (forall x. RelatedResource -> Rep RelatedResource x)
-> (forall x. Rep RelatedResource x -> RelatedResource)
-> Generic RelatedResource
forall x. Rep RelatedResource x -> RelatedResource
forall x. RelatedResource -> Rep RelatedResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RelatedResource x -> RelatedResource
$cfrom :: forall x. RelatedResource -> Rep RelatedResource x
Prelude.Generic)

-- |
-- Create a value of 'RelatedResource' 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:
--
-- 'additionalInfo', 'relatedResource_additionalInfo' - Other information about the resource.
--
-- 'resourceType', 'relatedResource_resourceType' - The type of resource.
--
-- 'resourceIdentifier', 'relatedResource_resourceIdentifier' - Information that identifies the resource.
newRelatedResource ::
  RelatedResource
newRelatedResource :: RelatedResource
newRelatedResource =
  RelatedResource' :: Maybe (HashMap Text Text)
-> Maybe ResourceType
-> Maybe ResourceIdentifier
-> RelatedResource
RelatedResource'
    { $sel:additionalInfo:RelatedResource' :: Maybe (HashMap Text Text)
additionalInfo = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:RelatedResource' :: Maybe ResourceType
resourceType = Maybe ResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceIdentifier:RelatedResource' :: Maybe ResourceIdentifier
resourceIdentifier = Maybe ResourceIdentifier
forall a. Maybe a
Prelude.Nothing
    }

-- | Other information about the resource.
relatedResource_additionalInfo :: Lens.Lens' RelatedResource (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
relatedResource_additionalInfo :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> RelatedResource -> f RelatedResource
relatedResource_additionalInfo = (RelatedResource -> Maybe (HashMap Text Text))
-> (RelatedResource
    -> Maybe (HashMap Text Text) -> RelatedResource)
-> Lens
     RelatedResource
     RelatedResource
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelatedResource' {Maybe (HashMap Text Text)
additionalInfo :: Maybe (HashMap Text Text)
$sel:additionalInfo:RelatedResource' :: RelatedResource -> Maybe (HashMap Text Text)
additionalInfo} -> Maybe (HashMap Text Text)
additionalInfo) (\s :: RelatedResource
s@RelatedResource' {} Maybe (HashMap Text Text)
a -> RelatedResource
s {$sel:additionalInfo:RelatedResource' :: Maybe (HashMap Text Text)
additionalInfo = Maybe (HashMap Text Text)
a} :: RelatedResource) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> RelatedResource -> f RelatedResource)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> RelatedResource
-> f RelatedResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of resource.
relatedResource_resourceType :: Lens.Lens' RelatedResource (Prelude.Maybe ResourceType)
relatedResource_resourceType :: (Maybe ResourceType -> f (Maybe ResourceType))
-> RelatedResource -> f RelatedResource
relatedResource_resourceType = (RelatedResource -> Maybe ResourceType)
-> (RelatedResource -> Maybe ResourceType -> RelatedResource)
-> Lens
     RelatedResource
     RelatedResource
     (Maybe ResourceType)
     (Maybe ResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelatedResource' {Maybe ResourceType
resourceType :: Maybe ResourceType
$sel:resourceType:RelatedResource' :: RelatedResource -> Maybe ResourceType
resourceType} -> Maybe ResourceType
resourceType) (\s :: RelatedResource
s@RelatedResource' {} Maybe ResourceType
a -> RelatedResource
s {$sel:resourceType:RelatedResource' :: Maybe ResourceType
resourceType = Maybe ResourceType
a} :: RelatedResource)

-- | Information that identifies the resource.
relatedResource_resourceIdentifier :: Lens.Lens' RelatedResource (Prelude.Maybe ResourceIdentifier)
relatedResource_resourceIdentifier :: (Maybe ResourceIdentifier -> f (Maybe ResourceIdentifier))
-> RelatedResource -> f RelatedResource
relatedResource_resourceIdentifier = (RelatedResource -> Maybe ResourceIdentifier)
-> (RelatedResource -> Maybe ResourceIdentifier -> RelatedResource)
-> Lens
     RelatedResource
     RelatedResource
     (Maybe ResourceIdentifier)
     (Maybe ResourceIdentifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelatedResource' {Maybe ResourceIdentifier
resourceIdentifier :: Maybe ResourceIdentifier
$sel:resourceIdentifier:RelatedResource' :: RelatedResource -> Maybe ResourceIdentifier
resourceIdentifier} -> Maybe ResourceIdentifier
resourceIdentifier) (\s :: RelatedResource
s@RelatedResource' {} Maybe ResourceIdentifier
a -> RelatedResource
s {$sel:resourceIdentifier:RelatedResource' :: Maybe ResourceIdentifier
resourceIdentifier = Maybe ResourceIdentifier
a} :: RelatedResource)

instance Core.FromJSON RelatedResource where
  parseJSON :: Value -> Parser RelatedResource
parseJSON =
    String
-> (Object -> Parser RelatedResource)
-> Value
-> Parser RelatedResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RelatedResource"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe ResourceType
-> Maybe ResourceIdentifier
-> RelatedResource
RelatedResource'
            (Maybe (HashMap Text Text)
 -> Maybe ResourceType
 -> Maybe ResourceIdentifier
 -> RelatedResource)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe ResourceType -> Maybe ResourceIdentifier -> RelatedResource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"additionalInfo" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe ResourceType -> Maybe ResourceIdentifier -> RelatedResource)
-> Parser (Maybe ResourceType)
-> Parser (Maybe ResourceIdentifier -> RelatedResource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceType")
            Parser (Maybe ResourceIdentifier -> RelatedResource)
-> Parser (Maybe ResourceIdentifier) -> Parser RelatedResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResourceIdentifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceIdentifier")
      )

instance Prelude.Hashable RelatedResource

instance Prelude.NFData RelatedResource