forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search Index Client builders (Azure#9)
* Data sdk v3 draft (Initial version) * Generated java data plane sdk using autorest v3 (azure-arm flag set to 'off') * Adding initial interface for the SearchIndexClient (and stubs) * adding generate script (with automatic spec fetching and tweaking) * adding pom.xml * adding some setup docs and customization stubs * Fixing BOM header issue in azure core
- Loading branch information
Showing
21 changed files
with
954 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
search/data-plane/data/bin/src/main/java/com/azure/search/data/docs/setup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Setting up the IntelliJ IDE | ||
|
||
1. Open IntelliJ and import a new project using the pom.xml file | ||
2. Go to the View->Tool Windows->Maven | ||
3. Click add, browse for sdk/core/pom.xml file | ||
4. Click 'reimport all Maven projects' | ||
5. Build the project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
search/data-plane/data/src/main/java/com/azure/search/data/SearchIndexASyncClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
package com.azure.search.data; | ||
|
||
import com.azure.core.http.rest.PagedFlux; | ||
import com.azure.search.data.generated.models.*; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* The public (Customer facing) interface for SearchIndexASyncClient. | ||
*/ | ||
public interface SearchIndexASyncClient { | ||
// Indices | ||
|
||
/** | ||
* Gets Client Api Version. | ||
* | ||
* @return the apiVersion value. | ||
*/ | ||
String getApiVersion(); | ||
|
||
/** | ||
* Gets The name of the Azure Search service. | ||
* | ||
* @return the searchServiceName value. | ||
*/ | ||
String getSearchServiceName(); | ||
|
||
/** | ||
* Gets The DNS suffix of the Azure Search service. The default is search.windows.net. | ||
* | ||
* @return the searchDnsSuffix value. | ||
*/ | ||
String getSearchDnsSuffix(); | ||
|
||
/** | ||
* Gets The name of the Azure Search index. | ||
* | ||
* @return the indexName value. | ||
*/ | ||
String getIndexName(); | ||
|
||
/** | ||
* Sets The name of the Azure Search index. | ||
* | ||
* @param indexName the indexName value. | ||
* @return the service client itself. | ||
*/ | ||
SearchIndexASyncClient setIndexName(String indexName); | ||
|
||
|
||
// Index Operations | ||
|
||
/** | ||
* Gets the number of documents | ||
* | ||
* @return the number of documents. | ||
*/ | ||
Mono<Long> countDocuments(); | ||
|
||
/** | ||
* Searches for documents in the Azure Search index | ||
* | ||
* @return the document search result. | ||
*/ | ||
PagedFlux<SearchResult> search(); | ||
|
||
/** | ||
* Searches for documents in the Azure Search index | ||
* | ||
* @return the document search result. | ||
*/ | ||
PagedFlux<SearchResult> search(String searchText, | ||
SearchParameters searchParameters, | ||
SearchRequestOptions searchRequestOptions); | ||
|
||
/** | ||
* Retrieves a document from the Azure Search index. | ||
* | ||
* @param key the name of the document | ||
* @return | ||
*/ | ||
Mono<Object> getDocument(String key); | ||
|
||
/** | ||
* Retrieves a document from the Azure Search index. | ||
* | ||
* @param key | ||
* @param selectedFields | ||
* @param searchRequestOptions | ||
* @return | ||
*/ | ||
Mono<Object> getDocument(String key, List<String> selectedFields, SearchRequestOptions searchRequestOptions); | ||
|
||
/** | ||
* Suggests documents in the Azure Search index that match the given partial query text. | ||
* | ||
* @param searchText | ||
* @param suggesterName | ||
* @return | ||
*/ | ||
PagedFlux<SuggestResult> suggest(String searchText, String suggesterName); | ||
|
||
/** | ||
* Suggests documents in the Azure Search index that match the given partial query text. | ||
* | ||
* @param searchText | ||
* @param suggesterName | ||
* @param suggestParameters | ||
* @param searchRequestOptions | ||
* @return | ||
*/ | ||
PagedFlux<SuggestResult> suggest(String searchText, String suggesterName, SuggestParameters suggestParameters, SearchRequestOptions searchRequestOptions); | ||
|
||
/** | ||
* Sends a batch of document write actions to the Azure Search index. | ||
* | ||
* @param batch | ||
* @return | ||
*/ | ||
Mono<DocumentIndexResult> index(IndexBatch batch); | ||
|
||
/** | ||
* Autocompletes incomplete query terms based on input text and matching terms in the Azure Search index. | ||
* | ||
* @param searchText | ||
* @param suggesterName | ||
* @return | ||
*/ | ||
Mono<AutocompleteResult> autocomplete(String searchText, String suggesterName); | ||
|
||
/** | ||
* Autocompletes incomplete query terms based on input text and matching terms in the Azure Search index. | ||
* | ||
* @param searchText | ||
* @param suggesterName | ||
* @param searchRequestOptions | ||
* @param autocompleteParameters | ||
* @return | ||
*/ | ||
Mono<AutocompleteResult> autocomplete(String searchText, String suggesterName, SearchRequestOptions searchRequestOptions, AutocompleteParameters autocompleteParameters); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
search/data-plane/data/src/main/java/com/azure/search/data/SearchIndexClientBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.azure.search.data; | ||
|
||
/** | ||
* The Fluent client builder. | ||
*/ | ||
public interface SearchIndexClientBuilder { | ||
|
||
// Fluent builders | ||
SearchIndexClient buildClient(); | ||
|
||
SearchIndexASyncClient buildAsyncClient(); | ||
} |
26 changes: 26 additions & 0 deletions
26
search/data-plane/data/src/main/java/com/azure/search/data/common/SearchPipelinePolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.azure.search.data.common; | ||
|
||
import com.azure.core.http.HttpPipelineCallContext; | ||
import com.azure.core.http.HttpPipelineNextPolicy; | ||
import com.azure.core.http.HttpResponse; | ||
import com.azure.core.http.policy.HttpPipelinePolicy; | ||
import org.apache.commons.lang3.StringUtils; | ||
import reactor.core.publisher.Mono; | ||
|
||
public class SearchPipelinePolicy implements HttpPipelinePolicy { | ||
|
||
private String apiKey; | ||
|
||
public SearchPipelinePolicy(String apiKey) { | ||
if (StringUtils.isBlank(apiKey)) { | ||
throw new IllegalArgumentException("Invalid apiKey"); | ||
} | ||
this.apiKey = apiKey; | ||
} | ||
|
||
@Override | ||
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { | ||
context.httpRequest().header("api-key", this.apiKey); | ||
return next.process(); | ||
} | ||
} |
Oops, something went wrong.