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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.ResourceType
import qualified Amazonka.Lens as Lens
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
(ResourceUri -> ResourceUri -> Bool)
-> (ResourceUri -> ResourceUri -> Bool) -> Eq ResourceUri
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]
(Int -> ReadS ResourceUri)
-> ReadS [ResourceUri]
-> ReadPrec ResourceUri
-> ReadPrec [ResourceUri]
-> Read 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
(Int -> ResourceUri -> ShowS)
-> (ResourceUri -> String)
-> ([ResourceUri] -> ShowS)
-> Show ResourceUri
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. ResourceUri -> Rep ResourceUri x)
-> (forall x. Rep ResourceUri x -> ResourceUri)
-> Generic ResourceUri
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' :: Maybe ResourceType -> Maybe Text -> ResourceUri
ResourceUri'
    { $sel:resourceType:ResourceUri' :: Maybe ResourceType
resourceType = Maybe ResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:uri:ResourceUri' :: Maybe Text
uri = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the resource.
resourceUri_resourceType :: Lens.Lens' ResourceUri (Prelude.Maybe ResourceType)
resourceUri_resourceType :: (Maybe ResourceType -> f (Maybe ResourceType))
-> ResourceUri -> f ResourceUri
resourceUri_resourceType = (ResourceUri -> Maybe ResourceType)
-> (ResourceUri -> Maybe ResourceType -> ResourceUri)
-> Lens
     ResourceUri ResourceUri (Maybe ResourceType) (Maybe 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 :: (Maybe Text -> f (Maybe Text)) -> ResourceUri -> f ResourceUri
resourceUri_uri = (ResourceUri -> Maybe Text)
-> (ResourceUri -> Maybe Text -> ResourceUri)
-> Lens ResourceUri ResourceUri (Maybe Text) (Maybe Text)
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 Core.FromJSON ResourceUri where
  parseJSON :: Value -> Parser ResourceUri
parseJSON =
    String
-> (Object -> Parser ResourceUri) -> Value -> Parser ResourceUri
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceUri"
      ( \Object
x ->
          Maybe ResourceType -> Maybe Text -> ResourceUri
ResourceUri'
            (Maybe ResourceType -> Maybe Text -> ResourceUri)
-> Parser (Maybe ResourceType)
-> Parser (Maybe Text -> ResourceUri)
forall (f :: * -> *) a b. Functor 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 Text -> ResourceUri)
-> Parser (Maybe Text) -> Parser ResourceUri
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
"Uri")
      )

instance Prelude.Hashable ResourceUri

instance Prelude.NFData ResourceUri

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ResourceType" Text -> ResourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ResourceType -> Pair) -> Maybe ResourceType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceType
resourceType,
            (Text
"Uri" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
uri
          ]
      )