SearchIndexRestClientBuilder.java
// Copyright (c) Microsoft Corporation. All rights reserved.
// 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.
package com.azure.search.documents.implementation;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.CookiePolicy;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
/**
* A builder for creating a new instance of the SearchIndexRestClient type.
*/
@ServiceClientBuilder(serviceClients = SearchIndexRestClientImpl.class)
public final class SearchIndexRestClientBuilder {
/*
* Client Api Version.
*/
private String apiVersion;
/**
* Sets Client Api Version.
*
* @param apiVersion the apiVersion value.
* @return the SearchIndexRestClientBuilder.
*/
public SearchIndexRestClientBuilder apiVersion(String apiVersion) {
this.apiVersion = apiVersion;
return this;
}
/*
* The endpoint URL of the search service.
*/
private String endpoint;
/**
* Sets The endpoint URL of the search service.
*
* @param endpoint the endpoint value.
* @return the SearchIndexRestClientBuilder.
*/
public SearchIndexRestClientBuilder endpoint(String endpoint) {
this.endpoint = endpoint;
return this;
}
/*
* The name of the index.
*/
private String indexName;
/**
* Sets The name of the index.
*
* @param indexName the indexName value.
* @return the SearchIndexRestClientBuilder.
*/
public SearchIndexRestClientBuilder indexName(String indexName) {
this.indexName = indexName;
return this;
}
/*
* The serializer to use for requests
*/
private SerializerAdapter serializer;
/**
* Sets The serializer to use for requests.
*
* @param serializer the serializer value.
* @return the SearchIndexRestClientBuilder.
*/
public SearchIndexRestClientBuilder serializer(SerializerAdapter serializer) {
this.serializer = serializer;
return this;
}
/*
* The HTTP pipeline to send requests through
*/
private HttpPipeline pipeline;
/**
* Sets The HTTP pipeline to send requests through.
*
* @param pipeline the pipeline value.
* @return the SearchIndexRestClientBuilder.
*/
public SearchIndexRestClientBuilder pipeline(HttpPipeline pipeline) {
this.pipeline = pipeline;
return this;
}
/**
* Builds an instance of SearchIndexRestClientImpl with the provided parameters.
*
* @return an instance of SearchIndexRestClientImpl.
*/
public SearchIndexRestClientImpl build() {
if (pipeline == null) {
this.pipeline = new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build();
}
SearchIndexRestClientImpl client = new SearchIndexRestClientImpl(pipeline, serializer);
if (this.apiVersion != null) {
client.setApiVersion(this.apiVersion);
}
if (this.endpoint != null) {
client.setEndpoint(this.endpoint);
}
if (this.indexName != null) {
client.setIndexName(this.indexName);
}
return client;
}
}