{-# 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.AuditManager.Types.URL
-- 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.AuditManager.Types.URL where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A uniform resource locator, used as a unique identifier to locate a
-- resource on the internet.
--
-- /See:/ 'newURL' smart constructor.
data URL = URL'
  { -- | The unique identifier for the internet resource.
    URL -> Maybe Text
link :: Prelude.Maybe Prelude.Text,
    -- | The name or word used as a hyperlink to the URL.
    URL -> Maybe Text
hyperlinkName :: Prelude.Maybe Prelude.Text
  }
  deriving (URL -> URL -> Bool
(URL -> URL -> Bool) -> (URL -> URL -> Bool) -> Eq URL
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: URL -> URL -> Bool
$c/= :: URL -> URL -> Bool
== :: URL -> URL -> Bool
$c== :: URL -> URL -> Bool
Prelude.Eq, ReadPrec [URL]
ReadPrec URL
Int -> ReadS URL
ReadS [URL]
(Int -> ReadS URL)
-> ReadS [URL] -> ReadPrec URL -> ReadPrec [URL] -> Read URL
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [URL]
$creadListPrec :: ReadPrec [URL]
readPrec :: ReadPrec URL
$creadPrec :: ReadPrec URL
readList :: ReadS [URL]
$creadList :: ReadS [URL]
readsPrec :: Int -> ReadS URL
$creadsPrec :: Int -> ReadS URL
Prelude.Read, Int -> URL -> ShowS
[URL] -> ShowS
URL -> String
(Int -> URL -> ShowS)
-> (URL -> String) -> ([URL] -> ShowS) -> Show URL
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [URL] -> ShowS
$cshowList :: [URL] -> ShowS
show :: URL -> String
$cshow :: URL -> String
showsPrec :: Int -> URL -> ShowS
$cshowsPrec :: Int -> URL -> ShowS
Prelude.Show, (forall x. URL -> Rep URL x)
-> (forall x. Rep URL x -> URL) -> Generic URL
forall x. Rep URL x -> URL
forall x. URL -> Rep URL x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep URL x -> URL
$cfrom :: forall x. URL -> Rep URL x
Prelude.Generic)

-- |
-- Create a value of 'URL' 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:
--
-- 'link', 'url_link' - The unique identifier for the internet resource.
--
-- 'hyperlinkName', 'url_hyperlinkName' - The name or word used as a hyperlink to the URL.
newURL ::
  URL
newURL :: URL
newURL =
  URL' :: Maybe Text -> Maybe Text -> URL
URL'
    { $sel:link:URL' :: Maybe Text
link = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:hyperlinkName:URL' :: Maybe Text
hyperlinkName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the internet resource.
url_link :: Lens.Lens' URL (Prelude.Maybe Prelude.Text)
url_link :: (Maybe Text -> f (Maybe Text)) -> URL -> f URL
url_link = (URL -> Maybe Text)
-> (URL -> Maybe Text -> URL)
-> Lens URL URL (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\URL' {Maybe Text
link :: Maybe Text
$sel:link:URL' :: URL -> Maybe Text
link} -> Maybe Text
link) (\s :: URL
s@URL' {} Maybe Text
a -> URL
s {$sel:link:URL' :: Maybe Text
link = Maybe Text
a} :: URL)

-- | The name or word used as a hyperlink to the URL.
url_hyperlinkName :: Lens.Lens' URL (Prelude.Maybe Prelude.Text)
url_hyperlinkName :: (Maybe Text -> f (Maybe Text)) -> URL -> f URL
url_hyperlinkName = (URL -> Maybe Text)
-> (URL -> Maybe Text -> URL)
-> Lens URL URL (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\URL' {Maybe Text
hyperlinkName :: Maybe Text
$sel:hyperlinkName:URL' :: URL -> Maybe Text
hyperlinkName} -> Maybe Text
hyperlinkName) (\s :: URL
s@URL' {} Maybe Text
a -> URL
s {$sel:hyperlinkName:URL' :: Maybe Text
hyperlinkName = Maybe Text
a} :: URL)

instance Core.FromJSON URL where
  parseJSON :: Value -> Parser URL
parseJSON =
    String -> (Object -> Parser URL) -> Value -> Parser URL
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"URL"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> URL
URL'
            (Maybe Text -> Maybe Text -> URL)
-> Parser (Maybe Text) -> Parser (Maybe Text -> URL)
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
"link")
            Parser (Maybe Text -> URL) -> Parser (Maybe Text) -> Parser URL
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
"hyperlinkName")
      )

instance Prelude.Hashable URL

instance Prelude.NFData URL