{-# 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.Kendra.Types.Urls
-- 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.Kendra.Types.Urls where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.SeedUrlConfiguration
import Amazonka.Kendra.Types.SiteMapsConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Provides the configuration information of the URLs to crawl.
--
-- You can only crawl websites that use the secure communication protocol,
-- Hypertext Transfer Protocol Secure (HTTPS). If you receive an error when
-- crawling a website, it could be that the website is blocked from
-- crawling.
--
-- /When selecting websites to index, you must adhere to the
-- <https://aws.amazon.com/aup/ Amazon Acceptable Use Policy> and all other
-- Amazon terms. Remember that you must only use Amazon Kendra Web Crawler
-- to index your own webpages, or webpages that you have authorization to
-- index./
--
-- /See:/ 'newUrls' smart constructor.
data Urls = Urls'
  { -- | Configuration of the seed or starting point URLs of the websites you
    -- want to crawl.
    --
    -- You can choose to crawl only the website host names, or the website host
    -- names with subdomains, or the website host names with subdomains and
    -- other domains that the webpages link to.
    --
    -- You can list up to 100 seed URLs.
    Urls -> Maybe SeedUrlConfiguration
seedUrlConfiguration :: Prelude.Maybe SeedUrlConfiguration,
    -- | Configuration of the sitemap URLs of the websites you want to crawl.
    --
    -- Only URLs belonging to the same website host names are crawled. You can
    -- list up to three sitemap URLs.
    Urls -> Maybe SiteMapsConfiguration
siteMapsConfiguration :: Prelude.Maybe SiteMapsConfiguration
  }
  deriving (Urls -> Urls -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Urls -> Urls -> Bool
$c/= :: Urls -> Urls -> Bool
== :: Urls -> Urls -> Bool
$c== :: Urls -> Urls -> Bool
Prelude.Eq, ReadPrec [Urls]
ReadPrec Urls
Int -> ReadS Urls
ReadS [Urls]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Urls]
$creadListPrec :: ReadPrec [Urls]
readPrec :: ReadPrec Urls
$creadPrec :: ReadPrec Urls
readList :: ReadS [Urls]
$creadList :: ReadS [Urls]
readsPrec :: Int -> ReadS Urls
$creadsPrec :: Int -> ReadS Urls
Prelude.Read, Int -> Urls -> ShowS
[Urls] -> ShowS
Urls -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Urls] -> ShowS
$cshowList :: [Urls] -> ShowS
show :: Urls -> String
$cshow :: Urls -> String
showsPrec :: Int -> Urls -> ShowS
$cshowsPrec :: Int -> Urls -> ShowS
Prelude.Show, forall x. Rep Urls x -> Urls
forall x. Urls -> Rep Urls x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Urls x -> Urls
$cfrom :: forall x. Urls -> Rep Urls x
Prelude.Generic)

-- |
-- Create a value of 'Urls' 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:
--
-- 'seedUrlConfiguration', 'urls_seedUrlConfiguration' - Configuration of the seed or starting point URLs of the websites you
-- want to crawl.
--
-- You can choose to crawl only the website host names, or the website host
-- names with subdomains, or the website host names with subdomains and
-- other domains that the webpages link to.
--
-- You can list up to 100 seed URLs.
--
-- 'siteMapsConfiguration', 'urls_siteMapsConfiguration' - Configuration of the sitemap URLs of the websites you want to crawl.
--
-- Only URLs belonging to the same website host names are crawled. You can
-- list up to three sitemap URLs.
newUrls ::
  Urls
newUrls :: Urls
newUrls =
  Urls'
    { $sel:seedUrlConfiguration:Urls' :: Maybe SeedUrlConfiguration
seedUrlConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:siteMapsConfiguration:Urls' :: Maybe SiteMapsConfiguration
siteMapsConfiguration = forall a. Maybe a
Prelude.Nothing
    }

-- | Configuration of the seed or starting point URLs of the websites you
-- want to crawl.
--
-- You can choose to crawl only the website host names, or the website host
-- names with subdomains, or the website host names with subdomains and
-- other domains that the webpages link to.
--
-- You can list up to 100 seed URLs.
urls_seedUrlConfiguration :: Lens.Lens' Urls (Prelude.Maybe SeedUrlConfiguration)
urls_seedUrlConfiguration :: Lens' Urls (Maybe SeedUrlConfiguration)
urls_seedUrlConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Urls' {Maybe SeedUrlConfiguration
seedUrlConfiguration :: Maybe SeedUrlConfiguration
$sel:seedUrlConfiguration:Urls' :: Urls -> Maybe SeedUrlConfiguration
seedUrlConfiguration} -> Maybe SeedUrlConfiguration
seedUrlConfiguration) (\s :: Urls
s@Urls' {} Maybe SeedUrlConfiguration
a -> Urls
s {$sel:seedUrlConfiguration:Urls' :: Maybe SeedUrlConfiguration
seedUrlConfiguration = Maybe SeedUrlConfiguration
a} :: Urls)

-- | Configuration of the sitemap URLs of the websites you want to crawl.
--
-- Only URLs belonging to the same website host names are crawled. You can
-- list up to three sitemap URLs.
urls_siteMapsConfiguration :: Lens.Lens' Urls (Prelude.Maybe SiteMapsConfiguration)
urls_siteMapsConfiguration :: Lens' Urls (Maybe SiteMapsConfiguration)
urls_siteMapsConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Urls' {Maybe SiteMapsConfiguration
siteMapsConfiguration :: Maybe SiteMapsConfiguration
$sel:siteMapsConfiguration:Urls' :: Urls -> Maybe SiteMapsConfiguration
siteMapsConfiguration} -> Maybe SiteMapsConfiguration
siteMapsConfiguration) (\s :: Urls
s@Urls' {} Maybe SiteMapsConfiguration
a -> Urls
s {$sel:siteMapsConfiguration:Urls' :: Maybe SiteMapsConfiguration
siteMapsConfiguration = Maybe SiteMapsConfiguration
a} :: Urls)

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

instance Prelude.Hashable Urls where
  hashWithSalt :: Int -> Urls -> Int
hashWithSalt Int
_salt Urls' {Maybe SiteMapsConfiguration
Maybe SeedUrlConfiguration
siteMapsConfiguration :: Maybe SiteMapsConfiguration
seedUrlConfiguration :: Maybe SeedUrlConfiguration
$sel:siteMapsConfiguration:Urls' :: Urls -> Maybe SiteMapsConfiguration
$sel:seedUrlConfiguration:Urls' :: Urls -> Maybe SeedUrlConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SeedUrlConfiguration
seedUrlConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SiteMapsConfiguration
siteMapsConfiguration

instance Prelude.NFData Urls where
  rnf :: Urls -> ()
rnf Urls' {Maybe SiteMapsConfiguration
Maybe SeedUrlConfiguration
siteMapsConfiguration :: Maybe SiteMapsConfiguration
seedUrlConfiguration :: Maybe SeedUrlConfiguration
$sel:siteMapsConfiguration:Urls' :: Urls -> Maybe SiteMapsConfiguration
$sel:seedUrlConfiguration:Urls' :: Urls -> Maybe SeedUrlConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SeedUrlConfiguration
seedUrlConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SiteMapsConfiguration
siteMapsConfiguration

instance Data.ToJSON Urls where
  toJSON :: Urls -> Value
toJSON Urls' {Maybe SiteMapsConfiguration
Maybe SeedUrlConfiguration
siteMapsConfiguration :: Maybe SiteMapsConfiguration
seedUrlConfiguration :: Maybe SeedUrlConfiguration
$sel:siteMapsConfiguration:Urls' :: Urls -> Maybe SiteMapsConfiguration
$sel:seedUrlConfiguration:Urls' :: Urls -> Maybe SeedUrlConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SeedUrlConfiguration" 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 SeedUrlConfiguration
seedUrlConfiguration,
            (Key
"SiteMapsConfiguration" 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 SiteMapsConfiguration
siteMapsConfiguration
          ]
      )