/*
 * Copyright (c) Microsoft Corporation.
 * Licensed under the MIT License.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is regenerated.
 */
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
/** Class containing Documents operations. */
export class DocumentsImpl {
    client;
    /**
     * Initialize a new instance of the class Documents class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Queries the number of documents in the index.
     * @param options The options parameters.
     */
    count(options) {
        return this.client.sendOperationRequest({ options }, countOperationSpec);
    }
    /**
     * Searches for documents in the index.
     * @param options The options parameters.
     */
    searchGet(options) {
        return this.client.sendOperationRequest({ options }, searchGetOperationSpec);
    }
    /**
     * Searches for documents in the index.
     * @param searchRequest The definition of the Search request.
     * @param options The options parameters.
     */
    searchPost(searchRequest, options) {
        return this.client.sendOperationRequest({ searchRequest, options }, searchPostOperationSpec);
    }
    /**
     * Retrieves a document from the index.
     * @param key The key of the document to retrieve.
     * @param options The options parameters.
     */
    get(key, options) {
        return this.client.sendOperationRequest({ key, options }, getOperationSpec);
    }
    /**
     * Suggests documents in the index that match the given partial query text.
     * @param searchText The search text to use to suggest documents. Must be at least 1 character, and no
     *                   more than 100 characters.
     * @param suggesterName The name of the suggester as specified in the suggesters collection that's part
     *                      of the index definition.
     * @param options The options parameters.
     */
    suggestGet(searchText, suggesterName, options) {
        return this.client.sendOperationRequest({ searchText, suggesterName, options }, suggestGetOperationSpec);
    }
    /**
     * Suggests documents in the index that match the given partial query text.
     * @param suggestRequest The Suggest request.
     * @param options The options parameters.
     */
    suggestPost(suggestRequest, options) {
        return this.client.sendOperationRequest({ suggestRequest, options }, suggestPostOperationSpec);
    }
    /**
     * Sends a batch of document write actions to the index.
     * @param batch The batch of index actions.
     * @param options The options parameters.
     */
    index(batch, options) {
        return this.client.sendOperationRequest({ batch, options }, indexOperationSpec);
    }
    /**
     * Autocompletes incomplete query terms based on input text and matching terms in the index.
     * @param searchText The incomplete term which should be auto-completed.
     * @param suggesterName The name of the suggester as specified in the suggesters collection that's part
     *                      of the index definition.
     * @param options The options parameters.
     */
    autocompleteGet(searchText, suggesterName, options) {
        return this.client.sendOperationRequest({ searchText, suggesterName, options }, autocompleteGetOperationSpec);
    }
    /**
     * Autocompletes incomplete query terms based on input text and matching terms in the index.
     * @param autocompleteRequest The definition of the Autocomplete request.
     * @param options The options parameters.
     */
    autocompletePost(autocompleteRequest, options) {
        return this.client.sendOperationRequest({ autocompleteRequest, options }, autocompletePostOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const countOperationSpec = {
    path: "/docs/$count",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: { type: { name: "Number" } },
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [Parameters.endpoint, Parameters.indexName],
    headerParameters: [Parameters.accept],
    serializer,
};
const searchGetOperationSpec = {
    path: "/docs",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SearchDocumentsResult,
        },
        206: {
            bodyMapper: Mappers.SearchDocumentsResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [
        Parameters.apiVersion,
        Parameters.searchText,
        Parameters.includeTotalResultCount,
        Parameters.facets,
        Parameters.filter,
        Parameters.highlightFields,
        Parameters.highlightPostTag,
        Parameters.highlightPreTag,
        Parameters.minimumCoverage,
        Parameters.orderBy,
        Parameters.queryType,
        Parameters.scoringParameters,
        Parameters.scoringProfile,
        Parameters.searchFields,
        Parameters.searchMode,
        Parameters.scoringStatistics,
        Parameters.sessionId,
        Parameters.select,
        Parameters.skip,
        Parameters.top,
        Parameters.semanticConfiguration,
        Parameters.semanticErrorHandling,
        Parameters.semanticMaxWaitInMilliseconds,
        Parameters.answers,
        Parameters.captions,
        Parameters.semanticQuery,
        Parameters.debug,
    ],
    urlParameters: [Parameters.endpoint, Parameters.indexName],
    headerParameters: [Parameters.accept],
    serializer,
};
const searchPostOperationSpec = {
    path: "/docs/search.post.search",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.SearchDocumentsResult,
        },
        206: {
            bodyMapper: Mappers.SearchDocumentsResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.searchRequest,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [Parameters.endpoint, Parameters.indexName],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getOperationSpec = {
    path: "/docs('{key}')",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: {
                type: { name: "Dictionary", value: { type: { name: "any" } } },
            },
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion, Parameters.selectedFields],
    urlParameters: [Parameters.endpoint, Parameters.indexName, Parameters.key],
    headerParameters: [Parameters.accept],
    serializer,
};
const suggestGetOperationSpec = {
    path: "/docs/search.suggest",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SuggestDocumentsResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [
        Parameters.apiVersion,
        Parameters.searchText1,
        Parameters.suggesterName,
        Parameters.filter1,
        Parameters.useFuzzyMatching,
        Parameters.highlightPostTag1,
        Parameters.highlightPreTag1,
        Parameters.minimumCoverage1,
        Parameters.orderBy1,
        Parameters.searchFields1,
        Parameters.select1,
        Parameters.top1,
    ],
    urlParameters: [Parameters.endpoint, Parameters.indexName],
    headerParameters: [Parameters.accept],
    serializer,
};
const suggestPostOperationSpec = {
    path: "/docs/search.post.suggest",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.SuggestDocumentsResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.suggestRequest,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [Parameters.endpoint, Parameters.indexName],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const indexOperationSpec = {
    path: "/docs/search.index",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.IndexDocumentsResult,
        },
        207: {
            bodyMapper: Mappers.IndexDocumentsResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.batch,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [Parameters.endpoint, Parameters.indexName],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const autocompleteGetOperationSpec = {
    path: "/docs/search.autocomplete",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.AutocompleteResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [
        Parameters.apiVersion,
        Parameters.searchText1,
        Parameters.suggesterName,
        Parameters.autocompleteMode,
        Parameters.filter2,
        Parameters.useFuzzyMatching1,
        Parameters.highlightPostTag2,
        Parameters.highlightPreTag2,
        Parameters.minimumCoverage2,
        Parameters.searchFields2,
        Parameters.top2,
    ],
    urlParameters: [Parameters.endpoint, Parameters.indexName],
    headerParameters: [Parameters.accept],
    serializer,
};
const autocompletePostOperationSpec = {
    path: "/docs/search.post.autocomplete",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.AutocompleteResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.autocompleteRequest,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [Parameters.endpoint, Parameters.indexName],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
//# sourceMappingURL=documents.js.map