{-# 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.Wisdom.Types.Document
-- 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.Wisdom.Types.Document 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
import Amazonka.Wisdom.Types.ContentReference
import Amazonka.Wisdom.Types.DocumentText

-- | The document.
--
-- /See:/ 'newDocument' smart constructor.
data Document = Document'
  { -- | The excerpt from the document.
    Document -> Maybe DocumentText
excerpt :: Prelude.Maybe DocumentText,
    -- | The title of the document.
    Document -> Maybe DocumentText
title :: Prelude.Maybe DocumentText,
    -- | A reference to the content resource.
    Document -> ContentReference
contentReference :: ContentReference
  }
  deriving (Document -> Document -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Document -> Document -> Bool
$c/= :: Document -> Document -> Bool
== :: Document -> Document -> Bool
$c== :: Document -> Document -> Bool
Prelude.Eq, Int -> Document -> ShowS
[Document] -> ShowS
Document -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Document] -> ShowS
$cshowList :: [Document] -> ShowS
show :: Document -> String
$cshow :: Document -> String
showsPrec :: Int -> Document -> ShowS
$cshowsPrec :: Int -> Document -> ShowS
Prelude.Show, forall x. Rep Document x -> Document
forall x. Document -> Rep Document x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Document x -> Document
$cfrom :: forall x. Document -> Rep Document x
Prelude.Generic)

-- |
-- Create a value of 'Document' 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:
--
-- 'excerpt', 'document_excerpt' - The excerpt from the document.
--
-- 'title', 'document_title' - The title of the document.
--
-- 'contentReference', 'document_contentReference' - A reference to the content resource.
newDocument ::
  -- | 'contentReference'
  ContentReference ->
  Document
newDocument :: ContentReference -> Document
newDocument ContentReference
pContentReference_ =
  Document'
    { $sel:excerpt:Document' :: Maybe DocumentText
excerpt = forall a. Maybe a
Prelude.Nothing,
      $sel:title:Document' :: Maybe DocumentText
title = forall a. Maybe a
Prelude.Nothing,
      $sel:contentReference:Document' :: ContentReference
contentReference = ContentReference
pContentReference_
    }

-- | The excerpt from the document.
document_excerpt :: Lens.Lens' Document (Prelude.Maybe DocumentText)
document_excerpt :: Lens' Document (Maybe DocumentText)
document_excerpt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Document' {Maybe DocumentText
excerpt :: Maybe DocumentText
$sel:excerpt:Document' :: Document -> Maybe DocumentText
excerpt} -> Maybe DocumentText
excerpt) (\s :: Document
s@Document' {} Maybe DocumentText
a -> Document
s {$sel:excerpt:Document' :: Maybe DocumentText
excerpt = Maybe DocumentText
a} :: Document)

-- | The title of the document.
document_title :: Lens.Lens' Document (Prelude.Maybe DocumentText)
document_title :: Lens' Document (Maybe DocumentText)
document_title = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Document' {Maybe DocumentText
title :: Maybe DocumentText
$sel:title:Document' :: Document -> Maybe DocumentText
title} -> Maybe DocumentText
title) (\s :: Document
s@Document' {} Maybe DocumentText
a -> Document
s {$sel:title:Document' :: Maybe DocumentText
title = Maybe DocumentText
a} :: Document)

-- | A reference to the content resource.
document_contentReference :: Lens.Lens' Document ContentReference
document_contentReference :: Lens' Document ContentReference
document_contentReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Document' {ContentReference
contentReference :: ContentReference
$sel:contentReference:Document' :: Document -> ContentReference
contentReference} -> ContentReference
contentReference) (\s :: Document
s@Document' {} ContentReference
a -> Document
s {$sel:contentReference:Document' :: ContentReference
contentReference = ContentReference
a} :: Document)

instance Data.FromJSON Document where
  parseJSON :: Value -> Parser Document
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Document"
      ( \Object
x ->
          Maybe DocumentText
-> Maybe DocumentText -> ContentReference -> Document
Document'
            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
"excerpt")
            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
"title")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"contentReference")
      )

instance Prelude.Hashable Document where
  hashWithSalt :: Int -> Document -> Int
hashWithSalt Int
_salt Document' {Maybe DocumentText
ContentReference
contentReference :: ContentReference
title :: Maybe DocumentText
excerpt :: Maybe DocumentText
$sel:contentReference:Document' :: Document -> ContentReference
$sel:title:Document' :: Document -> Maybe DocumentText
$sel:excerpt:Document' :: Document -> Maybe DocumentText
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DocumentText
excerpt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DocumentText
title
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ContentReference
contentReference

instance Prelude.NFData Document where
  rnf :: Document -> ()
rnf Document' {Maybe DocumentText
ContentReference
contentReference :: ContentReference
title :: Maybe DocumentText
excerpt :: Maybe DocumentText
$sel:contentReference:Document' :: Document -> ContentReference
$sel:title:Document' :: Document -> Maybe DocumentText
$sel:excerpt:Document' :: Document -> Maybe DocumentText
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentText
excerpt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentText
title
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ContentReference
contentReference