{-# 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.ServiceCatalogAppRegistry.Types.Resource
-- 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.ServiceCatalogAppRegistry.Types.Resource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ServiceCatalogAppRegistry.Types.ResourceIntegrations

-- | The information about the resource.
--
-- /See:/ 'newResource' smart constructor.
data Resource = Resource'
  { -- | The Amazon resource name (ARN) of the resource.
    Resource -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The service integration information about the resource.
    Resource -> Maybe ResourceIntegrations
integrations :: Prelude.Maybe ResourceIntegrations,
    -- | The time the resource was associated with the application.
    Resource -> Maybe POSIX
associationTime :: Prelude.Maybe Core.POSIX,
    -- | The name of the resource.
    Resource -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Resource -> Resource -> Bool
(Resource -> Resource -> Bool)
-> (Resource -> Resource -> Bool) -> Eq Resource
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]
(Int -> ReadS Resource)
-> ReadS [Resource]
-> ReadPrec Resource
-> ReadPrec [Resource]
-> Read 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
(Int -> Resource -> ShowS)
-> (Resource -> String) -> ([Resource] -> ShowS) -> Show Resource
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. Resource -> Rep Resource x)
-> (forall x. Rep Resource x -> Resource) -> Generic Resource
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 Amazon resource name (ARN) of the resource.
--
-- 'integrations', 'resource_integrations' - The service integration information about the resource.
--
-- 'associationTime', 'resource_associationTime' - The time the resource was associated with the application.
--
-- 'name', 'resource_name' - The name of the resource.
newResource ::
  Resource
newResource :: Resource
newResource =
  Resource' :: Maybe Text
-> Maybe ResourceIntegrations
-> Maybe POSIX
-> Maybe Text
-> Resource
Resource'
    { $sel:arn:Resource' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:integrations:Resource' :: Maybe ResourceIntegrations
integrations = Maybe ResourceIntegrations
forall a. Maybe a
Prelude.Nothing,
      $sel:associationTime:Resource' :: Maybe POSIX
associationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Resource' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon resource name (ARN) of the resource.
resource_arn :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_arn :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_arn = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
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 service integration information about the resource.
resource_integrations :: Lens.Lens' Resource (Prelude.Maybe ResourceIntegrations)
resource_integrations :: (Maybe ResourceIntegrations -> f (Maybe ResourceIntegrations))
-> Resource -> f Resource
resource_integrations = (Resource -> Maybe ResourceIntegrations)
-> (Resource -> Maybe ResourceIntegrations -> Resource)
-> Lens
     Resource
     Resource
     (Maybe ResourceIntegrations)
     (Maybe ResourceIntegrations)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe ResourceIntegrations
integrations :: Maybe ResourceIntegrations
$sel:integrations:Resource' :: Resource -> Maybe ResourceIntegrations
integrations} -> Maybe ResourceIntegrations
integrations) (\s :: Resource
s@Resource' {} Maybe ResourceIntegrations
a -> Resource
s {$sel:integrations:Resource' :: Maybe ResourceIntegrations
integrations = Maybe ResourceIntegrations
a} :: Resource)

-- | The time the resource was associated with the application.
resource_associationTime :: Lens.Lens' Resource (Prelude.Maybe Prelude.UTCTime)
resource_associationTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Resource -> f Resource
resource_associationTime = (Resource -> Maybe POSIX)
-> (Resource -> Maybe POSIX -> Resource)
-> Lens Resource Resource (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe POSIX
associationTime :: Maybe POSIX
$sel:associationTime:Resource' :: Resource -> Maybe POSIX
associationTime} -> Maybe POSIX
associationTime) (\s :: Resource
s@Resource' {} Maybe POSIX
a -> Resource
s {$sel:associationTime:Resource' :: Maybe POSIX
associationTime = Maybe POSIX
a} :: Resource) ((Maybe POSIX -> f (Maybe POSIX)) -> Resource -> f Resource)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Resource
-> f Resource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Core.FromJSON Resource where
  parseJSON :: Value -> Parser Resource
parseJSON =
    String -> (Object -> Parser Resource) -> Value -> Parser Resource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Resource"
      ( \Object
x ->
          Maybe Text
-> Maybe ResourceIntegrations
-> Maybe POSIX
-> Maybe Text
-> Resource
Resource'
            (Maybe Text
 -> Maybe ResourceIntegrations
 -> Maybe POSIX
 -> Maybe Text
 -> Resource)
-> Parser (Maybe Text)
-> Parser
     (Maybe ResourceIntegrations
      -> Maybe POSIX -> Maybe Text -> Resource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"arn")
            Parser
  (Maybe ResourceIntegrations
   -> Maybe POSIX -> Maybe Text -> Resource)
-> Parser (Maybe ResourceIntegrations)
-> Parser (Maybe POSIX -> Maybe Text -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResourceIntegrations)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"integrations")
            Parser (Maybe POSIX -> Maybe Text -> Resource)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"associationTime")
            Parser (Maybe Text -> Resource)
-> Parser (Maybe Text) -> Parser Resource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"name")
      )

instance Prelude.Hashable Resource

instance Prelude.NFData Resource