Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the SearchIndexClient class for
        /// querying an index and uploading, merging, or deleting documents.
        /// </summary>
        /// <param name="endpoint">
        /// Required.  The URI endpoint of the Search Service.  This is likely
        /// to be similar to "https://{search_service}.search.windows.net".
        /// The URI must use HTTPS.
        /// </param>
        /// <param name="indexName">
        /// Required.  The name of the Search Index.
        /// </param>
        /// <param name="credential">
        /// Required.  The API key credential used to authenticate requests
        /// against the search service.  You need to use an admin key to
        /// modify the documents in a Search Index.  See
        /// <see href="https://docs.microsoft.com/azure/search/search-security-api-keys"/>
        /// for more information about API keys in Azure Cognitive Search.
        /// </param>
        /// <param name="options">
        /// Client configuration options for connecting to Azure Cognitive
        /// Search.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when the <paramref name="endpoint"/>,
        /// <paramref name="indexName"/>, or <paramref name="credential"/> is
        /// null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown when the <paramref name="endpoint"/> is not using HTTPS or
        /// the <paramref name="indexName"/> is empty.
        /// </exception>
        public SearchIndexClient(
            Uri endpoint,
            string indexName,
            SearchApiKeyCredential credential,
            SearchClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            endpoint.AssertHttpsScheme(nameof(endpoint));
            Argument.AssertNotNullOrEmpty(indexName, nameof(indexName));
            Argument.AssertNotNull(credential, nameof(credential));

            options ??= new SearchClientOptions();
            Endpoint          = endpoint;
            IndexName         = indexName;
            ClientDiagnostics = new ClientDiagnostics(options);
            Pipeline          = options.Build(credential);
            Version           = options.Version;

            Operations = new DocumentsClient(
                ClientDiagnostics,
                Pipeline,
                endpoint.ToString(),
                IndexName,
                Version.ToVersionString());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the SearchIndexClient class for
 /// querying an index and uploading, merging, or deleting documents.
 /// </summary>
 /// <param name="endpoint">
 /// Required.  The URI endpoint of the Search Service.  This is likely
 /// to be similar to "https://{search_service}.search.windows.net".
 /// The URI must use HTTPS.
 /// </param>
 /// <param name="indexName">
 /// Required.  The name of the Search Index.
 /// </param>
 /// <param name="credential">
 /// Required.  The API key credential used to authenticate requests
 /// against the search service.  You need to use an admin key to
 /// modify the documents in a Search Index.  See
 /// <see href="https://docs.microsoft.com/azure/search/search-security-api-keys"/>
 /// for more information about API keys in Azure Cognitive Search.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Thrown when the <paramref name="endpoint"/>,
 /// <paramref name="indexName"/>, or <paramref name="credential"/> is
 /// null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Thrown when the <paramref name="endpoint"/> is not using HTTPS or
 /// the <paramref name="indexName"/> is empty.
 /// </exception>
 public SearchIndexClient(
     Uri endpoint,
     string indexName,
     SearchApiKeyCredential credential) :
     this(endpoint, indexName, credential, null)
 {
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create an <see cref="HttpPipeline"/> to send requests to the Search
 /// Service.
 /// </summary>
 /// <param name="credential">
 /// The <see cref="SearchApiKeyCredential"/> to authenticate requests.
 /// </param>
 /// <returns>An <see cref="HttpPipeline"/> to send requests.</returns>
 internal HttpPipeline Build(SearchApiKeyCredential credential)
 {
     Debug.Assert(credential != null);
     return(HttpPipelineBuilder.Build(
                options: this,
                perCallPolicies: new[] { new SearchApiKeyCredentialPolicy(credential) },
                perRetryPolicies: Array.Empty <HttpPipelinePolicy>(),
                responseClassifier: null));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the SearchServiceClient class.
        /// </summary>
        /// <param name="endpoint">
        /// Required.  The URI endpoint of the Search Service.  This is likely
        /// to be similar to "https://{search_service}.search.windows.net".
        /// The URI must use HTTPS.
        /// </param>
        /// <param name="credential">
        /// Required.  The API key credential used to authenticate requests
        /// against the search service.  You need to use an admin key to
        /// perform any operations on the SearchServiceClient.  See
        /// <see href="https://docs.microsoft.com/azure/search/search-security-api-keys"/>
        /// for more information about API keys in Azure Cognitive Search.
        /// </param>
        /// <param name="options">
        /// Client configuration options for connecting to Azure Cognitive
        /// Search.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when the <paramref name="endpoint"/> or
        /// <paramref name="credential"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown when the <paramref name="endpoint"/> is not using HTTPS.
        /// </exception>
        public SearchServiceClient(
            Uri endpoint,
            SearchApiKeyCredential credential,
            SearchClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            endpoint.AssertHttpsScheme(nameof(endpoint));
            Argument.AssertNotNull(credential, nameof(credential));

            options ??= new SearchClientOptions();
            Endpoint          = endpoint;
            ClientDiagnostics = new ClientDiagnostics(options);
            Pipeline          = options.Build(credential);
            Version           = options.Version;

            Protocol = new ServiceRestClient(
                ClientDiagnostics,
                Pipeline,
                Endpoint.ToString(),
                Version.ToVersionString());
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the SearchServiceClient class.
 /// </summary>
 /// <param name="endpoint">
 /// Required.  The URI endpoint of the Search Service.  This is likely
 /// to be similar to "https://{search_service}.search.windows.net".
 /// The URI must use HTTPS.
 /// </param>
 /// <param name="credential">
 /// Required.  The API key credential used to authenticate requests
 /// against the search service.  You need to use an admin key to
 /// perform any operations on the SearchServiceClient.  See
 /// <see href="https://docs.microsoft.com/azure/search/search-security-api-keys"/>
 /// for more information about API keys in Azure Cognitive Search.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Thrown when the <paramref name="endpoint"/> or
 /// <paramref name="credential"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Thrown when the <paramref name="endpoint"/> is not using HTTPS.
 /// </exception>
 public SearchServiceClient(Uri endpoint, SearchApiKeyCredential credential) :
     this(endpoint, credential, null)
 {
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="SearchApiKeyCredentialPolicy"/> class.
 /// </summary>
 /// <param name="credential">
 /// The <see cref="SearchApiKeyCredential"/> used to authenticate
 /// requests.
 /// </param>
 public SearchApiKeyCredentialPolicy(SearchApiKeyCredential credential)
 {
     Debug.Assert(credential != null);
     Credential = credential;
 }