Skip to content

create_knowledge_base

create_knowledge_base(
    aws_account_id: KbAwsAccountId,
    knowledge_base_id: KnowledgeBaseId,
    name: KnowledgeBaseName,
    data_source_arn: DataSourceArn,
    knowledge_base_configuration: KnowledgeBaseConfiguration,
    *,
    config_overrides: Optional[QuickSightClientConfig] = None,
    description: Optional[KnowledgeBaseDescription] = None,
    permissions: Optional[ResourcePermissionList] = None,
    media_extraction_configuration: Optional[MediaExtractionConfiguration] = None,
    access_control_configuration: Optional[AccessControlConfiguration] = None,
    primary_owner_arn: Optional[String] = None,
    tags: Optional[TagList] = None,
) -> CreateKnowledgeBaseResponse

Creates a knowledge base from a specified data source. Supported data source connector types include:

  • S3_KNOWLEDGE_BASE – Uses an Amazon S3 bucket as the data source.

  • WEB_CRAWLER – Uses web pages indexed by the built-in web crawler as the data source.

  • GOOGLE_DRIVE – Uses Google Drive as the data source. Supports service account authentication only.

  • SHAREPOINT – Uses SharePoint as the data source. Supports two-legged OAuth only.

  • ONE_DRIVE – Uses OneDrive as the data source. Supports two-legged OAuth only.

Parameters:

  • aws_account_id (KbAwsAccountId) –

    The ID of the Amazon Web Services account that contains the knowledge base.

  • knowledge_base_id (KnowledgeBaseId) –

    The unique identifier for the knowledge base.

  • name (KnowledgeBaseName) –

    The name of the knowledge base.

  • data_source_arn (DataSourceArn) –

    The Amazon Resource Name (ARN) of the data source for the knowledge base.

  • description (Optional[KnowledgeBaseDescription], default: None ) –

    A description for the knowledge base. If you don't specify a description, the knowledge base is created without one.

  • permissions (Optional[ResourcePermissionList], default: None ) –

    A list of resource permissions on the knowledge base. Each entry grants a specified Amazon QuickSight principal either owner or viewer access. If you don't specify permissions, only the primary owner (if provided) receives owner access.

  • access_control_configuration (Optional[AccessControlConfiguration], default: None ) –

    The access control configuration for the knowledge base. If you don't specify this parameter, document-level ACLs are disabled.

  • primary_owner_arn (Optional[String], default: None ) –

    The Amazon Resource Name (ARN) of the Amazon QuickSight user or group to set as the primary owner of the knowledge base. The specified principal is always granted owner access, regardless of what is specified in the Permissions field.

    This must be an Amazon QuickSight principal ARN, not an IAM user or role ARN. The API caller is never assigned as the owner automatically. If you don't specify a primary owner and don't grant owner access in Permissions, the knowledge base is created without an owner, even when you call the operation as an Amazon QuickSight user.

    When you call CreateKnowledgeBase as an IAM user or an assumed IAM role, specify PrimaryOwnerArn (as an Amazon QuickSight principal ARN) or an owner entry in Permissions so that the knowledge base has an owner. Although optional, specifying a primary owner is recommended.

  • tags (Optional[TagList], default: None ) –

    The tags to assign to the knowledge base. If you don't specify tags, the knowledge base is created without tags.

Raises:

Source code in docs_src/capo_quicksight/_services/quick_sight.py
def create_knowledge_base(
    self,
    aws_account_id: "capo_quicksight.types.kb_aws_account_id.KbAwsAccountId",
    knowledge_base_id: "capo_quicksight.types.knowledge_base_id.KnowledgeBaseId",
    name: "capo_quicksight.types.knowledge_base_name.KnowledgeBaseName",
    data_source_arn: "capo_quicksight.types.data_source_arn.DataSourceArn",
    knowledge_base_configuration: "capo_quicksight.types.knowledge_base_configuration.KnowledgeBaseConfiguration",
    *,
    config_overrides: Optional[QuickSightClientConfig] = None,
    description: Optional[
        "capo_quicksight.types.knowledge_base_description.KnowledgeBaseDescription"
    ] = None,
    permissions: Optional[
        "capo_quicksight.types.resource_permission_list.ResourcePermissionList"
    ] = None,
    media_extraction_configuration: Optional[
        "capo_quicksight.types.media_extraction_configuration.MediaExtractionConfiguration"
    ] = None,
    access_control_configuration: Optional[
        "capo_quicksight.types.access_control_configuration.AccessControlConfiguration"
    ] = None,
    primary_owner_arn: Optional["capo_quicksight.types.string.String"] = None,
    tags: Optional["capo_quicksight.types.tag_list.TagList"] = None,
) -> "capo_quicksight.types.create_knowledge_base_response.CreateKnowledgeBaseResponse":
    """<p>Creates a knowledge base from a specified data source. Supported data source connector types include:</p> <ul> <li> <p> <code>S3_KNOWLEDGE_BASE</code> – Uses an Amazon S3 bucket as the data source.</p> </li> <li> <p> <code>WEB_CRAWLER</code> – Uses web pages indexed by the built-in web crawler as the data source.</p> </li> <li> <p> <code>GOOGLE_DRIVE</code> – Uses Google Drive as the data source. Supports service account authentication only.</p> </li> <li> <p> <code>SHAREPOINT</code> – Uses SharePoint as the data source. Supports two-legged OAuth only.</p> </li> <li> <p> <code>ONE_DRIVE</code> – Uses OneDrive as the data source. Supports two-legged OAuth only.</p> </li> </ul>

    Args:
        aws_account_id: <p>The ID of the Amazon Web Services account that contains the knowledge base.</p>
        knowledge_base_id: <p>The unique identifier for the knowledge base.</p>
        name: <p>The name of the knowledge base.</p>
        data_source_arn: <p>The Amazon Resource Name (ARN) of the data source for the knowledge base.</p>
        description: <p>A description for the knowledge base. If you don't specify a description, the knowledge base is created without one.</p>
        permissions: <p>A list of resource permissions on the knowledge base. Each entry grants a specified Amazon QuickSight principal either owner or viewer access. If you don't specify permissions, only the primary owner (if provided) receives owner access.</p>
        access_control_configuration: <p>The access control configuration for the knowledge base. If you don't specify this parameter, document-level ACLs are disabled.</p>
        primary_owner_arn: <p>The Amazon Resource Name (ARN) of the Amazon QuickSight user or group to set as the primary owner of the knowledge base. The specified principal is always granted owner access, regardless of what is specified in the <code>Permissions</code> field.</p> <p>This must be an Amazon QuickSight principal ARN, not an IAM user or role ARN. The API caller is never assigned as the owner automatically. If you don't specify a primary owner and don't grant owner access in <code>Permissions</code>, the knowledge base is created without an owner, even when you call the operation as an Amazon QuickSight user.</p> <p>When you call <code>CreateKnowledgeBase</code> as an IAM user or an assumed IAM role, specify <code>PrimaryOwnerArn</code> (as an Amazon QuickSight principal ARN) or an owner entry in <code>Permissions</code> so that the knowledge base has an owner. Although optional, specifying a primary owner is recommended.</p>
        tags: <p>The tags to assign to the knowledge base. If you don't specify tags, the knowledge base is created without tags.</p>

    Raises:
        capo_quicksight.errors.access_denied_exception.AccessDeniedException: <p>You don't have access to this item. The provided credentials couldn't be validated. You might not be authorized to carry out the request. Make sure that your account is authorized to use the Amazon Quick Sight service, that your policies have the correct permissions, and that you are using the correct credentials.</p>
        capo_quicksight.errors.internal_failure_exception.InternalFailureException: <p>An internal failure occurred.</p>
        capo_quicksight.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One or more parameters has a value that isn't valid.</p>
        capo_quicksight.errors.invalid_request_exception.InvalidRequestException: <p>You don't have this feature activated for your account. To fix this issue, contact Amazon Web Services support.</p>
        capo_quicksight.errors.limit_exceeded_exception.LimitExceededException: <p>A limit is exceeded.</p>
        capo_quicksight.errors.precondition_not_met_exception.PreconditionNotMetException: <p>One or more preconditions aren't met.</p>
        capo_quicksight.errors.resource_exists_exception.ResourceExistsException: <p>The resource specified already exists. </p>
        capo_quicksight.errors.resource_not_found_exception.ResourceNotFoundException: <p>One or more resources can't be found.</p>
        capo_quicksight.errors.throttling_exception.ThrottlingException: <p>Access is throttled.</p>
        capo_quicksight.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_quicksight.types.create_knowledge_base_request.CreateKnowledgeBaseRequest]",
    ) -> OperationResponse[
        "capo_quicksight.types.create_knowledge_base_response.CreateKnowledgeBaseResponse"
    ]:
        import capo_quicksight._operations.quick_sight_20180401.create_knowledge_base

        output, http_response = (
            capo_quicksight._operations.quick_sight_20180401.create_knowledge_base.create_knowledge_base(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_quicksight.types.create_knowledge_base_request.CreateKnowledgeBaseRequest",
    ) -> dict[str, Any]:
        import capo_quicksight.types.create_knowledge_base_request

        return capo_quicksight.types.create_knowledge_base_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateKnowledgeBase", redact_input=_redact_input),
    )
    input_: capo_quicksight.types.create_knowledge_base_request.CreateKnowledgeBaseRequest = {
        "aws_account_id": aws_account_id,
        "knowledge_base_id": knowledge_base_id,
        "name": name,
        "data_source_arn": data_source_arn,
        "knowledge_base_configuration": knowledge_base_configuration,
    }
    if description is not None:
        input_["description"] = description
    if permissions is not None:
        input_["permissions"] = permissions
    if media_extraction_configuration is not None:
        input_["media_extraction_configuration"] = media_extraction_configuration
    if access_control_configuration is not None:
        input_["access_control_configuration"] = access_control_configuration
    if primary_owner_arn is not None:
        input_["primary_owner_arn"] = primary_owner_arn
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output