{-# 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.SeedUrlConfiguration
-- 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.SeedUrlConfiguration 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.WebCrawlerMode
import qualified Amazonka.Prelude as Prelude

-- | Provides the configuration information for the seed or starting point
-- URLs to crawl.
--
-- /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:/ 'newSeedUrlConfiguration' smart constructor.
data SeedUrlConfiguration = SeedUrlConfiguration'
  { -- | You can choose one of the following modes:
    --
    -- -   @HOST_ONLY@ – crawl only the website host names. For example, if the
    --     seed URL is \"abc.example.com\", then only URLs with host name
    --     \"abc.example.com\" are crawled.
    --
    -- -   @SUBDOMAINS@ – crawl the website host names with subdomains. For
    --     example, if the seed URL is \"abc.example.com\", then
    --     \"a.abc.example.com\" and \"b.abc.example.com\" are also crawled.
    --
    -- -   @EVERYTHING@ – crawl the website host names with subdomains and
    --     other domains that the webpages link to.
    --
    -- The default mode is set to @HOST_ONLY@.
    SeedUrlConfiguration -> Maybe WebCrawlerMode
webCrawlerMode :: Prelude.Maybe WebCrawlerMode,
    -- | The list of seed or starting point URLs of the websites you want to
    -- crawl.
    --
    -- The list can include a maximum of 100 seed URLs.
    SeedUrlConfiguration -> [Text]
seedUrls :: [Prelude.Text]
  }
  deriving (SeedUrlConfiguration -> SeedUrlConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SeedUrlConfiguration -> SeedUrlConfiguration -> Bool
$c/= :: SeedUrlConfiguration -> SeedUrlConfiguration -> Bool
== :: SeedUrlConfiguration -> SeedUrlConfiguration -> Bool
$c== :: SeedUrlConfiguration -> SeedUrlConfiguration -> Bool
Prelude.Eq, ReadPrec [SeedUrlConfiguration]
ReadPrec SeedUrlConfiguration
Int -> ReadS SeedUrlConfiguration
ReadS [SeedUrlConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SeedUrlConfiguration]
$creadListPrec :: ReadPrec [SeedUrlConfiguration]
readPrec :: ReadPrec SeedUrlConfiguration
$creadPrec :: ReadPrec SeedUrlConfiguration
readList :: ReadS [SeedUrlConfiguration]
$creadList :: ReadS [SeedUrlConfiguration]
readsPrec :: Int -> ReadS SeedUrlConfiguration
$creadsPrec :: Int -> ReadS SeedUrlConfiguration
Prelude.Read, Int -> SeedUrlConfiguration -> ShowS
[SeedUrlConfiguration] -> ShowS
SeedUrlConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SeedUrlConfiguration] -> ShowS
$cshowList :: [SeedUrlConfiguration] -> ShowS
show :: SeedUrlConfiguration -> String
$cshow :: SeedUrlConfiguration -> String
showsPrec :: Int -> SeedUrlConfiguration -> ShowS
$cshowsPrec :: Int -> SeedUrlConfiguration -> ShowS
Prelude.Show, forall x. Rep SeedUrlConfiguration x -> SeedUrlConfiguration
forall x. SeedUrlConfiguration -> Rep SeedUrlConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SeedUrlConfiguration x -> SeedUrlConfiguration
$cfrom :: forall x. SeedUrlConfiguration -> Rep SeedUrlConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SeedUrlConfiguration' 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:
--
-- 'webCrawlerMode', 'seedUrlConfiguration_webCrawlerMode' - You can choose one of the following modes:
--
-- -   @HOST_ONLY@ – crawl only the website host names. For example, if the
--     seed URL is \"abc.example.com\", then only URLs with host name
--     \"abc.example.com\" are crawled.
--
-- -   @SUBDOMAINS@ – crawl the website host names with subdomains. For
--     example, if the seed URL is \"abc.example.com\", then
--     \"a.abc.example.com\" and \"b.abc.example.com\" are also crawled.
--
-- -   @EVERYTHING@ – crawl the website host names with subdomains and
--     other domains that the webpages link to.
--
-- The default mode is set to @HOST_ONLY@.
--
-- 'seedUrls', 'seedUrlConfiguration_seedUrls' - The list of seed or starting point URLs of the websites you want to
-- crawl.
--
-- The list can include a maximum of 100 seed URLs.
newSeedUrlConfiguration ::
  SeedUrlConfiguration
newSeedUrlConfiguration :: SeedUrlConfiguration
newSeedUrlConfiguration =
  SeedUrlConfiguration'
    { $sel:webCrawlerMode:SeedUrlConfiguration' :: Maybe WebCrawlerMode
webCrawlerMode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:seedUrls:SeedUrlConfiguration' :: [Text]
seedUrls = forall a. Monoid a => a
Prelude.mempty
    }

-- | You can choose one of the following modes:
--
-- -   @HOST_ONLY@ – crawl only the website host names. For example, if the
--     seed URL is \"abc.example.com\", then only URLs with host name
--     \"abc.example.com\" are crawled.
--
-- -   @SUBDOMAINS@ – crawl the website host names with subdomains. For
--     example, if the seed URL is \"abc.example.com\", then
--     \"a.abc.example.com\" and \"b.abc.example.com\" are also crawled.
--
-- -   @EVERYTHING@ – crawl the website host names with subdomains and
--     other domains that the webpages link to.
--
-- The default mode is set to @HOST_ONLY@.
seedUrlConfiguration_webCrawlerMode :: Lens.Lens' SeedUrlConfiguration (Prelude.Maybe WebCrawlerMode)
seedUrlConfiguration_webCrawlerMode :: Lens' SeedUrlConfiguration (Maybe WebCrawlerMode)
seedUrlConfiguration_webCrawlerMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SeedUrlConfiguration' {Maybe WebCrawlerMode
webCrawlerMode :: Maybe WebCrawlerMode
$sel:webCrawlerMode:SeedUrlConfiguration' :: SeedUrlConfiguration -> Maybe WebCrawlerMode
webCrawlerMode} -> Maybe WebCrawlerMode
webCrawlerMode) (\s :: SeedUrlConfiguration
s@SeedUrlConfiguration' {} Maybe WebCrawlerMode
a -> SeedUrlConfiguration
s {$sel:webCrawlerMode:SeedUrlConfiguration' :: Maybe WebCrawlerMode
webCrawlerMode = Maybe WebCrawlerMode
a} :: SeedUrlConfiguration)

-- | The list of seed or starting point URLs of the websites you want to
-- crawl.
--
-- The list can include a maximum of 100 seed URLs.
seedUrlConfiguration_seedUrls :: Lens.Lens' SeedUrlConfiguration [Prelude.Text]
seedUrlConfiguration_seedUrls :: Lens' SeedUrlConfiguration [Text]
seedUrlConfiguration_seedUrls = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SeedUrlConfiguration' {[Text]
seedUrls :: [Text]
$sel:seedUrls:SeedUrlConfiguration' :: SeedUrlConfiguration -> [Text]
seedUrls} -> [Text]
seedUrls) (\s :: SeedUrlConfiguration
s@SeedUrlConfiguration' {} [Text]
a -> SeedUrlConfiguration
s {$sel:seedUrls:SeedUrlConfiguration' :: [Text]
seedUrls = [Text]
a} :: SeedUrlConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SeedUrlConfiguration where
  parseJSON :: Value -> Parser SeedUrlConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SeedUrlConfiguration"
      ( \Object
x ->
          Maybe WebCrawlerMode -> [Text] -> SeedUrlConfiguration
SeedUrlConfiguration'
            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
"WebCrawlerMode")
            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
"SeedUrls" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SeedUrlConfiguration where
  hashWithSalt :: Int -> SeedUrlConfiguration -> Int
hashWithSalt Int
_salt SeedUrlConfiguration' {[Text]
Maybe WebCrawlerMode
seedUrls :: [Text]
webCrawlerMode :: Maybe WebCrawlerMode
$sel:seedUrls:SeedUrlConfiguration' :: SeedUrlConfiguration -> [Text]
$sel:webCrawlerMode:SeedUrlConfiguration' :: SeedUrlConfiguration -> Maybe WebCrawlerMode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WebCrawlerMode
webCrawlerMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
seedUrls

instance Prelude.NFData SeedUrlConfiguration where
  rnf :: SeedUrlConfiguration -> ()
rnf SeedUrlConfiguration' {[Text]
Maybe WebCrawlerMode
seedUrls :: [Text]
webCrawlerMode :: Maybe WebCrawlerMode
$sel:seedUrls:SeedUrlConfiguration' :: SeedUrlConfiguration -> [Text]
$sel:webCrawlerMode:SeedUrlConfiguration' :: SeedUrlConfiguration -> Maybe WebCrawlerMode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe WebCrawlerMode
webCrawlerMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
seedUrls

instance Data.ToJSON SeedUrlConfiguration where
  toJSON :: SeedUrlConfiguration -> Value
toJSON SeedUrlConfiguration' {[Text]
Maybe WebCrawlerMode
seedUrls :: [Text]
webCrawlerMode :: Maybe WebCrawlerMode
$sel:seedUrls:SeedUrlConfiguration' :: SeedUrlConfiguration -> [Text]
$sel:webCrawlerMode:SeedUrlConfiguration' :: SeedUrlConfiguration -> Maybe WebCrawlerMode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"WebCrawlerMode" 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 WebCrawlerMode
webCrawlerMode,
            forall a. a -> Maybe a
Prelude.Just (Key
"SeedUrls" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
seedUrls)
          ]
      )