{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AuditManager.Types.URL 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

-- | Short for uniform resource locator. A URL is used as a unique identifier
-- to locate a resource on the internet.
--
-- /See:/ 'newURL' smart constructor.
data URL = URL'
  { -- | The name or word that\'s used as a hyperlink to the URL.
    URL -> Maybe Text
hyperlinkName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the internet resource.
    URL -> Maybe Text
link :: Prelude.Maybe Prelude.Text
  }
  deriving (URL -> URL -> Bool
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]
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
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. 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:
--
-- 'hyperlinkName', 'url_hyperlinkName' - The name or word that\'s used as a hyperlink to the URL.
--
-- 'link', 'url_link' - The unique identifier for the internet resource.
newURL ::
  URL
newURL :: URL
newURL =
  URL'
    { $sel:hyperlinkName:URL' :: Maybe Text
hyperlinkName = forall a. Maybe a
Prelude.Nothing,
      $sel:link:URL' :: Maybe Text
link = forall a. Maybe a
Prelude.Nothing
    }

-- | The name or word that\'s used as a hyperlink to the URL.
url_hyperlinkName :: Lens.Lens' URL (Prelude.Maybe Prelude.Text)
url_hyperlinkName :: Lens' URL (Maybe Text)
url_hyperlinkName = 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)

-- | The unique identifier for the internet resource.
url_link :: Lens.Lens' URL (Prelude.Maybe Prelude.Text)
url_link :: Lens' URL (Maybe Text)
url_link = 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)

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

instance Prelude.Hashable URL where
  hashWithSalt :: Int -> URL -> Int
hashWithSalt Int
_salt URL' {Maybe Text
link :: Maybe Text
hyperlinkName :: Maybe Text
$sel:link:URL' :: URL -> Maybe Text
$sel:hyperlinkName:URL' :: URL -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hyperlinkName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
link

instance Prelude.NFData URL where
  rnf :: URL -> ()
rnf URL' {Maybe Text
link :: Maybe Text
hyperlinkName :: Maybe Text
$sel:link:URL' :: URL -> Maybe Text
$sel:hyperlinkName:URL' :: URL -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hyperlinkName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
link