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

-- | A resource in Amazon Web Services that Amazon Web Services Resource
-- Explorer has discovered, and for which it has stored information in the
-- index of the Amazon Web Services Region that contains the resource.
--
-- /See:/ 'newResource' smart constructor.
data Resource = Resource'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
    -- of the resource.
    Resource -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The date and time that Resource Explorer last queried this resource and
    -- updated the index with the latest information about the resource.
    Resource -> Maybe ISO8601
lastReportedAt :: Prelude.Maybe Data.ISO8601,
    -- | The Amazon Web Services account that owns the resource.
    Resource -> Maybe Text
owningAccountId :: Prelude.Maybe Prelude.Text,
    -- | A structure with additional type-specific details about the resource.
    -- These properties can be added by turning on integration between Resource
    -- Explorer and other Amazon Web Services services.
    Resource -> Maybe [ResourceProperty]
properties :: Prelude.Maybe [ResourceProperty],
    -- | The Amazon Web Services Region in which the resource was created and
    -- exists.
    Resource -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | The type of the resource.
    Resource -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Service that owns the resource and is responsible for
    -- creating and updating it.
    Resource -> Maybe Text
service :: Prelude.Maybe 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:
--
-- 'arn', 'resource_arn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
-- of the resource.
--
-- 'lastReportedAt', 'resource_lastReportedAt' - The date and time that Resource Explorer last queried this resource and
-- updated the index with the latest information about the resource.
--
-- 'owningAccountId', 'resource_owningAccountId' - The Amazon Web Services account that owns the resource.
--
-- 'properties', 'resource_properties' - A structure with additional type-specific details about the resource.
-- These properties can be added by turning on integration between Resource
-- Explorer and other Amazon Web Services services.
--
-- 'region', 'resource_region' - The Amazon Web Services Region in which the resource was created and
-- exists.
--
-- 'resourceType', 'resource_resourceType' - The type of the resource.
--
-- 'service', 'resource_service' - The Amazon Web Service that owns the resource and is responsible for
-- creating and updating it.
newResource ::
  Resource
newResource :: Resource
newResource =
  Resource'
    { $sel:arn:Resource' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:lastReportedAt:Resource' :: Maybe ISO8601
lastReportedAt = forall a. Maybe a
Prelude.Nothing,
      $sel:owningAccountId:Resource' :: Maybe Text
owningAccountId = forall a. Maybe a
Prelude.Nothing,
      $sel:properties:Resource' :: Maybe [ResourceProperty]
properties = forall a. Maybe a
Prelude.Nothing,
      $sel:region:Resource' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:Resource' :: Maybe Text
resourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:service:Resource' :: Maybe Text
service = forall a. Maybe a
Prelude.Nothing
    }

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
-- of the resource.
resource_arn :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_arn :: Lens' Resource (Maybe Text)
resource_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
arn :: Maybe Text
$sel:arn:Resource' :: Resource -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:arn:Resource' :: Maybe Text
arn = Maybe Text
a} :: Resource)

-- | The date and time that Resource Explorer last queried this resource and
-- updated the index with the latest information about the resource.
resource_lastReportedAt :: Lens.Lens' Resource (Prelude.Maybe Prelude.UTCTime)
resource_lastReportedAt :: Lens' Resource (Maybe UTCTime)
resource_lastReportedAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe ISO8601
lastReportedAt :: Maybe ISO8601
$sel:lastReportedAt:Resource' :: Resource -> Maybe ISO8601
lastReportedAt} -> Maybe ISO8601
lastReportedAt) (\s :: Resource
s@Resource' {} Maybe ISO8601
a -> Resource
s {$sel:lastReportedAt:Resource' :: Maybe ISO8601
lastReportedAt = Maybe ISO8601
a} :: Resource) 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 Amazon Web Services account that owns the resource.
resource_owningAccountId :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_owningAccountId :: Lens' Resource (Maybe Text)
resource_owningAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
owningAccountId :: Maybe Text
$sel:owningAccountId:Resource' :: Resource -> Maybe Text
owningAccountId} -> Maybe Text
owningAccountId) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:owningAccountId:Resource' :: Maybe Text
owningAccountId = Maybe Text
a} :: Resource)

-- | A structure with additional type-specific details about the resource.
-- These properties can be added by turning on integration between Resource
-- Explorer and other Amazon Web Services services.
resource_properties :: Lens.Lens' Resource (Prelude.Maybe [ResourceProperty])
resource_properties :: Lens' Resource (Maybe [ResourceProperty])
resource_properties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe [ResourceProperty]
properties :: Maybe [ResourceProperty]
$sel:properties:Resource' :: Resource -> Maybe [ResourceProperty]
properties} -> Maybe [ResourceProperty]
properties) (\s :: Resource
s@Resource' {} Maybe [ResourceProperty]
a -> Resource
s {$sel:properties:Resource' :: Maybe [ResourceProperty]
properties = Maybe [ResourceProperty]
a} :: Resource) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Web Services Region in which the resource was created and
-- exists.
resource_region :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_region :: Lens' Resource (Maybe Text)
resource_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
region :: Maybe Text
$sel:region:Resource' :: Resource -> Maybe Text
region} -> Maybe Text
region) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:region:Resource' :: Maybe Text
region = Maybe Text
a} :: Resource)

-- | The type of the resource.
resource_resourceType :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_resourceType :: Lens' Resource (Maybe Text)
resource_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:Resource' :: Resource -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:resourceType:Resource' :: Maybe Text
resourceType = Maybe Text
a} :: Resource)

-- | The Amazon Web Service that owns the resource and is responsible for
-- creating and updating it.
resource_service :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_service :: Lens' Resource (Maybe Text)
resource_service = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
service :: Maybe Text
$sel:service:Resource' :: Resource -> Maybe Text
service} -> Maybe Text
service) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:service:Resource' :: Maybe Text
service = Maybe 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
-> Maybe ISO8601
-> Maybe Text
-> Maybe [ResourceProperty]
-> Maybe Text
-> Maybe Text
-> Maybe 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
"Arn")
            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
"OwningAccountId")
            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
"Properties" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Region")
            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
"ResourceType")
            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
"Service")
      )

instance Prelude.Hashable Resource where
  hashWithSalt :: Int -> Resource -> Int
hashWithSalt Int
_salt Resource' {Maybe [ResourceProperty]
Maybe Text
Maybe ISO8601
service :: Maybe Text
resourceType :: Maybe Text
region :: Maybe Text
properties :: Maybe [ResourceProperty]
owningAccountId :: Maybe Text
lastReportedAt :: Maybe ISO8601
arn :: Maybe Text
$sel:service:Resource' :: Resource -> Maybe Text
$sel:resourceType:Resource' :: Resource -> Maybe Text
$sel:region:Resource' :: Resource -> Maybe Text
$sel:properties:Resource' :: Resource -> Maybe [ResourceProperty]
$sel:owningAccountId:Resource' :: Resource -> Maybe Text
$sel:lastReportedAt:Resource' :: Resource -> Maybe ISO8601
$sel:arn:Resource' :: Resource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
lastReportedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
owningAccountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ResourceProperty]
properties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
service

instance Prelude.NFData Resource where
  rnf :: Resource -> ()
rnf Resource' {Maybe [ResourceProperty]
Maybe Text
Maybe ISO8601
service :: Maybe Text
resourceType :: Maybe Text
region :: Maybe Text
properties :: Maybe [ResourceProperty]
owningAccountId :: Maybe Text
lastReportedAt :: Maybe ISO8601
arn :: Maybe Text
$sel:service:Resource' :: Resource -> Maybe Text
$sel:resourceType:Resource' :: Resource -> Maybe Text
$sel:region:Resource' :: Resource -> Maybe Text
$sel:properties:Resource' :: Resource -> Maybe [ResourceProperty]
$sel:owningAccountId:Resource' :: Resource -> Maybe Text
$sel:lastReportedAt:Resource' :: Resource -> Maybe ISO8601
$sel:arn:Resource' :: Resource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      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
owningAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ResourceProperty]
properties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
service