{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateKnowledgeBase
-- 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)
--
-- Creates a knowledge base.
--
-- When using this API, you cannot reuse
-- <https://docs.aws.amazon.com/appintegrations/latest/APIReference/Welcome.html Amazon AppIntegrations>
-- DataIntegrations with external knowledge bases such as Salesforce and
-- ServiceNow. If you do, you\'ll get an @InvalidRequestException@ error.
--
-- >  <p>For example, you're programmatically managing your external knowledge base, and you want to add or remove one of the fields that is being ingested from Salesforce. Do the following:</p> <ol> <li> <p>Call <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_DeleteKnowledgeBase.html">DeleteKnowledgeBase</a>.</p> </li> <li> <p>Call <a href="https://docs.aws.amazon.com/appintegrations/latest/APIReference/API_DeleteDataIntegration.html">DeleteDataIntegration</a>.</p> </li> <li> <p>Call <a href="https://docs.aws.amazon.com/appintegrations/latest/APIReference/API_CreateDataIntegration.html">CreateDataIntegration</a> to recreate the DataIntegration or a create different one.</p> </li> <li> <p>Call CreateKnowledgeBase.</p> </li> </ol> </note>
module Amazonka.Wisdom.CreateKnowledgeBase
  ( -- * Creating a Request
    CreateKnowledgeBase (..),
    newCreateKnowledgeBase,

    -- * Request Lenses
    createKnowledgeBase_clientToken,
    createKnowledgeBase_renderingConfiguration,
    createKnowledgeBase_sourceConfiguration,
    createKnowledgeBase_description,
    createKnowledgeBase_serverSideEncryptionConfiguration,
    createKnowledgeBase_tags,
    createKnowledgeBase_knowledgeBaseType,
    createKnowledgeBase_name,

    -- * Destructuring the Response
    CreateKnowledgeBaseResponse (..),
    newCreateKnowledgeBaseResponse,

    -- * Response Lenses
    createKnowledgeBaseResponse_knowledgeBase,
    createKnowledgeBaseResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Wisdom.Types

-- | /See:/ 'newCreateKnowledgeBase' smart constructor.
data CreateKnowledgeBase = CreateKnowledgeBase'
  { -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    CreateKnowledgeBase -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | Information about how to render the content.
    CreateKnowledgeBase -> Maybe RenderingConfiguration
renderingConfiguration :: Prelude.Maybe RenderingConfiguration,
    -- | The source of the knowledge base content. Only set this argument for
    -- EXTERNAL knowledge bases.
    CreateKnowledgeBase -> Maybe SourceConfiguration
sourceConfiguration :: Prelude.Maybe SourceConfiguration,
    -- | The description.
    CreateKnowledgeBase -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The KMS key used for encryption.
    CreateKnowledgeBase -> Maybe ServerSideEncryptionConfiguration
serverSideEncryptionConfiguration :: Prelude.Maybe ServerSideEncryptionConfiguration,
    -- | The tags used to organize, track, or control access for this resource.
    CreateKnowledgeBase -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The type of knowledge base. Only CUSTOM knowledge bases allow you to
    -- upload your own content. EXTERNAL knowledge bases support integrations
    -- with third-party systems whose content is synchronized automatically.
    CreateKnowledgeBase -> KnowledgeBaseType
knowledgeBaseType :: KnowledgeBaseType,
    -- | The name of the knowledge base.
    CreateKnowledgeBase -> Text
name :: Prelude.Text
  }
  deriving (CreateKnowledgeBase -> CreateKnowledgeBase -> Bool
(CreateKnowledgeBase -> CreateKnowledgeBase -> Bool)
-> (CreateKnowledgeBase -> CreateKnowledgeBase -> Bool)
-> Eq CreateKnowledgeBase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateKnowledgeBase -> CreateKnowledgeBase -> Bool
$c/= :: CreateKnowledgeBase -> CreateKnowledgeBase -> Bool
== :: CreateKnowledgeBase -> CreateKnowledgeBase -> Bool
$c== :: CreateKnowledgeBase -> CreateKnowledgeBase -> Bool
Prelude.Eq, ReadPrec [CreateKnowledgeBase]
ReadPrec CreateKnowledgeBase
Int -> ReadS CreateKnowledgeBase
ReadS [CreateKnowledgeBase]
(Int -> ReadS CreateKnowledgeBase)
-> ReadS [CreateKnowledgeBase]
-> ReadPrec CreateKnowledgeBase
-> ReadPrec [CreateKnowledgeBase]
-> Read CreateKnowledgeBase
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateKnowledgeBase]
$creadListPrec :: ReadPrec [CreateKnowledgeBase]
readPrec :: ReadPrec CreateKnowledgeBase
$creadPrec :: ReadPrec CreateKnowledgeBase
readList :: ReadS [CreateKnowledgeBase]
$creadList :: ReadS [CreateKnowledgeBase]
readsPrec :: Int -> ReadS CreateKnowledgeBase
$creadsPrec :: Int -> ReadS CreateKnowledgeBase
Prelude.Read, Int -> CreateKnowledgeBase -> ShowS
[CreateKnowledgeBase] -> ShowS
CreateKnowledgeBase -> String
(Int -> CreateKnowledgeBase -> ShowS)
-> (CreateKnowledgeBase -> String)
-> ([CreateKnowledgeBase] -> ShowS)
-> Show CreateKnowledgeBase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateKnowledgeBase] -> ShowS
$cshowList :: [CreateKnowledgeBase] -> ShowS
show :: CreateKnowledgeBase -> String
$cshow :: CreateKnowledgeBase -> String
showsPrec :: Int -> CreateKnowledgeBase -> ShowS
$cshowsPrec :: Int -> CreateKnowledgeBase -> ShowS
Prelude.Show, (forall x. CreateKnowledgeBase -> Rep CreateKnowledgeBase x)
-> (forall x. Rep CreateKnowledgeBase x -> CreateKnowledgeBase)
-> Generic CreateKnowledgeBase
forall x. Rep CreateKnowledgeBase x -> CreateKnowledgeBase
forall x. CreateKnowledgeBase -> Rep CreateKnowledgeBase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateKnowledgeBase x -> CreateKnowledgeBase
$cfrom :: forall x. CreateKnowledgeBase -> Rep CreateKnowledgeBase x
Prelude.Generic)

-- |
-- Create a value of 'CreateKnowledgeBase' 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:
--
-- 'clientToken', 'createKnowledgeBase_clientToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'renderingConfiguration', 'createKnowledgeBase_renderingConfiguration' - Information about how to render the content.
--
-- 'sourceConfiguration', 'createKnowledgeBase_sourceConfiguration' - The source of the knowledge base content. Only set this argument for
-- EXTERNAL knowledge bases.
--
-- 'description', 'createKnowledgeBase_description' - The description.
--
-- 'serverSideEncryptionConfiguration', 'createKnowledgeBase_serverSideEncryptionConfiguration' - The KMS key used for encryption.
--
-- 'tags', 'createKnowledgeBase_tags' - The tags used to organize, track, or control access for this resource.
--
-- 'knowledgeBaseType', 'createKnowledgeBase_knowledgeBaseType' - The type of knowledge base. Only CUSTOM knowledge bases allow you to
-- upload your own content. EXTERNAL knowledge bases support integrations
-- with third-party systems whose content is synchronized automatically.
--
-- 'name', 'createKnowledgeBase_name' - The name of the knowledge base.
newCreateKnowledgeBase ::
  -- | 'knowledgeBaseType'
  KnowledgeBaseType ->
  -- | 'name'
  Prelude.Text ->
  CreateKnowledgeBase
newCreateKnowledgeBase :: KnowledgeBaseType -> Text -> CreateKnowledgeBase
newCreateKnowledgeBase KnowledgeBaseType
pKnowledgeBaseType_ Text
pName_ =
  CreateKnowledgeBase' :: Maybe Text
-> Maybe RenderingConfiguration
-> Maybe SourceConfiguration
-> Maybe Text
-> Maybe ServerSideEncryptionConfiguration
-> Maybe (HashMap Text Text)
-> KnowledgeBaseType
-> Text
-> CreateKnowledgeBase
CreateKnowledgeBase'
    { $sel:clientToken:CreateKnowledgeBase' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:renderingConfiguration:CreateKnowledgeBase' :: Maybe RenderingConfiguration
renderingConfiguration = Maybe RenderingConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceConfiguration:CreateKnowledgeBase' :: Maybe SourceConfiguration
sourceConfiguration = Maybe SourceConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateKnowledgeBase' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serverSideEncryptionConfiguration:CreateKnowledgeBase' :: Maybe ServerSideEncryptionConfiguration
serverSideEncryptionConfiguration = Maybe ServerSideEncryptionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateKnowledgeBase' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:knowledgeBaseType:CreateKnowledgeBase' :: KnowledgeBaseType
knowledgeBaseType = KnowledgeBaseType
pKnowledgeBaseType_,
      $sel:name:CreateKnowledgeBase' :: Text
name = Text
pName_
    }

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
createKnowledgeBase_clientToken :: Lens.Lens' CreateKnowledgeBase (Prelude.Maybe Prelude.Text)
createKnowledgeBase_clientToken :: (Maybe Text -> f (Maybe Text))
-> CreateKnowledgeBase -> f CreateKnowledgeBase
createKnowledgeBase_clientToken = (CreateKnowledgeBase -> Maybe Text)
-> (CreateKnowledgeBase -> Maybe Text -> CreateKnowledgeBase)
-> Lens
     CreateKnowledgeBase CreateKnowledgeBase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBase' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateKnowledgeBase
s@CreateKnowledgeBase' {} Maybe Text
a -> CreateKnowledgeBase
s {$sel:clientToken:CreateKnowledgeBase' :: Maybe Text
clientToken = Maybe Text
a} :: CreateKnowledgeBase)

-- | Information about how to render the content.
createKnowledgeBase_renderingConfiguration :: Lens.Lens' CreateKnowledgeBase (Prelude.Maybe RenderingConfiguration)
createKnowledgeBase_renderingConfiguration :: (Maybe RenderingConfiguration -> f (Maybe RenderingConfiguration))
-> CreateKnowledgeBase -> f CreateKnowledgeBase
createKnowledgeBase_renderingConfiguration = (CreateKnowledgeBase -> Maybe RenderingConfiguration)
-> (CreateKnowledgeBase
    -> Maybe RenderingConfiguration -> CreateKnowledgeBase)
-> Lens
     CreateKnowledgeBase
     CreateKnowledgeBase
     (Maybe RenderingConfiguration)
     (Maybe RenderingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBase' {Maybe RenderingConfiguration
renderingConfiguration :: Maybe RenderingConfiguration
$sel:renderingConfiguration:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe RenderingConfiguration
renderingConfiguration} -> Maybe RenderingConfiguration
renderingConfiguration) (\s :: CreateKnowledgeBase
s@CreateKnowledgeBase' {} Maybe RenderingConfiguration
a -> CreateKnowledgeBase
s {$sel:renderingConfiguration:CreateKnowledgeBase' :: Maybe RenderingConfiguration
renderingConfiguration = Maybe RenderingConfiguration
a} :: CreateKnowledgeBase)

-- | The source of the knowledge base content. Only set this argument for
-- EXTERNAL knowledge bases.
createKnowledgeBase_sourceConfiguration :: Lens.Lens' CreateKnowledgeBase (Prelude.Maybe SourceConfiguration)
createKnowledgeBase_sourceConfiguration :: (Maybe SourceConfiguration -> f (Maybe SourceConfiguration))
-> CreateKnowledgeBase -> f CreateKnowledgeBase
createKnowledgeBase_sourceConfiguration = (CreateKnowledgeBase -> Maybe SourceConfiguration)
-> (CreateKnowledgeBase
    -> Maybe SourceConfiguration -> CreateKnowledgeBase)
-> Lens
     CreateKnowledgeBase
     CreateKnowledgeBase
     (Maybe SourceConfiguration)
     (Maybe SourceConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBase' {Maybe SourceConfiguration
sourceConfiguration :: Maybe SourceConfiguration
$sel:sourceConfiguration:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe SourceConfiguration
sourceConfiguration} -> Maybe SourceConfiguration
sourceConfiguration) (\s :: CreateKnowledgeBase
s@CreateKnowledgeBase' {} Maybe SourceConfiguration
a -> CreateKnowledgeBase
s {$sel:sourceConfiguration:CreateKnowledgeBase' :: Maybe SourceConfiguration
sourceConfiguration = Maybe SourceConfiguration
a} :: CreateKnowledgeBase)

-- | The description.
createKnowledgeBase_description :: Lens.Lens' CreateKnowledgeBase (Prelude.Maybe Prelude.Text)
createKnowledgeBase_description :: (Maybe Text -> f (Maybe Text))
-> CreateKnowledgeBase -> f CreateKnowledgeBase
createKnowledgeBase_description = (CreateKnowledgeBase -> Maybe Text)
-> (CreateKnowledgeBase -> Maybe Text -> CreateKnowledgeBase)
-> Lens
     CreateKnowledgeBase CreateKnowledgeBase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBase' {Maybe Text
description :: Maybe Text
$sel:description:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateKnowledgeBase
s@CreateKnowledgeBase' {} Maybe Text
a -> CreateKnowledgeBase
s {$sel:description:CreateKnowledgeBase' :: Maybe Text
description = Maybe Text
a} :: CreateKnowledgeBase)

-- | The KMS key used for encryption.
createKnowledgeBase_serverSideEncryptionConfiguration :: Lens.Lens' CreateKnowledgeBase (Prelude.Maybe ServerSideEncryptionConfiguration)
createKnowledgeBase_serverSideEncryptionConfiguration :: (Maybe ServerSideEncryptionConfiguration
 -> f (Maybe ServerSideEncryptionConfiguration))
-> CreateKnowledgeBase -> f CreateKnowledgeBase
createKnowledgeBase_serverSideEncryptionConfiguration = (CreateKnowledgeBase -> Maybe ServerSideEncryptionConfiguration)
-> (CreateKnowledgeBase
    -> Maybe ServerSideEncryptionConfiguration -> CreateKnowledgeBase)
-> Lens
     CreateKnowledgeBase
     CreateKnowledgeBase
     (Maybe ServerSideEncryptionConfiguration)
     (Maybe ServerSideEncryptionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBase' {Maybe ServerSideEncryptionConfiguration
serverSideEncryptionConfiguration :: Maybe ServerSideEncryptionConfiguration
$sel:serverSideEncryptionConfiguration:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe ServerSideEncryptionConfiguration
serverSideEncryptionConfiguration} -> Maybe ServerSideEncryptionConfiguration
serverSideEncryptionConfiguration) (\s :: CreateKnowledgeBase
s@CreateKnowledgeBase' {} Maybe ServerSideEncryptionConfiguration
a -> CreateKnowledgeBase
s {$sel:serverSideEncryptionConfiguration:CreateKnowledgeBase' :: Maybe ServerSideEncryptionConfiguration
serverSideEncryptionConfiguration = Maybe ServerSideEncryptionConfiguration
a} :: CreateKnowledgeBase)

-- | The tags used to organize, track, or control access for this resource.
createKnowledgeBase_tags :: Lens.Lens' CreateKnowledgeBase (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createKnowledgeBase_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateKnowledgeBase -> f CreateKnowledgeBase
createKnowledgeBase_tags = (CreateKnowledgeBase -> Maybe (HashMap Text Text))
-> (CreateKnowledgeBase
    -> Maybe (HashMap Text Text) -> CreateKnowledgeBase)
-> Lens
     CreateKnowledgeBase
     CreateKnowledgeBase
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBase' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateKnowledgeBase
s@CreateKnowledgeBase' {} Maybe (HashMap Text Text)
a -> CreateKnowledgeBase
s {$sel:tags:CreateKnowledgeBase' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateKnowledgeBase) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateKnowledgeBase -> f CreateKnowledgeBase)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateKnowledgeBase
-> f CreateKnowledgeBase
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of knowledge base. Only CUSTOM knowledge bases allow you to
-- upload your own content. EXTERNAL knowledge bases support integrations
-- with third-party systems whose content is synchronized automatically.
createKnowledgeBase_knowledgeBaseType :: Lens.Lens' CreateKnowledgeBase KnowledgeBaseType
createKnowledgeBase_knowledgeBaseType :: (KnowledgeBaseType -> f KnowledgeBaseType)
-> CreateKnowledgeBase -> f CreateKnowledgeBase
createKnowledgeBase_knowledgeBaseType = (CreateKnowledgeBase -> KnowledgeBaseType)
-> (CreateKnowledgeBase
    -> KnowledgeBaseType -> CreateKnowledgeBase)
-> Lens
     CreateKnowledgeBase
     CreateKnowledgeBase
     KnowledgeBaseType
     KnowledgeBaseType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBase' {KnowledgeBaseType
knowledgeBaseType :: KnowledgeBaseType
$sel:knowledgeBaseType:CreateKnowledgeBase' :: CreateKnowledgeBase -> KnowledgeBaseType
knowledgeBaseType} -> KnowledgeBaseType
knowledgeBaseType) (\s :: CreateKnowledgeBase
s@CreateKnowledgeBase' {} KnowledgeBaseType
a -> CreateKnowledgeBase
s {$sel:knowledgeBaseType:CreateKnowledgeBase' :: KnowledgeBaseType
knowledgeBaseType = KnowledgeBaseType
a} :: CreateKnowledgeBase)

-- | The name of the knowledge base.
createKnowledgeBase_name :: Lens.Lens' CreateKnowledgeBase Prelude.Text
createKnowledgeBase_name :: (Text -> f Text) -> CreateKnowledgeBase -> f CreateKnowledgeBase
createKnowledgeBase_name = (CreateKnowledgeBase -> Text)
-> (CreateKnowledgeBase -> Text -> CreateKnowledgeBase)
-> Lens CreateKnowledgeBase CreateKnowledgeBase Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBase' {Text
name :: Text
$sel:name:CreateKnowledgeBase' :: CreateKnowledgeBase -> Text
name} -> Text
name) (\s :: CreateKnowledgeBase
s@CreateKnowledgeBase' {} Text
a -> CreateKnowledgeBase
s {$sel:name:CreateKnowledgeBase' :: Text
name = Text
a} :: CreateKnowledgeBase)

instance Core.AWSRequest CreateKnowledgeBase where
  type
    AWSResponse CreateKnowledgeBase =
      CreateKnowledgeBaseResponse
  request :: CreateKnowledgeBase -> Request CreateKnowledgeBase
request = Service -> CreateKnowledgeBase -> Request CreateKnowledgeBase
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateKnowledgeBase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateKnowledgeBase)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateKnowledgeBase))
-> Logger
-> Service
-> Proxy CreateKnowledgeBase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateKnowledgeBase)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe KnowledgeBaseData -> Int -> CreateKnowledgeBaseResponse
CreateKnowledgeBaseResponse'
            (Maybe KnowledgeBaseData -> Int -> CreateKnowledgeBaseResponse)
-> Either String (Maybe KnowledgeBaseData)
-> Either String (Int -> CreateKnowledgeBaseResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe KnowledgeBaseData)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"knowledgeBase")
            Either String (Int -> CreateKnowledgeBaseResponse)
-> Either String Int -> Either String CreateKnowledgeBaseResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateKnowledgeBase

instance Prelude.NFData CreateKnowledgeBase

instance Core.ToHeaders CreateKnowledgeBase where
  toHeaders :: CreateKnowledgeBase -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateKnowledgeBase -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateKnowledgeBase where
  toJSON :: CreateKnowledgeBase -> Value
toJSON CreateKnowledgeBase' {Maybe Text
Maybe (HashMap Text Text)
Maybe RenderingConfiguration
Maybe ServerSideEncryptionConfiguration
Maybe SourceConfiguration
Text
KnowledgeBaseType
name :: Text
knowledgeBaseType :: KnowledgeBaseType
tags :: Maybe (HashMap Text Text)
serverSideEncryptionConfiguration :: Maybe ServerSideEncryptionConfiguration
description :: Maybe Text
sourceConfiguration :: Maybe SourceConfiguration
renderingConfiguration :: Maybe RenderingConfiguration
clientToken :: Maybe Text
$sel:name:CreateKnowledgeBase' :: CreateKnowledgeBase -> Text
$sel:knowledgeBaseType:CreateKnowledgeBase' :: CreateKnowledgeBase -> KnowledgeBaseType
$sel:tags:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe (HashMap Text Text)
$sel:serverSideEncryptionConfiguration:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe ServerSideEncryptionConfiguration
$sel:description:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe Text
$sel:sourceConfiguration:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe SourceConfiguration
$sel:renderingConfiguration:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe RenderingConfiguration
$sel:clientToken:CreateKnowledgeBase' :: CreateKnowledgeBase -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            (Text
"renderingConfiguration" Text -> RenderingConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RenderingConfiguration -> Pair)
-> Maybe RenderingConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RenderingConfiguration
renderingConfiguration,
            (Text
"sourceConfiguration" Text -> SourceConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SourceConfiguration -> Pair)
-> Maybe SourceConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SourceConfiguration
sourceConfiguration,
            (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"serverSideEncryptionConfiguration" Text -> ServerSideEncryptionConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ServerSideEncryptionConfiguration -> Pair)
-> Maybe ServerSideEncryptionConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ServerSideEncryptionConfiguration
serverSideEncryptionConfiguration,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"knowledgeBaseType" Text -> KnowledgeBaseType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= KnowledgeBaseType
knowledgeBaseType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

instance Core.ToPath CreateKnowledgeBase where
  toPath :: CreateKnowledgeBase -> ByteString
toPath = ByteString -> CreateKnowledgeBase -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/knowledgeBases"

instance Core.ToQuery CreateKnowledgeBase where
  toQuery :: CreateKnowledgeBase -> QueryString
toQuery = QueryString -> CreateKnowledgeBase -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateKnowledgeBaseResponse' smart constructor.
data CreateKnowledgeBaseResponse = CreateKnowledgeBaseResponse'
  { -- | The knowledge base.
    CreateKnowledgeBaseResponse -> Maybe KnowledgeBaseData
knowledgeBase :: Prelude.Maybe KnowledgeBaseData,
    -- | The response's http status code.
    CreateKnowledgeBaseResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateKnowledgeBaseResponse -> CreateKnowledgeBaseResponse -> Bool
(CreateKnowledgeBaseResponse
 -> CreateKnowledgeBaseResponse -> Bool)
-> (CreateKnowledgeBaseResponse
    -> CreateKnowledgeBaseResponse -> Bool)
-> Eq CreateKnowledgeBaseResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateKnowledgeBaseResponse -> CreateKnowledgeBaseResponse -> Bool
$c/= :: CreateKnowledgeBaseResponse -> CreateKnowledgeBaseResponse -> Bool
== :: CreateKnowledgeBaseResponse -> CreateKnowledgeBaseResponse -> Bool
$c== :: CreateKnowledgeBaseResponse -> CreateKnowledgeBaseResponse -> Bool
Prelude.Eq, ReadPrec [CreateKnowledgeBaseResponse]
ReadPrec CreateKnowledgeBaseResponse
Int -> ReadS CreateKnowledgeBaseResponse
ReadS [CreateKnowledgeBaseResponse]
(Int -> ReadS CreateKnowledgeBaseResponse)
-> ReadS [CreateKnowledgeBaseResponse]
-> ReadPrec CreateKnowledgeBaseResponse
-> ReadPrec [CreateKnowledgeBaseResponse]
-> Read CreateKnowledgeBaseResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateKnowledgeBaseResponse]
$creadListPrec :: ReadPrec [CreateKnowledgeBaseResponse]
readPrec :: ReadPrec CreateKnowledgeBaseResponse
$creadPrec :: ReadPrec CreateKnowledgeBaseResponse
readList :: ReadS [CreateKnowledgeBaseResponse]
$creadList :: ReadS [CreateKnowledgeBaseResponse]
readsPrec :: Int -> ReadS CreateKnowledgeBaseResponse
$creadsPrec :: Int -> ReadS CreateKnowledgeBaseResponse
Prelude.Read, Int -> CreateKnowledgeBaseResponse -> ShowS
[CreateKnowledgeBaseResponse] -> ShowS
CreateKnowledgeBaseResponse -> String
(Int -> CreateKnowledgeBaseResponse -> ShowS)
-> (CreateKnowledgeBaseResponse -> String)
-> ([CreateKnowledgeBaseResponse] -> ShowS)
-> Show CreateKnowledgeBaseResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateKnowledgeBaseResponse] -> ShowS
$cshowList :: [CreateKnowledgeBaseResponse] -> ShowS
show :: CreateKnowledgeBaseResponse -> String
$cshow :: CreateKnowledgeBaseResponse -> String
showsPrec :: Int -> CreateKnowledgeBaseResponse -> ShowS
$cshowsPrec :: Int -> CreateKnowledgeBaseResponse -> ShowS
Prelude.Show, (forall x.
 CreateKnowledgeBaseResponse -> Rep CreateKnowledgeBaseResponse x)
-> (forall x.
    Rep CreateKnowledgeBaseResponse x -> CreateKnowledgeBaseResponse)
-> Generic CreateKnowledgeBaseResponse
forall x.
Rep CreateKnowledgeBaseResponse x -> CreateKnowledgeBaseResponse
forall x.
CreateKnowledgeBaseResponse -> Rep CreateKnowledgeBaseResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateKnowledgeBaseResponse x -> CreateKnowledgeBaseResponse
$cfrom :: forall x.
CreateKnowledgeBaseResponse -> Rep CreateKnowledgeBaseResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateKnowledgeBaseResponse' 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:
--
-- 'knowledgeBase', 'createKnowledgeBaseResponse_knowledgeBase' - The knowledge base.
--
-- 'httpStatus', 'createKnowledgeBaseResponse_httpStatus' - The response's http status code.
newCreateKnowledgeBaseResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateKnowledgeBaseResponse
newCreateKnowledgeBaseResponse :: Int -> CreateKnowledgeBaseResponse
newCreateKnowledgeBaseResponse Int
pHttpStatus_ =
  CreateKnowledgeBaseResponse' :: Maybe KnowledgeBaseData -> Int -> CreateKnowledgeBaseResponse
CreateKnowledgeBaseResponse'
    { $sel:knowledgeBase:CreateKnowledgeBaseResponse' :: Maybe KnowledgeBaseData
knowledgeBase =
        Maybe KnowledgeBaseData
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateKnowledgeBaseResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The knowledge base.
createKnowledgeBaseResponse_knowledgeBase :: Lens.Lens' CreateKnowledgeBaseResponse (Prelude.Maybe KnowledgeBaseData)
createKnowledgeBaseResponse_knowledgeBase :: (Maybe KnowledgeBaseData -> f (Maybe KnowledgeBaseData))
-> CreateKnowledgeBaseResponse -> f CreateKnowledgeBaseResponse
createKnowledgeBaseResponse_knowledgeBase = (CreateKnowledgeBaseResponse -> Maybe KnowledgeBaseData)
-> (CreateKnowledgeBaseResponse
    -> Maybe KnowledgeBaseData -> CreateKnowledgeBaseResponse)
-> Lens
     CreateKnowledgeBaseResponse
     CreateKnowledgeBaseResponse
     (Maybe KnowledgeBaseData)
     (Maybe KnowledgeBaseData)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBaseResponse' {Maybe KnowledgeBaseData
knowledgeBase :: Maybe KnowledgeBaseData
$sel:knowledgeBase:CreateKnowledgeBaseResponse' :: CreateKnowledgeBaseResponse -> Maybe KnowledgeBaseData
knowledgeBase} -> Maybe KnowledgeBaseData
knowledgeBase) (\s :: CreateKnowledgeBaseResponse
s@CreateKnowledgeBaseResponse' {} Maybe KnowledgeBaseData
a -> CreateKnowledgeBaseResponse
s {$sel:knowledgeBase:CreateKnowledgeBaseResponse' :: Maybe KnowledgeBaseData
knowledgeBase = Maybe KnowledgeBaseData
a} :: CreateKnowledgeBaseResponse)

-- | The response's http status code.
createKnowledgeBaseResponse_httpStatus :: Lens.Lens' CreateKnowledgeBaseResponse Prelude.Int
createKnowledgeBaseResponse_httpStatus :: (Int -> f Int)
-> CreateKnowledgeBaseResponse -> f CreateKnowledgeBaseResponse
createKnowledgeBaseResponse_httpStatus = (CreateKnowledgeBaseResponse -> Int)
-> (CreateKnowledgeBaseResponse
    -> Int -> CreateKnowledgeBaseResponse)
-> Lens
     CreateKnowledgeBaseResponse CreateKnowledgeBaseResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateKnowledgeBaseResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateKnowledgeBaseResponse' :: CreateKnowledgeBaseResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateKnowledgeBaseResponse
s@CreateKnowledgeBaseResponse' {} Int
a -> CreateKnowledgeBaseResponse
s {$sel:httpStatus:CreateKnowledgeBaseResponse' :: Int
httpStatus = Int
a} :: CreateKnowledgeBaseResponse)

instance Prelude.NFData CreateKnowledgeBaseResponse