{-# 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.Glue.Types.ResourceUri
-- 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.Glue.Types.ResourceUri where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.ResourceType
import qualified Amazonka.Prelude as Prelude

-- | The URIs for function resources.
--
-- /See:/ 'newResourceUri' smart constructor.
data ResourceUri = ResourceUri'
  { -- | The type of the resource.
    ResourceUri -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | The URI for accessing the resource.
    ResourceUri -> Maybe Text
uri :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceUri -> ResourceUri -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceUri -> ResourceUri -> Bool
$c/= :: ResourceUri -> ResourceUri -> Bool
== :: ResourceUri -> ResourceUri -> Bool
$c== :: ResourceUri -> ResourceUri -> Bool
Prelude.Eq, ReadPrec [ResourceUri]
ReadPrec ResourceUri
Int -> ReadS ResourceUri
ReadS [ResourceUri]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceUri]
$creadListPrec :: ReadPrec [ResourceUri]
readPrec :: ReadPrec ResourceUri
$creadPrec :: ReadPrec ResourceUri
readList :: ReadS [ResourceUri]
$creadList :: ReadS [ResourceUri]
readsPrec :: Int -> ReadS ResourceUri
$creadsPrec :: Int -> ReadS ResourceUri
Prelude.Read, Int -> ResourceUri -> ShowS
[ResourceUri] -> ShowS
ResourceUri -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceUri] -> ShowS
$cshowList :: [ResourceUri] -> ShowS
show :: ResourceUri -> String
$cshow :: ResourceUri -> String
showsPrec :: Int -> ResourceUri -> ShowS
$cshowsPrec :: Int -> ResourceUri -> ShowS
Prelude.Show, forall x. Rep ResourceUri x -> ResourceUri
forall x. ResourceUri -> Rep ResourceUri x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceUri x -> ResourceUri
$cfrom :: forall x. ResourceUri -> Rep ResourceUri x
Prelude.Generic)

-- |
-- Create a value of 'ResourceUri' 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:
--
-- 'resourceType', 'resourceUri_resourceType' - The type of the resource.
--
-- 'uri', 'resourceUri_uri' - The URI for accessing the resource.
newResourceUri ::
  ResourceUri
newResourceUri :: ResourceUri
newResourceUri =
  ResourceUri'
    { $sel:resourceType:ResourceUri' :: Maybe ResourceType
resourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:uri:ResourceUri' :: Maybe Text
uri = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The URI for accessing the resource.
resourceUri_uri :: Lens.Lens' ResourceUri (Prelude.Maybe Prelude.Text)
resourceUri_uri :: Lens' ResourceUri (Maybe Text)
resourceUri_uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceUri' {Maybe Text
uri :: Maybe Text
$sel:uri:ResourceUri' :: ResourceUri -> Maybe Text
uri} -> Maybe Text
uri) (\s :: ResourceUri
s@ResourceUri' {} Maybe Text
a -> ResourceUri
s {$sel:uri:ResourceUri' :: Maybe Text
uri = Maybe Text
a} :: ResourceUri)

instance Data.FromJSON ResourceUri where
  parseJSON :: Value -> Parser ResourceUri
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceUri"
      ( \Object
x ->
          Maybe ResourceType -> Maybe Text -> ResourceUri
ResourceUri'
            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
"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
"Uri")
      )

instance Prelude.Hashable ResourceUri where
  hashWithSalt :: Int -> ResourceUri -> Int
hashWithSalt Int
_salt ResourceUri' {Maybe Text
Maybe ResourceType
uri :: Maybe Text
resourceType :: Maybe ResourceType
$sel:uri:ResourceUri' :: ResourceUri -> Maybe Text
$sel:resourceType:ResourceUri' :: ResourceUri -> Maybe ResourceType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceType
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
uri

instance Prelude.NFData ResourceUri where
  rnf :: ResourceUri -> ()
rnf ResourceUri' {Maybe Text
Maybe ResourceType
uri :: Maybe Text
resourceType :: Maybe ResourceType
$sel:uri:ResourceUri' :: ResourceUri -> Maybe Text
$sel:resourceType:ResourceUri' :: ResourceUri -> Maybe ResourceType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceType
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
uri

instance Data.ToJSON ResourceUri where
  toJSON :: ResourceUri -> Value
toJSON ResourceUri' {Maybe Text
Maybe ResourceType
uri :: Maybe Text
resourceType :: Maybe ResourceType
$sel:uri:ResourceUri' :: ResourceUri -> Maybe Text
$sel:resourceType:ResourceUri' :: ResourceUri -> Maybe ResourceType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ResourceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceType
resourceType,
            (Key
"Uri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
uri
          ]
      )