{-# 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.ResourceExplorer2.Types.ResourceProperty
-- 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.ResourceExplorer2.Types.ResourceProperty 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
import Amazonka.ResourceExplorer2.Types.Document

-- | A structure that describes a property of a resource.
--
-- /See:/ 'newResourceProperty' smart constructor.
data ResourceProperty = ResourceProperty'
  { -- | Details about this property. The content of this field is a JSON object
    -- that varies based on the resource type.
    ResourceProperty -> Maybe Document
data' :: Prelude.Maybe Document,
    -- | The date and time that the information about this resource property was
    -- last updated.
    ResourceProperty -> Maybe ISO8601
lastReportedAt :: Prelude.Maybe Data.ISO8601,
    -- | The name of this property of the resource.
    ResourceProperty -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceProperty -> ResourceProperty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceProperty -> ResourceProperty -> Bool
$c/= :: ResourceProperty -> ResourceProperty -> Bool
== :: ResourceProperty -> ResourceProperty -> Bool
$c== :: ResourceProperty -> ResourceProperty -> Bool
Prelude.Eq, ReadPrec [ResourceProperty]
ReadPrec ResourceProperty
Int -> ReadS ResourceProperty
ReadS [ResourceProperty]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceProperty]
$creadListPrec :: ReadPrec [ResourceProperty]
readPrec :: ReadPrec ResourceProperty
$creadPrec :: ReadPrec ResourceProperty
readList :: ReadS [ResourceProperty]
$creadList :: ReadS [ResourceProperty]
readsPrec :: Int -> ReadS ResourceProperty
$creadsPrec :: Int -> ReadS ResourceProperty
Prelude.Read, Int -> ResourceProperty -> ShowS
[ResourceProperty] -> ShowS
ResourceProperty -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceProperty] -> ShowS
$cshowList :: [ResourceProperty] -> ShowS
show :: ResourceProperty -> String
$cshow :: ResourceProperty -> String
showsPrec :: Int -> ResourceProperty -> ShowS
$cshowsPrec :: Int -> ResourceProperty -> ShowS
Prelude.Show, forall x. Rep ResourceProperty x -> ResourceProperty
forall x. ResourceProperty -> Rep ResourceProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceProperty x -> ResourceProperty
$cfrom :: forall x. ResourceProperty -> Rep ResourceProperty x
Prelude.Generic)

-- |
-- Create a value of 'ResourceProperty' 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:
--
-- 'data'', 'resourceProperty_data' - Details about this property. The content of this field is a JSON object
-- that varies based on the resource type.
--
-- 'lastReportedAt', 'resourceProperty_lastReportedAt' - The date and time that the information about this resource property was
-- last updated.
--
-- 'name', 'resourceProperty_name' - The name of this property of the resource.
newResourceProperty ::
  ResourceProperty
newResourceProperty :: ResourceProperty
newResourceProperty =
  ResourceProperty'
    { $sel:data':ResourceProperty' :: Maybe Document
data' = forall a. Maybe a
Prelude.Nothing,
      $sel:lastReportedAt:ResourceProperty' :: Maybe ISO8601
lastReportedAt = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ResourceProperty' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | Details about this property. The content of this field is a JSON object
-- that varies based on the resource type.
resourceProperty_data :: Lens.Lens' ResourceProperty (Prelude.Maybe Document)
resourceProperty_data :: Lens' ResourceProperty (Maybe Document)
resourceProperty_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceProperty' {Maybe Document
data' :: Maybe Document
$sel:data':ResourceProperty' :: ResourceProperty -> Maybe Document
data'} -> Maybe Document
data') (\s :: ResourceProperty
s@ResourceProperty' {} Maybe Document
a -> ResourceProperty
s {$sel:data':ResourceProperty' :: Maybe Document
data' = Maybe Document
a} :: ResourceProperty)

-- | The date and time that the information about this resource property was
-- last updated.
resourceProperty_lastReportedAt :: Lens.Lens' ResourceProperty (Prelude.Maybe Prelude.UTCTime)
resourceProperty_lastReportedAt :: Lens' ResourceProperty (Maybe UTCTime)
resourceProperty_lastReportedAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceProperty' {Maybe ISO8601
lastReportedAt :: Maybe ISO8601
$sel:lastReportedAt:ResourceProperty' :: ResourceProperty -> Maybe ISO8601
lastReportedAt} -> Maybe ISO8601
lastReportedAt) (\s :: ResourceProperty
s@ResourceProperty' {} Maybe ISO8601
a -> ResourceProperty
s {$sel:lastReportedAt:ResourceProperty' :: Maybe ISO8601
lastReportedAt = Maybe ISO8601
a} :: ResourceProperty) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of this property of the resource.
resourceProperty_name :: Lens.Lens' ResourceProperty (Prelude.Maybe Prelude.Text)
resourceProperty_name :: Lens' ResourceProperty (Maybe Text)
resourceProperty_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceProperty' {Maybe Text
name :: Maybe Text
$sel:name:ResourceProperty' :: ResourceProperty -> Maybe Text
name} -> Maybe Text
name) (\s :: ResourceProperty
s@ResourceProperty' {} Maybe Text
a -> ResourceProperty
s {$sel:name:ResourceProperty' :: Maybe Text
name = Maybe Text
a} :: ResourceProperty)

instance Data.FromJSON ResourceProperty where
  parseJSON :: Value -> Parser ResourceProperty
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceProperty"
      ( \Object
x ->
          Maybe Document -> Maybe ISO8601 -> Maybe Text -> ResourceProperty
ResourceProperty'
            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
"Data")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LastReportedAt")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
      )

instance Prelude.Hashable ResourceProperty where
  hashWithSalt :: Int -> ResourceProperty -> Int
hashWithSalt Int
_salt ResourceProperty' {Maybe Text
Maybe ISO8601
Maybe Document
name :: Maybe Text
lastReportedAt :: Maybe ISO8601
data' :: Maybe Document
$sel:name:ResourceProperty' :: ResourceProperty -> Maybe Text
$sel:lastReportedAt:ResourceProperty' :: ResourceProperty -> Maybe ISO8601
$sel:data':ResourceProperty' :: ResourceProperty -> Maybe Document
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Document
data'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
lastReportedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData ResourceProperty where
  rnf :: ResourceProperty -> ()
rnf ResourceProperty' {Maybe Text
Maybe ISO8601
Maybe Document
name :: Maybe Text
lastReportedAt :: Maybe ISO8601
data' :: Maybe Document
$sel:name:ResourceProperty' :: ResourceProperty -> Maybe Text
$sel:lastReportedAt:ResourceProperty' :: ResourceProperty -> Maybe ISO8601
$sel:data':ResourceProperty' :: ResourceProperty -> Maybe Document
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Document
data'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
lastReportedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name